Skip to content

Commit

Permalink
fix: check if returnTo is defined (release) (#8518)
Browse files Browse the repository at this point in the history
fix: check if returnTo is defined (#8516)

* fix: check if returnTo is defined
* chore: add changeset
* chore: accept suggestion
  • Loading branch information
Couto authored Nov 28, 2024
1 parent 414f985 commit 9cea8d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-zoos-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": minor
---

Ensure returnTo value is defined before tracking analytics
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function LiveApp({ match, appId: propsAppId, location }: Props) {
};
};
const appId = propsAppId || match.params?.appId;
const returnTo = useMemo(() => {
const returnTo = useMemo<string | undefined>(() => {
const params = new URLSearchParams(search);
return urlParams?.returnTo || params.get("returnTo") || internalParams?.returnTo;
}, [search, urlParams?.returnTo, internalParams?.returnTo]);
Expand All @@ -60,14 +60,15 @@ 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",
partner: appId,
page: "swap",
});
}

history.push(returnTo || `/platform`);
}, [history, returnTo, appId, swapTrackingProperties, track]);
const themeType = useTheme().colors.palette.type;
Expand Down

0 comments on commit 9cea8d5

Please sign in to comment.