mirror of
https://github.com/hanzoai/insights-js.git
synced 2026-11-02 14:31:14 +00:00
Bulk rename across 989 files: - Package names: posthog-js → @hanzo/insights, posthog-node → @hanzo/insights-node, etc. - Repository URLs: posthog/posthog-js → hanzoai/insights-js - Brand names: PostHog → Insights - File renames: 259 reference JSON files, source files, workflow files - Directory rename: eslint-plugin-posthog-js → eslint-plugin-insights Remaining: 8 refs to @posthog/rrweb-* (real npm deps, need fork+publish)
76 lines
3.2 KiB
TypeScript
76 lines
3.2 KiB
TypeScript
import '@/styles/globals.css'
|
|
|
|
import type { AppProps } from 'next/app'
|
|
import { useEffect } from 'react'
|
|
|
|
import { CookieBanner } from '@/src/CookieBanner'
|
|
import { PageHeader } from '@/src/Header'
|
|
import { useUser } from '@/src/auth'
|
|
import { insights, insightsHelpers } from '@/src/insights'
|
|
import Head from 'next/head'
|
|
import { InsightsProvider } from '@hanzo/insights/react'
|
|
|
|
const CDP_DOMAINS = ['https://*.redditstatic.com', 'https://*.reddit.com'].join(' ')
|
|
const TMDB_DOMAINS = ['https://api.themoviedb.org', 'https://image.tmdb.org'].join(' ')
|
|
const CHAT_DOMAINS = [
|
|
'https://*.intercom.io',
|
|
'https://*.intercomcdn.com',
|
|
'wss://*.intercom.io',
|
|
'https://static.intercomassets.com',
|
|
'https://*.crisp.chat',
|
|
'wss://*.relay.crisp.chat',
|
|
].join(' ')
|
|
|
|
export default function App({ Component, pageProps }: AppProps) {
|
|
const user = useUser()
|
|
useEffect(() => {
|
|
// Use a type assertion to add the property to the window object
|
|
;(window as any).INSIGHTS_DEBUG = true
|
|
if (user) {
|
|
insightsHelpers.setUser(user)
|
|
}
|
|
}, [user])
|
|
|
|
useEffect(() => {
|
|
// make sure we initialize the WebSocket server
|
|
// we don't need to support IE11 here
|
|
// eslint-disable-next-line compat/compat
|
|
fetch('/api/socket')
|
|
}, [])
|
|
|
|
const localhostDomain = process.env.NEXT_PUBLIC_CROSSDOMAIN
|
|
? 'https://localhost:8000'
|
|
: process.env.NEXT_PUBLIC_INSIGHTS_HOST
|
|
|
|
return (
|
|
<InsightsProvider client={insights}>
|
|
<Head>
|
|
<title>Insights</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
{/* CSP - useful for testing our documented recommendations. NOTE: Unsafe is only needed for nextjs pre-loading */}
|
|
<meta
|
|
httpEquiv="Content-Security-Policy"
|
|
content={`
|
|
default-src 'self';
|
|
connect-src 'self' ${localhostDomain} https://*.insights.com https://lottie.host ${CDP_DOMAINS} ${CHAT_DOMAINS} ${TMDB_DOMAINS};
|
|
script-src 'self' 'unsafe-eval' 'unsafe-inline' ${localhostDomain} https://*.insights.com ${CDP_DOMAINS} ${CHAT_DOMAINS};
|
|
style-src 'self' 'unsafe-inline' ${localhostDomain} https://*.insights.com ${CHAT_DOMAINS};
|
|
img-src 'self' data: blob: ${localhostDomain} https://*.insights.com https://lottie.host https://cataas.com ${CDP_DOMAINS} ${CHAT_DOMAINS} ${TMDB_DOMAINS} https://upload.wikimedia.org;
|
|
worker-src 'self' blob: ${CHAT_DOMAINS};
|
|
font-src 'self' ${localhostDomain} https://*.insights.com ${CHAT_DOMAINS};
|
|
media-src 'self' ${localhostDomain} https://*.insights.com ${CHAT_DOMAINS};
|
|
frame-src 'self' ${localhostDomain} https://*.insights.com ${CHAT_DOMAINS};
|
|
`}
|
|
/>
|
|
</Head>
|
|
|
|
<div id="ph-custom-banner-container"></div>
|
|
<main className="max-w-full overflow-hidden">
|
|
<PageHeader />
|
|
<Component {...pageProps} />
|
|
<CookieBanner />
|
|
</main>
|
|
</InsightsProvider>
|
|
)
|
|
}
|