-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
910430e
commit 661b93c
Showing
45 changed files
with
387 additions
and
174 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"name": "@fern-docs/analytics", | ||
"version": "0.0.0", | ||
"private": true, | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"types": "./src/index.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"./provider": { | ||
"types": "./src/provider.tsx", | ||
"default": "./dist/provider.js" | ||
} | ||
}, | ||
"scripts": { | ||
"compile": "tsc --build", | ||
"clean": "rm -rf ./dist && tsc --build --clean", | ||
"format": "prettier --write --ignore-unknown --ignore-path ../../shared/.prettierignore \"**\"", | ||
"format:check": "prettier --check --ignore-unknown --ignore-path ../../shared/.prettierignore \"**\"", | ||
"lint": "eslint --max-warnings 0 src --ext .ts --resolve-plugins-relative-to ../../", | ||
"dev": "tsc --watch tsconfig.json" | ||
}, | ||
"peerDependencies": { | ||
"next": "^14", | ||
"react": "^18", | ||
"react-dom": "^18" | ||
}, | ||
"devDependencies": { | ||
"@fern-api/fdr-sdk": "workspace:*", | ||
"@fern-platform/configs": "workspace:*", | ||
"@types/mixpanel-browser": "^2.50.2", | ||
"@types/node": "^18.7.18", | ||
"@types/react": "^18", | ||
"@types/react-dom": "^18.3.0", | ||
"depcheck": "^1.4.3", | ||
"eslint": "^8.56.0", | ||
"next": "^14", | ||
"organize-imports-cli": "^0.10.0", | ||
"prettier": "^3.3.2", | ||
"react": "^18", | ||
"react-dom": "^18", | ||
"typescript": "5.4.3" | ||
}, | ||
"dependencies": { | ||
"@amplitude/analytics-browser": "^2.11.10", | ||
"@datadog/browser-rum": "^5.34.0", | ||
"@hotjar/browser": "^1.0.9", | ||
"@segment/snippet": "^5.2.1", | ||
"fathom-client": "^3.7.2", | ||
"logrocket": "^9.0.0", | ||
"mixpanel-browser": "^2.57.1", | ||
"posthog-js": "^1.154.5", | ||
"zod": "^3.24.1" | ||
} | ||
} |
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
6 changes: 3 additions & 3 deletions
6
...ages/ui/app/src/analytics/datadog-rum.tsx → packages/ui/analytics/src/datadog-rum.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
4 changes: 2 additions & 2 deletions
4
packages/ui/app/src/analytics/fathom.tsx → packages/ui/analytics/src/fathom.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
6 changes: 3 additions & 3 deletions
6
packages/ui/app/src/analytics/fullstory.tsx → packages/ui/analytics/src/fullstory.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
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
6 changes: 3 additions & 3 deletions
6
packages/ui/app/src/analytics/heap.tsx → packages/ui/analytics/src/heap.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
8 changes: 4 additions & 4 deletions
8
packages/ui/app/src/analytics/hotjar.tsx → packages/ui/analytics/src/hotjar.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
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,7 @@ | ||
declare global { | ||
interface Window { | ||
[key: string]: any; | ||
} | ||
} | ||
|
||
export { track, trackInternal } from "./track"; |
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
6 changes: 3 additions & 3 deletions
6
packages/ui/app/src/analytics/koala.tsx → packages/ui/analytics/src/koala.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
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
6 changes: 3 additions & 3 deletions
6
packages/ui/app/src/analytics/mixpanel.tsx → packages/ui/analytics/src/mixpanel.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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import posthog from "posthog-js"; | ||
import { ReactNode, useEffect } from "react"; | ||
import { useRouteChangeComplete } from "./use-route-changed"; | ||
import { useSafeListenTrackEvents } from "./use-track"; | ||
import { useUserInfo } from "./user"; | ||
|
||
export default function Posthog({ route }: { route: string }): ReactNode { | ||
// initialize the posthog instance | ||
useEffect(() => { | ||
const token = process.env.NEXT_PUBLIC_POSTHOG_API_KEY; | ||
if (token == null) { | ||
// eslint-disable-next-line no-console | ||
console.warn("Posthog will NOT be initialized."); | ||
return; | ||
} | ||
|
||
posthog.init(token, { | ||
api_host: route, | ||
capture_pageview: true, | ||
capture_pageleave: true, | ||
}); | ||
}, [route]); | ||
|
||
// identify the user after the posthog instance is initialized | ||
const user = useUserInfo(); | ||
useEffect(() => { | ||
if (user && user.email && posthog._isIdentified()) { | ||
posthog.identify(user.email); | ||
} else if (posthog._isIdentified()) { | ||
posthog.reset(); | ||
} | ||
}, [user]); | ||
|
||
// capture pageviews | ||
useRouteChangeComplete(() => { | ||
// posthog doesn't handle this automatically: https://posthog.com/docs/libraries/next-js#pageview | ||
posthog.capture("$pageview"); | ||
}); | ||
|
||
// capture events | ||
useSafeListenTrackEvents(({ event, properties }) => { | ||
posthog.capture(event, properties); | ||
}, true); | ||
|
||
return false; | ||
} |
Oops, something went wrong.