Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Posthog configuration on web app #3617

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions clients/apps/web/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const nextConfig = {
transpilePackages: ['polarkit', 'shiki'],
pageExtensions: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'],

// This is required to support PostHog trailing slash API requests
skipTrailingSlashRedirect: true,

images: {
remotePatterns: [
{
Expand Down Expand Up @@ -81,8 +84,12 @@ const nextConfig = {

// PostHog Rewrite
{
source: '/ingest/:path*',
destination: 'https://app.posthog.com/:path*',
source: "/ingest/static/:path*",
destination: "https://us-assets.i.posthog.com/static/:path*",
},
{
source: "/ingest/:path*",
destination: "https://us.i.posthog.com/:path*",
},
]
}
Expand Down
13 changes: 8 additions & 5 deletions clients/apps/web/src/app/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ import { queryClient } from '@/utils/api'
import { CONFIG } from '@/utils/config'
import { QueryClientProvider } from '@tanstack/react-query'
import { ReactQueryStreamedHydration } from '@tanstack/react-query-next-experimental'
import { AppProgressBar as ProgressBar } from 'next-nprogress-bar'
import { ThemeProvider } from 'next-themes'
import { usePathname, useSearchParams } from 'next/navigation'
import posthog from 'posthog-js'
import { PostHogProvider } from 'posthog-js/react'
import { useEffect } from 'react'
import { AppProgressBar as ProgressBar } from 'next-nprogress-bar'


if (CONFIG.POSTHOG_TOKEN && typeof window !== 'undefined') {
posthog.init(CONFIG.POSTHOG_TOKEN, {
api_host: CONFIG.POSTHOG_HOST ?? 'https://app.posthog.com',
ui_host: 'https://app.posthog.com',
api_host: '/ingest',
ui_host: 'https://us.posthog.com',
})
}

Expand Down Expand Up @@ -73,7 +72,11 @@ export function PolarQueryClientProvider({
)
}

export function PolarToploaderProvider({ children }: { children: React.ReactNode }) {
export function PolarToploaderProvider({
children,
}: {
children: React.ReactNode
}) {
return (
<>
{children}
Expand Down
1 change: 0 additions & 1 deletion clients/apps/web/src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ let defaults = {
process.env.NEXT_PUBLIC_GITHUB_BADGE_EMBED_DEFAULT_LABEL || 'Fund',
SENTRY_DSN: process.env.NEXT_PUBLIC_SENTRY_DSN || undefined,
POSTHOG_TOKEN: process.env.NEXT_PUBLIC_POSTHOG_TOKEN || '',
POSTHOG_HOST: process.env.NEXT_PUBLIC_POSTHOG_HOST || undefined,
STRIPE_COUNTRIES_WHITELIST_CSV:
process.env.NEXT_PUBLIC_STRIPE_COUNTRIES_WHITELIST || STRIPE_COUNTRIES,
APPLE_DOMAIN_ASSOCIATION:
Expand Down
Loading