diff --git a/.changeset/giant-zoos-reply.md b/.changeset/giant-zoos-reply.md new file mode 100644 index 000000000000..f54a19133920 --- /dev/null +++ b/.changeset/giant-zoos-reply.md @@ -0,0 +1,5 @@ +--- +"ledger-live-desktop": minor +--- + +Ensure returnTo value is defined before tracking analytics diff --git a/apps/ledger-live-desktop/src/renderer/screens/platform/LiveApp.tsx b/apps/ledger-live-desktop/src/renderer/screens/platform/LiveApp.tsx index 46e8b0714cea..61496ed1faf4 100644 --- a/apps/ledger-live-desktop/src/renderer/screens/platform/LiveApp.tsx +++ b/apps/ledger-live-desktop/src/renderer/screens/platform/LiveApp.tsx @@ -45,7 +45,7 @@ export function LiveApp({ match, appId: propsAppId, location }: Props) { }; }; const appId = propsAppId || match.params?.appId; - const returnTo = useMemo(() => { + const returnTo = useMemo(() => { const params = new URLSearchParams(search); return urlParams?.returnTo || params.get("returnTo") || internalParams?.returnTo; }, [search, urlParams?.returnTo, internalParams?.returnTo]); @@ -60,7 +60,7 @@ export function LiveApp({ match, appId: propsAppId, location }: Props) { }, [search, customDappUrl, urlParams?.customDappUrl, internalParams?.customDappUrl]); const handleClose = useCallback(() => { - if (returnTo.startsWith("/swap")) { + if (returnTo?.startsWith("/swap")) { track("button_click", { ...swapTrackingProperties, button: "close X", @@ -68,6 +68,7 @@ export function LiveApp({ match, appId: propsAppId, location }: Props) { page: "swap", }); } + history.push(returnTo || `/platform`); }, [history, returnTo, appId, swapTrackingProperties, track]); const themeType = useTheme().colors.palette.type;