@posthog/electron 0.0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utility.mjs","names":["PostHog","singleton","Facade"],"sources":["../src/shared/exception-autocapture.ts","../src/renderer/exception-autocapture.ts","../src/shared/protocol.ts","../src/renderer/autocapture.ts","../src/renderer/index.ts","../src/utility/protocol.ts","../src/utility/bridge.ts","../src/utility/index.ts"],"sourcesContent":["import { BucketedRateLimiter, createLogger, resolveExceptionRateLimiterConfig } from '@posthog/core/utils'\nimport type { EventHint } from '@posthog/core/error-tracking'\n\nexport type ExceptionCapture = (\n error: unknown,\n properties: { $exception_source: string },\n hint: EventHint\n) => Promise<void>\n\n/** Never let reporting failures escape a runtime's global error dispatch. */\nexport function createExceptionObserver(\n canCapture: () => boolean,\n capture: ExceptionCapture,\n isIgnored: (error: unknown, mechanism: string) => boolean = () => false\n): (error: unknown, mechanism: string, source: string) => void {\n const limiter = new BucketedRateLimiter({\n ...resolveExceptionRateLimiterConfig(),\n refillInterval: 1000,\n _logger: createLogger('[PostHog]', () => {}),\n })\n let capturing = false\n return (error, mechanism, source) => {\n try {\n // Check consent before inspecting any part of the error, even its type or message.\n if (capturing || !canCapture()) return\n capturing = true\n try {\n // Ignored errors don't spend the rate limit. isIgnored can run application getters, so it runs\n // inside the reentrancy guard.\n if (isIgnored(error, mechanism) || limiter.consumeRateLimit('exceptions')) return\n void capture(\n error,\n { $exception_source: source },\n { mechanism: { type: mechanism, handled: false } }\n ).catch(() => {})\n } finally {\n capturing = false\n }\n } catch {\n // Error accessors, IPC and consumer hooks may all fail while reporting.\n }\n }\n}\n","import { createExceptionObserver, type ExceptionCapture } from '../shared/exception-autocapture'\n\nexport function startRendererExceptionAutocapture(canCapture: () => boolean, capture: ExceptionCapture): () => void {\n const observe = createExceptionObserver(canCapture, capture)\n const error = (event: ErrorEvent): void => {\n // Resource-load events are not JavaScript exceptions. Forward the raw ErrorEvent to core.\n if (event instanceof ErrorEvent) observe(event, 'onerror', 'browser.window_onerror')\n }\n const rejection = (event: PromiseRejectionEvent): void => {\n observe(event, 'onunhandledrejection', 'browser.unhandledrejection')\n }\n window.addEventListener('error', error)\n window.addEventListener('unhandledrejection', rejection)\n return () => {\n window.removeEventListener('error', error)\n window.removeEventListener('unhandledrejection', rejection)\n }\n}\n","import type { FeatureFlagValue, FeatureFlagResult, JsonType, PostHogEventProperties } from '@posthog/core'\n\nimport type { AutocaptureState } from './autocapture'\n\nexport const COMMAND_CHANNEL = 'posthog:command:v1'\nexport const STATE_CHANNEL = 'posthog:state:v1'\nexport const BRIDGE_KEY = '__POSTHOG_ELECTRON__'\nexport const PROTOCOL_VERSION = 1\nexport const MAX_MESSAGE_BYTES = 256 * 1024\n\nexport type Properties = PostHogEventProperties\nexport type { FeatureFlagValue, FeatureFlagResult, JsonType }\n\nexport interface FeatureFlagReadOptions {\n /** Report a deduplicated exposure by default; false suppresses it. Takes precedence over sendEvent. */\n sendFeatureFlagEvent?: boolean\n /** Compatibility option; prefer sendFeatureFlagEvent. */\n sendEvent?: boolean\n}\n\nexport interface IsFeatureEnabledOptions extends FeatureFlagReadOptions {\n /** Fallback for unknown or unavailable flags; never overrides a known false or empty variant. */\n defaultValue?: boolean\n}\n\n// Core currently marks empty variants enabled; normalize reads without changing exposure values.\nexport function normalizeFlagResult(result: FeatureFlagResult): FeatureFlagResult {\n return structuredClone({ ...result, enabled: result.variant === '' ? false : result.enabled })\n}\n\nexport interface State {\n revision: number\n generation: number\n distinctId: string\n anonymousId: string\n sessionId: string\n optedOut: boolean\n disabled?: boolean\n autocapture?: AutocaptureState\n featureFlags: Record<string, FeatureFlagValue>\n flagsLoaded?: boolean\n flagRevision: number\n featureFlagPayloads: Record<string, JsonType>\n}\n\nexport type Command =\n | { type: 'hello' }\n | { type: 'capture'; event: string; properties?: Properties }\n | { type: 'alias'; alias: string }\n | { type: 'screen'; name: string; properties?: Properties }\n | { type: 'setPersonProperties'; properties?: Properties; propertiesOnce?: Properties }\n | { type: 'setPersonPropertiesForFlags'; properties: Properties; reloadFeatureFlags: boolean }\n | { type: 'setGroupPropertiesForFlags'; properties: Record<string, Properties>; reloadFeatureFlags: boolean }\n | { type: 'resetPersonPropertiesForFlags' | 'resetGroupPropertiesForFlags'; reloadFeatureFlags: boolean }\n | { type: 'identify'; distinctId: string; properties?: Properties }\n | { type: 'reset' }\n | { type: 'group'; groupType: string; groupKey: string | number; properties?: Properties }\n | { type: 'register'; properties: Properties }\n | { type: 'unregister'; key: string }\n | { type: 'optIn' }\n | { type: 'optOut' }\n | { type: 'flag'; key: string; flagRevision: number; value: FeatureFlagValue | null }\n | { type: 'reloadFeatureFlags' }\n | { type: 'loadAutocaptureConfig' }\n | { type: 'flush' }\n | { type: 'exception'; properties: Properties }\n\nexport function isFlagContextCommand(command: Command): command is Extract<Command, { reloadFeatureFlags: boolean }> {\n return (\n command.type === 'setPersonPropertiesForFlags' ||\n command.type === 'setGroupPropertiesForFlags' ||\n command.type === 'resetPersonPropertiesForFlags' ||\n command.type === 'resetGroupPropertiesForFlags'\n )\n}\n\nexport interface Request {\n version: number\n sequence: number\n generation: number\n command: Command\n}\n\nexport type Response = { ok: true; state: State } | { ok: false; error: string }\n\nexport interface Bridge {\n request(request: Request): Promise<Response>\n subscribe(callback: (state: State) => void): () => void\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nexport function assertJson(value: unknown, depth = 0, allowReservedKeys = false): void {\n let remaining = MAX_MESSAGE_BYTES\n const spend = (size: number): void => {\n remaining -= size\n if (remaining < 0) throw new Error('PostHog message exceeds 256 KiB')\n }\n const visit = (item: unknown, level: number): void => {\n if (level > 20) throw new Error('PostHog payload is too deeply nested')\n // Count each occurrence, including shared references, against a lower bound on JSON size.\n spend(typeof item === 'string' ? item.length + 2 : 1)\n if (item === null || typeof item === 'string' || typeof item === 'boolean') return\n if (typeof item === 'number' && Number.isFinite(item)) return\n if (Array.isArray(item)) {\n for (const element of item) visit(element, level + 1)\n return\n }\n if (\n isRecord(item) &&\n (Object.getPrototypeOf(item) === Object.prototype || Object.getPrototypeOf(item) === null)\n ) {\n for (const key in item) {\n if (!Object.hasOwn(item, key)) continue\n spend(key.length + 3)\n if (!allowReservedKeys && ['__proto__', 'constructor', 'prototype'].includes(key))\n throw new Error('Unsafe PostHog property key')\n visit(item[key], level + 1)\n }\n return\n }\n throw new Error('PostHog properties must be JSON serializable')\n }\n visit(value, depth)\n}\n\nexport function validateRequest(value: unknown): asserts value is Request {\n assertJson(value)\n if (new TextEncoder().encode(JSON.stringify(value)).byteLength > MAX_MESSAGE_BYTES) {\n throw new Error('PostHog message exceeds 256 KiB')\n }\n if (\n !isRecord(value) ||\n value.version !== PROTOCOL_VERSION ||\n !Number.isSafeInteger(value.sequence) ||\n (value.sequence as number) < 1 ||\n !Number.isSafeInteger(value.generation) ||\n !isRecord(value.command)\n ) {\n throw new Error('Invalid PostHog request')\n }\n const command = value.command\n const string = (key: string): boolean =>\n typeof command[key] === 'string' && (command[key] as string).trim().length > 0\n const properties = (): boolean => command.properties === undefined || isRecord(command.properties)\n switch (command.type) {\n case 'hello':\n case 'reset':\n case 'optIn':\n case 'optOut':\n case 'reloadFeatureFlags':\n case 'loadAutocaptureConfig':\n case 'flush':\n return\n case 'capture':\n if (string('event') && !['$snapshot', '$exception'].includes(command.event as string) && properties())\n return\n break\n case 'alias':\n if (string('alias')) return\n break\n case 'screen':\n if (string('name') && properties()) return\n break\n case 'setPersonProperties':\n if (properties() && (command.propertiesOnce === undefined || isRecord(command.propertiesOnce))) return\n break\n case 'setPersonPropertiesForFlags':\n if (isRecord(command.properties) && typeof command.reloadFeatureFlags === 'boolean') return\n break\n case 'setGroupPropertiesForFlags':\n if (\n isRecord(command.properties) &&\n Object.values(command.properties).every(isRecord) &&\n typeof command.reloadFeatureFlags === 'boolean'\n )\n return\n break\n case 'resetPersonPropertiesForFlags':\n case 'resetGroupPropertiesForFlags':\n if (typeof command.reloadFeatureFlags === 'boolean') return\n break\n case 'identify':\n if (string('distinctId') && properties()) return\n break\n case 'group':\n if (string('groupType') && (string('groupKey') || typeof command.groupKey === 'number') && properties())\n return\n break\n case 'register':\n if (isRecord(command.properties)) return\n break\n case 'exception':\n if (\n isRecord(command.properties) &&\n Array.isArray(command.properties.$exception_list) &&\n command.properties.$exception_list.length > 0 &&\n command.properties.$exception_list.every(\n (exception) =>\n isRecord(exception) && typeof exception.type === 'string' && typeof exception.value === 'string'\n )\n )\n return\n break\n case 'unregister':\n if (string('key')) return\n break\n case 'flag':\n if (\n string('key') &&\n Number.isSafeInteger(command.flagRevision) &&\n (command.value === null || typeof command.value === 'boolean' || typeof command.value === 'string')\n )\n return\n break\n }\n throw new Error('Invalid PostHog command')\n}\n\nexport function trustedUrl(url: string, allowedUrls: readonly string[]): boolean {\n try {\n const target = new URL(url)\n target.hash = ''\n // Windows pathToFileURL escapes tildes in short paths, while Electron loadFile leaves them literal.\n if (target.protocol === 'file:') target.pathname = target.pathname.replace(/%7e/gi, '~')\n return allowedUrls.some((allowed) => {\n const candidate = new URL(allowed)\n candidate.hash = ''\n if (candidate.protocol === 'file:') candidate.pathname = candidate.pathname.replace(/%7e/gi, '~')\n return candidate.href === target.href\n })\n } catch {\n return false\n }\n}\n","import {\n Autocapture,\n type AutocaptureClient,\n type AutocaptureRemoteConfigResult,\n} from '@posthog/browser-common/autocapture'\nimport type { AutocaptureConfig as SharedAutocaptureConfig } from '@posthog/browser-common/autocapture-config'\nimport type { KeyValueStore } from '@posthog/browser-common'\nimport { AUTOCAPTURE_DISABLED_SERVER_SIDE } from '@posthog/browser-common/constants'\nimport type { Properties, State } from '../shared/protocol'\n\nconst AUTOCAPTURE_CONFIG_KEYS = [\n 'maskAllText',\n 'maskAllElementAttributes',\n 'disableCaptureUrlHashes',\n 'url_allowlist',\n 'url_ignorelist',\n 'dom_event_allowlist',\n 'element_allowlist',\n 'css_selector_allowlist',\n 'css_selector_ignorelist',\n 'element_attribute_ignorelist',\n] as const\n\nexport type AutocaptureConfig = Partial<Pick<SharedAutocaptureConfig, (typeof AUTOCAPTURE_CONFIG_KEYS)[number]>>\n\ninterface AutocaptureHost {\n getState(): Pick<State, 'generation' | 'distinctId' | 'optedOut' | 'autocapture'>\n capture(event: string, properties?: Properties): void\n loadConfig(): Promise<void>\n onError(error: unknown): void\n}\n\n/** Volatile extension state only; main owns the durable project config cache. */\nclass AutocaptureStore implements KeyValueStore {\n private values = new Map<string, unknown>()\n initialize(): void {}\n get<T extends object>(keys: readonly (keyof T & string)[]): Partial<T>\n get<T = unknown>(key: string): T | undefined\n get(key: string | readonly string[]): unknown {\n if (typeof key === 'string') return this.values.get(key)\n return Object.fromEntries(\n key.filter((name) => this.values.has(name)).map((name) => [name, this.values.get(name)])\n )\n }\n set(key: string, value: unknown): void\n set(values: Record<string, unknown>): void\n set(key: string | Record<string, unknown>, value?: unknown): void {\n if (typeof key === 'string') this.values.set(key, value)\n else for (const [name, item] of Object.entries(key)) this.values.set(name, item)\n }\n remove(keys: string | readonly string[]): void {\n for (const key of typeof keys === 'string' ? [keys] : keys) this.values.delete(key)\n }\n}\n\nexport class RendererAutocapture {\n private extension?: Autocapture\n private remoteListener?: (result: AutocaptureRemoteConfigResult) => void\n private generation?: number\n private requestedGeneration?: number\n private disposed = false\n private active = false\n private loading = false\n private retryTimer?: ReturnType<typeof setTimeout>\n private retryDelay = 1000\n\n constructor(\n private host: AutocaptureHost,\n private config: AutocaptureConfig\n ) {}\n\n update(paused: boolean): void {\n if (this.disposed) return\n const state = this.host.getState()\n if (paused || state.optedOut || state.generation !== this.generation) this.stop()\n if (paused || state.optedOut) return\n this.active = true\n this.generation = state.generation\n if (!this.extension) {\n const kv = new AutocaptureStore()\n if (typeof state.autocapture?.autocapture_opt_out === 'boolean') {\n kv.set(AUTOCAPTURE_DISABLED_SERVER_SIDE, state.autocapture.autocapture_opt_out)\n }\n const extension = new Autocapture({\n refresh: (config) => {\n for (const key of AUTOCAPTURE_CONFIG_KEYS) {\n if (this.config[key] !== undefined) Object.assign(config, { [key]: this.config[key] })\n }\n // This runs before shared Autocapture reads or serializes an event target.\n const current = this.host.getState()\n config.enabled = !this.disposed && !current.optedOut && current.autocapture?.status !== 'pending'\n config.remoteRequestsDisabled = current.autocapture?.status === 'disabled'\n },\n })\n this.extension = extension\n const host = this.host\n const adapter: AutocaptureClient = {\n get distinctId() {\n return host.getState().distinctId\n },\n kv,\n onRemoteConfig: (listener) => {\n this.remoteListener = listener\n return {\n dispose: () => {\n this.remoteListener = undefined\n },\n }\n },\n capture: (event, properties) => {\n host.capture(event, properties ?? undefined)\n return true\n },\n }\n try {\n extension.setup(adapter)\n } catch (error) {\n this.stop()\n host.onError(error)\n return\n }\n }\n const remote = state.autocapture\n if (remote?.status === 'loaded') this.remoteListener?.({ ok: true, config: remote })\n if (remote?.status === 'failed') {\n // Apply only last-known cached settings; a failed fetch itself never changes the opt-out decision.\n if (remote.elementsChainAsString)\n this.remoteListener?.({\n ok: true,\n config: {\n elementsChainAsString: remote.elementsChainAsString,\n ...(typeof remote.autocapture_opt_out === 'boolean'\n ? { autocapture_opt_out: remote.autocapture_opt_out }\n : {}),\n },\n })\n this.remoteListener?.({ ok: false })\n }\n if (remote?.status === 'disabled') this.extension?.startIfEnabled()\n if (remote?.status === 'loaded' || remote?.status === 'disabled') {\n clearTimeout(this.retryTimer)\n this.retryTimer = undefined\n this.retryDelay = 1000\n }\n if (this.requestedGeneration !== state.generation && remote?.status !== 'disabled') this.loadConfig()\n else if (remote?.status === 'failed') this.scheduleRetry()\n }\n\n private loadConfig(): void {\n if (this.disposed || !this.active || this.loading) return\n this.loading = true\n this.requestedGeneration = this.host.getState().generation\n void this.host\n .loadConfig()\n .catch((error) => this.host.onError(error))\n .finally(() => {\n this.loading = false\n if (this.disposed || !this.active) return\n if (this.requestedGeneration !== this.host.getState().generation) this.update(false)\n else this.scheduleRetry()\n })\n }\n\n private scheduleRetry(): void {\n const status = this.host.getState().autocapture?.status\n if (\n this.disposed ||\n !this.active ||\n this.loading ||\n this.retryTimer ||\n status === 'loaded' ||\n status === 'disabled'\n )\n return\n this.retryTimer = setTimeout(() => {\n this.retryTimer = undefined\n this.loadConfig()\n }, this.retryDelay)\n this.retryDelay = Math.min(this.retryDelay * 2, 60_000)\n }\n\n private stop(): void {\n this.active = false\n clearTimeout(this.retryTimer)\n this.retryTimer = undefined\n this.retryDelay = 1000\n this.requestedGeneration = undefined\n this.extension?.dispose()\n this.extension = undefined\n this.remoteListener = undefined\n }\n\n dispose(): void {\n this.disposed = true\n this.stop()\n }\n}\n","import {\n ErrorPropertiesBuilder,\n ErrorCoercer,\n ErrorEventCoercer,\n PromiseRejectionEventCoercer,\n type EventHint,\n ObjectCoercer,\n StringCoercer,\n PrimitiveCoercer,\n createDefaultStackParser,\n} from '@posthog/core/error-tracking'\nimport { startRendererExceptionAutocapture } from './exception-autocapture'\nimport {\n BRIDGE_KEY,\n PROTOCOL_VERSION,\n isFlagContextCommand,\n type FeatureFlagReadOptions,\n type IsFeatureEnabledOptions,\n type FeatureFlagResult,\n type Bridge,\n type Command,\n type FeatureFlagValue,\n type JsonType,\n type Properties,\n type State,\n} from '../shared/protocol'\n\nimport { RendererAutocapture, type AutocaptureConfig } from './autocapture'\n\nexport type {\n State,\n Properties,\n FeatureFlagValue,\n FeatureFlagResult,\n FeatureFlagReadOptions,\n IsFeatureEnabledOptions,\n JsonType,\n AutocaptureConfig,\n}\n\nexport interface RendererOptions {\n autocapture?: boolean | AutocaptureConfig\n onError?: (error: unknown) => void\n enableExceptionAutocapture?: boolean\n}\n\n// Keep the main frame's high-water mark across dispose/init on the same preload bridge.\nconst bridgeSequences = new WeakMap<Bridge, number>()\n\nexport class PostHog {\n private _autocapture?: RendererAutocapture\n private _autocapturePauses = 0\n private _pendingOptOuts = 0\n private _state?: State\n private _ready?: Promise<void>\n private _reportedFlags = new Set<string>()\n private _tail: Promise<unknown> = Promise.resolve()\n private _listeners = new Set<(state: State) => void>()\n private _unsubscribe: () => void\n private _disposed = false\n private _stopExceptionAutocapture?: () => void\n private _builder = new ErrorPropertiesBuilder(\n [\n new ErrorEventCoercer(),\n new PromiseRejectionEventCoercer(),\n new ErrorCoercer(),\n new ObjectCoercer(),\n new StringCoercer(),\n new PrimitiveCoercer(),\n ],\n createDefaultStackParser()\n )\n\n constructor(\n private _bridge: Bridge,\n private _options: RendererOptions = {}\n ) {\n if (_options.autocapture) {\n this._autocapture = new RendererAutocapture(\n {\n getState: () => {\n const state = this._state\n if (!state) throw new Error('PostHog renderer is not ready')\n return {\n generation: state.generation,\n distinctId: state.distinctId,\n optedOut: state.optedOut,\n autocapture: state.autocapture,\n }\n },\n capture: (event, properties) => this.capture(event, properties),\n loadConfig: () => this._send({ type: 'loadAutocaptureConfig' }),\n onError: (error) => this._report(error),\n },\n typeof _options.autocapture === 'object' ? _options.autocapture : {}\n )\n }\n this._unsubscribe = this._bridge.subscribe((state) => this._update(state))\n }\n\n private _update(state: State): void {\n if (this._disposed || (this._state && state.revision <= this._state.revision)) return\n if (\n this._state?.generation !== state.generation ||\n this._state?.flagRevision !== state.flagRevision ||\n this._state?.sessionId !== state.sessionId ||\n this._state?.optedOut !== state.optedOut\n ) {\n this._reportedFlags = new Set()\n }\n this._state = structuredClone(state)\n this._autocapture?.update(this._autocapturePauses > 0)\n for (const listener of this._listeners) {\n try {\n listener(this.getState())\n } catch {}\n }\n }\n\n private async _send(command: Command): Promise<void> {\n const generation = this._state?.generation ?? 0\n // Reject non-cloneable input as before, but snapshot with JSON semantics so caller toJSON redaction applies.\n structuredClone(command)\n const snapshot: Command = JSON.parse(JSON.stringify(command))\n const dispatched = this._tail.then(() => {\n if (this._disposed) throw new Error('PostHog renderer has been disposed')\n if (command.type === 'exception' && !this._canCaptureException()) return { response: undefined }\n const sequence = (bridgeSequences.get(this._bridge) ?? 0) + 1\n bridgeSequences.set(this._bridge, sequence)\n return {\n response: this._bridge.request({\n version: PROTOCOL_VERSION,\n sequence,\n generation,\n command: snapshot,\n }),\n }\n })\n const operation = dispatched.then(async ({ response: pending }) => {\n if (!pending) return\n const response = await pending\n if (!response.ok) throw new Error(response.error)\n this._update(response.state)\n })\n // Network-bound commands keep their place in main's ordered queue but must not hold later\n // renderer commands (especially consent) behind a slow response.\n const networkBound =\n command.type === 'flush' ||\n command.type === 'reloadFeatureFlags' ||\n command.type === 'loadAutocaptureConfig' ||\n (isFlagContextCommand(command) && command.reloadFeatureFlags)\n this._tail = (networkBound ? dispatched : operation).catch(() => {})\n return operation\n }\n\n private _pauseAutocapture(command: Command): Promise<void> {\n this._autocapturePauses++\n if (this._state) this._autocapture?.update(true)\n return this._send(command).finally(() => {\n this._autocapturePauses--\n if (this._state) this._autocapture?.update(this._autocapturePauses > 0)\n })\n }\n\n async ready(): Promise<void> {\n if (this._disposed) throw new Error('PostHog renderer has been disposed')\n await (this._ready ??= this._send({ type: 'hello' }).catch((error: unknown) => {\n this._ready = undefined\n throw error\n }))\n if (\n !this._disposed &&\n !this._stopExceptionAutocapture &&\n this._options.enableExceptionAutocapture === true &&\n typeof window !== 'undefined'\n ) {\n this._stopExceptionAutocapture = startRendererExceptionAutocapture(\n () => this._canCaptureException(),\n (error, properties, hint) => this._captureException(error, properties, hint)\n )\n }\n }\n\n // A capture whose failure would feed back into onError doesn't report that failure, so an onError that\n // captures can't loop while main keeps refusing requests. That covers any capture made while onError runs\n // synchronously, and captureException(error) for an error already reported, including after an await.\n // A different capture made after an await in onError is not covered; the README warns against it.\n private _inOnError = false\n private _reportedFailures = new WeakSet<object>()\n private _report(error: unknown): void {\n const inOnError = this._inOnError\n this._inOnError = true\n try {\n const result: unknown = this._options.onError?.(error)\n if (typeof (result as PromiseLike<unknown> | undefined)?.then === 'function') {\n void Promise.resolve(result).catch(() => {})\n }\n } catch {\n } finally {\n this._inOnError = inOnError\n }\n }\n private _reportFailure(promise: Promise<void>, quiet = this._inOnError): void {\n void promise.catch((error: unknown) => {\n if (quiet) return\n if (typeof error === 'object' && error !== null) this._reportedFailures.add(error)\n this._report(error)\n })\n }\n /** Fire-and-forget: never throws or rejects. Failed requests are reported through `onError`. */\n capture(event: string, properties?: Properties): void {\n if (typeof event !== 'string' || this.hasOptedOutCapturing()) return\n this._reportFailure(this._send({ type: 'capture', event, ...(properties ? { properties } : {}) }))\n }\n /**\n * Link the current distinct ID to an alias without switching identity or reloading flags.\n * Ignored when opted out or personProfiles is 'never'. Resolves after local persistence, not delivery.\n */\n alias(alias: string): Promise<void> {\n if (!alias?.trim()) return Promise.resolve()\n if (this.hasOptedOutCapturing()) return Promise.resolve()\n return this._send({ type: 'alias', alias })\n }\n /**\n * Capture an event-only $screen; name wins over properties.$screen_name without setting persistent screen context.\n * Fire-and-forget: never throws or rejects; ignored when opted out.\n */\n screen(name: string, properties?: Properties): void {\n if (typeof name !== 'string' || !name.trim()) return\n if (this.hasOptedOutCapturing()) return\n this._reportFailure(this._send({ type: 'screen', name, ...(properties ? { properties } : {}) }))\n }\n /**\n * Update the current person's $set/$set_once properties without changing identity; empty updates do nothing.\n * Also updates flag context. Resolves after local persistence, not delivery or the background flag refresh.\n * Ignored when opted out or personProfiles is 'never'.\n */\n setPersonProperties(properties?: Properties, propertiesOnce?: Properties): Promise<void> {\n if (this.hasOptedOutCapturing()) return Promise.resolve()\n return this._send({\n type: 'setPersonProperties',\n ...(properties ? { properties } : {}),\n ...(propertiesOnce ? { propertiesOnce } : {}),\n })\n }\n /**\n * Merge a call-time copy of local person overrides for flag evaluation, without updating the person profile.\n * Accepts nested $set/$set_once; empty input does nothing. Otherwise awaits persistence and, by default, a refresh attempt.\n * With false, only saves context; cached flag values stay unchanged until a reload.\n */\n setPersonPropertiesForFlags(properties: Properties, reloadFeatureFlags = true): Promise<void> {\n return this._send({ type: 'setPersonPropertiesForFlags', properties, reloadFeatureFlags })\n }\n /**\n * Merge a call-time copy of local overrides by group type, without changing profiles or group membership.\n * Empty input does nothing. Otherwise awaits persistence and, by default, a flag refresh attempt.\n * With false, only saves context; cached flag values stay unchanged until a reload.\n */\n setGroupPropertiesForFlags(properties: Record<string, Properties>, reloadFeatureFlags = true): Promise<void> {\n return this._send({ type: 'setGroupPropertiesForFlags', properties, reloadFeatureFlags })\n }\n /**\n * Clear all local person flag overrides, not profile data or identity. Resolves after persistence.\n * Cached flag values stay unchanged unless true is passed to also await a refresh attempt.\n */\n resetPersonPropertiesForFlags(reloadFeatureFlags = false): Promise<void> {\n return this._send({ type: 'resetPersonPropertiesForFlags', reloadFeatureFlags })\n }\n /**\n * Clear local flag overrides for every group type, not profiles or membership. Resolves after persistence.\n * Cached flag values stay unchanged unless true is passed to also await a refresh attempt.\n */\n resetGroupPropertiesForFlags(reloadFeatureFlags = false): Promise<void> {\n return this._send({ type: 'resetGroupPropertiesForFlags', reloadFeatureFlags })\n }\n identify(distinctId: string, properties?: Properties): Promise<void> {\n return this._pauseAutocapture({ type: 'identify', distinctId, ...(properties ? { properties } : {}) })\n }\n reset(): Promise<void> {\n return this._pauseAutocapture({ type: 'reset' })\n }\n group(groupType: string, groupKey: string | number, properties?: Properties): Promise<void> {\n if (this.hasOptedOutCapturing()) return Promise.resolve()\n return this._send({ type: 'group', groupType, groupKey, ...(properties ? { properties } : {}) })\n }\n register(properties: Properties): Promise<void> {\n return this._send({ type: 'register', properties })\n }\n unregister(key: string): Promise<void> {\n return this._send({ type: 'unregister', key })\n }\n optIn(): Promise<void> {\n return this._send({ type: 'optIn' })\n }\n optOut(): Promise<void> {\n this._pendingOptOuts++\n return this._pauseAutocapture({ type: 'optOut' }).finally(() => {\n this._pendingOptOuts--\n })\n }\n /**\n * Refresh flags using the shared identity/context after earlier mutations, then persist and synchronize the cache.\n * A failed fetch normally retains cached flags and resolves; completion does not guarantee fresh values.\n */\n reloadFeatureFlags(): Promise<void> {\n return this._send({ type: 'reloadFeatureFlags' })\n }\n /** Compatibility alias for reloadFeatureFlags(), with the same completion and failure semantics. */\n reloadFeatureFlagsAsync(): Promise<void> {\n return this.reloadFeatureFlags()\n }\n flush(): Promise<void> {\n return this._send({ type: 'flush' })\n }\n\n /** Fire-and-forget: never throws or rejects. Failed requests are reported through `onError`. */\n captureException(error: unknown, properties?: Properties): void {\n const reported = typeof error === 'object' && error !== null && this._reportedFailures.has(error)\n this._reportFailure(this._captureException(error, properties), this._inOnError || reported)\n }\n private _canCaptureException(): boolean {\n return !this._disposed && !this._pendingOptOuts && !this._state?.disabled && !this.hasOptedOutCapturing()\n }\n protected _captureException(error: unknown, properties?: Properties, hint?: EventHint): Promise<void> {\n if (!this._canCaptureException()) return Promise.resolve()\n try {\n const exception = this._builder.buildFromUnknown(error, hint)\n return this._send({\n type: 'exception',\n properties: { ...properties, ...exception } as unknown as Properties,\n })\n } catch {\n return Promise.resolve()\n }\n }\n\n getDistinctId(): string {\n return this._state?.distinctId ?? ''\n }\n /** Return the shared anonymous ID, stable across identify and rotated by reset; '' before synchronization. */\n getAnonymousId(): string {\n return this._state?.anonymousId ?? ''\n }\n /** Cached consent state; conservatively true until the first synchronized snapshot. */\n get optedOut(): boolean {\n return this.hasOptedOutCapturing()\n }\n getSessionId(): string {\n return this._state?.sessionId ?? ''\n }\n hasOptedOutCapturing(): boolean {\n return this._state?.optedOut ?? true\n }\n\n /**\n * Read the cached value without fetching. A missing key is false with a nonempty cache, otherwise undefined.\n * Reports a deduplicated exposure for the observed snapshot by default; sendFeatureFlagEvent: false suppresses it.\n */\n getFeatureFlag(key: string, options?: FeatureFlagReadOptions): FeatureFlagValue | undefined {\n const flags = this._state?.featureFlags\n const value =\n flags && Object.prototype.hasOwnProperty.call(flags, key)\n ? flags[key]\n : flags && Object.keys(flags).length > 0\n ? false\n : undefined\n if ((options?.sendFeatureFlagEvent ?? options?.sendEvent) !== false && this._state) {\n const reportedFlags = this._reportedFlags\n const reportKey = JSON.stringify([key, value ?? null])\n if (!reportedFlags.has(reportKey)) {\n reportedFlags.add(reportKey)\n void this._send({\n type: 'flag',\n key,\n flagRevision: this._state.flagRevision,\n value: value ?? null,\n }).catch(() => reportedFlags.delete(reportKey))\n }\n }\n return value\n }\n /**\n * Read cached enabled state without fetching; empty variants are disabled. defaultValue applies only to\n * unknown/unavailable flags. Without it, missing-key behavior matches getFeatureFlag().\n * Reports exposure by default; sendFeatureFlagEvent: false suppresses it.\n */\n isFeatureEnabled(key: string, options: IsFeatureEnabledOptions & { defaultValue: boolean }): boolean\n /**\n * Read cached enabled state without fetching; empty variants are disabled. Missing keys follow getFeatureFlag()\n * unless defaultValue is supplied. Reports exposure by default; sendFeatureFlagEvent: false suppresses it.\n */\n isFeatureEnabled(key: string, options?: IsFeatureEnabledOptions): boolean | undefined\n isFeatureEnabled(key: string, options?: IsFeatureEnabledOptions): boolean | undefined {\n if (options?.defaultValue !== undefined) {\n const result = this.getFeatureFlagResult(key, options)\n return result === undefined ? options.defaultValue : Boolean(result.variant ?? result.enabled)\n }\n const value = this.getFeatureFlag(key, options)\n return value === undefined ? undefined : Boolean(value)\n }\n /**\n * Return a copied cached result, or undefined for unknown/unavailable flags; never fetches.\n * Empty variants are disabled. Reports exposure by default; sendFeatureFlagEvent: false suppresses it.\n */\n getFeatureFlagResult(key: string, options?: FeatureFlagReadOptions): FeatureFlagResult | undefined {\n // Exposure commands retain the observed snapshot revision, including missing-key reads.\n this.getFeatureFlag(key, options)\n if (!this._state || !Object.prototype.hasOwnProperty.call(this._state.featureFlags, key)) return undefined\n const value = this._state.featureFlags[key]\n return {\n key,\n enabled: Boolean(value),\n ...(typeof value === 'string' ? { variant: value } : {}),\n payload: this.getFeatureFlagPayload(key) ?? null,\n }\n }\n /** Return copied cached results (empty when unavailable), without fetching or reporting exposures. */\n getAllFeatureFlags(): FeatureFlagResult[] {\n return Object.keys(this._state?.featureFlags ?? {}).map((key) =>\n this.getFeatureFlagResult(key, { sendFeatureFlagEvent: false })!\n )\n }\n /**\n * Read a copied, decoded cached payload without fetching or reporting exposure.\n * Missing payloads are null once flags are loaded, otherwise undefined; strings are not decoded again.\n */\n getFeatureFlagPayload(key: string): JsonType | undefined {\n const payloads = this._state?.featureFlagPayloads\n const value = payloads && Object.prototype.hasOwnProperty.call(payloads, key) ? payloads[key] : undefined\n return value === undefined ? (this._state?.flagsLoaded ? null : undefined) : structuredClone(value)\n }\n getState(): State {\n if (!this._state) throw new Error('PostHog renderer is not ready')\n return structuredClone(this._state)\n }\n onStateChange(callback: (state: State) => void): () => void {\n this._listeners.add(callback)\n if (this._state) callback(this.getState())\n return () => this._listeners.delete(callback)\n }\n dispose(): void {\n if (this._disposed) return\n this._disposed = true\n this._stopExceptionAutocapture?.()\n this._stopExceptionAutocapture = undefined\n this._autocapture?.dispose()\n this._unsubscribe()\n this._listeners.clear()\n this._reportedFlags.clear()\n if (singleton === this) singleton = undefined\n }\n}\n\nlet singleton: PostHog | undefined\nlet initializing: Promise<PostHog> | undefined\n\nexport function init(options: RendererOptions = {}): Promise<PostHog> {\n if (initializing) return initializing\n if (singleton) return Promise.resolve(singleton)\n const bridge = (globalThis as typeof globalThis & { [BRIDGE_KEY]?: Bridge })[BRIDGE_KEY]\n if (!bridge) return Promise.reject(new Error('PostHog preload bridge is missing; configure your Electron preload'))\n const client = new PostHog(bridge, options)\n initializing = client\n .ready()\n .then(() => {\n singleton = client\n return client\n })\n .catch((error: unknown) => {\n client.dispose()\n throw error\n })\n .finally(() => {\n initializing = undefined\n })\n return initializing\n}\n","import {\n assertJson,\n isRecord,\n MAX_MESSAGE_BYTES,\n PROTOCOL_VERSION,\n type Response,\n type State,\n} from '../shared/protocol'\n\nexport const UTILITY_CHANNEL = 'posthog:utility:v1'\nexport const UTILITY_TIMEOUT_MS = 10_000\n\nexport function envelope(message: Record<string, unknown>): Record<string, unknown> {\n return { channel: UTILITY_CHANNEL, version: PROTOCOL_VERSION, ...message }\n}\n\n// Application messages may share parentPort, but never enter the SDK command path.\nexport function readEnvelope(\n value: unknown,\n direction: 'to-main' | 'to-utility' = 'to-main'\n): Record<string, unknown> | undefined {\n if (!isRecord(value) || value.channel !== UTILITY_CHANNEL) return\n assertJson(value, 0, direction === 'to-utility')\n if (new TextEncoder().encode(JSON.stringify(value)).byteLength > MAX_MESSAGE_BYTES) {\n throw new Error('PostHog utility message exceeds 256 KiB')\n }\n if (value.version !== PROTOCOL_VERSION) throw new Error('Unsupported PostHog utility protocol')\n return value\n}\n\nexport function isState(value: unknown): value is State {\n return (\n isRecord(value) &&\n ['revision', 'generation', 'flagRevision'].every(\n (key) => Number.isSafeInteger(value[key]) && (value[key] as number) >= 0\n ) &&\n ['distinctId', 'anonymousId', 'sessionId'].every((key) => typeof value[key] === 'string') &&\n typeof value.optedOut === 'boolean' &&\n (value.flagsLoaded === undefined || typeof value.flagsLoaded === 'boolean') &&\n isRecord(value.featureFlags) &&\n Object.values(value.featureFlags).every((flag) => typeof flag === 'boolean' || typeof flag === 'string') &&\n isRecord(value.featureFlagPayloads)\n )\n}\n\nexport function isResponse(value: unknown): value is Response {\n return (\n isRecord(value) &&\n ((value.ok === true && isState(value.state)) || (value.ok === false && typeof value.error === 'string'))\n )\n}\n","import type { ParentPort } from 'electron'\nimport type { Bridge, Request, Response, State } from '../shared/protocol'\nimport { envelope, isResponse, isState, readEnvelope, UTILITY_TIMEOUT_MS } from './protocol'\n\nexport function createUtilityBridge(port: ParentPort): Bridge {\n let token: string | undefined\n let closed = false\n const listeners = new Set<(state: State) => void>()\n const pending = new Map<\n number,\n { resolve: (value: Response) => void; reject: (error: Error) => void; timer: ReturnType<typeof setTimeout> }\n >()\n let connectedResolve!: () => void\n let connectedReject!: (error: Error) => void\n const connected = new Promise<void>((resolve, reject) => {\n connectedResolve = resolve\n connectedReject = reject\n })\n // Disposal may precede the facade's first request.\n void connected.catch(() => {})\n const timer = setTimeout(() => close(new Error('PostHog utility connection timed out')), UTILITY_TIMEOUT_MS)\n const close = (error: Error): void => {\n if (closed) return\n closed = true\n clearTimeout(timer)\n port.removeListener('message', message)\n connectedReject(error)\n for (const operation of pending.values()) {\n clearTimeout(operation.timer)\n operation.reject(error)\n }\n pending.clear()\n listeners.clear()\n }\n const message = (event: Electron.MessageEvent): void => {\n try {\n const data = readEnvelope(event.data, 'to-utility')\n if (!data) return\n if (data.kind === 'connected' && typeof data.token === 'string' && data.token.length <= 128) {\n if (token && token !== data.token) throw new Error('PostHog utility connection changed')\n token = data.token\n clearTimeout(timer)\n connectedResolve()\n return\n }\n if (!token || data.token !== token) throw new Error('Invalid PostHog utility connection')\n if (data.kind === 'closed') {\n close(new Error('PostHog utility connection closed'))\n } else if (data.kind === 'state' && isState(data.state)) {\n for (const listener of listeners) listener(data.state)\n } else if (data.kind === 'response' && Number.isSafeInteger(data.sequence) && isResponse(data.response)) {\n const operation = pending.get(data.sequence as number)\n if (!operation) return\n pending.delete(data.sequence as number)\n clearTimeout(operation.timer)\n operation.resolve(data.response)\n } else throw new Error('Invalid PostHog utility message')\n } catch (error) {\n close(error instanceof Error ? error : new Error('Invalid PostHog utility message'))\n }\n }\n port.on('message', message)\n try {\n port.postMessage(envelope({ kind: 'connect' }))\n } catch {\n close(new Error('PostHog parentPort unavailable'))\n }\n return {\n request: async (request: Request) => {\n await connected\n if (closed) throw new Error('PostHog utility connection closed')\n return new Promise<Response>((resolve, reject) => {\n // Stop waiting, but keep the authenticated channel: the owner may still finish this work\n // (for example a long multi-batch flush), and later requests must keep working.\n // Its late response is ignored because it is no longer pending.\n const timeout = setTimeout(() => {\n if (pending.get(request.sequence)?.timer !== timeout) return\n pending.delete(request.sequence)\n reject(new Error('PostHog utility request timed out'))\n }, UTILITY_TIMEOUT_MS)\n pending.set(request.sequence, { resolve, reject, timer: timeout })\n try {\n const value = envelope({ kind: 'request', token, request })\n readEnvelope(value)\n port.postMessage(value)\n } catch (error) {\n pending.delete(request.sequence)\n clearTimeout(timeout)\n const failure = error instanceof Error ? error : new Error('PostHog utility request failed')\n reject(failure)\n close(failure)\n }\n })\n },\n subscribe: (callback) => {\n listeners.add(callback)\n return () => {\n listeners.delete(callback)\n close(new Error('PostHog utility client disposed'))\n }\n },\n }\n}\n","import { PostHog as Facade, type RendererOptions } from '../renderer'\nimport { createUtilityBridge } from './bridge'\n\nexport type { State, Properties, FeatureFlagValue, JsonType } from '../shared/protocol'\nexport type UtilityOptions = Pick<RendererOptions, 'onError'>\n\n/** A trusted utility facade. Identity, consent, storage and delivery belong to main. */\nexport class PostHog extends Facade {\n constructor(options: UtilityOptions = {}) {\n if (!process.parentPort) throw new Error('PostHog utility requires Electron utilityProcess.parentPort')\n super(createUtilityBridge(process.parentPort), { onError: options.onError })\n }\n\n override dispose(): void {\n super.dispose()\n if (singleton === this) singleton = undefined\n }\n}\n\nlet singleton: PostHog | undefined\nlet initializing: Promise<PostHog> | undefined\n\nexport function init(options: UtilityOptions = {}): Promise<PostHog> {\n if (initializing) return initializing\n if (singleton) return Promise.resolve(singleton)\n const client = new PostHog(options)\n initializing = client\n .ready()\n .then(() => {\n singleton = client\n return client\n })\n .catch((error: unknown) => {\n client.dispose()\n throw error\n })\n .finally(() => {\n initializing = undefined\n })\n return initializing\n}\n"],"mappings":";;;;;;AAUA,SAAgB,wBACZ,YACA,SACA,kBAAkE,OACP;CAC3D,MAAM,UAAU,IAAI,oBAAoB;EACpC,GAAG,kCAAkC;EACrC,gBAAgB;EAChB,SAAS,aAAa,mBAAmB,CAAC,CAAC;CAC/C,CAAC;CACD,IAAI,YAAY;CAChB,QAAQ,OAAO,WAAW,WAAW;EACjC,IAAI;GAEA,IAAI,aAAa,CAAC,WAAW,GAAG;GAChC,YAAY;GACZ,IAAI;IAGA,IAAI,UAAU,OAAO,SAAS,KAAK,QAAQ,iBAAiB,YAAY,GAAG;IAC3E,QACI,OACA,EAAE,mBAAmB,OAAO,GAC5B,EAAE,WAAW;KAAE,MAAM;KAAW,SAAS;IAAM,EAAE,CACrD,CAAC,CAAC,YAAY,CAAC,CAAC;GACpB,UAAU;IACN,YAAY;GAChB;EACJ,QAAQ,CAER;CACJ;AACJ;;;ACxCA,SAAgB,kCAAkC,YAA2B,SAAuC;CAChH,MA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,OAAO;IACjB;GACJ,CAAC;EACL;EACA,YAAY,aAAa;GACrB,UAAU,IAAI,QAAQ;GACtB,aAAa;IACT,UAAU,OAAO,QAAQ;IACzB,sBAAM,IAAI,MAAM,iCAAiC,CAAC;GACtD;EACJ;CACJ;AACJ;;;;AC/FA,IAAa,UAAb,cAA6BC,UAAO;CAChC,YAAY,UAA0B,CAAC,GAAG;EACtC,IAAI,CAAC,QAAQ,YAAY,MAAM,IAAI,MAAM,6DAA6D;EACtG,MAAM,oBAAoB,QAAQ,UAAU,GAAG,EAAE,SAAS,QAAQ,QAAQ,CAAC;CAC/E;CAEA,UAAyB;EACrB,MAAM,QAAQ;EACd,IAAI,cAAc,MAAM,YAAY,KAAA;CACxC;AACJ;AAEA,IAAI;AACJ,IAAI;AAEJ,SAAgB,KAAK,UAA0B,CAAC,GAAqB;CACjE,IAAI,cAAc,OAAO;CACzB,IAAI,WAAW,OAAO,QAAQ,QAAQ,SAAS;CAC/C,MAAM,SAAS,IAAI,QAAQ,OAAO;CAClC,eAAe,OACV,MAAM,CAAC,CACP,WAAW;EACR,YAAY;EACZ,OAAO;CACX,CAAC,CAAC,CACD,OAAO,UAAmB;EACvB,OAAO,QAAQ;EACf,MAAM;CACV,CAAC,CAAC,CACD,cAAc;EACX,eAAe,KAAA;CACnB,CAAC;CACL,OAAO;AACX"}
package/package.json CHANGED
@@ -1,10 +1,108 @@
1
1
  {
2
2
  "name": "@posthog/electron",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for @posthog/electron",
5
- "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
10
- }
3
+ "version": "0.1.1",
4
+ "description": "PostHog analytics and feature flags for Electron applications",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/PostHog/posthog-js.git",
9
+ "directory": "packages/electron"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/PostHog/posthog-js/issues"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "MIGRATION.md",
18
+ "CHANGELOG.md",
19
+ "LICENSE"
20
+ ],
21
+ "main": "dist/main.cjs",
22
+ "module": "dist/main.mjs",
23
+ "types": "dist/main.d.ts",
24
+ "exports": {
25
+ "./main": {
26
+ "types": "./dist/main.d.ts",
27
+ "import": "./dist/main.mjs",
28
+ "require": "./dist/main.cjs"
29
+ },
30
+ "./utility": {
31
+ "types": "./dist/utility.d.ts",
32
+ "import": "./dist/utility.mjs",
33
+ "require": "./dist/utility.cjs"
34
+ },
35
+ "./renderer": {
36
+ "types": "./dist/renderer.d.ts",
37
+ "import": "./dist/renderer.mjs",
38
+ "require": "./dist/renderer.cjs"
39
+ },
40
+ "./preload": {
41
+ "types": "./dist/preload.d.ts",
42
+ "default": "./dist/preload.cjs"
43
+ },
44
+ "./preload/helper": {
45
+ "types": "./dist/preload-helper.d.ts",
46
+ "import": "./dist/preload-helper.mjs",
47
+ "require": "./dist/preload-helper.cjs"
48
+ },
49
+ "./react": {
50
+ "types": "./dist/react.d.ts",
51
+ "import": "./dist/react.mjs",
52
+ "require": "./dist/react.cjs"
53
+ }
54
+ },
55
+ "dependencies": {
56
+ "@posthog/core": "^1.69.2",
57
+ "@posthog/browser-common": "^0.13.0"
58
+ },
59
+ "publishConfig": {
60
+ "access": "public",
61
+ "registry": "https://registry.npmjs.org"
62
+ },
63
+ "peerDependencies": {
64
+ "electron": ">=41",
65
+ "react": ">=18.0.0",
66
+ "@types/react": ">=18.0.0"
67
+ },
68
+ "devDependencies": {
69
+ "@types/node": "^22.19.1",
70
+ "electron": "42.4.0",
71
+ "tsdown": "0.22.14",
72
+ "typescript": "7.0.2",
73
+ "vitest": "^1.6.1",
74
+ "react": "^19.2.1",
75
+ "react-dom": "^19.2.1",
76
+ "@types/react": "^19.2.7",
77
+ "@testing-library/react": "^16.3.0",
78
+ "@testing-library/dom": "^10.4.1",
79
+ "jsdom": "^26.1.0",
80
+ "@types/react-dom": "~19.2.0",
81
+ "@posthog-tooling/tsconfig-base": "1.1.1"
82
+ },
83
+ "peerDependenciesMeta": {
84
+ "react": {
85
+ "optional": true
86
+ },
87
+ "@types/react": {
88
+ "optional": true
89
+ }
90
+ },
91
+ "scripts": {
92
+ "prebuild": "node ../../tooling/write-version.mjs",
93
+ "build": "tsdown",
94
+ "dev": "tsdown --watch",
95
+ "check-types": "pnpm prebuild && tsc --noEmit --project tsconfig.json",
96
+ "test:unit": "vitest run",
97
+ "test:delivery": "node --test test/delivery/delivery.test.mjs",
98
+ "test:built": "node --test test/exports.test.mjs test/react-exports.test.mjs",
99
+ "test:utility": "node test/utility-process/run.mjs",
100
+ "test:errors": "node test/error-autocapture.test.mjs",
101
+ "test:transport": "node --test test/transport/transport.test.mjs",
102
+ "lint": "oxlint --report-unused-disable-directives-severity error src",
103
+ "lint:fix": "oxlint --report-unused-disable-directives-severity error src --fix",
104
+ "clean": "rimraf dist coverage",
105
+ "package": "pnpm pack --out $PACKAGE_DEST/%s.tgz",
106
+ "test:autocapture": "node test/autocapture/run.mjs"
107
+ }
108
+ }