@posthog/browser 0.1.0 → 0.2.0
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 +29 -23
- package/README.md +66 -30
- package/dist/analytics-api.d.ts +26 -0
- package/dist/analytics-api.js +18 -0
- package/dist/analytics-api.mjs +1 -0
- package/dist/analytics-buffer.d.ts +3 -3
- package/dist/analytics-buffer.js +2 -161
- package/dist/analytics-buffer.mjs +2 -161
- package/dist/analytics-extension.d.ts +76 -0
- package/dist/analytics-extension.js +589 -0
- package/dist/analytics-extension.mjs +551 -0
- package/dist/analytics-internal.d.ts +32 -18
- package/dist/analytics-options.d.ts +7 -2
- package/dist/analytics-options.js +38 -1
- package/dist/analytics-options.mjs +17 -1
- package/dist/analytics.d.ts +4 -3
- package/dist/autocapture.d.ts +2 -2
- package/dist/autocapture.js +21 -10
- package/dist/autocapture.mjs +21 -10
- package/dist/automatic-analytics.d.ts +2 -2
- package/dist/browser-client.d.ts +44 -4
- package/dist/capture-properties.d.ts +9 -0
- package/dist/capture-properties.js +68 -0
- package/dist/capture-properties.mjs +30 -0
- package/dist/capture-v1.js +7 -19
- package/dist/capture-v1.mjs +1 -13
- package/dist/core.d.ts +7 -5
- package/dist/extensions/registry.d.ts +42 -7
- package/dist/extensions/registry.js +194 -37
- package/dist/extensions/registry.mjs +194 -37
- package/dist/flags-token.d.ts +4 -4
- package/dist/flags.js +16 -2
- package/dist/flags.mjs +16 -2
- package/dist/immutable.d.ts +1 -0
- package/dist/immutable.js +46 -0
- package/dist/immutable.mjs +8 -0
- package/dist/index.d.ts +7 -5
- package/dist/index.js +3 -67
- package/dist/index.mjs +3 -67
- package/dist/lane.js +1 -1
- package/dist/lane.mjs +1 -1
- package/dist/logs-internal.d.ts +2 -2
- package/dist/logs.js +5 -2
- package/dist/logs.mjs +5 -2
- package/dist/person-processing.d.ts +11 -0
- package/dist/person-processing.js +84 -0
- package/dist/person-processing.mjs +37 -0
- package/dist/posthog.d.ts +4 -3
- package/dist/posthog.js +155 -349
- package/dist/posthog.mjs +155 -349
- package/dist/rate-limiter.d.ts +5 -0
- package/dist/rate-limiter.js +14 -8
- package/dist/rate-limiter.mjs +14 -8
- package/dist/root-composition.d.ts +11 -0
- package/dist/root-composition.js +138 -0
- package/dist/root-composition.mjs +100 -0
- package/dist/state.d.ts +1 -0
- package/dist/state.js +4 -0
- package/dist/state.mjs +4 -0
- package/dist/surveys-extension.js +11 -6
- package/dist/surveys-extension.mjs +11 -6
- package/dist/surveys-internal.d.ts +3 -2
- package/dist/surveys.d.ts +0 -1
- package/dist/surveys.js +1 -4
- package/dist/surveys.mjs +1 -4
- package/dist/types.d.ts +13 -19
- package/dist/utf8.d.ts +1 -0
- package/dist/utf8.js +52 -0
- package/dist/utf8.mjs +14 -0
- package/dist/version.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
const deepFreeze = (value)=>{
|
|
31
|
+
if (value && 'object' == typeof value) {
|
|
32
|
+
Object.values(value).forEach(deepFreeze);
|
|
33
|
+
Object.freeze(value);
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
};
|
|
37
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
38
|
+
deepFreeze: deepFreeze
|
|
39
|
+
});
|
|
40
|
+
exports.deepFreeze = __webpack_exports__.deepFreeze;
|
|
41
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
42
|
+
"deepFreeze"
|
|
43
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
44
|
+
Object.defineProperty(exports, '__esModule', {
|
|
45
|
+
value: true
|
|
46
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
/** Creates a browser
|
|
3
|
-
export declare const createPostHog: (options: PostHogOptions) => Promise<
|
|
1
|
+
import type { IPostHog, PostHogOptions } from './types';
|
|
2
|
+
/** Creates a browser host with on-demand first-party analytics acquisition. */
|
|
3
|
+
export declare const createPostHog: (options: PostHogOptions) => Promise<IPostHog>;
|
|
4
|
+
export type { IAnalytics } from './analytics-api';
|
|
4
5
|
export { version } from './version';
|
|
5
6
|
export { FeatureFlagsExtension, type FeatureFlags } from './flags-token';
|
|
6
|
-
export type {
|
|
7
|
-
export type { AnalyticsConfiguration, AnalyticsOptions, ApiResponse, AutomaticAnalyticsOptions, BrowserFetch, BrowserNavigator, CaptureOptions, CaptureOutcome, CaptureOutcomeStatus, CaptureSummary, CorePostHogOptions, Disposable, Extension, LoadStrategy, NewSessionInfo, NewSessionReason,
|
|
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';
|
|
8
9
|
export type { FlagsOptions, FlagsConfiguration, FlagsCallback, FeatureFlagResult, FeatureFlagsReloadResult, } from './flags-options';
|
|
9
10
|
export type { LogsOptions, LogsConfiguration, CaptureLogOptions } from './logs-options';
|
|
10
11
|
export type { SurveysOptions, SurveysConfiguration, Survey, SurveyCallback, DisplaySurveyOptions, SurveyRenderReason, } from './surveys-options';
|
|
11
12
|
export type { AutocaptureOptions, AutocaptureConfiguration, RageclickOptions } from './autocapture-options';
|
|
13
|
+
export type { PersonProfileMode } from './analytics-options';
|
package/dist/index.js
CHANGED
|
@@ -32,77 +32,13 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
32
32
|
createPostHog: ()=>createPostHog,
|
|
33
33
|
version: ()=>external_version_js_namespaceObject.version
|
|
34
34
|
});
|
|
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
35
|
const external_posthog_js_namespaceObject = require("./posthog.js");
|
|
39
|
-
const
|
|
40
|
-
const external_automatic_analytics_js_namespaceObject = require("./automatic-analytics.js");
|
|
36
|
+
const external_root_composition_js_namespaceObject = require("./root-composition.js");
|
|
41
37
|
const external_version_js_namespaceObject = require("./version.js");
|
|
42
38
|
const external_flags_token_js_namespaceObject = require("./flags-token.js");
|
|
43
39
|
const createPostHog = async (options)=>{
|
|
44
|
-
const extensions =
|
|
45
|
-
|
|
46
|
-
];
|
|
47
|
-
const loadingErrors = [];
|
|
48
|
-
const install = (label, matches, load, prepend = false)=>{
|
|
49
|
-
if (extensions.some(matches)) return;
|
|
50
|
-
const add = (extension)=>{
|
|
51
|
-
if (prepend) extensions.unshift(extension);
|
|
52
|
-
else extensions.push(extension);
|
|
53
|
-
};
|
|
54
|
-
const failed = (error)=>{
|
|
55
|
-
if (error) loadingErrors.push([
|
|
56
|
-
label,
|
|
57
|
-
error
|
|
58
|
-
]);
|
|
59
|
-
};
|
|
60
|
-
try {
|
|
61
|
-
const extension = load();
|
|
62
|
-
if (extension instanceof Promise) return extension.then(add).catch(failed);
|
|
63
|
-
if (extension) add(extension);
|
|
64
|
-
} catch (error) {
|
|
65
|
-
failed(error);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
install('analytics', external_analytics_internal_js_namespaceObject.isAnalyticsExtension, ()=>{
|
|
69
|
-
let configuration = {
|
|
70
|
-
load: 'lazy'
|
|
71
|
-
};
|
|
72
|
-
try {
|
|
73
|
-
configuration = options?.analytics ?? configuration;
|
|
74
|
-
} catch {}
|
|
75
|
-
return false === configuration ? void 0 : (0, external_automatic_analytics_js_namespaceObject.analytics)(configuration);
|
|
76
|
-
}, true);
|
|
77
|
-
const flagsLoading = install('flags', (extension)=>'featureFlags' === extension.name, ()=>{
|
|
78
|
-
const configuration = options?.flags;
|
|
79
|
-
if (false === configuration) return;
|
|
80
|
-
const snapshot = configuration && JSON.parse(JSON.stringify(configuration));
|
|
81
|
-
return import("./flags.js").then(({ flags })=>flags(snapshot));
|
|
82
|
-
});
|
|
83
|
-
if (flagsLoading) await flagsLoading;
|
|
84
|
-
const logsLoading = install('logs', (extension)=>'logs' === extension.name, ()=>{
|
|
85
|
-
const configuration = options?.logs;
|
|
86
|
-
if (false === configuration) return;
|
|
87
|
-
const snapshot = (0, external_logs_options_js_namespaceObject.snapshotLogsOptions)(configuration);
|
|
88
|
-
return import("./logs.js").then(({ logs })=>logs(snapshot));
|
|
89
|
-
});
|
|
90
|
-
if (logsLoading) await logsLoading;
|
|
91
|
-
const surveysLoading = install('surveys', (extension)=>'surveys' === extension.name, ()=>{
|
|
92
|
-
const configuration = options?.surveys;
|
|
93
|
-
if (false === configuration) return;
|
|
94
|
-
const snapshot = (0, external_surveys_options_js_namespaceObject.snapshotSurveysOptions)(configuration);
|
|
95
|
-
return import("./automatic-surveys.js").then(({ surveys })=>surveys(snapshot));
|
|
96
|
-
});
|
|
97
|
-
if (surveysLoading) await surveysLoading;
|
|
98
|
-
const autocaptureLoading = install('autocapture', (extension)=>'autocapture' === extension.name, ()=>{
|
|
99
|
-
const configuration = options?.autocapture;
|
|
100
|
-
if (false === configuration) return;
|
|
101
|
-
const snapshot = (0, external_autocapture_options_js_namespaceObject.snapshotAutocaptureOptions)(configuration);
|
|
102
|
-
return import("./autocapture.js").then(({ autocapture })=>autocapture(snapshot));
|
|
103
|
-
});
|
|
104
|
-
if (autocaptureLoading) await autocaptureLoading;
|
|
105
|
-
const client = await (0, external_posthog_js_namespaceObject.createPostHogCore)(options, extensions);
|
|
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);
|
|
106
42
|
for (const [label, error] of loadingErrors.reverse())client.logger.error(`Automatic ${label} loading failed`, error);
|
|
107
43
|
return client;
|
|
108
44
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,72 +1,8 @@
|
|
|
1
|
-
import { snapshotAutocaptureOptions } from "./autocapture-options.mjs";
|
|
2
|
-
import { snapshotSurveysOptions } from "./surveys-options.mjs";
|
|
3
|
-
import { snapshotLogsOptions } from "./logs-options.mjs";
|
|
4
1
|
import { createPostHogCore } from "./posthog.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { analytics } from "./automatic-analytics.mjs";
|
|
2
|
+
import { createProductComposition } from "./root-composition.mjs";
|
|
7
3
|
const createPostHog = async (options)=>{
|
|
8
|
-
const extensions =
|
|
9
|
-
|
|
10
|
-
];
|
|
11
|
-
const loadingErrors = [];
|
|
12
|
-
const install = (label, matches, load, prepend = false)=>{
|
|
13
|
-
if (extensions.some(matches)) return;
|
|
14
|
-
const add = (extension)=>{
|
|
15
|
-
if (prepend) extensions.unshift(extension);
|
|
16
|
-
else extensions.push(extension);
|
|
17
|
-
};
|
|
18
|
-
const failed = (error)=>{
|
|
19
|
-
if (error) loadingErrors.push([
|
|
20
|
-
label,
|
|
21
|
-
error
|
|
22
|
-
]);
|
|
23
|
-
};
|
|
24
|
-
try {
|
|
25
|
-
const extension = load();
|
|
26
|
-
if (extension instanceof Promise) return extension.then(add).catch(failed);
|
|
27
|
-
if (extension) add(extension);
|
|
28
|
-
} catch (error) {
|
|
29
|
-
failed(error);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
install('analytics', isAnalyticsExtension, ()=>{
|
|
33
|
-
let configuration = {
|
|
34
|
-
load: 'lazy'
|
|
35
|
-
};
|
|
36
|
-
try {
|
|
37
|
-
configuration = options?.analytics ?? configuration;
|
|
38
|
-
} catch {}
|
|
39
|
-
return false === configuration ? void 0 : analytics(configuration);
|
|
40
|
-
}, true);
|
|
41
|
-
const flagsLoading = install('flags', (extension)=>'featureFlags' === extension.name, ()=>{
|
|
42
|
-
const configuration = options?.flags;
|
|
43
|
-
if (false === configuration) return;
|
|
44
|
-
const snapshot = configuration && JSON.parse(JSON.stringify(configuration));
|
|
45
|
-
return import("./flags.mjs").then(({ flags })=>flags(snapshot));
|
|
46
|
-
});
|
|
47
|
-
if (flagsLoading) await flagsLoading;
|
|
48
|
-
const logsLoading = install('logs', (extension)=>'logs' === extension.name, ()=>{
|
|
49
|
-
const configuration = options?.logs;
|
|
50
|
-
if (false === configuration) return;
|
|
51
|
-
const snapshot = snapshotLogsOptions(configuration);
|
|
52
|
-
return import("./logs.mjs").then(({ logs })=>logs(snapshot));
|
|
53
|
-
});
|
|
54
|
-
if (logsLoading) await logsLoading;
|
|
55
|
-
const surveysLoading = install('surveys', (extension)=>'surveys' === extension.name, ()=>{
|
|
56
|
-
const configuration = options?.surveys;
|
|
57
|
-
if (false === configuration) return;
|
|
58
|
-
const snapshot = snapshotSurveysOptions(configuration);
|
|
59
|
-
return import("./automatic-surveys.mjs").then(({ surveys })=>surveys(snapshot));
|
|
60
|
-
});
|
|
61
|
-
if (surveysLoading) await surveysLoading;
|
|
62
|
-
const autocaptureLoading = install('autocapture', (extension)=>'autocapture' === extension.name, ()=>{
|
|
63
|
-
const configuration = options?.autocapture;
|
|
64
|
-
if (false === configuration) return;
|
|
65
|
-
const snapshot = snapshotAutocaptureOptions(configuration);
|
|
66
|
-
return import("./autocapture.mjs").then(({ autocapture })=>autocapture(snapshot));
|
|
67
|
-
});
|
|
68
|
-
if (autocaptureLoading) await autocaptureLoading;
|
|
69
|
-
const client = await createPostHogCore(options, extensions);
|
|
4
|
+
const { extensions, loaders, automatic, loadingErrors } = createProductComposition(options);
|
|
5
|
+
const client = await createPostHogCore(options, extensions, loaders, automatic);
|
|
70
6
|
for (const [label, error] of loadingErrors.reverse())client.logger.error(`Automatic ${label} loading failed`, error);
|
|
71
7
|
return client;
|
|
72
8
|
};
|
package/dist/lane.js
CHANGED
|
@@ -295,7 +295,7 @@ class Lane {
|
|
|
295
295
|
}
|
|
296
296
|
let retryEntries = [];
|
|
297
297
|
try {
|
|
298
|
-
const retry = result
|
|
298
|
+
const retry = result ? result.retry : void 0;
|
|
299
299
|
if (Array.isArray(retry)) {
|
|
300
300
|
const selected = [];
|
|
301
301
|
const length = Math.min(retry.length, entries.length);
|
package/dist/lane.mjs
CHANGED
|
@@ -266,7 +266,7 @@ class Lane {
|
|
|
266
266
|
}
|
|
267
267
|
let retryEntries = [];
|
|
268
268
|
try {
|
|
269
|
-
const retry = result
|
|
269
|
+
const retry = result ? result.retry : void 0;
|
|
270
270
|
if (Array.isArray(retry)) {
|
|
271
271
|
const selected = [];
|
|
272
272
|
const length = Math.min(retry.length, entries.length);
|
package/dist/logs-internal.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BrowserExtension } from './browser-client';
|
|
2
2
|
import type { CaptureLogOptions } from '@posthog/types';
|
|
3
|
-
export interface LogsExtension extends
|
|
3
|
+
export interface LogsExtension extends BrowserExtension {
|
|
4
4
|
captureLog(options: CaptureLogOptions): void;
|
|
5
5
|
flush(): Promise<void>;
|
|
6
6
|
reset(): void;
|
package/dist/logs.js
CHANGED
|
@@ -91,15 +91,18 @@ const logs = (options = {})=>{
|
|
|
91
91
|
};
|
|
92
92
|
return {
|
|
93
93
|
name: 'logs',
|
|
94
|
+
bindings: {
|
|
95
|
+
logs: shared
|
|
96
|
+
},
|
|
94
97
|
setup: async (value)=>{
|
|
95
|
-
environment.client = value;
|
|
98
|
+
environment.client = value.sharedClient;
|
|
96
99
|
try {
|
|
97
100
|
environment.browserWindow = globalThis.window;
|
|
98
101
|
} catch {}
|
|
99
102
|
subscriptions.push(value.onReset(()=>shared.reset()), value.onConsentChange(({ current })=>{
|
|
100
103
|
if ('denied' === current) shared.reset();
|
|
101
104
|
}));
|
|
102
|
-
await shared.setup(value);
|
|
105
|
+
await shared.setup(value.sharedClient);
|
|
103
106
|
if (environment.disposed) return;
|
|
104
107
|
environment.browserWindow?.addEventListener('pagehide', pagehide);
|
|
105
108
|
},
|
package/dist/logs.mjs
CHANGED
|
@@ -59,15 +59,18 @@ const logs = (options = {})=>{
|
|
|
59
59
|
};
|
|
60
60
|
return {
|
|
61
61
|
name: 'logs',
|
|
62
|
+
bindings: {
|
|
63
|
+
logs: shared
|
|
64
|
+
},
|
|
62
65
|
setup: async (value)=>{
|
|
63
|
-
environment.client = value;
|
|
66
|
+
environment.client = value.sharedClient;
|
|
64
67
|
try {
|
|
65
68
|
environment.browserWindow = globalThis.window;
|
|
66
69
|
} catch {}
|
|
67
70
|
subscriptions.push(value.onReset(()=>shared.reset()), value.onConsentChange(({ current })=>{
|
|
68
71
|
if ('denied' === current) shared.reset();
|
|
69
72
|
}));
|
|
70
|
-
await shared.setup(value);
|
|
73
|
+
await shared.setup(value.sharedClient);
|
|
71
74
|
if (environment.disposed) return;
|
|
72
75
|
environment.browserWindow?.addEventListener('pagehide', pagehide);
|
|
73
76
|
},
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PersonProfileMode } from './analytics-options';
|
|
2
|
+
export declare const snapshotPersonProfileMode: (read: () => unknown) => PersonProfileMode;
|
|
3
|
+
export declare const shouldProcessPerson: (mode: PersonProfileMode, identified: boolean, grouped: boolean, explicitlyEnabled: boolean) => boolean;
|
|
4
|
+
export interface PersonProperties {
|
|
5
|
+
readonly signature: string;
|
|
6
|
+
readonly set: Record<string, unknown>;
|
|
7
|
+
readonly setOnce: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
/** Snapshot caller-controlled values before local flag state or analytics state consumes them. */
|
|
10
|
+
export declare const snapshotPersonProperties: (distinctId: string, set: Record<string, unknown> | undefined, setOnce: Record<string, unknown> | undefined) => PersonProperties | undefined;
|
|
11
|
+
export declare const personPropertyNames: (value: string | readonly string[]) => string[];
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
const snapshotPersonProfileMode = (read)=>{
|
|
31
|
+
try {
|
|
32
|
+
const value = read();
|
|
33
|
+
if ('always' === value || 'never' === value) return value;
|
|
34
|
+
} catch {}
|
|
35
|
+
return 'identified_only';
|
|
36
|
+
};
|
|
37
|
+
const shouldProcessPerson = (mode, identified, grouped, explicitlyEnabled)=>'always' === mode || 'never' !== mode && (identified || grouped || explicitlyEnabled);
|
|
38
|
+
const isRecord = (value)=>null !== value && 'object' == typeof value && !Array.isArray(value);
|
|
39
|
+
const snapshotPersonProperties = (distinctId, set, setOnce)=>{
|
|
40
|
+
try {
|
|
41
|
+
const signature = JSON.stringify([
|
|
42
|
+
distinctId,
|
|
43
|
+
set ?? {},
|
|
44
|
+
setOnce ?? {}
|
|
45
|
+
]);
|
|
46
|
+
const values = JSON.parse(signature);
|
|
47
|
+
if (!Array.isArray(values) || !isRecord(values[1]) || !isRecord(values[2])) return;
|
|
48
|
+
return {
|
|
49
|
+
signature,
|
|
50
|
+
set: values[1],
|
|
51
|
+
setOnce: values[2]
|
|
52
|
+
};
|
|
53
|
+
} catch {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const personPropertyNames = (value)=>{
|
|
58
|
+
try {
|
|
59
|
+
return (Array.isArray(value) ? value : [
|
|
60
|
+
value
|
|
61
|
+
]).filter((name)=>'string' == typeof name && name.length > 0);
|
|
62
|
+
} catch {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
67
|
+
personPropertyNames: personPropertyNames,
|
|
68
|
+
shouldProcessPerson: shouldProcessPerson,
|
|
69
|
+
snapshotPersonProfileMode: snapshotPersonProfileMode,
|
|
70
|
+
snapshotPersonProperties: snapshotPersonProperties
|
|
71
|
+
});
|
|
72
|
+
exports.personPropertyNames = __webpack_exports__.personPropertyNames;
|
|
73
|
+
exports.shouldProcessPerson = __webpack_exports__.shouldProcessPerson;
|
|
74
|
+
exports.snapshotPersonProfileMode = __webpack_exports__.snapshotPersonProfileMode;
|
|
75
|
+
exports.snapshotPersonProperties = __webpack_exports__.snapshotPersonProperties;
|
|
76
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
77
|
+
"personPropertyNames",
|
|
78
|
+
"shouldProcessPerson",
|
|
79
|
+
"snapshotPersonProfileMode",
|
|
80
|
+
"snapshotPersonProperties"
|
|
81
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
82
|
+
Object.defineProperty(exports, '__esModule', {
|
|
83
|
+
value: true
|
|
84
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const snapshotPersonProfileMode = (read)=>{
|
|
2
|
+
try {
|
|
3
|
+
const value = read();
|
|
4
|
+
if ('always' === value || 'never' === value) return value;
|
|
5
|
+
} catch {}
|
|
6
|
+
return 'identified_only';
|
|
7
|
+
};
|
|
8
|
+
const shouldProcessPerson = (mode, identified, grouped, explicitlyEnabled)=>'always' === mode || 'never' !== mode && (identified || grouped || explicitlyEnabled);
|
|
9
|
+
const isRecord = (value)=>null !== value && 'object' == typeof value && !Array.isArray(value);
|
|
10
|
+
const snapshotPersonProperties = (distinctId, set, setOnce)=>{
|
|
11
|
+
try {
|
|
12
|
+
const signature = JSON.stringify([
|
|
13
|
+
distinctId,
|
|
14
|
+
set ?? {},
|
|
15
|
+
setOnce ?? {}
|
|
16
|
+
]);
|
|
17
|
+
const values = JSON.parse(signature);
|
|
18
|
+
if (!Array.isArray(values) || !isRecord(values[1]) || !isRecord(values[2])) return;
|
|
19
|
+
return {
|
|
20
|
+
signature,
|
|
21
|
+
set: values[1],
|
|
22
|
+
setOnce: values[2]
|
|
23
|
+
};
|
|
24
|
+
} catch {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const personPropertyNames = (value)=>{
|
|
29
|
+
try {
|
|
30
|
+
return (Array.isArray(value) ? value : [
|
|
31
|
+
value
|
|
32
|
+
]).filter((name)=>'string' == typeof name && name.length > 0);
|
|
33
|
+
} catch {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export { personPropertyNames, shouldProcessPerson, snapshotPersonProfileMode, snapshotPersonProperties };
|
package/dist/posthog.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type
|
|
3
|
-
|
|
1
|
+
import type { IPostHogInternal, BrowserExtension as Extension } from './browser-client';
|
|
2
|
+
import { type AutomaticExtension, type ExtensionLoader } from './extensions/registry';
|
|
3
|
+
import type { CorePostHogOptions, IPostHog } from './types';
|
|
4
|
+
export declare const createPostHogCore: (options: CorePostHogOptions, configured?: readonly Extension[], automaticLoaders?: Readonly<Record<string, ExtensionLoader<IPostHogInternal>>>, automatic?: readonly AutomaticExtension<IPostHogInternal>[]) => Promise<IPostHog>;
|