mirror of
https://github.com/Xevion/rdap.git
synced 2025-12-10 08:08:16 -06:00
feat: add PostHog telemetry with privacy-focused tracking
Integrate optional PostHog telemetry to track page views, RDAP queries, user interactions, and errors while maintaining user privacy. Key features: - Type-safe event tracking with discriminated unions - Automatic source map upload for production error tracking - Privacy protections (query targets excluded from successful lookups) - Do Not Track (DNT) header support - Optional telemetry (disabled by default without environment variables) - Error boundary with automatic error tracking - Context-based telemetry integration throughout UI components Environment variables required for telemetry: - NEXT_PUBLIC_POSTHOG_KEY: PostHog project API key (client-side) - NEXT_PUBLIC_POSTHOG_HOST: PostHog API endpoint (client-side) - POSTHOG_PERSONAL_API_KEY: Source map upload key (server-side)
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
// @ts-check
|
||||
import { withPostHogConfig } from "@posthog/nextjs-config";
|
||||
|
||||
/**
|
||||
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation.
|
||||
* This is especially useful for Docker builds.
|
||||
@@ -6,11 +8,27 @@
|
||||
!process.env.SKIP_ENV_VALIDATION && (await import("./src/env/server.mjs"));
|
||||
|
||||
/** @type {import("next").NextConfig} */
|
||||
const config = {
|
||||
const nextConfig = {
|
||||
reactStrictMode: true,
|
||||
i18n: {
|
||||
locales: ["en"],
|
||||
defaultLocale: "en",
|
||||
},
|
||||
};
|
||||
export default config;
|
||||
|
||||
// PostHog source map configuration
|
||||
// Only uploads source maps in production builds when POSTHOG_PERSONAL_API_KEY is set
|
||||
const postHogConfig = {
|
||||
personalApiKey: process.env.POSTHOG_PERSONAL_API_KEY || "",
|
||||
envId: "238067", // PostHog project ID for source map correlation
|
||||
host: "https://us.i.posthog.com",
|
||||
sourcemaps: {
|
||||
// Only enable on production builds with API key
|
||||
enabled: process.env.NODE_ENV === "production" && !!process.env.POSTHOG_PERSONAL_API_KEY,
|
||||
project: "rdap",
|
||||
version: process.env.VERCEL_GIT_COMMIT_SHA || "local",
|
||||
deleteAfterUpload: true,
|
||||
},
|
||||
};
|
||||
|
||||
export default withPostHogConfig(nextConfig, postHogConfig);
|
||||
|
||||
Reference in New Issue
Block a user