Repository navigation
feat: [SDK-5821] mark composite login on the Create User request - #2857
abdulraqeeb33 wants to merge 4 commits into
Conversation
Identity-only and composite login share the same POST. Send OneSignal-API-Method only when the login was built with a profile so the next release can be counted from the trace. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Turbine allowlist: https://github.com/OneSignal/turbine/pull/1865 |
📊 Diff Coverage ReportDiff Coverage Report (Changed Lines Only)Gate: aggregate coverage on changed executable lines must be ≥ 80% (JaCoCo line data for lines touched in the diff). Changed Files Coverage
Overall (aggregate gate)18/23 touched executable lines covered (78.3% — requires ≥ 80%) Per-file detail (informational; gate is aggregate above):
❌ Coverage Check FailedAggregate coverage on touched lines is 78.3% (minimum 80%). |
Keep OptionalHeaders null-checks consistent with Kotlin idiomatic style. Co-authored-by: Cursor <cursoragent@cursor.com>
Make the composite marker explicit on construct instead of leaving it unset. Co-authored-by: Cursor <cursoragent@cursor.com>
| subscriptionList.map { it.second }, | ||
| properties, | ||
| jwt, | ||
| apiMethod = if (createUserOperation.profileLogin) LOGIN_WITH_PROFILE_METHOD else null, |
There was a problem hiding this comment.
Non-blocking: a composite login with an empty or enabled-only profile from an existing server user (IV off) fails hasProfileFields() in shouldCreateUserDirectly, so it takes the SetAlias path and never POSTs. Those never get counted. The PR body only mentions the same-user case, so maybe document this one too.
| } | ||
| if (other.tags.isNotEmpty()) tags = tags + other.tags | ||
| if (other.aliases.isNotEmpty()) aliases = aliases + other.aliases | ||
| if (other.profileLogin) profileLogin = true |
There was a problem hiding this comment.
Nit: OperationRepo only calls mergeProfileFrom when the existing login is still queued. If it's already in flight, the incoming composite op's profile and flag are dropped. That was already the case before this PR, so a follow-up ticket might be enough.
There was a problem hiding this comment.
Agreed, pre-existing. Leaving for a follow-up.
| this.onesignalId = onesignalId | ||
| this.externalId = externalId | ||
| this.existingOnesignalId = existingOneSignalId | ||
| profileLogin = profile != null |
There was a problem hiding this comment.
Nit: this writes profileLogin: false into every persisted login op. Since the getter treats a missing key as false, if (profile != null) profileLogin = true would be enough.
There was a problem hiding this comment.
Reverted to if (profile != null) profileLogin = true.
| matchingBackendSubscription(remaining, "local-email", local) shouldBe null | ||
| } | ||
|
|
||
| test("composite login sends the api method and identity-only login does not") { |
There was a problem hiding this comment.
Nit: the identity-only half has no grouped email/SMS CreateSubscriptionOperation, which is the case the header is meant to tell apart. Worth adding one so it's covered.
There was a problem hiding this comment.
Identity-only half now includes a grouped email CreateSubscription.
| restored.profileLogin shouldBe true | ||
| } | ||
|
|
||
| test("mergeProfileFrom keeps the composite marker from either login") { |
There was a problem hiding this comment.
Nit: the name says "either login" but it only checks identity.mergeProfileFrom(composite). Could add the reverse direction too.
There was a problem hiding this comment.
Added the reverse merge direction.
| if (headers?.rywToken != null) { | ||
| con.setRequestProperty("OneSignal-RYW-Token", headers.rywToken.toString()) | ||
| headers?.rywToken?.let { | ||
| con.setRequestProperty("OneSignal-RYW-Token", it.toString()) |
There was a problem hiding this comment.
Nit: rywToken is already a String, so .toString() isn't needed.
There was a problem hiding this comment.
Dropped the extra .toString().
Tighten tests for grouped identity-only create and merge both ways, and drop redundant profileLogin false / rywToken toString. Co-authored-by: Cursor <cursoragent@cursor.com>
Description
One Line Summary
Send
OneSignal-API-Method: login_with_profileon composite Create User so the call can be counted from the trace.Details
Motivation
Composite login and identity-only login both POST
apps/{app_id}/users. An identity-only login can carry an email or SMS on that same body whenaddEmailoraddSmsis still queued, so the JSON shape cannot tell the two calls apart.SDK-5821
Scope
LoginUserOperationrecords that it was built with a profile, including an empty one, and the Create User request sendsOneSignal-API-Method: login_with_profileonly in that case. Identity-only login does not send the header, including when a pending email or SMS is folded into the same POST. The flag stays on the operation, so a retry still sends it. No email, phone, tag, or alias value is in the header.Cases that never POST Create User also never get counted: a same-user login with an empty profile, and a composite login with an empty or enabled-only profile from an existing server user when IV is off (that path uses SetAlias instead).
This is queryable only after Turbine allowlists
onesignal-api-method. Clients already on 5.11.0 do not send it. Traces are sampled, and a Tempo metrics query covers about three and a half hours.Testing
Unit testing
HttpClient sends the header only when
apiMethodis set. UserBackendService forwards it onto the POST. The login executor sendslogin_with_profilefor a composite login, including an empty profile, and omits it for identity-only login even when a grouped email CreateSubscription is folded into the same POST. The flag survives a JSON round trip andmergeProfileFromin both directions.Manual testing
Not run on a device. The change is a request header on an internal Create User call, covered by
HttpClientTests,UserBackendServiceTests, andLoginUserOperationExecutorTests.Affected code checklist
Checklist
Overview
Testing
Final pass
Made with Cursor