-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
25 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/ui/src/components/tracking/TrackUnplannedPageView.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {useEffect} from 'react'; | ||
import {usePostHog} from 'posthog-js/react'; | ||
|
||
type Props = { | ||
pageName: string; | ||
}; | ||
|
||
export const TrackUnplannedPageView = ({pageName}: Props) => { | ||
const posthog = usePostHog(); | ||
|
||
useEffect(() => { | ||
if (posthog) { | ||
// Envoie la pageview à PostHog | ||
posthog.capture('$pageview', { | ||
$current_url: pageName, | ||
}); | ||
} | ||
}, [posthog, pageName]); | ||
|
||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters