@posthog/browser 0.4.0 → 0.4.2

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.
Files changed (151) hide show
  1. package/ARCHITECTURE.md +17 -1
  2. package/dist/{core.d.ts → composition/npm/core.d.ts} +7 -7
  3. package/dist/{core.js → composition/npm/core.js} +6 -6
  4. package/dist/composition/npm/core.mjs +5 -0
  5. package/dist/{index.d.ts → composition/npm/index.d.ts} +11 -11
  6. package/dist/{index.js → composition/npm/index.js} +6 -6
  7. package/dist/{index.mjs → composition/npm/index.mjs} +3 -3
  8. package/dist/{root-composition.d.ts → composition/npm/root-composition.d.ts} +3 -3
  9. package/dist/{root-composition.js → composition/npm/root-composition.js} +13 -13
  10. package/dist/{root-composition.mjs → composition/npm/root-composition.mjs} +9 -9
  11. package/dist/{browser-client.d.ts → core/context/browser-client.d.ts} +7 -7
  12. package/dist/{posthog.d.ts → core/posthog.d.ts} +1 -1
  13. package/dist/{posthog.js → core/posthog.js} +15 -15
  14. package/dist/{posthog.mjs → core/posthog.mjs} +7 -7
  15. package/dist/{remote-config.d.ts → core/remote-config.d.ts} +1 -1
  16. package/dist/{remote-config.js → core/remote-config.js} +2 -2
  17. package/dist/{remote-config.mjs → core/remote-config.mjs} +1 -1
  18. package/dist/{bot-filter.d.ts → core/state/bot-filter.d.ts} +1 -1
  19. package/dist/{key-value-store.d.ts → core/state/key-value-store.d.ts} +1 -1
  20. package/dist/{state.d.ts → core/state/state.d.ts} +1 -1
  21. package/dist/{state.js → core/state/state.js} +10 -6
  22. package/dist/{state.mjs → core/state/state.mjs} +5 -1
  23. package/dist/{types.d.ts → core/types.d.ts} +6 -6
  24. package/dist/{request.d.ts → platform/request.d.ts} +1 -1
  25. package/dist/{version.js → primitives/version.js} +1 -1
  26. package/dist/primitives/version.mjs +2 -0
  27. package/dist/{capture-summary.d.ts → products/analytics/admission/capture-summary.d.ts} +1 -1
  28. package/dist/{capture-summary.js → products/analytics/admission/capture-summary.js} +2 -2
  29. package/dist/{capture-summary.mjs → products/analytics/admission/capture-summary.mjs} +1 -1
  30. package/dist/{analytics-api.d.ts → products/analytics/analytics-api.d.ts} +2 -2
  31. package/dist/{analytics-extension.d.ts → products/analytics/analytics-extension.d.ts} +2 -2
  32. package/dist/{analytics-extension.js → products/analytics/analytics-extension.js} +35 -35
  33. package/dist/{analytics-extension.mjs → products/analytics/analytics-extension.mjs} +11 -11
  34. package/dist/{analytics-internal.d.ts → products/analytics/analytics-internal.d.ts} +7 -7
  35. package/dist/{analytics.js → products/analytics/analytics.js} +2 -2
  36. package/dist/{analytics.mjs → products/analytics/analytics.mjs} +1 -1
  37. package/dist/{automatic-analytics.js → products/analytics/automatic-analytics.js} +1 -1
  38. package/dist/{automatic-analytics.mjs → products/analytics/automatic-analytics.mjs} +1 -1
  39. package/dist/{analytics-delivery.d.ts → products/analytics/delivery/analytics-delivery.d.ts} +1 -1
  40. package/dist/{analytics-delivery.js → products/analytics/delivery/analytics-delivery.js} +2 -2
  41. package/dist/{analytics-delivery.mjs → products/analytics/delivery/analytics-delivery.mjs} +1 -1
  42. package/dist/{capture-v1.d.ts → products/analytics/delivery/capture-v1.d.ts} +2 -2
  43. package/dist/{capture-v1.js → products/analytics/delivery/capture-v1.js} +13 -13
  44. package/dist/{capture-v1.mjs → products/analytics/delivery/capture-v1.mjs} +4 -4
  45. package/dist/{lane.d.ts → products/analytics/delivery/lane.d.ts} +1 -1
  46. package/dist/{person-processing.d.ts → products/analytics/properties/person-processing.d.ts} +1 -1
  47. package/dist/{autocapture.d.ts → products/autocapture/autocapture.d.ts} +1 -1
  48. package/dist/{flags-token.d.ts → products/flags/flags-token.d.ts} +1 -1
  49. package/dist/{logs-internal.d.ts → products/logs/logs-internal.d.ts} +1 -1
  50. package/dist/{surveys-internal.d.ts → products/surveys/surveys-internal.d.ts} +1 -1
  51. package/package.json +29 -29
  52. package/dist/core.mjs +0 -5
  53. package/dist/version.mjs +0 -2
  54. /package/dist/{browser-client.js → core/context/browser-client.js} +0 -0
  55. /package/dist/{browser-client.mjs → core/context/browser-client.mjs} +0 -0
  56. /package/dist/{extensions → core/extensions}/registry.d.ts +0 -0
  57. /package/dist/{extensions → core/extensions}/registry.js +0 -0
  58. /package/dist/{extensions → core/extensions}/registry.mjs +0 -0
  59. /package/dist/{bot-filter.js → core/state/bot-filter.js} +0 -0
  60. /package/dist/{bot-filter.mjs → core/state/bot-filter.mjs} +0 -0
  61. /package/dist/{key-value-store.js → core/state/key-value-store.js} +0 -0
  62. /package/dist/{key-value-store.mjs → core/state/key-value-store.mjs} +0 -0
  63. /package/dist/{types.js → core/types.js} +0 -0
  64. /package/dist/{types.mjs → core/types.mjs} +0 -0
  65. /package/dist/{logger.d.ts → platform/logger.d.ts} +0 -0
  66. /package/dist/{logger.js → platform/logger.js} +0 -0
  67. /package/dist/{logger.mjs → platform/logger.mjs} +0 -0
  68. /package/dist/{request.js → platform/request.js} +0 -0
  69. /package/dist/{request.mjs → platform/request.mjs} +0 -0
  70. /package/dist/{id.d.ts → primitives/id.d.ts} +0 -0
  71. /package/dist/{id.js → primitives/id.js} +0 -0
  72. /package/dist/{id.mjs → primitives/id.mjs} +0 -0
  73. /package/dist/{immutable.d.ts → primitives/immutable.d.ts} +0 -0
  74. /package/dist/{immutable.js → primitives/immutable.js} +0 -0
  75. /package/dist/{immutable.mjs → primitives/immutable.mjs} +0 -0
  76. /package/dist/{named-error.d.ts → primitives/named-error.d.ts} +0 -0
  77. /package/dist/{named-error.js → primitives/named-error.js} +0 -0
  78. /package/dist/{named-error.mjs → primitives/named-error.mjs} +0 -0
  79. /package/dist/{utf8.d.ts → primitives/utf8.d.ts} +0 -0
  80. /package/dist/{utf8.js → primitives/utf8.js} +0 -0
  81. /package/dist/{utf8.mjs → primitives/utf8.mjs} +0 -0
  82. /package/dist/{version.d.ts → primitives/version.d.ts} +0 -0
  83. /package/dist/{capture-properties.d.ts → products/analytics/admission/capture-properties.d.ts} +0 -0
  84. /package/dist/{capture-properties.js → products/analytics/admission/capture-properties.js} +0 -0
  85. /package/dist/{capture-properties.mjs → products/analytics/admission/capture-properties.mjs} +0 -0
  86. /package/dist/{event-buffer.d.ts → products/analytics/admission/event-buffer.d.ts} +0 -0
  87. /package/dist/{event-buffer.js → products/analytics/admission/event-buffer.js} +0 -0
  88. /package/dist/{event-buffer.mjs → products/analytics/admission/event-buffer.mjs} +0 -0
  89. /package/dist/{rate-limiter.d.ts → products/analytics/admission/rate-limiter.d.ts} +0 -0
  90. /package/dist/{rate-limiter.js → products/analytics/admission/rate-limiter.js} +0 -0
  91. /package/dist/{rate-limiter.mjs → products/analytics/admission/rate-limiter.mjs} +0 -0
  92. /package/dist/{analytics-api.js → products/analytics/analytics-api.js} +0 -0
  93. /package/dist/{analytics-api.mjs → products/analytics/analytics-api.mjs} +0 -0
  94. /package/dist/{analytics-buffer.d.ts → products/analytics/analytics-buffer.d.ts} +0 -0
  95. /package/dist/{analytics-buffer.js → products/analytics/analytics-buffer.js} +0 -0
  96. /package/dist/{analytics-buffer.mjs → products/analytics/analytics-buffer.mjs} +0 -0
  97. /package/dist/{analytics-internal.js → products/analytics/analytics-internal.js} +0 -0
  98. /package/dist/{analytics-internal.mjs → products/analytics/analytics-internal.mjs} +0 -0
  99. /package/dist/{analytics-options.d.ts → products/analytics/analytics-options.d.ts} +0 -0
  100. /package/dist/{analytics-options.js → products/analytics/analytics-options.js} +0 -0
  101. /package/dist/{analytics-options.mjs → products/analytics/analytics-options.mjs} +0 -0
  102. /package/dist/{analytics.d.ts → products/analytics/analytics.d.ts} +0 -0
  103. /package/dist/{automatic-analytics.d.ts → products/analytics/automatic-analytics.d.ts} +0 -0
  104. /package/dist/{lane.js → products/analytics/delivery/lane.js} +0 -0
  105. /package/dist/{lane.mjs → products/analytics/delivery/lane.mjs} +0 -0
  106. /package/dist/{analytics-properties.d.ts → products/analytics/properties/analytics-properties.d.ts} +0 -0
  107. /package/dist/{analytics-properties.js → products/analytics/properties/analytics-properties.js} +0 -0
  108. /package/dist/{analytics-properties.mjs → products/analytics/properties/analytics-properties.mjs} +0 -0
  109. /package/dist/{analytics-session-properties.d.ts → products/analytics/properties/analytics-session-properties.d.ts} +0 -0
  110. /package/dist/{analytics-session-properties.js → products/analytics/properties/analytics-session-properties.js} +0 -0
  111. /package/dist/{analytics-session-properties.mjs → products/analytics/properties/analytics-session-properties.mjs} +0 -0
  112. /package/dist/{person-processing.js → products/analytics/properties/person-processing.js} +0 -0
  113. /package/dist/{person-processing.mjs → products/analytics/properties/person-processing.mjs} +0 -0
  114. /package/dist/{autocapture-options.d.ts → products/autocapture/autocapture-options.d.ts} +0 -0
  115. /package/dist/{autocapture-options.js → products/autocapture/autocapture-options.js} +0 -0
  116. /package/dist/{autocapture-options.mjs → products/autocapture/autocapture-options.mjs} +0 -0
  117. /package/dist/{autocapture.js → products/autocapture/autocapture.js} +0 -0
  118. /package/dist/{autocapture.mjs → products/autocapture/autocapture.mjs} +0 -0
  119. /package/dist/{flags-internal.d.ts → products/flags/flags-internal.d.ts} +0 -0
  120. /package/dist/{flags-internal.js → products/flags/flags-internal.js} +0 -0
  121. /package/dist/{flags-internal.mjs → products/flags/flags-internal.mjs} +0 -0
  122. /package/dist/{flags-options.d.ts → products/flags/flags-options.d.ts} +0 -0
  123. /package/dist/{flags-options.js → products/flags/flags-options.js} +0 -0
  124. /package/dist/{flags-options.mjs → products/flags/flags-options.mjs} +0 -0
  125. /package/dist/{flags-token.js → products/flags/flags-token.js} +0 -0
  126. /package/dist/{flags-token.mjs → products/flags/flags-token.mjs} +0 -0
  127. /package/dist/{flags.d.ts → products/flags/flags.d.ts} +0 -0
  128. /package/dist/{flags.js → products/flags/flags.js} +0 -0
  129. /package/dist/{flags.mjs → products/flags/flags.mjs} +0 -0
  130. /package/dist/{logs-internal.js → products/logs/logs-internal.js} +0 -0
  131. /package/dist/{logs-internal.mjs → products/logs/logs-internal.mjs} +0 -0
  132. /package/dist/{logs-options.d.ts → products/logs/logs-options.d.ts} +0 -0
  133. /package/dist/{logs-options.js → products/logs/logs-options.js} +0 -0
  134. /package/dist/{logs-options.mjs → products/logs/logs-options.mjs} +0 -0
  135. /package/dist/{logs.d.ts → products/logs/logs.d.ts} +0 -0
  136. /package/dist/{logs.js → products/logs/logs.js} +0 -0
  137. /package/dist/{logs.mjs → products/logs/logs.mjs} +0 -0
  138. /package/dist/{automatic-surveys.d.ts → products/surveys/automatic-surveys.d.ts} +0 -0
  139. /package/dist/{automatic-surveys.js → products/surveys/automatic-surveys.js} +0 -0
  140. /package/dist/{automatic-surveys.mjs → products/surveys/automatic-surveys.mjs} +0 -0
  141. /package/dist/{surveys-extension.d.ts → products/surveys/surveys-extension.d.ts} +0 -0
  142. /package/dist/{surveys-extension.js → products/surveys/surveys-extension.js} +0 -0
  143. /package/dist/{surveys-extension.mjs → products/surveys/surveys-extension.mjs} +0 -0
  144. /package/dist/{surveys-internal.js → products/surveys/surveys-internal.js} +0 -0
  145. /package/dist/{surveys-internal.mjs → products/surveys/surveys-internal.mjs} +0 -0
  146. /package/dist/{surveys-options.d.ts → products/surveys/surveys-options.d.ts} +0 -0
  147. /package/dist/{surveys-options.js → products/surveys/surveys-options.js} +0 -0
  148. /package/dist/{surveys-options.mjs → products/surveys/surveys-options.mjs} +0 -0
  149. /package/dist/{surveys.d.ts → products/surveys/surveys.d.ts} +0 -0
  150. /package/dist/{surveys.js → products/surveys/surveys.js} +0 -0
  151. /package/dist/{surveys.mjs → products/surveys/surveys.mjs} +0 -0
