Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Revisit Leanplum device id generation #15593

Closed
st3fan opened this issue Oct 1, 2020 · 5 comments
Closed

Revisit Leanplum device id generation #15593

st3fan opened this issue Oct 1, 2020 · 5 comments
Assignees
Labels
🐞 bug Crashes, Something isn't working, .. eng:qa:verified QA Verified needs:triage Issue needs triage

Comments

@st3fan
Copy link
Contributor

st3fan commented Oct 1, 2020

This issue replaces #15586 with a new approach. We now understand the situation better and have come to a different conclusion. Summarized, I think this should be our strategy:

Simplify deviceId generation to be Leanplum.setDeviceId(randomUUID().toString())

This is exactly what we had before #13230 where we thought creating a new UUID on every cold start was a bad idea. But that assumption was wrong - the Leanplum SDK will ignore new DeviceIDs once they have been set. We verified this in the SDK code.

  • Revert back to Leanplum.setDeviceId(randomUUID().toString())
  • Remove all caching we do

This will work properly for new installs and migrated installs:

  • For a new install, Leanplum takes our random UUID as the device ID. It will store that ID in its own preferences. The next time setDeviceId() is called, it will ignore that value. (Verified in SDK source code)
  • For migrated users that had Leanplum enabled in Fennec, the Leanplum SDK will properly find the old preferences (set by the Leanplum SDK) and re-use those. That will automatically migrate the device id. We are ok with that persisting because this is an app upgrade.

Do not cache any identifier and depend on Leanplum.getDeviceId() as the source of truth

  • Leanplum knows best what its deviceID is - source of truth
  • Removes caching/state issues
  • This will fix the uid check we do in the DeepLinkValidator (how this all started)

Fortunately these changes actually simplify things a lot and are much more about code removing and relying on the Leanplum SDK as the source of truth.

Context

There is a lot of context in the following issues:

┆Issue is synchronized with this Jira Task

@st3fan st3fan added 🐞 bug Crashes, Something isn't working, .. Leanplum labels Oct 1, 2020
@github-actions github-actions bot added the needs:triage Issue needs triage label Oct 1, 2020
@boek boek self-assigned this Oct 1, 2020
boek added a commit to boek/fenix that referenced this issue Oct 1, 2020
boek added a commit to boek/fenix that referenced this issue Oct 1, 2020
boek added a commit to boek/fenix that referenced this issue Oct 1, 2020
boek added a commit to boek/fenix that referenced this issue Oct 1, 2020
@st3fan
Copy link
Contributor Author

st3fan commented Oct 2, 2020

Testing results:

✅ Leanplum persists the device identifier at cold start

I did the following two times:

  1. Install Firefox Nightly
  2. Grep for `` in adb logcat | grep LeanplumCloudMessagingProvider and observe the push token in that message.
  3. Find the device in the Leanplum console using the push token, observe the deviceId (UUID)
  4. Reboot device (killing the app should be fine...)

It consistently shows the same push and deviceId identifiers.

✅ Leanplum does not persist the device identifier between app installs

I did the following two times:

  1. Install Firefox Nightly
  2. Grep for `` in adb logcat | grep LeanplumCloudMessagingProvider and observe the push token in that message.
  3. Find the device in the Leanplum console using the push token, observe the deviceId (UUID)
  4. Delete Nightly from the device. Reinstall from the Play Store.

It consistently shows the same push token and a new Leanplum deviceId. (Assuming the push token is connected to some app/device combination, so I assume that is correct - and also out of our control)

✅ On a migrated device, the device identifier is inherited from the old Fennec settings

  1. Install Fennec 68.7b1
  2. Upgrade to Fenix 82.0.0-beta.3
  3. Grep for `` in adb logcat | grep LeanplumCloudMessagingProvider and observe the push token in that message.
  4. Find the device in the Leanplum console using the push token, observe the deviceId (UUID)
  5. adb shell into (rooted) device and see if the deviceId matches the value in /data/data/org.mozilla.fenix/shared_prefs/org.mozilla.firefox_beta/org.mozilla.gecko.BrowserApp.xml
  6. Send test push notification with deep link like fenix-beta://open?url=https://www.mozilla.org&uid={{User ID}}

The leanplum device id was properly migrated over from Fennec.

✅ Deeplinks validate and work properly

  1. Install Fennec 68.7b1
  2. Upgrade to Fenix 82.0.0-beta.3
  3. Grep for `` in adb logcat | grep LeanplumCloudMessagingProvider and observe the push token in that message.
  4. Find the device in the Leanplum console using the push token, observe the deviceId (UUID)
  5. Send test push notification with deep link like fenix-beta://open?url=https://www.mozilla.org&uid={{User ID}}

