Skip to content

Commit

Permalink
✨(llm) add default analytics for deeplinks (#8295)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasWerey authored Nov 6, 2024
1 parent c6d32b9 commit 4120120
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-boxes-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": patch
---

Add default deeplink analytics
23 changes: 18 additions & 5 deletions apps/ledger-live-mobile/src/navigation/DeeplinksProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ import Config from "react-native-config";
import { useRemoteLiveAppContext } from "@ledgerhq/live-common/platform/providers/RemoteLiveAppProvider/index";
import { useFeature } from "@ledgerhq/live-common/featureFlags/index";
import { BUY_SELL_UI_APP_ID } from "@ledgerhq/live-common/wallet-api/constants";

import Braze from "@braze/react-native-sdk";
import { LiveAppManifest } from "@ledgerhq/live-common/platform/types";
import * as Sentry from "@sentry/react-native";

import { hasCompletedOnboardingSelector } from "~/reducers/settings";
import { navigationRef, isReadyRef } from "../rootnavigation";
import { ScreenName, NavigatorName } from "~/const";
Expand All @@ -29,8 +27,8 @@ import { track } from "~/analytics";
import { setEarnInfoModal } from "~/actions/earn";
import { blockPasswordLock } from "../actions/appstate";
import { useStorylyContext } from "~/components/StorylyStories/StorylyProvider";

const routingInstrumentation = new Sentry.ReactNavigationInstrumentation();
const TRACKING_EVENT = "deeplink_clicked";

const themes: {
[key: string]: Theme;
Expand Down Expand Up @@ -489,6 +487,12 @@ export const DeeplinksProvider = ({
currency,
installApp,
appName,
deeplinkSource,
deeplinkType,
deeplinkDestination,
deeplinkChannel,
deeplinkMedium,
deeplinkCampaign,
} = query;

if (!ajsPropSource && !Config.MOCK) {
Expand All @@ -504,7 +508,7 @@ export const DeeplinksProvider = ({

// Track deeplink only when ajsPropSource attribute exists.
if (ajsPropSource) {
track("deeplink_clicked", {
track(TRACKING_EVENT, {
deeplinkSource: ajsPropSource,
deeplinkCampaign: ajsPropCampaign,
url: hostname,
Expand All @@ -513,7 +517,16 @@ export const DeeplinksProvider = ({
appName,
...(ajsPropTrackData ? JSON.parse(ajsPropTrackData) : {}),
});
}
} else
track(TRACKING_EVENT, {
deeplinkSource,
deeplinkType,
deeplinkDestination,
deeplinkChannel,
deeplinkMedium,
deeplinkCampaign,
});

const platform = pathname.split("/")[1];

if (isStorylyLink(url.toString())) {
Expand Down

0 comments on commit 4120120

Please sign in to comment.