package/ARCHITECTURE.md CHANGED
@@ -43,6 +43,22 @@ A minifier cannot correct a bad package boundary. An automatic dynamic import do
43
43
 
44
44
  ## 4. Package layers
45
45
 
46
+ Source files are grouped by responsibility:
47
+
48
+ | Directory | Responsibility |
49
+ | ------------------------------------ | ---------------------------------------------------------------------------------------- |
50
+ | `src/composition/npm/` | Default and manual SDK compositions and product selection |
51
+ | `src/composition/script/` | Self-initializing classic-script composition |
52
+ | `src/core/` | Client lifecycle, shared contracts, scoped views, extension registry and state authority |
53
+ | `src/products/` | Product factories, operations and implementations |
54
+ | `src/products/analytics/admission/` | Analytics event construction, buffering and admission |
55
+ | `src/products/analytics/properties/` | Registered context and person-processing policy |
56
+ | `src/products/analytics/delivery/` | Capture V1 encoding, scheduling, transport and retries |
57
+ | `src/platform/` | Browser request and console mechanisms |
58
+ | `src/primitives/` | Independent identifiers, immutable snapshots, errors, UTF-8 and version utilities |
59
+
60
+ Product factories remain with their products. Supported package import paths are defined by the `exports` map, independently of the internal source and emitted-file layout.
61
+
46
62
  Use these layers:
47
63
 
48
64
  ```text
@@ -468,7 +484,7 @@ The package needs preserved ES module boundaries for consumer tree shaking.
468
484
 
469
485
  ### CDN-only classic entry
470
486
 
471
- The standalone classic-script installer lives in `snippet/`, outside Rslib's `src` glob and the npm `files` allowlist. `build:cdn` emits `dist-cdn/script.js` with the complete initial core graph embedded, plus optional asynchronous chunks and source maps. Rspack's automatic public path captures the executing external script's directory synchronously and removes its query and fragment before loading chunks. There is no separate client download between the initial response and core construction.
487
+ The standalone classic-script installer lives in `src/composition/script/`, explicitly excluded from Rslib's npm entry glob and declaration build. Its generated CDN artifacts remain outside the npm `files` allowlist. `build:cdn` emits `dist-cdn/script.js` with the complete initial core graph embedded, plus optional asynchronous chunks and source maps. Rspack's automatic public path captures the executing external script's directory synchronously and removes its query and fragment before loading chunks. There is no separate client download between the initial response and core construction.
472
488
 
473
489
  This deployment artifact intentionally initializes a client; it is not an npm export and does not change the import-purity contract or `sideEffects: false`. Keep the root factory's extension setup order, override precedence, snapshots, consent, and failure isolation unchanged. The installer delegates readiness to that factory. See the [script installation guide](./README.md#classic-script-installation-draft-cdn-distribution) for query configuration, global ownership, and ready-event semantics. `bundle-size:cdn` checks the generated initial graph and reports initial/deferred artifact sizes and module attribution; `test:snippet` runs the generated classic artifacts in plain HTML against the SDK mock server.
474
490
 
@@ -1,9 +1,9 @@
1
- import type { CorePostHogOptions, IPostHog } from './types';
1
+ import type { CorePostHogOptions, IPostHog } from '../../core/types';
2
2
  /** Creates a host with only explicitly supplied products and no automatic product imports. */
3
3
  export declare const createPostHog: (options: CorePostHogOptions) => Promise<IPostHog>;
4
- export { version } from './version';
5
- export { FeatureFlagsExtension, type FeatureFlags } from './flags-token';
6
- export type { IPostHogInternal, BrowserExtension, IdentifyInfo, GroupInfo } from './browser-client';
7
- export type { IAnalytics } from './analytics-api';
8
- export type { AnalyticsOptions, ApiResponse, BrowserFetch, BrowserNavigator, CaptureOptions, CaptureOutcome, CaptureOutcomeStatus, CaptureSummary, CorePostHogOptions, Disposable, Extension, NewSessionInfo, NewSessionReason, IPostHog, RemoteConfig, SendRequestInit, SessionContext, StorageLike, } from './types';
9
- export type { PersonProfileMode } from './analytics-options';
4
+ export { version } from '../../primitives/version';
5
+ export { FeatureFlagsExtension, type FeatureFlags } from '../../products/flags/flags-token';
6
+ export type { IPostHogInternal, BrowserExtension, IdentifyInfo, GroupInfo } from '../../core/context/browser-client';
7
+ export type { IAnalytics } from '../../products/analytics/analytics-api';
8
+ export type { AnalyticsOptions, ApiResponse, BrowserFetch, BrowserNavigator, CaptureOptions, CaptureOutcome, CaptureOutcomeStatus, CaptureSummary, CorePostHogOptions, Disposable, Extension, NewSessionInfo, NewSessionReason, IPostHog, RemoteConfig, SendRequestInit, SessionContext, StorageLike, } from '../../core/types';
9
+ export type { PersonProfileMode } from '../../products/analytics/analytics-options';
@@ -28,14 +28,14 @@ var __webpack_require__ = {};
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
30
  __webpack_require__.d(__webpack_exports__, {
31
- FeatureFlagsExtension: ()=>external_flags_token_js_namespaceObject.FeatureFlagsExtension,
31
+ FeatureFlagsExtension: ()=>flags_token_js_namespaceObject.FeatureFlagsExtension,
32
32
  createPostHog: ()=>createPostHog,
33
- version: ()=>external_version_js_namespaceObject.version
33
+ version: ()=>version_js_namespaceObject.version
34
34
  });
35
- const external_posthog_js_namespaceObject = require("./posthog.js");
36
- const external_version_js_namespaceObject = require("./version.js");
37
- const external_flags_token_js_namespaceObject = require("./flags-token.js");
38
- const createPostHog = async (options)=>(0, external_posthog_js_namespaceObject.createPostHogCore)(options);
35
+ const posthog_js_namespaceObject = require("../../core/posthog.js");
36
+ const version_js_namespaceObject = require("../../primitives/version.js");
37
+ const flags_token_js_namespaceObject = require("../../products/flags/flags-token.js");
38
+ const createPostHog = async (options)=>(0, posthog_js_namespaceObject.createPostHogCore)(options);
39
39
  exports.FeatureFlagsExtension = __webpack_exports__.FeatureFlagsExtension;
40
40
  exports.createPostHog = __webpack_exports__.createPostHog;
41
41
  exports.version = __webpack_exports__.version;
@@ -0,0 +1,5 @@
1
+ import { createPostHogCore } from "../../core/posthog.mjs";
2
+ const createPostHog = async (options)=>createPostHogCore(options);
3
+ export { version } from "../../primitives/version.mjs";
4
+ export { FeatureFlagsExtension } from "../../products/flags/flags-token.mjs";
5
+ export { createPostHog };
@@ -1,13 +1,13 @@
1
- import type { IPostHog, PostHogOptions } from './types';
1
+ import type { IPostHog, PostHogOptions } from '../../core/types';
2
2
  /** Creates a browser host with on-demand first-party analytics acquisition. */
3
3
  export declare const createPostHog: (options: PostHogOptions) => Promise<IPostHog>;
4
- export type { IAnalytics } from './analytics-api';
5
- export { version } from './version';
6
- export { FeatureFlagsExtension, type FeatureFlags } from './flags-token';
7
- export type { IPostHogInternal, BrowserExtension, IdentifyInfo, GroupInfo } from './browser-client';
8
- export type { AnalyticsConfiguration, AnalyticsOptions, ApiResponse, AutomaticAnalyticsOptions, BrowserFetch, BrowserNavigator, CaptureOptions, CaptureOutcome, CaptureOutcomeStatus, CaptureSummary, CorePostHogOptions, Disposable, Extension, LoadStrategy, NewSessionInfo, NewSessionReason, IPostHog, PostHogOptions, RemoteConfig, SendRequestInit, SessionContext, StorageLike, } from './types';
9
- export type { FlagsOptions, FlagsConfiguration, FlagsCallback, FeatureFlagResult, FeatureFlagsReloadResult, } from './flags-options';
10
- export type { LogsOptions, LogsConfiguration, CaptureLogOptions } from './logs-options';
11
- export type { SurveysOptions, SurveysConfiguration, Survey, SurveyCallback, DisplaySurveyOptions, SurveyRenderReason, } from './surveys-options';
12
- export type { AutocaptureOptions, AutocaptureConfiguration, RageclickOptions } from './autocapture-options';
13
- export type { PersonProfileMode } from './analytics-options';
4
+ export type { IAnalytics } from '../../products/analytics/analytics-api';
5
+ export { version } from '../../primitives/version';
6
+ export { FeatureFlagsExtension, type FeatureFlags } from '../../products/flags/flags-token';
7
+ export type { IPostHogInternal, BrowserExtension, IdentifyInfo, GroupInfo } from '../../core/context/browser-client';
8
+ export type { AnalyticsConfiguration, AnalyticsOptions, ApiResponse, AutomaticAnalyticsOptions, BrowserFetch, BrowserNavigator, CaptureOptions, CaptureOutcome, CaptureOutcomeStatus, CaptureSummary, CorePostHogOptions, Disposable, Extension, LoadStrategy, NewSessionInfo, NewSessionReason, IPostHog, PostHogOptions, RemoteConfig, SendRequestInit, SessionContext, StorageLike, } from '../../core/types';
9
+ export type { FlagsOptions, FlagsConfiguration, FlagsCallback, FeatureFlagResult, FeatureFlagsReloadResult, } from '../../products/flags/flags-options';
10
+ export type { LogsOptions, LogsConfiguration, CaptureLogOptions } from '../../products/logs/logs-options';
11
+ export type { SurveysOptions, SurveysConfiguration, Survey, SurveyCallback, DisplaySurveyOptions, SurveyRenderReason, } from '../../products/surveys/surveys-options';
12
+ export type { AutocaptureOptions, AutocaptureConfiguration, RageclickOptions, } from '../../products/autocapture/autocapture-options';
13
+ export type { PersonProfileMode } from '../../products/analytics/analytics-options';
@@ -28,17 +28,17 @@ var __webpack_require__ = {};
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
30
  __webpack_require__.d(__webpack_exports__, {
31
- FeatureFlagsExtension: ()=>external_flags_token_js_namespaceObject.FeatureFlagsExtension,
31
+ FeatureFlagsExtension: ()=>flags_token_js_namespaceObject.FeatureFlagsExtension,
32
32
  createPostHog: ()=>createPostHog,
33
- version: ()=>external_version_js_namespaceObject.version
33
+ version: ()=>version_js_namespaceObject.version
34
34
  });
35
- const external_posthog_js_namespaceObject = require("./posthog.js");
35
+ const posthog_js_namespaceObject = require("../../core/posthog.js");
36
36
  const external_root_composition_js_namespaceObject = require("./root-composition.js");
37
- const external_version_js_namespaceObject = require("./version.js");
38
- const external_flags_token_js_namespaceObject = require("./flags-token.js");
37
+ const version_js_namespaceObject = require("../../primitives/version.js");
38
+ const flags_token_js_namespaceObject = require("../../products/flags/flags-token.js");
39
39
  const createPostHog = async (options)=>{
40
40
  const { extensions, loaders, automatic, loadingErrors } = (0, external_root_composition_js_namespaceObject.createProductComposition)(options);
41
- const client = await (0, external_posthog_js_namespaceObject.createPostHogCore)(options, extensions, loaders, automatic);
41
+ const client = await (0, posthog_js_namespaceObject.createPostHogCore)(options, extensions, loaders, automatic);
42
42
  for (const [label, error] of loadingErrors.reverse())client.logger.error(`Automatic ${label} loading failed`, error);
43
43
  return client;
44
44
  };
@@ -1,4 +1,4 @@
1
- import { createPostHogCore } from "./posthog.mjs";
1
+ import { createPostHogCore } from "../../core/posthog.mjs";
2
2
  import { createProductComposition } from "./root-composition.mjs";
3
3
  const createPostHog = async (options)=>{
4
4
  const { extensions, loaders, automatic, loadingErrors } = createProductComposition(options);
@@ -6,6 +6,6 @@ const createPostHog = async (options)=>{
6
6
  for (const [label, error] of loadingErrors.reverse())client.logger.error(`Automatic ${label} loading failed`, error);
7
7
  return client;
8
8
  };
9
- export { version } from "./version.mjs";
10
- export { FeatureFlagsExtension } from "./flags-token.mjs";
9
+ export { version } from "../../primitives/version.mjs";
10
+ export { FeatureFlagsExtension } from "../../products/flags/flags-token.mjs";
11
11
  export { createPostHog };
@@ -1,6 +1,6 @@
1
- import type { IPostHogInternal, BrowserExtension } from './browser-client';
2
- import type { PostHogOptions } from './types';
3
- import type { AutomaticExtension, ExtensionLoader } from './extensions/registry';
1
+ import type { IPostHogInternal, BrowserExtension } from '../../core/context/browser-client';
2
+ import type { PostHogOptions } from '../../core/types';
3
+ import type { AutomaticExtension, ExtensionLoader } from '../../core/extensions/registry';
4
4
  interface ProductComposition {
5
5
  extensions: BrowserExtension[];
6
6
  loaders: Record<string, ExtensionLoader<IPostHogInternal>>;
@@ -32,10 +32,10 @@ __webpack_require__.d(__webpack_exports__, {
32
32
  });
33
33
  const constants_namespaceObject = require("@posthog/browser-common/constants");
34
34
  const surveys_config_namespaceObject = require("@posthog/browser-common/surveys-config");
35
- const external_autocapture_options_js_namespaceObject = require("./autocapture-options.js");
36
- const external_surveys_options_js_namespaceObject = require("./surveys-options.js");
37
- const external_logs_options_js_namespaceObject = require("./logs-options.js");
38
- const external_analytics_options_js_namespaceObject = require("./analytics-options.js");
35
+ const autocapture_options_js_namespaceObject = require("../../products/autocapture/autocapture-options.js");
36
+ const surveys_options_js_namespaceObject = require("../../products/surveys/surveys-options.js");
37
+ const logs_options_js_namespaceObject = require("../../products/logs/logs-options.js");
38
+ const analytics_options_js_namespaceObject = require("../../products/analytics/analytics-options.js");
39
39
  const activateFromSignals = (hasSaved, enabled)=>(host, acquire)=>{
40
40
  let loading;
41
41
  host.onRemoteConfig((result)=>{
@@ -67,8 +67,8 @@ const configureAnalytics = (options, composition)=>{
67
67
  else try {
68
68
  configuration = options?.analytics;
69
69
  } catch {}
70
- const snapshot = (0, external_analytics_options_js_namespaceObject.snapshotAutomaticAnalyticsOptions)(configuration || {});
71
- if (false !== configuration) composition.loaders.analytics = ()=>import("./automatic-analytics.js").then(({ analytics })=>analytics(snapshot));
70
+ const snapshot = (0, analytics_options_js_namespaceObject.snapshotAutomaticAnalyticsOptions)(configuration || {});
71
+ if (false !== configuration) composition.loaders.analytics = ()=>import("../../products/analytics/automatic-analytics.js").then(({ analytics })=>analytics(snapshot));
72
72
  return snapshot;
73
73
  };
74
74
  const configureFlags = (options)=>{
@@ -76,24 +76,24 @@ const configureFlags = (options)=>{
76
76
  if (false === configuration) return;
77
77
  const snapshot = configuration && JSON.parse(JSON.stringify(configuration));
78
78
  return {
79
- load: ()=>import("./flags.js").then(({ flags })=>flags(snapshot))
79
+ load: ()=>import("../../products/flags/flags.js").then(({ flags })=>flags(snapshot))
80
80
  };
81
81
  };
82
82
  const configureLogs = (options)=>{
83
83
  const configuration = options?.logs;
84
84
  if (false === configuration) return;
85
- const snapshot = (0, external_logs_options_js_namespaceObject.snapshotLogsOptions)(configuration);
85
+ const snapshot = (0, logs_options_js_namespaceObject.snapshotLogsOptions)(configuration);
86
86
  return {
87
- load: ()=>import("./logs.js").then(({ logs })=>logs(snapshot)),
87
+ load: ()=>import("../../products/logs/logs.js").then(({ logs })=>logs(snapshot)),
88
88
  activate: void 0 === configuration ? activateFromSignals((host)=>true === host.kv.get('consoleCaptureEnabled'), (config)=>config.logs?.captureConsoleLogs === true) : void 0
89
89
  };
90
90
  };
91
91
  const configureSurveys = (options)=>{
92
92
  const configuration = options?.surveys;
93
93
  if (false === configuration) return;
94
- const snapshot = (0, external_surveys_options_js_namespaceObject.snapshotSurveysOptions)(configuration);
94
+ const snapshot = (0, surveys_options_js_namespaceObject.snapshotSurveysOptions)(configuration);
95
95
  return {
96
- load: ()=>import("./automatic-surveys.js").then(({ surveys })=>surveys(snapshot)),
96
+ load: ()=>import("../../products/surveys/automatic-surveys.js").then(({ surveys })=>surveys(snapshot)),
97
97
  activate: void 0 === configuration ? activateFromSignals((host)=>{
98
98
  const cached = host.kv.get(surveys_config_namespaceObject.SURVEYS);
99
99
  return Array.isArray(cached) && cached.length > 0;
@@ -103,9 +103,9 @@ const configureSurveys = (options)=>{
103
103
  const configureAutocapture = (options)=>{
104
104
  const configuration = options?.autocapture;
105
105
  if (false === configuration) return;
106
- const snapshot = (0, external_autocapture_options_js_namespaceObject.snapshotAutocaptureOptions)(configuration);
106
+ const snapshot = (0, autocapture_options_js_namespaceObject.snapshotAutocaptureOptions)(configuration);
107
107
  return {
108
- load: ()=>import("./autocapture.js").then(({ autocapture })=>autocapture(snapshot)),
108
+ load: ()=>import("../../products/autocapture/autocapture.js").then(({ autocapture })=>autocapture(snapshot)),
109
109
  activate: void 0 === configuration ? activateFromSignals((host)=>false === host.kv.get(constants_namespaceObject.AUTOCAPTURE_DISABLED_SERVER_SIDE), (config)=>false === config.autocapture_opt_out) : void 0
110
110
  };
111
111
  };
@@ -1,9 +1,9 @@
1
1
  import { AUTOCAPTURE_DISABLED_SERVER_SIDE } from "@posthog/browser-common/constants";
2
2
  import { SURVEYS } from "@posthog/browser-common/surveys-config";
3
- import { snapshotAutocaptureOptions } from "./autocapture-options.mjs";
4
- import { snapshotSurveysOptions } from "./surveys-options.mjs";
5
- import { snapshotLogsOptions } from "./logs-options.mjs";
6
- import { snapshotAutomaticAnalyticsOptions } from "./analytics-options.mjs";
3
+ import { snapshotAutocaptureOptions } from "../../products/autocapture/autocapture-options.mjs";
4
+ import { snapshotSurveysOptions } from "../../products/surveys/surveys-options.mjs";
5
+ import { snapshotLogsOptions } from "../../products/logs/logs-options.mjs";
6
+ import { snapshotAutomaticAnalyticsOptions } from "../../products/analytics/analytics-options.mjs";
7
7
  const activateFromSignals = (hasSaved, enabled)=>(host, acquire)=>{
8
8
  let loading;
9
9
  host.onRemoteConfig((result)=>{
@@ -36,7 +36,7 @@ const configureAnalytics = (options, composition)=>{
36
36
  configuration = options?.analytics;
37
37
  } catch {}
38
38
  const snapshot = snapshotAutomaticAnalyticsOptions(configuration || {});
39
- if (false !== configuration) composition.loaders.analytics = ()=>import("./automatic-analytics.mjs").then(({ analytics })=>analytics(snapshot));
39
+ if (false !== configuration) composition.loaders.analytics = ()=>import("../../products/analytics/automatic-analytics.mjs").then(({ analytics })=>analytics(snapshot));
40
40
  return snapshot;
41
41
  };
42
42
  const configureFlags = (options)=>{
@@ -44,7 +44,7 @@ const configureFlags = (options)=>{
44
44
  if (false === configuration) return;
45
45
  const snapshot = configuration && JSON.parse(JSON.stringify(configuration));
46
46
  return {
47
- load: ()=>import("./flags.mjs").then(({ flags })=>flags(snapshot))
47
+ load: ()=>import("../../products/flags/flags.mjs").then(({ flags })=>flags(snapshot))
48
48
  };
49
49
  };
50
50
  const configureLogs = (options)=>{
@@ -52,7 +52,7 @@ const configureLogs = (options)=>{
52
52
  if (false === configuration) return;
53
53
  const snapshot = snapshotLogsOptions(configuration);
54
54
  return {
55
- load: ()=>import("./logs.mjs").then(({ logs })=>logs(snapshot)),
55
+ load: ()=>import("../../products/logs/logs.mjs").then(({ logs })=>logs(snapshot)),
56
56
  activate: void 0 === configuration ? activateFromSignals((host)=>true === host.kv.get('consoleCaptureEnabled'), (config)=>config.logs?.captureConsoleLogs === true) : void 0
57
57
  };
58
58
  };
@@ -61,7 +61,7 @@ const configureSurveys = (options)=>{
61
61
  if (false === configuration) return;
62
62
  const snapshot = snapshotSurveysOptions(configuration);
63
63
  return {
64
- load: ()=>import("./automatic-surveys.mjs").then(({ surveys })=>surveys(snapshot)),
64
+ load: ()=>import("../../products/surveys/automatic-surveys.mjs").then(({ surveys })=>surveys(snapshot)),
65
65
  activate: void 0 === configuration ? activateFromSignals((host)=>{
66
66
  const cached = host.kv.get(SURVEYS);
67
67
  return Array.isArray(cached) && cached.length > 0;
@@ -73,7 +73,7 @@ const configureAutocapture = (options)=>{
73
73
  if (false === configuration) return;
74
74
  const snapshot = snapshotAutocaptureOptions(configuration);
75
75
  return {
76
- load: ()=>import("./autocapture.mjs").then(({ autocapture })=>autocapture(snapshot)),
76
+ load: ()=>import("../../products/autocapture/autocapture.mjs").then(({ autocapture })=>autocapture(snapshot)),
77
77
  activate: void 0 === configuration ? activateFromSignals((host)=>false === host.kv.get(AUTOCAPTURE_DISABLED_SERVER_SIDE), (config)=>false === config.autocapture_opt_out) : void 0
78
78
  };
79
79
  };
@@ -1,11 +1,11 @@
1
1
  import type { Client, DeepReadonly, Extension, ExtensionToken, Listener } from '@posthog/browser-common';
2
- import type { IAnalytics } from './analytics-api';
3
- import type { IAnalyticsExtension } from './analytics-internal';
4
- import type { FeatureFlags } from './flags-token';
5
- import type { FlagsExtension } from './flags-internal';
6
- import type { LogsExtension } from './logs-internal';
7
- import type { SurveysExtension } from './surveys-internal';
8
- import type { ConsentState } from './state';
2
+ import type { IAnalytics } from '../../products/analytics/analytics-api';
3
+ import type { IAnalyticsExtension } from '../../products/analytics/analytics-internal';
4
+ import type { FeatureFlags } from '../../products/flags/flags-token';
5
+ import type { FlagsExtension } from '../../products/flags/flags-internal';
6
+ import type { LogsExtension } from '../../products/logs/logs-internal';
7
+ import type { SurveysExtension } from '../../products/surveys/surveys-internal';
8
+ import type { ConsentState } from '../state/state';
9
9
  export interface IdentifyInfo {
10
10
  readonly distinctId: string;
11
11
  readonly previousDistinctId: string;
@@ -1,4 +1,4 @@
1
- import type { IPostHogInternal, BrowserExtension as Extension } from './browser-client';
1
+ import type { IPostHogInternal, BrowserExtension as Extension } from './context/browser-client';
2
2
  import { type AutomaticExtension, type ExtensionLoader } from './extensions/registry';
3
3
  import type { CorePostHogOptions, IPostHog } from './types';
4
4
  export declare const createPostHogCore: (options: CorePostHogOptions, configured?: readonly Extension[], automaticLoaders?: Readonly<Record<string, ExtensionLoader<IPostHogInternal>>>, automatic?: readonly AutomaticExtension<IPostHogInternal>[]) => Promise<IPostHog>;
@@ -32,14 +32,14 @@ __webpack_require__.d(__webpack_exports__, {
32
32
  });
33
33
  const external_remote_config_js_namespaceObject = require("./remote-config.js");
34
34
  const pubsub_namespaceObject = require("@posthog/browser-common/pubsub");
35
- const external_analytics_internal_js_namespaceObject = require("./analytics-internal.js");
36
- const external_bot_filter_js_namespaceObject = require("./bot-filter.js");
35
+ const analytics_internal_js_namespaceObject = require("../products/analytics/analytics-internal.js");
36
+ const bot_filter_js_namespaceObject = require("./state/bot-filter.js");
37
37
  const registry_js_namespaceObject = require("./extensions/registry.js");
38
- const external_immutable_js_namespaceObject = require("./immutable.js");
39
- const external_logger_js_namespaceObject = require("./logger.js");
40
- const external_request_js_namespaceObject = require("./request.js");
41
- const external_state_js_namespaceObject = require("./state.js");
42
- const external_version_js_namespaceObject = require("./version.js");
38
+ const immutable_js_namespaceObject = require("../primitives/immutable.js");
39
+ const logger_js_namespaceObject = require("../platform/logger.js");
40
+ const request_js_namespaceObject = require("../platform/request.js");
41
+ const state_js_namespaceObject = require("./state/state.js");
42
+ const version_js_namespaceObject = require("../primitives/version.js");
43
43
  const CONSENT_CHANGE_EVENT = '__posthog_browser_consent_change__';
44
44
  const DEFAULT_SHUTDOWN_TIMEOUT_MS = 30000;
45
45
  const normalizeHost = (host)=>{
@@ -78,7 +78,7 @@ class PostHog {
78
78
  constructor(options, loaders){
79
79
  this.library = Object.freeze({
80
80
  name: 'web',
81
- version: external_version_js_namespaceObject.version
81
+ version: version_js_namespaceObject.version
82
82
  });
83
83
  this._immediateAuthority = {};
84
84
  this._closing = false;
@@ -91,11 +91,11 @@ class PostHog {
91
91
  } catch {}
92
92
  this.projectToken = projectToken;
93
93
  this._capturePageview = options.capturePageview ?? true;
94
- this.logger = (0, external_logger_js_namespaceObject.createLogger)('[PostHog]', options.debug ?? false);
94
+ this.logger = (0, logger_js_namespaceObject.createLogger)('[PostHog]', options.debug ?? false);
95
95
  if (!projectToken) this.logger.error('A PostHog project token is required');
96
96
  const initialPersonProperties = options.initialPersonProperties;
97
97
  try {
98
- this.initialPersonProperties = initialPersonProperties ? (0, external_immutable_js_namespaceObject.deepFreeze)(JSON.parse(JSON.stringify(initialPersonProperties))) : Object.freeze({});
98
+ this.initialPersonProperties = initialPersonProperties ? (0, immutable_js_namespaceObject.deepFreeze)(JSON.parse(JSON.stringify(initialPersonProperties))) : Object.freeze({});
99
99
  } catch {
100
100
  this.initialPersonProperties = Object.freeze({});
101
101
  }
@@ -110,10 +110,10 @@ class PostHog {
110
110
  this._consentChangePublisher = new pubsub_namespaceObject.Publisher((error)=>this.logger.error('A consent change listener failed', error));
111
111
  const browserNavigator = false === options.navigator ? void 0 : options.navigator ?? getDefaultNavigator();
112
112
  const browserFetch = false === options.fetch ? void 0 : options.fetch ?? getDefaultFetch();
113
- this._blocked = !projectToken || !(options.disableBotDetection ?? false) && (0, external_bot_filter_js_namespaceObject.isLikelyBot)(browserNavigator, options.blockedUserAgents ?? []);
114
- const requestedStorage = false === options.storage ? void 0 : options.storage ?? (0, external_state_js_namespaceObject.getDefaultStorage)();
113
+ this._blocked = !projectToken || !(options.disableBotDetection ?? false) && (0, bot_filter_js_namespaceObject.isLikelyBot)(browserNavigator, options.blockedUserAgents ?? []);
114
+ const requestedStorage = false === options.storage ? void 0 : options.storage ?? (0, state_js_namespaceObject.getDefaultStorage)();
115
115
  const storage = this._blocked ? void 0 : requestedStorage;
116
- this._state = new external_state_js_namespaceObject.BrowserState(projectToken, storage, options.persistenceKey, options.consentPersistenceName, options.optOutByDefault ?? false, !this._blocked && void 0 === options.storage && void 0 !== requestedStorage ? external_state_js_namespaceObject.getDefaultSessionStorage : void 0, (consent, previous)=>{
116
+ this._state = new state_js_namespaceObject.BrowserState(projectToken, storage, options.persistenceKey, options.consentPersistenceName, options.optOutByDefault ?? false, !this._blocked && void 0 === options.storage && void 0 !== requestedStorage ? state_js_namespaceObject.getDefaultSessionStorage : void 0, (consent, previous)=>{
117
117
  if ('denied' === consent) {
118
118
  this._immediateAuthority = {};
119
119
  this._analytics?.purge();
@@ -206,7 +206,7 @@ class PostHog {
206
206
  return 'denied' === this._state.consent;
207
207
  }
208
208
  sendRequest(path, init) {
209
- return (0, external_request_js_namespaceObject.sendRequest)(this._requestRuntime, path, init, ()=>!this._blocked && !this.hasOptedOut());
209
+ return (0, request_js_namespaceObject.sendRequest)(this._requestRuntime, path, init, ()=>!this._blocked && !this.hasOptedOut());
210
210
  }
211
211
  async getRemoteConfig() {
212
212
  if (this._closing || this._disposed) return;
@@ -547,7 +547,7 @@ class PostHog {
547
547
  }
548
548
  async _setupExtension(extension, host) {
549
549
  if (this._closing || this._disposed) throw new Error('The browser client is closing');
550
- if (!(0, external_analytics_internal_js_namespaceObject.isAnalyticsExtension)(extension)) {
550
+ if (!(0, analytics_internal_js_namespaceObject.isAnalyticsExtension)(extension)) {
551
551
  await extension.setup(host);
552
552
  if (this._closing || this._disposed) throw new Error('The browser client is closing');
553
553
  return;
@@ -1,13 +1,13 @@
1
1
  import { loadRemoteConfig } from "./remote-config.mjs";
2
2
  import { Publisher } from "@posthog/browser-common/pubsub";
3
- import { isAnalyticsExtension } from "./analytics-internal.mjs";
4
- import { isLikelyBot } from "./bot-filter.mjs";
3
+ import { isAnalyticsExtension } from "../products/analytics/analytics-internal.mjs";
4
+ import { isLikelyBot } from "./state/bot-filter.mjs";
5
5
  import { ExtensionRegistry } from "./extensions/registry.mjs";
6
- import { deepFreeze } from "./immutable.mjs";
7
- import { createLogger } from "./logger.mjs";
8
- import { sendRequest } from "./request.mjs";
9
- import { BrowserState, getDefaultSessionStorage, getDefaultStorage } from "./state.mjs";
10
- import { version } from "./version.mjs";
6
+ import { deepFreeze } from "../primitives/immutable.mjs";
7
+ import { createLogger } from "../platform/logger.mjs";
8
+ import { sendRequest } from "../platform/request.mjs";
9
+ import { BrowserState, getDefaultSessionStorage, getDefaultStorage } from "./state/state.mjs";
10
+ import { version } from "../primitives/version.mjs";
11
11
  const CONSENT_CHANGE_EVENT = '__posthog_browser_consent_change__';
12
12
  const DEFAULT_SHUTDOWN_TIMEOUT_MS = 30000;
13
13
  const normalizeHost = (host)=>{
@@ -1,3 +1,3 @@
1
1
  import type { RemoteConfig } from '@posthog/browser-common';
2
- import { type RequestRuntime } from './request';
2
+ import { type RequestRuntime } from '../platform/request';
3
3
  export declare const loadRemoteConfig: (runtime: RequestRuntime, signal: AbortSignal | undefined, canSend: () => boolean) => Promise<RemoteConfig | undefined>;
@@ -30,9 +30,9 @@ __webpack_require__.r(__webpack_exports__);
30
30
  __webpack_require__.d(__webpack_exports__, {
31
31
  loadRemoteConfig: ()=>loadRemoteConfig
32
32
  });
33
- const external_request_js_namespaceObject = require("./request.js");
33
+ const request_js_namespaceObject = require("../platform/request.js");
34
34
  const loadRemoteConfig = async (runtime, signal, canSend)=>{
35
- const response = await (0, external_request_js_namespaceObject.sendRequest)(runtime, `/array/${encodeURIComponent(runtime[1])}/config`, {
35
+ const response = await (0, request_js_namespaceObject.sendRequest)(runtime, `/array/${encodeURIComponent(runtime[1])}/config`, {
36
36
  target: 'assets'
37
37
  }, canSend, signal);
38
38
  const config = response.json;
@@ -1,4 +1,4 @@
1
- import { sendRequest } from "./request.mjs";
1
+ import { sendRequest } from "../platform/request.mjs";
2
2
  const loadRemoteConfig = async (runtime, signal, canSend)=>{
3
3
  const response = await sendRequest(runtime, `/array/${encodeURIComponent(runtime[1])}/config`, {
4
4
  target: 'assets'
@@ -1,2 +1,2 @@
1
- import type { BrowserNavigator } from './types';
1
+ import type { BrowserNavigator } from '../types';
2
2
  export declare const isLikelyBot: (navigator: BrowserNavigator | undefined, blockedUserAgents: readonly string[]) => boolean;
@@ -1,5 +1,5 @@
1
1
  import type { KeyValueStore } from '@posthog/browser-common';
2
- import type { StorageLike } from './types';
2
+ import type { StorageLike } from '../types';
3
3
  export declare const cloneJson: <T>(value: T) => T;
4
4
  interface StoreContext {
5
5
  values(): Record<string, unknown>;
@@ -1,5 +1,5 @@
1
1
  import type { KeyValueStore, SessionContext } from '@posthog/browser-common';
2
- import type { NewSessionReason, StorageLike } from './types';
2
+ import type { NewSessionReason, StorageLike } from '../types';
3
3
  export type ConsentState = 'implicit' | 'granted' | 'denied';
4
4
  interface PersistedSession {
5
5
  sessionId: string;
@@ -32,8 +32,10 @@ __webpack_require__.d(__webpack_exports__, {
32
32
  getDefaultSessionStorage: ()=>getDefaultSessionStorage,
33
33
  getDefaultStorage: ()=>getDefaultStorage
34
34
  });
35
- const external_id_js_namespaceObject = require("./id.js");
35
+ const id_js_namespaceObject = require("../../primitives/id.js");
36
36
  const external_key_value_store_js_namespaceObject = require("./key-value-store.js");
37
+ const FEATURE_FLAGS_EXTENSION = 'featureFlags';
38
+ const STORED_GROUP_PROPERTIES_KEY = '$stored_group_properties';
37
39
  const emptyRecord = ()=>Object.create(null);
38
40
  const isRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
39
41
  const readGroups = (value)=>{
@@ -98,7 +100,7 @@ const readExtensionData = (value)=>{
98
100
  return extensionData;
99
101
  };
100
102
  const createSession = (now, revision)=>({
101
- sessionId: (0, external_id_js_namespaceObject.createId)(),
103
+ sessionId: (0, id_js_namespaceObject.createId)(),
102
104
  sessionStartTimestamp: now,
103
105
  lastActivityTimestamp: now,
104
106
  revision
@@ -127,7 +129,7 @@ const nextRevision = (now, local, external)=>{
127
129
  const clock = readRevision(now) ?? '0';
128
130
  return compareRevisions(clock, incremented) > 0 ? clock : incremented;
129
131
  };
130
- const createInitialState = (deviceId = (0, external_id_js_namespaceObject.createId)(), anonymousId = deviceId)=>({
132
+ const createInitialState = (deviceId = (0, id_js_namespaceObject.createId)(), anonymousId = deviceId)=>({
131
133
  version: 1,
132
134
  deviceId,
133
135
  anonymousId,
@@ -294,6 +296,8 @@ class BrowserState {
294
296
  }
295
297
  resetGroups() {
296
298
  this._state.groups = emptyRecord();
299
+ const flagsData = this._state.extensionData[FEATURE_FLAGS_EXTENSION];
300
+ if (flagsData && STORED_GROUP_PROPERTIES_KEY in flagsData) delete flagsData[STORED_GROUP_PROPERTIES_KEY];
297
301
  this._save();
298
302
  }
299
303
  prepareSessionForEvent(now = Date.now()) {
@@ -363,7 +367,7 @@ class BrowserState {
363
367
  const now = Date.now();
364
368
  const safeNow = isTimestamp(now) ? now : 0;
365
369
  const resetRevision = nextRevision(safeNow, this._state, external);
366
- this._state = createInitialState(this._state.deviceId, (0, external_id_js_namespaceObject.createId)());
370
+ this._state = createInitialState(this._state.deviceId, (0, id_js_namespaceObject.createId)());
367
371
  this._state.sessionReset = resetRevision;
368
372
  this._lastActivityWriteTimestamp = 0;
369
373
  this._pendingSessionReason = 'reset';
@@ -438,7 +442,7 @@ class BrowserState {
438
442
  }
439
443
  _prepareWindow(rotated) {
440
444
  if (rotated || this._windowId) return {
441
- windowId: rotated ? (0, external_id_js_namespaceObject.createId)() : this._windowId,
445
+ windowId: rotated ? (0, id_js_namespaceObject.createId)() : this._windowId,
442
446
  storage: void 0,
443
447
  storageResolved: false
444
448
  };
@@ -458,7 +462,7 @@ class BrowserState {
458
462
  } catch {}
459
463
  const reusable = lastWindowId && (!primaryWindowExists || this._isReload()) ? lastWindowId : void 0;
460
464
  return {
461
- windowId: reusable ?? (0, external_id_js_namespaceObject.createId)(),
465
+ windowId: reusable ?? (0, id_js_namespaceObject.createId)(),
462
466
  storage,
463
467
  storageResolved: true
464
468
  };
@@ -1,5 +1,7 @@
1
- import { createId } from "./id.mjs";
1
+ import { createId } from "../../primitives/id.mjs";
2
2
  import { TabValues, createKeyValueStore } from "./key-value-store.mjs";
3
+ const FEATURE_FLAGS_EXTENSION = 'featureFlags';
4
+ const STORED_GROUP_PROPERTIES_KEY = '$stored_group_properties';
3
5
  const emptyRecord = ()=>Object.create(null);
4
6
  const isRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
5
7
  const readGroups = (value)=>{
@@ -260,6 +262,8 @@ class BrowserState {
260
262
  }
261
263
  resetGroups() {
262
264
  this._state.groups = emptyRecord();
265
+ const flagsData = this._state.extensionData[FEATURE_FLAGS_EXTENSION];
266
+ if (flagsData && STORED_GROUP_PROPERTIES_KEY in flagsData) delete flagsData[STORED_GROUP_PROPERTIES_KEY];
263
267
  this._save();
264
268
  }
265
269
  prepareSessionForEvent(now = Date.now()) {
@@ -1,9 +1,9 @@
1
- import type { FlagsConfiguration } from './flags-options';
2
- import type { ICoreCapabilities, BrowserExtensionAccess, BrowserExtension as Extension } from './browser-client';
3
- import type { LogsConfiguration } from './logs-options';
4
- import type { SurveysConfiguration } from './surveys-options';
5
- import type { AutocaptureConfiguration } from './autocapture-options';
6
- import type { AnalyticsConfiguration, AnalyticsOptions, AutomaticAnalyticsOptions, LoadStrategy, PersonProfileMode } from './analytics-options';
1
+ import type { FlagsConfiguration } from '../products/flags/flags-options';
2
+ import type { ICoreCapabilities, BrowserExtensionAccess, BrowserExtension as Extension } from './context/browser-client';
3
+ import type { LogsConfiguration } from '../products/logs/logs-options';
4
+ import type { SurveysConfiguration } from '../products/surveys/surveys-options';
5
+ import type { AutocaptureConfiguration } from '../products/autocapture/autocapture-options';
6
+ import type { AnalyticsConfiguration, AnalyticsOptions, AutomaticAnalyticsOptions, LoadStrategy, PersonProfileMode } from '../products/analytics/analytics-options';
7
7
  import type { ApiResponse, CaptureOptions, Disposable, Listener, RemoteConfig, SendRequestInit, SessionContext } from '@posthog/browser-common';
8
8
  export interface StorageLike {
9
9
  getItem(key: string): string | null;
@@ -1,5 +1,5 @@
1
1
  import type { ApiResponse, SendRequestInit } from '@posthog/browser-common';
2
- import type { BrowserFetch, BrowserNavigator } from './types';
2
+ import type { BrowserFetch, BrowserNavigator } from '../core/types';
3
3
  export declare const createFailedResponse: (error?: unknown) => ApiResponse;
4
4
  export type RequestRuntime = [
5
5
  hosts: {
@@ -27,7 +27,7 @@ var __webpack_require__ = {};
27
27
  })();
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
- const version = "0.4.0";
30
+ const version = "0.4.2";
31
31
  __webpack_require__.d(__webpack_exports__, {}, {
32
32
  version: version
33
33
  });
@@ -0,0 +1,2 @@
1
+ const version = "0.4.2";
2
+ export { version };
@@ -1,3 +1,3 @@
1
- import type { CaptureSummary } from './types';
1
+ import type { CaptureSummary } from '../../../core/types';
2
2
  export declare const EMPTY_CAPTURE_SUMMARY: CaptureSummary;
3
3
  export declare const captureFailure: (cause: unknown, summary?: CaptureSummary) => CaptureSummary;