Skip to content
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

Enable posthog for profile #1018

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"book": "pnpm --filter @cartridge/documentation",
"ui": "pnpm --filter @cartridge/ui",
"ui:next": "pnpm --filter @cartridge/ui-next",
"profil": "pnpm --filter @cartridge/profile",
"profile": "pnpm --filter @cartridge/profile",
"utils": "pnpm --filter @cartridge/utils",
"example:next": "pnpm --filter @cartridge/controller-example-next",
"example:svelte": "pnpm --filter @cartridge/controller-example-svelte",
Expand All @@ -39,4 +39,4 @@
"vercel": "^37.4.2",
"@types/react": "^18.3.12"
}
}
}
2 changes: 2 additions & 0 deletions packages/profile/.env.development
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VITE_CARTRIDGE_API_URL="http://localhost:8000"
VITE_KEYCHAIN_URL="http://localhost:3001"
VITE_RPC_SEPOLIA="http://localhost:8001/x/starknet/sepolia"
NEXT_PUBLIC_POSTHOG_KEY=phc_UWaJajNQ00PjHhveZ81SJ2zVtBicKrzewdZHGiyavQQ
NEXT_PUBLIC_POSTHOG_HOST=https://x.cartridge.gg/ingest
2 changes: 2 additions & 0 deletions packages/profile/.env.production
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VITE_CARTRIDGE_API_URL="https://api.cartridge.gg"
VITE_KEYCHAIN_URL="https://x.cartridge.gg"
VITE_RPC_SEPOLIA="https://api.cartridge.gg/x/starknet/sepolia"
NEXT_PUBLIC_POSTHOG_KEY=phc_UWaJajNQ00PjHhveZ81SJ2zVtBicKrzewdZHGiyavQQ
NEXT_PUBLIC_POSTHOG_HOST=https://x.cartridge.gg/ingest
2 changes: 2 additions & 0 deletions packages/profile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@cartridge/penpal": "^6.2.3",
"@cartridge/ui-next": "workspace:^",
"@cartridge/utils": "workspace:^",
"posthog-js": "^1.181.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-query": "^3.39.2",
Expand All @@ -26,6 +27,7 @@
},
"devDependencies": {
"@eslint/js": "^9.9.0",
"@types/node": "^20.6.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react-swc": "^3.5.0",
Expand Down
44 changes: 29 additions & 15 deletions packages/profile/src/components/context/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,39 @@ import { BrowserRouter } from "react-router-dom";
import { CartridgeAPIProvider } from "@cartridge/utils/api/cartridge";
import { IndexerAPIProvider } from "@cartridge/utils/api/indexer";
import { DataProvider } from "./data";
import posthog from "posthog-js";
import { PostHogProvider } from "posthog-js/react";

if (typeof window !== "undefined") {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
person_profiles: "always",
loaded: (posthog) => {
if (process.env.NODE_ENV === "development") posthog.debug();
},
});
}

export function Provider({ children }: PropsWithChildren) {
const queryClient = new QueryClient();

return (
<BrowserRouter>
<ThemeProvider defaultScheme="system">
<CartridgeAPIProvider
url={`${import.meta.env.VITE_CARTRIDGE_API_URL!}/query`}
>
<IndexerAPIProvider credentials="omit">
<QueryClientProvider client={queryClient}>
<ConnectionProvider>
<DataProvider>{children}</DataProvider>
</ConnectionProvider>
</QueryClientProvider>
</IndexerAPIProvider>
</CartridgeAPIProvider>
</ThemeProvider>
</BrowserRouter>
<PostHogProvider client={posthog}>
<BrowserRouter>
<ThemeProvider defaultScheme="system">
<CartridgeAPIProvider
url={`${import.meta.env.VITE_CARTRIDGE_API_URL!}/query`}
>
<IndexerAPIProvider credentials="omit">
<QueryClientProvider client={queryClient}>
<ConnectionProvider>
<DataProvider>{children}</DataProvider>
</ConnectionProvider>
</QueryClientProvider>
</IndexerAPIProvider>
</CartridgeAPIProvider>
</ThemeProvider>
</BrowserRouter>
</PostHogProvider>
);
}
29 changes: 26 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading