question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Verify that the Leanplum Device Identifier was properly migrated or generated

See original GitHub issue

I 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:

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

cc to @boek and @pocmo

┆Issue is synchronized with this Jira Task

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
st3fancommented, Oct 1, 2020

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 the deviceId 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:

Starting Leanplum with device id: dba5cb2c-96e7-4fcf-87cf-0c1dbc5c1a2d
Started Leanplum with deviceId 4318eae1-829d-4066-8b1d-0a20372d3823 and userId 4318eae1-829d-4066-8b1d-0a20372d3823

And there is the problem. We initialize Leanplum with dba5cb2c-96e7-4fcf-87cf-0c1dbc5c1a2d - we pass that into Leanplum.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:

Rejecting Leanplum deep link because uid 4318eae1-829d-4066-8b1d-0a20372d3823 does not
   match dba5cb2c-96e7-4fcf-87cf-0c1dbc5c1a2d

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:

<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
    <boolean name="android.not_a_preference.klar.package.installed" value="false" />
    <string name="android.not_a_preference.leanplum.device_id">4318eae1-829d-4066-8b1d-0a20372d3823</string>
    <boolean name="android.not_a_preference.focus.package.installed" value="false" />
</map>

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:

You can choose how the device ID will be set the first time start is called on that device by calling one of these before start: Leanplum.setDeviceId("customAndUniqueId") Sets the device ID to a custom ID. Make sure that your custom ID is unique per device.

But then it also says this:

The deviceId is set when Leanplum.start runs for the first time on that device. After this, it cannot be changed unless the user completely uninstalls and reinstalls your app.

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 the deviceId 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 the android.not_a_preference.leanplum.device_id value and use that.

0reactions
stale[bot]commented, Apr 13, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Push notification troubleshooting and FAQ
There are a few different reasons your device might not receive a push notification. Check the following possible causes to troubleshoot a push...
Read more >
Android - Leanplum Documentation
This article is your first step to activating the Leanplum Android SDK. The following setup guide is for developers using Gradle to manage...
Read more >
Manage email subscriptions - Leanplum Documentation
Manage email subscriptions · Properly handle users with multiple devices · Prevent users from creating multiple accounts · Import historical subscription data.
Read more >
Register a Test device - Leanplum Documentation
To navigate to the Devices page, click on the Test Devices item in the dashboard navigation. Then, hover over your device and click...
Read more >
Testing and Debugging - Leanplum Documentation
Development v Production Modes. In Leanplum, you are issued a set of API keys with each Leanplum app that is created. There is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found