Skip to content

Commit

Permalink
fix: change distinct_id to posthog_id in dynamic links
Browse files Browse the repository at this point in the history
  • Loading branch information
olegshilov committed Aug 8, 2024
1 parent 90257dc commit 434a6a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
17 changes: 7 additions & 10 deletions src/components/ui/dynamic-link-redirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ export function DynamicLinkRedirect() {
const posthog = usePostHog();

useEffect(() => {
const goTo = params.get('go_to');
const distinctId = params.get('distinct_id');

if (distinctId && goTo) {
if (distinctId !== 'undefined' && distinctId !== '') {
posthog.identify(distinctId);
const posthogId = params.get('posthog_id');
if (posthogId && posthogId !== 'undefined' && posthogId !== '') {
posthog.identify(posthogId);
}

if (goTo !== 'undefined' && goTo !== '') {
redirect(goTo);
}
}
const goTo = params.get('go_to');
if (goTo && goTo !== 'undefined' && goTo !== '') {
redirect(goTo);
}
}, [params, posthog]);

Expand Down
4 changes: 2 additions & 2 deletions src/utils/get-dynamic-link.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export function getDynamicLink(
link: string,
distinctId: string,
posthogId: string,
forwardTo?: string,
) {
const linkIrl = new URL(link);
linkIrl.searchParams.append('distinct_id', distinctId);
linkIrl.searchParams.append('posthog_id', posthogId);

if (forwardTo) {
linkIrl.searchParams.append('go_to', forwardTo);
Expand Down

0 comments on commit 434a6a3

Please sign in to comment.