-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Posthog Analytics #226
Merged
Merged
Posthog Analytics #226
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
dcc2755
chore(hub): adds posthog
bearpong 70cf81c
fix: adds posthog page view
bearpong fcfb027
feat(bex): add support for PostHog analytics inside the useAnalytics …
PaulMcInnis 40dc9f4
remove NEXT_PUBLIC_DEVELOPMENT_ANALYTICS which belongs in the .env.lo…
PaulMcInnis a55e6ac
Merge branch 'v2' into posthog-setup
PaulMcInnis edf8de9
fix(bex): rebuild lockfile w/ posthog deps + update secrets to includ…
PaulMcInnis 9dff1a2
Merge branch 'v2' into posthog-setup
PaulMcInnis f6239b4
feat(bex): add support for tracking redeem events in analytics
PaulMcInnis 743218a
fix(bex): move to a swap_token event with the data inside.
PaulMcInnis 2022dd9
feat(bex): add tracking for redeem swaps
PaulMcInnis 17c5b99
fix(bex): swap_redeem --> redeem
PaulMcInnis 76557ec
feat(bex): add coverage for pool withdraw event
PaulMcInnis b8e7461
feat(bex): add coverage for pool deposit
PaulMcInnis 37ac136
feat(bex): add tracking support for stake/unstake + properly track fa…
PaulMcInnis a767beb
Merge branch 'v2' into posthog-setup
PaulMcInnis 3961952
feat(bex): properly handle errors when sending events to posthog + gr…
PaulMcInnis ac8e990
fix(bex): include the token symbols in add/withdraw + formatting
PaulMcInnis 4d6f3cb
fix(bex): just track token symbols not addresses
PaulMcInnis 7ba2de4
fix(bex): map the token symbols in add/withdraw using the pool token …
PaulMcInnis 1fc9692
fix(bex): update secrets
PaulMcInnis 336854e
Merge branch 'v2' into posthog-setup
PaulMcInnis 8ff0258
fix(bex): rename swap_token -> swap
PaulMcInnis 7a63b80
feat(bex): record the withdraw liquidity kind (proportional/single)
PaulMcInnis 41f0a37
Merge branch 'v2' into posthog-setup
PaulMcInnis 286b60f
fix(bex): dump the mixpanel hooks and config in analytics
PaulMcInnis b9e7eeb
fix(bex): remove mixpanel dependencies and dodge upgrading to react 1…
PaulMcInnis 77d091e
fix(bex): update secrets
PaulMcInnis 59ca174
Merge branch 'v2' into posthog-setup
PaulMcInnis 9f44ea2
Merge branch 'v2' into posthog-setup
PaulMcInnis d00e20d
fix(bex): merge update + dump mixpanel from env.local.example
PaulMcInnis ddd583a
fix(bex): throw away lock on react version
PaulMcInnis d978342
fix(bex): reduce pnpm churn
PaulMcInnis 385c855
chore(bex): update static build node version from 18 to 20
PaulMcInnis b293d32
Merge branch 'v2' into posthog-setup
PaulMcInnis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,25 @@ | ||
"use client"; | ||
|
||
import { usePathname, useSearchParams } from "next/navigation"; | ||
import { useEffect } from "react"; | ||
import { usePostHog } from "posthog-js/react"; | ||
|
||
export default function PostHogPageView(): null { | ||
const pathname = usePathname(); | ||
const searchParams = useSearchParams(); | ||
const posthog = usePostHog(); | ||
useEffect(() => { | ||
// Track pageviews | ||
if (pathname && posthog) { | ||
let url = window.origin + pathname; | ||
if (searchParams.toString()) { | ||
url = `${url}?${searchParams.toString()}`; | ||
} | ||
posthog.capture("$pageview", { | ||
$current_url: url, | ||
}); | ||
} | ||
}, [pathname, searchParams, posthog]); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,40 @@ | ||
"use client"; | ||
import React, { type PropsWithChildren } from "react"; | ||
|
||
import React, { useEffect, type PropsWithChildren } from "react"; | ||
import { BeraJsProvider, BlockTimeProvider } from "@bera/berajs"; | ||
import { BeraWagmi } from "@bera/wagmi"; | ||
import posthog from "posthog-js"; | ||
import { PostHogProvider } from "posthog-js/react"; | ||
|
||
import { ThemeProvider } from "~/components/theme-provider"; | ||
import { BeraJsProvider, BlockTimeProvider } from "@bera/berajs"; | ||
|
||
export default function Providers({ children }: PropsWithChildren<any>) { | ||
useEffect(() => { | ||
if (!process.env.NEXT_PUBLIC_POSTHOG_KEY) { | ||
return; | ||
} | ||
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, { | ||
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST, | ||
person_profiles: "identified_only", | ||
capture_pageview: false, // Disable automatic pageview capture, as we capture manually | ||
}); | ||
}, []); | ||
return ( | ||
<BeraWagmi> | ||
<BeraJsProvider configOverride={undefined}> | ||
<BlockTimeProvider> | ||
<ThemeProvider | ||
attribute="class" | ||
defaultTheme="dark" | ||
forcedTheme="dark" | ||
themes={["dark"]} | ||
> | ||
{children} | ||
</ThemeProvider> | ||
</BlockTimeProvider> | ||
</BeraJsProvider> | ||
</BeraWagmi> | ||
<PostHogProvider client={posthog}> | ||
<BeraWagmi> | ||
<BeraJsProvider configOverride={undefined}> | ||
<BlockTimeProvider> | ||
<ThemeProvider | ||
attribute="class" | ||
defaultTheme="dark" | ||
forcedTheme="dark" | ||
themes={["dark"]} | ||
> | ||
{children} | ||
</ThemeProvider> | ||
</BlockTimeProvider> | ||
</BeraJsProvider> | ||
</BeraWagmi> | ||
</PostHogProvider> | ||
); | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this kinda sucks, but the reason is that we dont have the token symbols inside the queryOutput, so we have to match the address to get it back out from the pool data itself.
If there's a better way lmk, we need to maintain the ordering so that the amounts correspond.