Verify that the Leanplum Device Identifier was properly migrated or generated
See original GitHub issueI am debugging a case where Leanplum is:
- properly initialized
- has a push token
- can receive remote notification messages and in-app messages
But what fails is opening deeplinks, specifically the following two:
fenix://open?url=https%3A%2F%2Fsupport.mozilla.org%2Fen-US%2Fkb%2Fwhats-new-firefox-android%2526utm_source%3Dleanplum-push-notification%2526utm_campaign%3D09.28.20-EN-fenix81-qa&uid={{User
fenix://settings?uid={{User ID}}
Note that these work properly for me (@st3fan) but not for @cbonacuse
In the Leanplum console I see that both our test devices are up to date (Firefox 81.1.1) and both have a push token assigned.
Since this works well for me, end-to-end, that gives me confidence that the LeanplumMetricsService
and fenix://
intent handling works as expected. However, we did make two changes relatively recently related to the uid={{User ID}}
part of those URLs that I am trying to rule out:
-
We used to (incorrectly) randomize the device identifier at every app cold start. This was fixed by caching the device identifier. See https://github.com/mozilla-mobile/fenix/pull/13230
-
We used to not check the
uid
parameter in the deeplink URL, which was fixed with https://github.com/mozilla-mobile/fenix/commit/77263aad704844782a461b49a92b51a8bed31c16
It is important to rule these out because if push notification messages appear but the links are rejected that will most likely mean that the check for the device identifier fails.
This issue is to re-read / re-review those two patches and think about edge cases that could cause the caching or the check to fail. Keeping in mind the following scenarios:
- Migration
- A user upgrading from a Fenix version that did not have these changes
┆Issue is synchronized with this Jira Task
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (17 by maintainers)
I uplifted #15584 to Fenix 81.1.2 and I rooted my Pixel 2XL to get easier access to the preferences of Firefox.
The following was tested on a device where I first installed Fennec 68.11 and then upgraded/migrated to Fenix 81.1.2.
I registered my device in the Leanplum console as a test device, using the Push Token that is printed during app startup. According to Leanplum my device is
4318eae1-829d-4066-8b1d-0a20372d3823
. Let’s consider this the source of truth because this is thedeviceId
that the SDK uses to identify me and what it uses to successfully communicate.Here we go, at app startup, the following is now printed:
And there is the problem. We initialize Leanplum with
dba5cb2c-96e7-4fcf-87cf-0c1dbc5c1a2d
- we pass that intoLeanplum.setDeviceId()
but when Leanplum has started, it has ignored the device Id that we asked it to use and used a new Id. (Spoiler: At the end you can read that this id not actually new but instead migrated from Fennec).Opening a test notification prints:
Now, this code works as expected on new installs. So we must hit some weird corner case where Leanplum is picking up the old config files from Fennec and ignoring the
deviceId
that we tell it to use.Now that I can root shell into my device, it is easy to pick up
/data/data/org.mozilla.firefox/shared_prefs/org.mozilla.gecko.BrowserApp.xml
which has the following:We inherited the
deviceId
that was previously used in Fennec. And it did not pick up the new identifier that Fenix generated.So what went wrong here?
I thouight we hit some kind of bug in the Leanplum SDK where it does not properly pick up a custom
deviceId
… because:Their documentation at https://docs.leanplum.com/reference#device-ids clearly says:
But then it also says this:
And I think that is exactly what we are running into now. You cannot change the
deviceId
once it has been set, and on migrated builds the Leanplum SDK picks up thedeviceId
that was previously configured in Fennec, and will not allow us to override that.A fix should be simple: If
org.mozilla.gecko.BrowserApp.xml
exists then pick up theandroid.not_a_preference.leanplum.device_id
value and use that.See: https://github.com/mozilla-mobile/fenix/issues/17373 This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.