Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Duplicate GET /user call on cold start when calling login with the same external_id #2015

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

jkasten2
Copy link
Member

@jkasten2 jkasten2 commented Mar 5, 2024

Description

One Line Summary

Omit making a GET /user call on cold start when calling login on the same external_id.

Details

We already refresh when the app is cold started, so this results in two GET calls back-to-back for apps that call login every time the app is opened the by the user. We are still refreshing the user if switch user happens.

Motivation

Optimize network calls is beneficial to the device and OneSignal's backend.

Scope

Only effects OneSignal.login, only omitting an extra get User call.

Testing

Unit testing

Adding a test is out of scope for this PR, since there is no existing test infrastructure to test code in OneSignalImp. Also such code should be refactored out into a different class to make it more testable anyway.

Manual testing

Test on an Android 14 emulator.

Before

Screenshot 2024-03-04 Before remove extra Get User call on login

After

Screenshot 2024-03-04 194601 After remove extra Get User call on login

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

This change is Reviewable

We already refresh when the app is cold started, so this results
in two GET calls back-to-back for apps that call login every time
the app is opened the by the user. We are still refreshing the user if
switch user happens.

Didn't add any unit test since there is no existing test infrastructure
to test code in OneSignalImp. Also such code should be refactored out
into a different class to make it more testable anyway.
@jkasten2 jkasten2 merged commit 7b4e48e into main Mar 5, 2024
2 checks passed
@jkasten2 jkasten2 deleted the fix/extra-get-call-on-login branch March 5, 2024 17:45
@jkasten2 jkasten2 mentioned this pull request Mar 29, 2024
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