solid-posthog
Version:
Allows you to PostHog within SolidJS
33 lines (28 loc) • 996 B
TypeScript
import * as solid_js from 'solid-js';
import { JSX } from 'solid-js';
import posthog, { PostHog, PostHogConfig } from 'posthog-js';
declare const PostHogContext: solid_js.Context<{
client: typeof posthog;
}>;
type WithOptionalChildren<T> = T & {
children: JSX.Element | undefined;
};
/**
* Props for the PostHogProvider component.
* This is a discriminated union type that ensures mutually exclusive props:
*
* - If `client` is provided, `apiKey` and `options` must not be provided
* - If `apiKey` is provided, `client` must not be provided, and `options` is optional
*/
type PostHogProviderProps = {
client: PostHog;
apiKey?: never;
options?: never;
} | {
apiKey: string;
options?: Partial<PostHogConfig>;
client?: never;
};
declare function PostHogProvider({ children, client, apiKey, options, }: WithOptionalChildren<PostHogProviderProps>): JSX.Element;
declare const usePostHog: () => PostHog;
export { PostHogContext, PostHogProvider, usePostHog };