Skip to content

feat: [SDK-5821] mark composite login on the Create User request - #2857

Open
abdulraqeeb33 wants to merge 4 commits into
mainfrom
ar/sdk-5821
Open

abdulraqeeb33 wants to merge 4 commits into
mainfrom
ar/sdk-5821

Conversation

@abdulraqeeb33

@abdulraqeeb33 abdulraqeeb33 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

One Line Summary

Send OneSignal-API-Method: login_with_profile on 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 when addEmail or addSms is still queued, so the JSON shape cannot tell the two calls apart.

SDK-5821

Scope

LoginUserOperation records that it was built with a profile, including an empty one, and the Create User request sends OneSignal-API-Method: login_with_profile only 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 apiMethod is set. UserBackendService forwards it onto the POST. The login executor sends login_with_profile for 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 and mergeProfileFrom in 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, and LoginUserOperationExecutorTests.

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

Made with Cursor

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>
@abdulraqeeb33
abdulraqeeb33 requested a review from a team as a code owner November 20, 2026 21:48
@abdulraqeeb33

Copy link
Copy Markdown
Contributor Author

Turbine allowlist: https://github.com/OneSignal/turbine/pull/1865

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

📊 Diff Coverage Report

Diff 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

  • AnrCheckEvaluator.kt: 2/2 touched executable lines (100.0%) (4 touched lines in diff)
  • AndroidLogAnrDetector.kt: 0/5 touched executable lines (0.0%) (16 touched lines in diff)
    • 5 uncovered touched lines in this file
  • AndroidLogCrashHandler.kt: 16/16 touched executable lines (100.0%) (37 touched lines in diff)

Overall (aggregate gate)

18/23 touched executable lines covered (78.3% — requires ≥ 80%)

Per-file detail (informational; gate is aggregate above):

  • AndroidLogAnrDetector.kt: 0.0% (5 uncovered touched lines)

❌ Coverage Check Failed

Aggregate coverage on touched lines is 78.3% (minimum 80%).

📥 View workflow run

AR Abdul Azeez and others added 2 commits November 30, 2026 12:39
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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test

}
if (other.tags.isNotEmpty()) tags = tags + other.tags
if (other.aliases.isNotEmpty()) aliases = aliases + other.aliases
if (other.profileLogin) profileLogin = true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, pre-existing. Leaving for a follow-up.

this.onesignalId = onesignalId
this.externalId = externalId
this.existingOnesignalId = existingOneSignalId
profileLogin = profile != null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identity-only half now includes a grouped email CreateSubscription.

restored.profileLogin shouldBe true
}

test("mergeProfileFrom keeps the composite marker from either login") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the name says "either login" but it only checks identity.mergeProfileFrom(composite). Could add the reverse direction too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: rywToken is already a String, so .toString() isn't needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants