Skip to content

Commit

Permalink
dynamic apis
Browse files Browse the repository at this point in the history
  • Loading branch information
collinschaafsma committed Oct 16, 2024
1 parent f1c6837 commit d34988c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/capture-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function captureEvent(event: Event) {

// If there is no distinctId, attempt to get one from the cookie.
// If there is no cookie, getDistinctId will generate a new one using nanoid()
if (!event.distinctId) event.distinctId = getDistinctId()
if (!event.distinctId) event.distinctId = await getDistinctId()

const postHog = postHogClient()
if (!postHog) return
Expand Down
4 changes: 2 additions & 2 deletions lib/post-hog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export function postHogClient() {
})
}

export function getDistinctId() {
const cookie = cookies().get(
export async function getDistinctId() {
const cookie = (await cookies()).get(
`ph_${process.env.NEXT_PUBLIC_POSTHOG_KEY!}_posthog`
)
if (!cookie) return nanoid()
Expand Down

0 comments on commit d34988c

Please sign in to comment.