@posthog/browser 0.4.0 → 0.4.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.
- package/ARCHITECTURE.md +17 -1
- package/dist/{core.d.ts → composition/npm/core.d.ts} +7 -7
- package/dist/{core.js → composition/npm/core.js} +6 -6
- package/dist/composition/npm/core.mjs +5 -0
- package/dist/{index.d.ts → composition/npm/index.d.ts} +11 -11
- package/dist/{index.js → composition/npm/index.js} +6 -6
- package/dist/{index.mjs → composition/npm/index.mjs} +3 -3
- package/dist/{root-composition.d.ts → composition/npm/root-composition.d.ts} +3 -3
- package/dist/{root-composition.js → composition/npm/root-composition.js} +13 -13
- package/dist/{root-composition.mjs → composition/npm/root-composition.mjs} +9 -9
- package/dist/{browser-client.d.ts → core/context/browser-client.d.ts} +7 -7
- package/dist/{posthog.d.ts → core/posthog.d.ts} +1 -1
- package/dist/{posthog.js → core/posthog.js} +15 -15
- package/dist/{posthog.mjs → core/posthog.mjs} +7 -7
- package/dist/{remote-config.d.ts → core/remote-config.d.ts} +1 -1
- package/dist/{remote-config.js → core/remote-config.js} +2 -2
- package/dist/{remote-config.mjs → core/remote-config.mjs} +1 -1
- package/dist/{bot-filter.d.ts → core/state/bot-filter.d.ts} +1 -1
- package/dist/{key-value-store.d.ts → core/state/key-value-store.d.ts} +1 -1
- package/dist/{state.d.ts → core/state/state.d.ts} +1 -1
- package/dist/{state.js → core/state/state.js} +6 -6
- package/dist/{state.mjs → core/state/state.mjs} +1 -1
- package/dist/{types.d.ts → core/types.d.ts} +6 -6
- package/dist/{request.d.ts → platform/request.d.ts} +1 -1
- package/dist/{version.js → primitives/version.js} +1 -1
- package/dist/primitives/version.mjs +2 -0
- package/dist/{capture-summary.d.ts → products/analytics/admission/capture-summary.d.ts} +1 -1
- package/dist/{capture-summary.js → products/analytics/admission/capture-summary.js} +2 -2
- package/dist/{capture-summary.mjs → products/analytics/admission/capture-summary.mjs} +1 -1
- package/dist/{analytics-api.d.ts → products/analytics/analytics-api.d.ts} +2 -2
- package/dist/{analytics-extension.d.ts → products/analytics/analytics-extension.d.ts} +2 -2
- package/dist/{analytics-extension.js → products/analytics/analytics-extension.js} +35 -35
- package/dist/{analytics-extension.mjs → products/analytics/analytics-extension.mjs} +11 -11
- package/dist/{analytics-internal.d.ts → products/analytics/analytics-internal.d.ts} +7 -7
- package/dist/{analytics.js → products/analytics/analytics.js} +2 -2
- package/dist/{analytics.mjs → products/analytics/analytics.mjs} +1 -1
- package/dist/{automatic-analytics.js → products/analytics/automatic-analytics.js} +1 -1
- package/dist/{automatic-analytics.mjs → products/analytics/automatic-analytics.mjs} +1 -1
- package/dist/{analytics-delivery.d.ts → products/analytics/delivery/analytics-delivery.d.ts} +1 -1
- package/dist/{analytics-delivery.js → products/analytics/delivery/analytics-delivery.js} +2 -2
- package/dist/{analytics-delivery.mjs → products/analytics/delivery/analytics-delivery.mjs} +1 -1
- package/dist/{capture-v1.d.ts → products/analytics/delivery/capture-v1.d.ts} +2 -2
- package/dist/{capture-v1.js → products/analytics/delivery/capture-v1.js} +13 -13
- package/dist/{capture-v1.mjs → products/analytics/delivery/capture-v1.mjs} +4 -4
- package/dist/{lane.d.ts → products/analytics/delivery/lane.d.ts} +1 -1
- package/dist/{person-processing.d.ts → products/analytics/properties/person-processing.d.ts} +1 -1
- package/dist/{autocapture.d.ts → products/autocapture/autocapture.d.ts} +1 -1
- package/dist/{flags-token.d.ts → products/flags/flags-token.d.ts} +1 -1
- package/dist/{logs-internal.d.ts → products/logs/logs-internal.d.ts} +1 -1
- package/dist/{surveys-internal.d.ts → products/surveys/surveys-internal.d.ts} +1 -1
- package/package.json +25 -25
- package/dist/core.mjs +0 -5
- package/dist/version.mjs +0 -2
- /package/dist/{browser-client.js → core/context/browser-client.js} +0 -0
- /package/dist/{browser-client.mjs → core/context/browser-client.mjs} +0 -0
- /package/dist/{extensions → core/extensions}/registry.d.ts +0 -0
- /package/dist/{extensions → core/extensions}/registry.js +0 -0
- /package/dist/{extensions → core/extensions}/registry.mjs +0 -0
- /package/dist/{bot-filter.js → core/state/bot-filter.js} +0 -0
- /package/dist/{bot-filter.mjs → core/state/bot-filter.mjs} +0 -0
- /package/dist/{key-value-store.js → core/state/key-value-store.js} +0 -0
- /package/dist/{key-value-store.mjs → core/state/key-value-store.mjs} +0 -0
- /package/dist/{types.js → core/types.js} +0 -0
- /package/dist/{types.mjs → core/types.mjs} +0 -0
- /package/dist/{logger.d.ts → platform/logger.d.ts} +0 -0
- /package/dist/{logger.js → platform/logger.js} +0 -0
- /package/dist/{logger.mjs → platform/logger.mjs} +0 -0
- /package/dist/{request.js → platform/request.js} +0 -0
- /package/dist/{request.mjs → platform/request.mjs} +0 -0
- /package/dist/{id.d.ts → primitives/id.d.ts} +0 -0
- /package/dist/{id.js → primitives/id.js} +0 -0
- /package/dist/{id.mjs → primitives/id.mjs} +0 -0
- /package/dist/{immutable.d.ts → primitives/immutable.d.ts} +0 -0
- /package/dist/{immutable.js → primitives/immutable.js} +0 -0
- /package/dist/{immutable.mjs → primitives/immutable.mjs} +0 -0
- /package/dist/{named-error.d.ts → primitives/named-error.d.ts} +0 -0
- /package/dist/{named-error.js → primitives/named-error.js} +0 -0
- /package/dist/{named-error.mjs → primitives/named-error.mjs} +0 -0
- /package/dist/{utf8.d.ts → primitives/utf8.d.ts} +0 -0
- /package/dist/{utf8.js → primitives/utf8.js} +0 -0
- /package/dist/{utf8.mjs → primitives/utf8.mjs} +0 -0
- /package/dist/{version.d.ts → primitives/version.d.ts} +0 -0
- /package/dist/{capture-properties.d.ts → products/analytics/admission/capture-properties.d.ts} +0 -0
- /package/dist/{capture-properties.js → products/analytics/admission/capture-properties.js} +0 -0
- /package/dist/{capture-properties.mjs → products/analytics/admission/capture-properties.mjs} +0 -0
- /package/dist/{event-buffer.d.ts → products/analytics/admission/event-buffer.d.ts} +0 -0
- /package/dist/{event-buffer.js → products/analytics/admission/event-buffer.js} +0 -0
- /package/dist/{event-buffer.mjs → products/analytics/admission/event-buffer.mjs} +0 -0
- /package/dist/{rate-limiter.d.ts → products/analytics/admission/rate-limiter.d.ts} +0 -0
- /package/dist/{rate-limiter.js → products/analytics/admission/rate-limiter.js} +0 -0
- /package/dist/{rate-limiter.mjs → products/analytics/admission/rate-limiter.mjs} +0 -0
- /package/dist/{analytics-api.js → products/analytics/analytics-api.js} +0 -0
- /package/dist/{analytics-api.mjs → products/analytics/analytics-api.mjs} +0 -0
- /package/dist/{analytics-buffer.d.ts → products/analytics/analytics-buffer.d.ts} +0 -0
- /package/dist/{analytics-buffer.js → products/analytics/analytics-buffer.js} +0 -0
- /package/dist/{analytics-buffer.mjs → products/analytics/analytics-buffer.mjs} +0 -0
- /package/dist/{analytics-internal.js → products/analytics/analytics-internal.js} +0 -0
- /package/dist/{analytics-internal.mjs → products/analytics/analytics-internal.mjs} +0 -0
- /package/dist/{analytics-options.d.ts → products/analytics/analytics-options.d.ts} +0 -0
- /package/dist/{analytics-options.js → products/analytics/analytics-options.js} +0 -0
- /package/dist/{analytics-options.mjs → products/analytics/analytics-options.mjs} +0 -0
- /package/dist/{analytics.d.ts → products/analytics/analytics.d.ts} +0 -0
- /package/dist/{automatic-analytics.d.ts → products/analytics/automatic-analytics.d.ts} +0 -0
- /package/dist/{lane.js → products/analytics/delivery/lane.js} +0 -0
- /package/dist/{lane.mjs → products/analytics/delivery/lane.mjs} +0 -0
- /package/dist/{analytics-properties.d.ts → products/analytics/properties/analytics-properties.d.ts} +0 -0
- /package/dist/{analytics-properties.js → products/analytics/properties/analytics-properties.js} +0 -0
- /package/dist/{analytics-properties.mjs → products/analytics/properties/analytics-properties.mjs} +0 -0
- /package/dist/{analytics-session-properties.d.ts → products/analytics/properties/analytics-session-properties.d.ts} +0 -0
- /package/dist/{analytics-session-properties.js → products/analytics/properties/analytics-session-properties.js} +0 -0
- /package/dist/{analytics-session-properties.mjs → products/analytics/properties/analytics-session-properties.mjs} +0 -0
- /package/dist/{person-processing.js → products/analytics/properties/person-processing.js} +0 -0
- /package/dist/{person-processing.mjs → products/analytics/properties/person-processing.mjs} +0 -0
- /package/dist/{autocapture-options.d.ts → products/autocapture/autocapture-options.d.ts} +0 -0
- /package/dist/{autocapture-options.js → products/autocapture/autocapture-options.js} +0 -0
- /package/dist/{autocapture-options.mjs → products/autocapture/autocapture-options.mjs} +0 -0
- /package/dist/{autocapture.js → products/autocapture/autocapture.js} +0 -0
- /package/dist/{autocapture.mjs → products/autocapture/autocapture.mjs} +0 -0
- /package/dist/{flags-internal.d.ts → products/flags/flags-internal.d.ts} +0 -0
- /package/dist/{flags-internal.js → products/flags/flags-internal.js} +0 -0
- /package/dist/{flags-internal.mjs → products/flags/flags-internal.mjs} +0 -0
- /package/dist/{flags-options.d.ts → products/flags/flags-options.d.ts} +0 -0
- /package/dist/{flags-options.js → products/flags/flags-options.js} +0 -0
- /package/dist/{flags-options.mjs → products/flags/flags-options.mjs} +0 -0
- /package/dist/{flags-token.js → products/flags/flags-token.js} +0 -0
- /package/dist/{flags-token.mjs → products/flags/flags-token.mjs} +0 -0
- /package/dist/{flags.d.ts → products/flags/flags.d.ts} +0 -0
- /package/dist/{flags.js → products/flags/flags.js} +0 -0
- /package/dist/{flags.mjs → products/flags/flags.mjs} +0 -0
- /package/dist/{logs-internal.js → products/logs/logs-internal.js} +0 -0
- /package/dist/{logs-internal.mjs → products/logs/logs-internal.mjs} +0 -0
- /package/dist/{logs-options.d.ts → products/logs/logs-options.d.ts} +0 -0
- /package/dist/{logs-options.js → products/logs/logs-options.js} +0 -0
- /package/dist/{logs-options.mjs → products/logs/logs-options.mjs} +0 -0
- /package/dist/{logs.d.ts → products/logs/logs.d.ts} +0 -0
- /package/dist/{logs.js → products/logs/logs.js} +0 -0
- /package/dist/{logs.mjs → products/logs/logs.mjs} +0 -0
- /package/dist/{automatic-surveys.d.ts → products/surveys/automatic-surveys.d.ts} +0 -0
- /package/dist/{automatic-surveys.js → products/surveys/automatic-surveys.js} +0 -0
- /package/dist/{automatic-surveys.mjs → products/surveys/automatic-surveys.mjs} +0 -0
- /package/dist/{surveys-extension.d.ts → products/surveys/surveys-extension.d.ts} +0 -0
- /package/dist/{surveys-extension.js → products/surveys/surveys-extension.js} +0 -0
- /package/dist/{surveys-extension.mjs → products/surveys/surveys-extension.mjs} +0 -0
- /package/dist/{surveys-internal.js → products/surveys/surveys-internal.js} +0 -0
- /package/dist/{surveys-internal.mjs → products/surveys/surveys-internal.mjs} +0 -0
- /package/dist/{surveys-options.d.ts → products/surveys/surveys-options.d.ts} +0 -0
- /package/dist/{surveys-options.js → products/surveys/surveys-options.js} +0 -0
- /package/dist/{surveys-options.mjs → products/surveys/surveys-options.mjs} +0 -0
- /package/dist/{surveys.d.ts → products/surveys/surveys.d.ts} +0 -0
- /package/dist/{surveys.js → products/surveys/surveys.js} +0 -0
- /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 `
|
|
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 '
|
|
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 '
|
|
5
|
-
export { FeatureFlagsExtension, type FeatureFlags } from '
|
|
6
|
-
export type { IPostHogInternal, BrowserExtension, IdentifyInfo, GroupInfo } from '
|
|
7
|
-
export type { IAnalytics } from '
|
|
8
|
-
export type { AnalyticsOptions, ApiResponse, BrowserFetch, BrowserNavigator, CaptureOptions, CaptureOutcome, CaptureOutcomeStatus, CaptureSummary, CorePostHogOptions, Disposable, Extension, NewSessionInfo, NewSessionReason, IPostHog, RemoteConfig, SendRequestInit, SessionContext, StorageLike, } from '
|
|
9
|
-
export type { PersonProfileMode } from '
|
|
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: ()=>
|
|
31
|
+
FeatureFlagsExtension: ()=>flags_token_js_namespaceObject.FeatureFlagsExtension,
|
|
32
32
|
createPostHog: ()=>createPostHog,
|
|
33
|
-
version: ()=>
|
|
33
|
+
version: ()=>version_js_namespaceObject.version
|
|
34
34
|
});
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const createPostHog = async (options)=>(0,
|
|
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 '
|
|
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 '
|
|
5
|
-
export { version } from '
|
|
6
|
-
export { FeatureFlagsExtension, type FeatureFlags } from '
|
|
7
|
-
export type { IPostHogInternal, BrowserExtension, IdentifyInfo, GroupInfo } from '
|
|
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 '
|
|
9
|
-
export type { FlagsOptions, FlagsConfiguration, FlagsCallback, FeatureFlagResult, FeatureFlagsReloadResult, } from '
|
|
10
|
-
export type { LogsOptions, LogsConfiguration, CaptureLogOptions } from '
|
|
11
|
-
export type { SurveysOptions, SurveysConfiguration, Survey, SurveyCallback, DisplaySurveyOptions, SurveyRenderReason, } from '
|
|
12
|
-
export type { AutocaptureOptions, AutocaptureConfiguration, RageclickOptions } from '
|
|
13
|
-
export type { PersonProfileMode } from '
|
|
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: ()=>
|
|
31
|
+
FeatureFlagsExtension: ()=>flags_token_js_namespaceObject.FeatureFlagsExtension,
|
|
32
32
|
createPostHog: ()=>createPostHog,
|
|
33
|
-
version: ()=>
|
|
33
|
+
version: ()=>version_js_namespaceObject.version
|
|
34
34
|
});
|
|
35
|
-
const
|
|
35
|
+
const posthog_js_namespaceObject = require("../../core/posthog.js");
|
|
36
36
|
const external_root_composition_js_namespaceObject = require("./root-composition.js");
|
|
37
|
-
const
|
|
38
|
-
const
|
|
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,
|
|
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 "
|
|
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 "
|
|
10
|
-
export { FeatureFlagsExtension } from "
|
|
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 '
|
|
2
|
-
import type { PostHogOptions } from '
|
|
3
|
-
import type { AutomaticExtension, ExtensionLoader } from '
|
|
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
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
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,
|
|
71
|
-
if (false !== configuration) composition.loaders.analytics = ()=>import("
|
|
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("
|
|
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,
|
|
85
|
+
const snapshot = (0, logs_options_js_namespaceObject.snapshotLogsOptions)(configuration);
|
|
86
86
|
return {
|
|
87
|
-
load: ()=>import("
|
|
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,
|
|
94
|
+
const snapshot = (0, surveys_options_js_namespaceObject.snapshotSurveysOptions)(configuration);
|
|
95
95
|
return {
|
|
96
|
-
load: ()=>import("
|
|
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,
|
|
106
|
+
const snapshot = (0, autocapture_options_js_namespaceObject.snapshotAutocaptureOptions)(configuration);
|
|
107
107
|
return {
|
|
108
|
-
load: ()=>import("
|
|
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 "
|
|
4
|
-
import { snapshotSurveysOptions } from "
|
|
5
|
-
import { snapshotLogsOptions } from "
|
|
6
|
-
import { snapshotAutomaticAnalyticsOptions } from "
|
|
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("
|
|
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("
|
|
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("
|
|
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("
|
|
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("
|
|
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 '
|
|
3
|
-
import type { IAnalyticsExtension } from '
|
|
4
|
-
import type { FeatureFlags } from '
|
|
5
|
-
import type { FlagsExtension } from '
|
|
6
|
-
import type { LogsExtension } from '
|
|
7
|
-
import type { SurveysExtension } from '
|
|
8
|
-
import type { ConsentState } from '
|
|
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
|
|
36
|
-
const
|
|
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
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
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:
|
|
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,
|
|
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,
|
|
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,
|
|
114
|
-
const requestedStorage = false === options.storage ? void 0 : options.storage ?? (0,
|
|
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
|
|
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,
|
|
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,
|
|
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 "
|
|
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 "
|
|
7
|
-
import { createLogger } from "
|
|
8
|
-
import { sendRequest } from "
|
|
9
|
-
import { BrowserState, getDefaultSessionStorage, getDefaultStorage } from "./state.mjs";
|
|
10
|
-
import { version } from "
|
|
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 '
|
|
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
|
|
33
|
+
const request_js_namespaceObject = require("../platform/request.js");
|
|
34
34
|
const loadRemoteConfig = async (runtime, signal, canSend)=>{
|
|
35
|
-
const response = await (0,
|
|
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 "
|
|
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 '
|
|
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 '
|
|
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 '
|
|
2
|
+
import type { NewSessionReason, StorageLike } from '../types';
|
|
3
3
|
export type ConsentState = 'implicit' | 'granted' | 'denied';
|
|
4
4
|
interface PersistedSession {
|
|
5
5
|
sessionId: string;
|
|
@@ -32,7 +32,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
32
32
|
getDefaultSessionStorage: ()=>getDefaultSessionStorage,
|
|
33
33
|
getDefaultStorage: ()=>getDefaultStorage
|
|
34
34
|
});
|
|
35
|
-
const
|
|
35
|
+
const id_js_namespaceObject = require("../../primitives/id.js");
|
|
36
36
|
const external_key_value_store_js_namespaceObject = require("./key-value-store.js");
|
|
37
37
|
const emptyRecord = ()=>Object.create(null);
|
|
38
38
|
const isRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
|
|
@@ -98,7 +98,7 @@ const readExtensionData = (value)=>{
|
|
|
98
98
|
return extensionData;
|
|
99
99
|
};
|
|
100
100
|
const createSession = (now, revision)=>({
|
|
101
|
-
sessionId: (0,
|
|
101
|
+
sessionId: (0, id_js_namespaceObject.createId)(),
|
|
102
102
|
sessionStartTimestamp: now,
|
|
103
103
|
lastActivityTimestamp: now,
|
|
104
104
|
revision
|
|
@@ -127,7 +127,7 @@ const nextRevision = (now, local, external)=>{
|
|
|
127
127
|
const clock = readRevision(now) ?? '0';
|
|
128
128
|
return compareRevisions(clock, incremented) > 0 ? clock : incremented;
|
|
129
129
|
};
|
|
130
|
-
const createInitialState = (deviceId = (0,
|
|
130
|
+
const createInitialState = (deviceId = (0, id_js_namespaceObject.createId)(), anonymousId = deviceId)=>({
|
|
131
131
|
version: 1,
|
|
132
132
|
deviceId,
|
|
133
133
|
anonymousId,
|
|
@@ -363,7 +363,7 @@ class BrowserState {
|
|
|
363
363
|
const now = Date.now();
|
|
364
364
|
const safeNow = isTimestamp(now) ? now : 0;
|
|
365
365
|
const resetRevision = nextRevision(safeNow, this._state, external);
|
|
366
|
-
this._state = createInitialState(this._state.deviceId, (0,
|
|
366
|
+
this._state = createInitialState(this._state.deviceId, (0, id_js_namespaceObject.createId)());
|
|
367
367
|
this._state.sessionReset = resetRevision;
|
|
368
368
|
this._lastActivityWriteTimestamp = 0;
|
|
369
369
|
this._pendingSessionReason = 'reset';
|
|
@@ -438,7 +438,7 @@ class BrowserState {
|
|
|
438
438
|
}
|
|
439
439
|
_prepareWindow(rotated) {
|
|
440
440
|
if (rotated || this._windowId) return {
|
|
441
|
-
windowId: rotated ? (0,
|
|
441
|
+
windowId: rotated ? (0, id_js_namespaceObject.createId)() : this._windowId,
|
|
442
442
|
storage: void 0,
|
|
443
443
|
storageResolved: false
|
|
444
444
|
};
|
|
@@ -458,7 +458,7 @@ class BrowserState {
|
|
|
458
458
|
} catch {}
|
|
459
459
|
const reusable = lastWindowId && (!primaryWindowExists || this._isReload()) ? lastWindowId : void 0;
|
|
460
460
|
return {
|
|
461
|
-
windowId: reusable ?? (0,
|
|
461
|
+
windowId: reusable ?? (0, id_js_namespaceObject.createId)(),
|
|
462
462
|
storage,
|
|
463
463
|
storageResolved: true
|
|
464
464
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createId } from "
|
|
1
|
+
import { createId } from "../../primitives/id.mjs";
|
|
2
2
|
import { TabValues, createKeyValueStore } from "./key-value-store.mjs";
|
|
3
3
|
const emptyRecord = ()=>Object.create(null);
|
|
4
4
|
const isRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { FlagsConfiguration } from '
|
|
2
|
-
import type { ICoreCapabilities, BrowserExtensionAccess, BrowserExtension as Extension } from './browser-client';
|
|
3
|
-
import type { LogsConfiguration } from '
|
|
4
|
-
import type { SurveysConfiguration } from '
|
|
5
|
-
import type { AutocaptureConfiguration } from '
|
|
6
|
-
import type { AnalyticsConfiguration, AnalyticsOptions, AutomaticAnalyticsOptions, LoadStrategy, PersonProfileMode } from '
|
|
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 '
|
|
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: {
|
|
@@ -31,7 +31,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
31
31
|
EMPTY_CAPTURE_SUMMARY: ()=>EMPTY_CAPTURE_SUMMARY,
|
|
32
32
|
captureFailure: ()=>captureFailure
|
|
33
33
|
});
|
|
34
|
-
const
|
|
34
|
+
const named_error_js_namespaceObject = require("../../../primitives/named-error.js");
|
|
35
35
|
const EMPTY_CAPTURE_SUMMARY = Object.freeze({
|
|
36
36
|
submitted: 0,
|
|
37
37
|
notPersisted: 0,
|
|
@@ -42,7 +42,7 @@ const captureFailure = (cause, summary = EMPTY_CAPTURE_SUMMARY)=>{
|
|
|
42
42
|
const error = new Error('Immediate capture failed', {
|
|
43
43
|
cause
|
|
44
44
|
});
|
|
45
|
-
(0,
|
|
45
|
+
(0, named_error_js_namespaceObject.defineErrorName)(error, 'PostHogCaptureError');
|
|
46
46
|
try {
|
|
47
47
|
if (cause instanceof Error) error.message = String(cause.message);
|
|
48
48
|
} catch {}
|