Push notification with deep link works: it arrives and tapping it opens Fenix Beta and opens the right link

(Also confirmed that the above steps do not work with Fenix Beta 82.0.0-beta.2.)

st3fan added a commit that referenced this issue Oct 2, 2020
@st3fan
Copy link
Contributor Author

st3fan commented Oct 2, 2020

Since this all looks pretty good - I've added this patch to the uplift plan.

@AndiAJ
Copy link
Collaborator

AndiAJ commented Oct 5, 2020

Hi, I've just checked this on 82.0.0-beta.3 using a Google Pixel 3a (Android 11)

✅ 1️⃣ Leanplum persists the device identifier at cold start

• Fresh install of Firefox Beta

► Leanplum

Device ID: c360efbf-61bb-4739-8ed9-9cda6ade1cc2
Android push token: ccuQxEcLKro:APA91bE2OGyMEJz2nzkUVhzUO4ulisHQ_0wz3TPeoOczzxe5fz-BwtBbhGO9A0PN7dfJnn7tJUeLft0c2XtQk4EFFaf35GSaCaFvkJYwYiuNzZB2Pz9vXxvqCUcmT8Ro4VaW9RS7rikI
image


► Log after running adb: logcat | findstr LeanplumCloudMessagingProvider

10-05 11:22:29.077 15703 15703 I [INFO][Leanplum]: [com.leanplum.LeanplumCloudMessagingProvider::onRegistrationIdReceived::3]: Device registered for push notifications with registration token, ccuQxEcLKro:APA91bE2OGyMEJz2nzkUVhzUO4ulisHQ_0wz3TPeoOczzxe5fz-BwtBbhGO9A0PN7dfJnn7tJUeLft0c2XtQk4EFFaf35GSaCaFvkJYwYiuNzZB2Pz9vXxvqCUcmT8Ro4VaW9RS7rikI
10-05 11:22:29.088 15703 15856 I [INFO][Leanplum]: [com.leanplum.LeanplumCloudMessagingProvider::onRegistrationIdReceived::3]: Device registered for push notifications with registration token, ccuQxEcLKro:APA91bE2OGyMEJz2nzkUVhzUO4ulisHQ_0wz3TPeoOczzxe5fz-BwtBbhGO9A0PN7dfJnn7tJUeLft0c2XtQk4EFFaf35GSaCaFvkJYwYiuNzZB2Pz9vXxvqCUcmT8Ro4VaW9RS7rikI

• Force stop Firefox beta and re-launch it

► Leanplum

Device ID: c360efbf-61bb-4739-8ed9-9cda6ade1cc2
Android push token: ccuQxEcLKro:APA91bE2OGyMEJz2nzkUVhzUO4ulisHQ_0wz3TPeoOczzxe5fz-BwtBbhGO9A0PN7dfJnn7tJUeLft0c2XtQk4EFFaf35GSaCaFvkJYwYiuNzZB2Pz9vXxvqCUcmT8Ro4VaW9RS7rikI
image


► Log after running adb: logcat | findstr LeanplumCloudMessagingProvider

10-05 11:39:30.516 16958 16958 I [INFO][Leanplum]: [com.leanplum.LeanplumCloudMessagingProvider::onRegistrationIdReceived::3]: Device registered for push notifications with registration token, ccuQxEcLKro:APA91bE2OGyMEJz2nzkUVhzUO4ulisHQ_0wz3TPeoOczzxe5fz-BwtBbhGO9A0PN7dfJnn7tJUeLft0c2XtQk4EFFaf35GSaCaFvkJYwYiuNzZB2Pz9vXxvqCUcmT8Ro4VaW9RS7rikI


📝Notes

✔️ Consistently shows the same push token and device ID identifiers.


✅ 2️⃣ Leanplum does not persist the device identifier between app installs

• Fresh install of Firefox Beta

► Leanplum

Device ID: ffebba05-938e-48ff-b157-0ac70a5329ee
Android push token: cSUyyUnMO4I:APA91bGH9iXe2DTAJuh0tqN2HyZeK9gV-D0L6G59ZDFEcxmjkmqnVXYI6CbQ9N4Jaj3rZUUqPAnBOyZ_VKExBt3E8666wj5eDD9yg9O466O0VugKHL2oxmtY-WM7Tzufr0NB35c_LvYM
image


► Log after running adb: logcat | findstr LeanplumCloudMessagingProvider

