Skip to content

Commit 4d143e0

Browse files
committed
fix: resolve OutlitProvider initialization and TypeScript module resolution
- Update tsconfig.json moduleResolution from 'node' to 'bundler' to properly resolve '@outlit/browser/react' package exports - Replace imperative outlitInit() with declarative OutlitProvider component in providers.tsx - Remove double initialization conflict between layout.tsx and providers.tsx - Consolidate Outlit configuration in single client component following PostHog pattern This fixes TypeScript errors and ensures proper Outlit analytics tracking for pageviews, forms, user identification, and calendar embeds.
1 parent 8f9c98a commit 4d143e0

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

src/app/providers.tsx

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
import { posthog } from 'posthog-js'
44
import { PostHogProvider } from 'posthog-js/react'
5-
import { useEffect } from 'react'
6-
import { init as outlitInit, track as outlitTrack } from '@outlit/browser'
5+
import { OutlitProvider } from '@outlit/browser/react'
76

87
if (typeof window !== 'undefined' && process.env.NEXT_PUBLIC_POSTHOG_KEY) {
98
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
@@ -16,19 +15,16 @@ if (typeof window !== 'undefined' && process.env.NEXT_PUBLIC_POSTHOG_KEY) {
1615
})
1716
}
1817

19-
if (
20-
typeof window !== 'undefined' &&
21-
process.env.NEXT_PUBLIC_OUTLIT_PUBLIC_KEY
22-
) {
23-
outlitInit({
24-
publicKey: process.env.NEXT_PUBLIC_OUTLIT_PUBLIC_KEY,
25-
trackPageviews: true,
26-
trackForms: true,
27-
autoIdentify: true,
28-
trackCalendarEmbeds: true,
29-
})
30-
}
31-
3218
export function Providers({ children }: { children: React.ReactNode }) {
33-
return <PostHogProvider client={posthog}>{children}</PostHogProvider>
19+
return (
20+
<OutlitProvider
21+
publicKey={process.env.NEXT_PUBLIC_OUTLIT_PUBLIC_KEY!}
22+
trackPageviews
23+
trackForms
24+
autoIdentify
25+
trackCalendarEmbeds
26+
>
27+
<PostHogProvider client={posthog}>{children}</PostHogProvider>
28+
</OutlitProvider>
29+
)
3430
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"noEmit": true,
1414
"esModuleInterop": true,
1515
"module": "esnext",
16-
"moduleResolution": "node",
16+
"moduleResolution": "bundler",
1717
"resolveJsonModule": true,
1818
"isolatedModules": true,
1919
"jsx": "react-jsx",

0 commit comments

Comments
 (0)