File tree Expand file tree Collapse file tree 3 files changed +24
-6
lines changed
Expand file tree Collapse file tree 3 files changed +24
-6
lines changed Original file line number Diff line number Diff line change 11import './default-extensions'
22import './external-scripts-loader'
3- import { init_as_module } from '../posthog-core'
4- export { PostHog } from '../posthog-core'
3+ import { init_as_module , PostHog as _PostHog , type PostHogWithExtensions } from '../posthog-core'
4+
5+ // In the full bundle, tree-shakeable extensions are always loaded,
6+ // so we narrow the type to make them non-optional.
7+ export const PostHog = _PostHog as typeof _PostHog &
8+ ( new ( ...args : ConstructorParameters < typeof _PostHog > ) => PostHogWithExtensions )
9+ export type PostHog = PostHogWithExtensions
10+
511export * from '../types'
612export * from '../posthog-surveys-types'
713export * from '../posthog-product-tours-types'
814export * from '../posthog-conversations-types'
9- export const posthog = init_as_module ( )
15+ export const posthog = init_as_module ( ) as PostHogWithExtensions
1016export default posthog
Original file line number Diff line number Diff line change 11import './default-extensions'
2- import { init_as_module } from '../posthog-core'
3- export { PostHog } from '../posthog-core'
2+ import { init_as_module , PostHog as _PostHog , type PostHogWithExtensions } from '../posthog-core'
3+
4+ // In the full bundle, tree-shakeable extensions are always loaded,
5+ // so we narrow the type to make them non-optional.
6+ export const PostHog = _PostHog as typeof _PostHog & ( new ( ...args : ConstructorParameters < typeof _PostHog > ) => PostHogWithExtensions )
7+ export type PostHog = PostHogWithExtensions
8+
49export * from '../types'
510export * from '../posthog-surveys-types'
611export * from '../posthog-product-tours-types'
712export * from '../posthog-conversations-types'
8- export const posthog = init_as_module ( )
13+ export const posthog = init_as_module ( ) as PostHogWithExtensions
914export default posthog
Original file line number Diff line number Diff line change @@ -3889,6 +3889,13 @@ export function init_from_snippet(): void {
38893889 add_dom_loaded_handler ( )
38903890}
38913891
3892+ /**
3893+ * When using the full bundle, all tree-shakeable extensions are guaranteed to be available.
3894+ * The slim bundle keeps them optional.
3895+ */
3896+ export type PostHogWithExtensions = PostHog &
3897+ Required < Pick < PostHog , 'surveys' | 'conversations' | 'logs' | 'experiments' | 'toolbar' | 'exceptions' > >
3898+
38923899export function init_as_module ( ) : PostHog {
38933900 const posthogMain = ( instances [ PRIMARY_INSTANCE_NAME ] = new PostHog ( ) )
38943901
You can’t perform that action at this time.
0 commit comments