Skip to content

Commit 9a06dc4

Browse files
committed
fix: knip
1 parent 3bd3576 commit 9a06dc4

6 files changed

Lines changed: 7 additions & 19 deletions

File tree

src/lib/posthog-client.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import posthog from 'posthog-js'
66

77
import { env } from '@/env'
88
import { POSTHOG_EVENT_VERSION } from '@/lib/posthog-events'
9-
import { POSTHOG_FEATURE_FLAGS } from '@/lib/posthog-flags'
109
import { getErrorKind, sanitizeProperties } from '@/lib/posthog-sanitize'
1110

1211
function getBaseProperties(pathname?: string, locale?: string, userRole?: string) {
@@ -20,16 +19,10 @@ function getBaseProperties(pathname?: string, locale?: string, userRole?: string
2019
}
2120
}
2221

23-
export function isPostHogClientEnabled() {
22+
function isPostHogClientEnabled() {
2423
return Boolean(env.NEXT_PUBLIC_POSTHOG_KEY && env.NEXT_PUBLIC_POSTHOG_HOST)
2524
}
2625

27-
export function areClientAnalyticsEventsEnabled() {
28-
if (!isPostHogClientEnabled()) return false
29-
30-
return posthog.isFeatureEnabled(POSTHOG_FEATURE_FLAGS.analyticsClientEvents) !== false
31-
}
32-
3326
export function captureClientEvent<
3427
TEvent extends Extract<
3528
PostHogEventName,
@@ -43,7 +36,7 @@ export function captureClientEvent<
4336
properties: EventProperties<TEvent>,
4437
context: { pathname?: string; locale?: string; userRole?: string } = {},
4538
) {
46-
if (!areClientAnalyticsEventsEnabled()) return
39+
if (!isPostHogClientEnabled()) return
4740

4841
posthog.capture(event, {
4942
...getBaseProperties(context.pathname, context.locale, context.userRole),

src/lib/posthog-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function getPostHogHost() {
1010
return env.NEXT_PUBLIC_POSTHOG_HOST ? trimTrailingSlash(env.NEXT_PUBLIC_POSTHOG_HOST) : undefined
1111
}
1212

13-
export function isPostHogEnabled() {
13+
function isPostHogEnabled() {
1414
return Boolean(env.NEXT_PUBLIC_POSTHOG_KEY && getPostHogHost())
1515
}
1616

src/lib/posthog-flags.ts

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

src/lib/posthog-identity.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function parsePostHogCookie(cookieValue: string) {
1010
}
1111
}
1212

13-
export function getPostHogCookieValue(cookieHeader?: string | string[]) {
13+
function getPostHogCookieValue(cookieHeader?: string | string[]) {
1414
if (!cookieHeader) return
1515

1616
const cookieString = Array.isArray(cookieHeader) ? cookieHeader.join('; ') : cookieHeader
@@ -29,7 +29,7 @@ export function getDistinctIdFromPostHogCookie(cookieHeader?: string | string[])
2929
return typeof parsed.distinct_id === 'string' && parsed.distinct_id.length > 0 ? parsed.distinct_id : undefined
3030
}
3131

32-
export function getAnonymousDistinctId(headers: Headers) {
32+
function getAnonymousDistinctId(headers: Headers) {
3333
const forwardedDistinctId = headers.get('x-posthog-distinct-id')
3434
if (forwardedDistinctId) return forwardedDistinctId
3535

src/lib/posthog-sanitize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function sanitizeRecord(value: Record<string, unknown>) {
3232
)
3333
}
3434

35-
export function sanitizeValue(value: unknown): unknown {
35+
function sanitizeValue(value: unknown): unknown {
3636
if (value === null || value === undefined) return value
3737
if (typeof value === 'boolean' || typeof value === 'number') return value
3838
if (typeof value === 'string') return sanitizeString(value)

src/lib/posthog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { getErrorKind, sanitizeProperties } from './posthog-sanitize'
1010

1111
let posthogInstance: PostHog | null = null
1212

13-
export function getPostHogServerOrNull() {
13+
function getPostHogServerOrNull() {
1414
const host = getPostHogHost()
1515

1616
if (!env.NEXT_PUBLIC_POSTHOG_KEY || !host) {

0 commit comments

Comments
 (0)