10-05 11:57:51.916 18096 18096 I [INFO][Leanplum]: [com.leanplum.LeanplumCloudMessagingProvider::onRegistrationIdReceived::3]: Device registered for push notifications with registration token, cSUyyUnMO4I:APA91bGH9iXe2DTAJuh0tqN2HyZeK9gV-D0L6G59ZDFEcxmjkmqnVXYI6CbQ9N4Jaj3rZUUqPAnBOyZ_VKExBt3E8666wj5eDD9yg9O466O0VugKHL2oxmtY-WM7Tzufr0NB35c_LvYM
10-05 11:57:51.924 18096 18265 I [INFO][Leanplum]: [com.leanplum.LeanplumCloudMessagingProvider::onRegistrationIdReceived::3]: Device registered for push notifications with registration token, cSUyyUnMO4I:APA91bGH9iXe2DTAJuh0tqN2HyZeK9gV-D0L6G59ZDFEcxmjkmqnVXYI6CbQ9N4Jaj3rZUUqPAnBOyZ_VKExBt3E8666wj5eDD9yg9O466O0VugKHL2oxmtY-WM7Tzufr0NB35c_LvYM

• Delete Firefox beta and Re-install it using the .apk from task index (not available yet on Play Store)

► Leanplum

Device ID: 0e309c95-6eea-4d47-b8d5-a16c124a01bb
Android push token: eR8XwX68Eb8:APA91bEwUGP97lmVkgEQvx2Jhvi3UkNtoogV5G268igogP57Dq881SI2z4UACxlHrP92h-zGB-EXPh2HbCDLEmgkqpC9flrdC6eHIEBTfjizilHAzyt5FSjpI12Ur4ZPCYTFIeswRWEU
image


► Log after running adb: logcat | findstr LeanplumCloudMessagingProvider

10-05 12:07:30.767 18984 19163 I [INFO][Leanplum]: [com.leanplum.LeanplumCloudMessagingProvider::onRegistrationIdReceived::3]: Device registered for push notifications with registration token, eR8XwX68Eb8:APA91bEwUGP97lmVkgEQvx2Jhvi3UkNtoogV5G268igogP57Dq881SI2z4UACxlHrP92h-zGB-EXPh2HbCDLEmgkqpC9flrdC6eHIEBTfjizilHAzyt5FSjpI12Ur4ZPCYTFIeswRWEU
10-05 12:07:30.774 18984 18984 I [INFO][Leanplum]: [com.leanplum.LeanplumCloudMessagingProvider::onRegistrationIdReceived::3]: Device registered for push notifications with registration token, eR8XwX68Eb8:APA91bEwUGP97lmVkgEQvx2Jhvi3UkNtoogV5G268igogP57Dq881SI2z4UACxlHrP92h-zGB-EXPh2HbCDLEmgkqpC9flrdC6eHIEBTfjizilHAzyt5FSjpI12Ur4ZPCYTFIeswRWEU

📝Notes:

✔️ A new device ID and push token are generated and assigned after reinstalling Firefox Beta


❓ 3️⃣ On a migrated device, the device identifier is inherited from the old Fennec settings

• Fresh install of Fennec Beta 68.7b1

► Leanplum

Device ID: ccddf528-eb11-455a-9c34-0ad76424601e
Android push token: APA91bGT8kB2ahLCZ55ziqs-GV8R7frPnm_3EqM-HQeCjW9qbTOoKgJiXKPmHOFwjBRWsjszHbntQyLAGeXhRsSBjuXtnZTuT-5KyIEK1B2HO29UL6M0JXdXWZ7GneinKP-EL_1etprHJ1QOGVu3wMIYLeQSGUhrtg
image


► About:config
Device ID:ccddf528-eb11-455a-9c34-0ad76424601e
Untttitled


• Upgrade to Firefox Beta 82.0.0-beta.3

► Leanplum

Device ID: ccddf528-eb11-455a-9c34-0ad76424601e
❔ Android push token: cQfGwa2M3oc:APA91bGJa5RkCVP45xDDOhA3nh7uVydtf3OJ7sGwAW_mr2wuILeAzLNL4OMk34rzx_8M72sjDrQViNiC28JrvhNvzx3p1qN4cn740T1GwHEIyn-6fW0fHtvbb22wUd8XC-yHeAbLmb2Y


► Log after running adb: logcat | findstr LeanplumCloudMessagingProvider

✔️ 10-05 12:50:03.151 23925 24082 I [INFO][Leanplum]:
[com.leanplum.LeanplumCloudMessagingProvider::onRegistrationIdReceived::3]: Device registered for push notifications with registration token, cQfGwa2M3oc:APA91bGJa5RkCVP45xDDOhA3nh7uVydtf3OJ7sGwAW_mr2wuILeAzLNL4OMk34rzx_8M72sjDrQViNiC28JrvhNvzx3p1qN4cn740T1GwHEIyn-6fW0fHtvbb22wUd8XC-yHeAbLmb2Y
❔ 10-05 12:50:05.591 23925 24082 I [INFO][Leanplum]: [com.leanplum.LeanplumCloudMessagingProvider::onRegistrationIdReceived::3]: Device registered for push notifications with registration token, dfE4oI5e7hk:APA91bFbigGVQdFL5RhtrhQoCGWAc-5YVsmgagQROcypF-w6qF-i-Btva2rAco4kF-iro8r01-7_Maiq_3DPIjjVmS86OZr1mgFIE9BflmC2sIU5QM_DgolPGLFPYfTAdfaLPLUw6RE5

