Skip to content

Commit 1698763

Browse files
authored
Add posthog (#188)
- [x] needs new secrets configured before ready to merge
1 parent b92b914 commit 1698763

File tree

6 files changed

+86
-1
lines changed

6 files changed

+86
-1
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ DIGITALOCEAN_TOKEN=
1313
## Error reporting
1414
SENTRY_INGEST=
1515
SENTRY_RELEASES=
16+
17+
VITE_PUBLIC_POSTHOG_KEY=phc_…
18+
VITE_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com

.github/workflows/node.js.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ jobs:
143143
--from-literal=DISCORD_TEST_GUILD=${{ secrets.DISCORD_TEST_GUILD }} \
144144
--from-literal=SENTRY_INGEST=${{ secrets.SENTRY_INGEST }} \
145145
--from-literal=SENTRY_RELEASES=${{ secrets.SENTRY_RELEASES }} \
146+
--from-literal=VITE_PUBLIC_POSTHOG_KEY=${{ secrets.VITE_PUBLIC_POSTHOG_KEY }} \
147+
--from-literal=VITE_PUBLIC_POSTHOG_HOST=${{ secrets.VITE_PUBLIC_POSTHOG_HOST }} \
146148
--from-literal=DATABASE_URL=${{ secrets.DATABASE_URL }}
147149
kubectl apply -k .
148150

app/entry.client.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
import { HydratedRouter } from "react-router/dom";
22
import { hydrateRoot } from "react-dom/client";
3+
import { PostHogProvider } from "posthog-js/react";
34

4-
hydrateRoot(document, <HydratedRouter />);
5+
const options = {
6+
api_host: import.meta.env.VITE_PUBLIC_POSTHOG_HOST,
7+
defaults: "2025-05-24" as const,
8+
};
9+
10+
hydrateRoot(
11+
document,
12+
<PostHogProvider
13+
apiKey={import.meta.env.VITE_PUBLIC_POSTHOG_KEY}
14+
options={options}
15+
>
16+
<HydratedRouter />
17+
</PostHogProvider>,
18+
);

cluster/deployment.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ spec:
7373
name: modbot-env
7474
key: SENTRY_RELEASES
7575

76+
- name: VITE_PUBLIC_POSTHOG_KEY
77+
valueFrom:
78+
secretKeyRef:
79+
name: modbot-env
80+
key: VITE_PUBLIC_POSTHOG_KEY
81+
82+
- name: VITE_PUBLIC_POSTHOG_HOST
83+
valueFrom:
84+
secretKeyRef:
85+
name: modbot-env
86+
key: VITE_PUBLIC_POSTHOG_HOST
87+
7688
- name: DATABASE_URL
7789
valueFrom:
7890
secretKeyRef:

package-lock.json

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"node-cron": "^3.0.0",
5858
"node-fetch": "^3.3.2",
5959
"pino-http": "^10.4.0",
60+
"posthog-js": "^1.280.1",
6061
"pretty-bytes": "^5.6.0",
6162
"query-string": "^9.2.2",
6263
"reacord": "^0.6.0",

0 commit comments

Comments
 (0)