Skip to content

Commit 0a10fce

Browse files
AAorrisjoshsny
andauthored
Update PostHog example (#1142)
### Description Improvements for the PostHog example, including a proper link to the upcoming Flags SDK docs and the latest package version --------- Co-authored-by: Joshua Snyder <joshua@posthog.com>
1 parent 9c0bb83 commit 0a10fce

File tree

6 files changed

+14
-26
lines changed

6 files changed

+14
-26
lines changed

flags-sdk/posthog/.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# For @flags-sdk/posthog
2+
# node -e 'console.log(`${crypto.randomBytes(32).toString("base64url")}`)'
23
FLAGS_SECRET=""
3-
EDGE_CONFIG=""
4+
45
NEXT_PUBLIC_POSTHOG_KEY=""
56
NEXT_PUBLIC_POSTHOG_HOST="https://us.i.posthog.com"
67

flags-sdk/posthog/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PostHog Flags SDK Example
22

3-
This example uses [PostHog](https://posthog.com) for feature flags with the [Flags SDK](https://flags-sdk.dev) along with the `@flags-sdk/posthog` [PostHog adapter](https://flags-sdk.dev/docs/api-reference/adapters/posthog) and the [Flags Explorer](https://vercel.com/docs/workflow-collaboration/feature-flags/using-vercel-toolbar).
3+
This example uses [PostHog](https://posthog.com) for feature flags with the [Flags SDK](https://flags-sdk.dev) along with the `@flags-sdk/posthog` [PostHog adapter](https://flags-sdk.dev/providers/posthog) and the [Flags Explorer](https://vercel.com/docs/workflow-collaboration/feature-flags/using-vercel-toolbar).
44

55
## Demo
66

flags-sdk/posthog/app/.well-known/vercel/flags/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export const GET = createFlagsDiscoveryEndpoint(
1212
getProviderData(flags),
1313
// metadata from PostHog API using the default posthog adapter
1414
getPostHogProviderData({
15-
personalApiKey: process.env.POSTHOG_PERSONAL_API_KEY,
16-
projectId: process.env.POSTHOG_PROJECT_ID,
15+
personalApiKey: process.env.POSTHOG_PERSONAL_API_KEY as string,
16+
projectId: process.env.POSTHOG_PROJECT_ID as string,
1717
}),
1818
])
1919
},

flags-sdk/posthog/lib/identify.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { Identify } from 'flags';
2-
import { dedupe } from 'flags/next';
3-
import { getStableId } from './get-stable-id';
1+
import type { Identify } from 'flags'
2+
import { dedupe } from 'flags/next'
3+
import { getStableId } from './get-stable-id'
44

55
export type PostHogEntities = {
6-
distinctId: string;
7-
};
6+
distinctId: string
7+
}
88

99
export const identify = dedupe(async () => {
10-
const stableId = await getStableId();
10+
const stableId = await getStableId()
1111

12-
return { distinctId: stableId.value };
13-
}) satisfies Identify<PostHogEntities>;
12+
return { distinctId: stableId.value }
13+
}) satisfies Identify<PostHogEntities>

flags-sdk/posthog/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"start": "next start"
1010
},
1111
"dependencies": {
12-
"@flags-sdk/posthog": "0.1.0-2e7a523a-20250522190315",
12+
"@flags-sdk/posthog": "0.1.0",
1313
"@headlessui/react": "^2.2.0",
1414
"@heroicons/react": "2.2.0",
1515
"@tailwindcss/aspect-ratio": "0.4.2",

flags-sdk/posthog/utils/get-stable-id.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)