Skip to content

Commit

Permalink
fix: add deeplink track to llm and improve deeplink track lld
Browse files Browse the repository at this point in the history
  • Loading branch information
sarneijim committed Aug 24, 2023
1 parent d1c93c2 commit 3493eb9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .changeset/calm-falcons-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"ledger-live-desktop": patch
"live-mobile": patch
---

Add deeplink_clicked track to LLM and improve deeplink_clicked track to LLD
17 changes: 11 additions & 6 deletions apps/ledger-live-desktop/src/renderer/hooks/useDeeplinking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,26 @@ export function useDeepLinkHandler() {
const query = Object.fromEntries(searchParams);
const fullUrl = pathname.replace(/(^\/+|\/+$)/g, "");
const [url, path] = fullUrl.split("/");
// Track deeplink only when ajsPropSource attribute exists.
const ajsPropSource = searchParams.get("ajs_prop_source");
const ajsPropCampaign = searchParams.get("ajs_prop_campaign");
const ajsPropTrackData = searchParams.get("ajs_prop_track_data");

Check failure on line 104 in apps/ledger-live-desktop/src/renderer/hooks/useDeeplinking.ts

View check run for this annotation

live-github-bot / @Desktop • Test App

prettier/prettier

Delete `······`

Check failure on line 104 in apps/ledger-live-desktop/src/renderer/hooks/useDeeplinking.ts

View check run for this annotation

live-github-bot / @Desktop • Test App

prettier/prettier

Delete `······`
const {
ajs_prop_source: ajsPropSource,
ajs_prop_campaign: ajsPropCampaign,
ajs_prop_track_data: ajsPropTrackData,
currency,
installApp,
appName,
} = query;

// Track deeplink only when ajsPropSource attribute exists.
if (ajsPropSource) {
const { currency, installApp, appName } = query;
track("deeplink_clicked", {
deeplinkSource: ajsPropSource,
deeplinkCampaign: ajsPropCampaign,
url,
currency,
installApp,
appName,
...(ajsPropTrackData ? JSON.parse(ajsPropTrackData) : {}),
...(ajsPropTrackData ? JSON.parse(decodeURI(ajsPropTrackData)) : {}),
});
}
switch (url) {
Expand Down
32 changes: 27 additions & 5 deletions apps/ledger-live-mobile/src/navigation/DeeplinksProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,33 @@ export const DeeplinksProvider = ({
},
getStateFromPath: (path, config) => {
const url = new URL(`ledgerlive://${path}`);
const { hostname, pathname } = url;
const { hostname, pathname, searchParams, search, href } = url;

Check failure on line 460 in apps/ledger-live-mobile/src/navigation/DeeplinksProvider.tsx

View check run for this annotation

live-github-bot / @Mobile • Test App

@typescript-eslint/no-unused-vars

'search' is assigned a value but never used.
const query = Object.fromEntries(searchParams);

const {
ajs_prop_campaign: ajsPropCampaign,
ajs_prop_track_data: ajsPropTrackData,
ajs_prop_source: ajsPropSource,
currency,
installApp,
appName,
} = query;

// Track deeplink only when ajsPropSource attribute exists.
if (ajsPropSource) {
track("deeplink_clicked", {
deeplinkSource: ajsPropSource,
deeplinkCampaign: ajsPropCampaign,
url: hostname,
currency,
installApp,
appName,
...(ajsPropTrackData ? JSON.parse(decodeURI(ajsPropTrackData)) : {}),
});
}
const platform = pathname.split("/")[1];

if (hostname === "earn") {
const searchParams = url.searchParams;
if (searchParams.get("action") === "info-modal") {
const message = searchParams.get("message") || "";
const messageTitle = searchParams.get("messageTitle") || "";
Expand Down Expand Up @@ -495,9 +517,9 @@ export const DeeplinksProvider = ({

const manifest = manifests.find(m => m.id.toLowerCase() === platform.toLowerCase());
if (!manifest) return undefined;
url.pathname = `/${manifest.id}`;
url.searchParams.set("name", manifest.name);
return getStateFromPath(url.href?.split("://")[1], config);
pathname = `/${manifest.id}`;
searchParams.set("name", manifest.name);
return getStateFromPath(href?.split("://")[1], config);
}
if (path === "linkdrop-nft-claim/qr-scanning") {
track("deeplink", { action: "Claim NFT scan QR code again" });
Expand Down

0 comments on commit 3493eb9

Please sign in to comment.