► ❔ Force closed Firefox Beta 82.0.0-beta.3 and re-run adb: logcat | findstr LeanplumCloudMessagingProvider and resulted in the following log:
10-05 12:58:35.255 24776 24776 I [INFO][Leanplum]: [com.leanplum.LeanplumCloudMessagingProvider::onRegistrationIdReceived::3]: Device registered for push notifications with registration token, dfE4oI5e7hk:APA91bFbigGVQdFL5RhtrhQoCGWAc-5YVsmgagQROcypF-w6qF-i-Btva2rAco4kF-iro8r01-7_Maiq_3DPIjjVmS86OZr1mgFIE9BflmC2sIU5QM_DgolPGLFPYfTAdfaLPLUw6RE5

► Re-checked on Leanplum
✔️ Device ID: ccddf528-eb11-455a-9c34-0ad76424601e
❔ Android push token: dfE4oI5e7hk:APA91bFbigGVQdFL5RhtrhQoCGWAc-5YVsmgagQROcypF-w6qF-i-Btva2rAco4kF-iro8r01-7_Maiq_3DPIjjVmS86OZr1mgFIE9BflmC2sIU5QM_DgolPGLFPYfTAdfaLPLUw6RE5
image


• Sent a Push Notification VIA Leanplum

✔️ Properly sent the Push Notification VIA Leanplum based on the User ID
✔️ Received the notification and after tapping it Firefox Beta opened

► Video
20201005-135426


📝Notes:

✔️ The device ID was inherited from Fennec Beta
✔️ Properly sent and received the push notification.
✔️ Tapping it opened https://www.mozilla.org
❓ The push token got changed as it follows:

Fennec : APA91bGT8kB2ahLCZ55ziqs-GV8R7frPnm_3EqM-HQeCjW9qbTOoKgJiXKPmHOFwjBRWsjszHbntQyLAGeXhRsSBjuXtnZTuT-5KyIEK1B2HO29UL6M0JXdXWZ7GneinKP-EL_1etprHJ1QOGVu3wMIYLeQSGUhrtg

Right after the update the log showed 2 new push tokens:
✔️Same as per Leanplum cQfGwa2M3oc:APA91bGJa5RkCVP45xDDOhA3nh7uVydtf3OJ7sGwAW_mr2wuILeAzLNL4OMk34rzx_8M72sjDrQViNiC28JrvhNvzx3p1qN4cn740T1GwHEIyn-6fW0fHtvbb22wUd8XC-yHeAbLmb2Y
and
Different than the one displayed in Leanplum dfE4oI5e7hk:APA91bFbigGVQdFL5RhtrhQoCGWAc-5YVsmgagQROcypF-w6qF-i-Btva2rAco4kF-iro8r01-7_Maiq_3DPIjjVmS86OZr1mgFIE9BflmC2sIU5QM_DgolPGLFPYfTAdfaLPLUw6RE5

Force closed Firefox Beta 82.0.0-beta.3 and rechecked both the log and Leanplum and it got changed to:
✔️ dfE4oI5e7hk:APA91bFbigGVQdFL5RhtrhQoCGWAc-5YVsmgagQROcypF-w6qF-i-Btva2rAco4kF-iro8r01-7_Maiq_3DPIjjVmS86OZr1mgFIE9BflmC2sIU5QM_DgolPGLFPYfTAdfaLPLUw6RE5

@st3fan could you please review and advise? ☺️
Not sure if the push token changes after performing a migration are expected or not?

@st3fan
Copy link
Contributor Author

st3fan commented Oct 5, 2020

The push token changing is fine. That is expected.

@AndiAJ
Copy link
Collaborator

AndiAJ commented Oct 5, 2020

Many thanks! ☺️
In this case, I'll mark this matter verified as fixed on 82.0.0-beta.3 using a Google Pixel 3a (Android 11)

@AndiAJ AndiAJ closed this as completed Oct 5, 2020
@AndiAJ AndiAJ added the eng:qa:verified QA Verified label Oct 5, 2020
boek added a commit to boek/fenix that referenced this issue Oct 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐞 bug Crashes, Something isn't working, .. eng:qa:verified QA Verified needs:triage Issue needs triage
Projects
None yet
Development

No branches or pull requests

3 participants