@posthog/browser 0.4.2 → 0.6.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 +36 -48
- package/README.md +97 -69
- package/dist/composition/npm/core.d.ts +3 -4
- package/dist/composition/npm/core.js +2 -1
- package/dist/composition/npm/core.mjs +2 -1
- package/dist/composition/npm/index.d.ts +4 -5
- package/dist/composition/npm/index.js +2 -1
- package/dist/composition/npm/index.mjs +2 -1
- package/dist/composition/npm/root-composition.d.ts +4 -4
- package/dist/composition/npm/root-composition.js +0 -16
- package/dist/composition/npm/root-composition.mjs +0 -16
- package/dist/core/context/browser-client.d.ts +4 -35
- package/dist/core/extensions/registry.d.ts +15 -36
- package/dist/core/extensions/registry.js +67 -198
- package/dist/core/extensions/registry.mjs +67 -198
- package/dist/core/posthog.d.ts +3 -2
- package/dist/core/posthog.js +190 -173
- package/dist/core/posthog.mjs +191 -174
- package/dist/core/state/state.d.ts +33 -3
- package/dist/core/state/state.js +122 -27
- package/dist/core/state/state.mjs +107 -27
- package/dist/core/types.d.ts +134 -14
- package/dist/persistence/cookie.d.ts +19 -0
- package/dist/persistence/cookie.js +273 -0
- package/dist/persistence/cookie.mjs +235 -0
- package/dist/platform/logger.d.ts +5 -1
- package/dist/platform/logger.js +3 -3
- package/dist/platform/logger.mjs +3 -3
- package/dist/primitives/id.d.ts +5 -0
- package/dist/primitives/id.js +10 -2
- package/dist/primitives/id.mjs +6 -1
- package/dist/primitives/version.js +1 -1
- package/dist/primitives/version.mjs +1 -1
- package/dist/products/analytics/analytics-core.d.ts +89 -0
- package/dist/products/analytics/analytics-core.js +563 -0
- package/dist/products/analytics/analytics-core.mjs +516 -0
- package/dist/products/analytics/analytics-internal.d.ts +16 -37
- package/dist/products/analytics/analytics-internal.js +2 -10
- package/dist/products/analytics/analytics-internal.mjs +1 -3
- package/dist/products/analytics/analytics-options.d.ts +0 -9
- package/dist/products/analytics/analytics-options.js +1 -38
- package/dist/products/analytics/analytics-options.mjs +1 -17
- package/dist/products/analytics/delivery/analytics-delivery.js +1 -1
- package/dist/products/analytics/delivery/analytics-delivery.mjs +1 -1
- package/dist/products/analytics/delivery/lane.d.ts +8 -1
- package/dist/products/analytics/delivery/lane.js +16 -4
- package/dist/products/analytics/delivery/lane.mjs +16 -4
- package/dist/products/analytics/groups.d.ts +8 -0
- package/dist/products/analytics/groups.js +84 -0
- package/dist/products/analytics/groups.mjs +40 -0
- package/dist/products/analytics/person.d.ts +11 -0
- package/dist/products/analytics/person.js +91 -0
- package/dist/products/analytics/person.mjs +41 -0
- package/dist/products/analytics/properties/analytics-properties.d.ts +1 -0
- package/dist/products/analytics/properties/analytics-properties.js +3 -0
- package/dist/products/analytics/properties/analytics-properties.mjs +1 -1
- package/dist/products/autocapture/autocapture.js +2 -6
- package/dist/products/autocapture/autocapture.mjs +2 -6
- package/dist/products/flags/flags-internal.d.ts +4 -2
- package/dist/products/flags/flags-options.d.ts +16 -2
- package/dist/products/flags/flags-token.d.ts +31 -4
- package/dist/products/flags/flags.d.ts +1 -1
- package/dist/products/flags/flags.js +112 -11
- package/dist/products/flags/flags.mjs +112 -11
- package/dist/products/logs/logs.js +2 -5
- package/dist/products/logs/logs.mjs +2 -5
- package/dist/products/surveys/surveys-extension.js +78 -46
- package/dist/products/surveys/surveys-extension.mjs +80 -48
- package/dist/products/surveys/surveys-internal.d.ts +6 -0
- package/package.json +7 -7
- package/dist/products/analytics/analytics-api.d.ts +0 -32
- package/dist/products/analytics/analytics-api.js +0 -18
- package/dist/products/analytics/analytics-api.mjs +0 -1
- package/dist/products/analytics/analytics-buffer.d.ts +0 -4
- package/dist/products/analytics/analytics-buffer.js +0 -41
- package/dist/products/analytics/analytics-buffer.mjs +0 -3
- package/dist/products/analytics/analytics-extension.d.ts +0 -87
- package/dist/products/analytics/analytics-extension.js +0 -649
- package/dist/products/analytics/analytics-extension.mjs +0 -611
- package/dist/products/analytics/analytics.d.ts +0 -6
- package/dist/products/analytics/analytics.js +0 -42
- package/dist/products/analytics/analytics.mjs +0 -4
- package/dist/products/analytics/automatic-analytics.d.ts +0 -3
- package/dist/products/analytics/automatic-analytics.js +0 -44
- package/dist/products/analytics/automatic-analytics.mjs +0 -6
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { DEFAULT_DISPLAY_SURVEY_OPTIONS } from "@posthog/browser-common/utils/survey-utils";
|
|
1
|
+
import { PostHogSurveys, SurveyEventName, SurveyEventProperties } from "@posthog/browser-common/surveys";
|
|
2
|
+
import { DEFAULT_DISPLAY_SURVEY_OPTIONS, setSurveySeenOnLocalStorage } from "@posthog/browser-common/utils/survey-utils";
|
|
4
3
|
import { SurveyEventReceiver } from "@posthog/browser-common/survey-event-receiver";
|
|
5
4
|
import { getTargetingUrl } from "@posthog/browser-common/utils/url-targeting-utils";
|
|
5
|
+
import { analyticsOf } from "../analytics/analytics-core.mjs";
|
|
6
6
|
import { snapshotSurveysOptions } from "./surveys-options.mjs";
|
|
7
|
+
const MATCHING_CONDITION_EVENTS = [
|
|
8
|
+
'$pageview',
|
|
9
|
+
SurveyEventName.SHOWN,
|
|
10
|
+
SurveyEventName.DISMISSED,
|
|
11
|
+
SurveyEventName.SENT
|
|
12
|
+
];
|
|
7
13
|
const createSurveys = (options, load)=>{
|
|
8
14
|
const config = snapshotSurveysOptions(options);
|
|
9
15
|
let elementSelectors = new Set();
|
|
@@ -20,6 +26,7 @@ const createSurveys = (options, load)=>{
|
|
|
20
26
|
let loading;
|
|
21
27
|
let remoteSubscription;
|
|
22
28
|
let resetSubscription;
|
|
29
|
+
let seenSubscription;
|
|
23
30
|
const getFlagsContext = ()=>client?.featureFlags?.getSurveyContext?.();
|
|
24
31
|
const reset = ()=>{
|
|
25
32
|
shared.reset();
|
|
@@ -52,7 +59,36 @@ const createSurveys = (options, load)=>{
|
|
|
52
59
|
if (!disposed) callback(error);
|
|
53
60
|
});
|
|
54
61
|
}
|
|
55
|
-
})
|
|
62
|
+
}),
|
|
63
|
+
onMatchingConditionsChanged: (callback)=>{
|
|
64
|
+
const subscriptions = [];
|
|
65
|
+
if (client) subscriptions.push(client.onEvent(({ event })=>{
|
|
66
|
+
if (MATCHING_CONDITION_EVENTS.includes(event)) callback();
|
|
67
|
+
}));
|
|
68
|
+
const onShown = ()=>callback();
|
|
69
|
+
if ("u" > typeof window) window.addEventListener('PHSurveyShown', onShown);
|
|
70
|
+
let listening = false;
|
|
71
|
+
let stopped = false;
|
|
72
|
+
const subscribeToFlags = (flags)=>{
|
|
73
|
+
subscriptions.push(flags.onFeatureFlags(()=>{
|
|
74
|
+
if (listening) callback();
|
|
75
|
+
}));
|
|
76
|
+
listening = true;
|
|
77
|
+
};
|
|
78
|
+
const flags = client?.featureFlags;
|
|
79
|
+
if (flags) subscribeToFlags(flags);
|
|
80
|
+
else if (client) client.resolveExtension('featureFlags').then((installed)=>{
|
|
81
|
+
if (stopped || !installed) return;
|
|
82
|
+
subscribeToFlags(installed);
|
|
83
|
+
callback();
|
|
84
|
+
}, ()=>{});
|
|
85
|
+
return ()=>{
|
|
86
|
+
stopped = true;
|
|
87
|
+
listening = false;
|
|
88
|
+
subscriptions.splice(0).forEach((subscription)=>subscription.dispose());
|
|
89
|
+
if ("u" > typeof window) window.removeEventListener('PHSurveyShown', onShown);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
56
92
|
};
|
|
57
93
|
const shared = new class extends PostHogSurveys {
|
|
58
94
|
_createEventReceiver(value, onActivationChanged) {
|
|
@@ -109,36 +145,54 @@ const createSurveys = (options, load)=>{
|
|
|
109
145
|
}
|
|
110
146
|
});
|
|
111
147
|
};
|
|
148
|
+
const subscribe = (callback, listen)=>{
|
|
149
|
+
let active = true;
|
|
150
|
+
const notify = deliver((surveys, context)=>{
|
|
151
|
+
if (active) callback(surveys, context);
|
|
152
|
+
});
|
|
153
|
+
const unsubscribe = listen(notify);
|
|
154
|
+
if (!client || "u" < typeof document) notify([], {
|
|
155
|
+
isLoaded: false,
|
|
156
|
+
error: 'Survey renderer unavailable'
|
|
157
|
+
});
|
|
158
|
+
else if (!disposed) {
|
|
159
|
+
manual = true;
|
|
160
|
+
try {
|
|
161
|
+
shared.loadIfEnabled();
|
|
162
|
+
} catch (error) {
|
|
163
|
+
client.logger.error('Survey renderer loading failed', error);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
dispose: ()=>{
|
|
168
|
+
active = false;
|
|
169
|
+
unsubscribe();
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
};
|
|
112
173
|
let teardownSubscription;
|
|
113
174
|
const pagehide = ()=>{
|
|
114
175
|
if (!teardownSubscription?.deliveryAvailable) shared.handlePageUnload();
|
|
115
176
|
};
|
|
116
177
|
return {
|
|
117
178
|
name: 'surveys',
|
|
118
|
-
bindings: {
|
|
119
|
-
surveys: shared
|
|
120
|
-
},
|
|
121
179
|
setup: async (value)=>{
|
|
122
180
|
client = value;
|
|
123
|
-
await value.resolveExtension('analytics');
|
|
124
|
-
if (disposed) return;
|
|
125
181
|
await value.kv.initialize();
|
|
126
182
|
if (disposed) return;
|
|
127
183
|
resetSubscription = value.onReset(reset);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
Object.defineProperty(renderClient, 'kv', {
|
|
138
|
-
value: renderKv
|
|
184
|
+
seenSubscription = value.onEvent(({ event, properties })=>{
|
|
185
|
+
if (event !== SurveyEventName.DISMISSED && event !== SurveyEventName.SENT) return;
|
|
186
|
+
const id = properties[SurveyEventProperties.SURVEY_ID];
|
|
187
|
+
const iteration = properties[SurveyEventProperties.SURVEY_ITERATION];
|
|
188
|
+
if ('string' != typeof id) return;
|
|
189
|
+
setSurveySeenOnLocalStorage({
|
|
190
|
+
id,
|
|
191
|
+
current_iteration: 'number' == typeof iteration ? iteration : null
|
|
192
|
+
});
|
|
139
193
|
});
|
|
140
194
|
runtimeHost = {
|
|
141
|
-
client:
|
|
195
|
+
client: value,
|
|
142
196
|
get config () {
|
|
143
197
|
return source.get();
|
|
144
198
|
},
|
|
@@ -151,9 +205,9 @@ const createSurveys = (options, load)=>{
|
|
|
151
205
|
if (remoteEnabled && !disposed) manager?.startAutomaticDisplay?.();
|
|
152
206
|
}
|
|
153
207
|
});
|
|
154
|
-
await shared.setup(value
|
|
208
|
+
await shared.setup(value);
|
|
155
209
|
if (disposed) return void shared.dispose();
|
|
156
|
-
teardownSubscription =
|
|
210
|
+
teardownSubscription = analyticsOf(value)?.onBeforeTeardown(()=>shared.handlePageUnload());
|
|
157
211
|
if ("u" > typeof window) window.addEventListener('pagehide', pagehide);
|
|
158
212
|
},
|
|
159
213
|
getSurveys: (callback, forceReload)=>run(callback, (notify)=>shared.getSurveys(notify, forceReload)),
|
|
@@ -185,31 +239,8 @@ const createSurveys = (options, load)=>{
|
|
|
185
239
|
reject(error);
|
|
186
240
|
});
|
|
187
241
|
}),
|
|
188
|
-
onSurveysLoaded: (callback)=>
|
|
189
|
-
|
|
190
|
-
const notify = deliver((surveys, context)=>{
|
|
191
|
-
if (active) callback(surveys, context);
|
|
192
|
-
});
|
|
193
|
-
const unsubscribe = shared.onSurveysLoaded(notify);
|
|
194
|
-
if (!client || "u" < typeof document) notify([], {
|
|
195
|
-
isLoaded: false,
|
|
196
|
-
error: 'Survey renderer unavailable'
|
|
197
|
-
});
|
|
198
|
-
else if (!disposed) {
|
|
199
|
-
manual = true;
|
|
200
|
-
try {
|
|
201
|
-
shared.loadIfEnabled();
|
|
202
|
-
} catch (error) {
|
|
203
|
-
client.logger.error('Survey renderer loading failed', error);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
dispose: ()=>{
|
|
208
|
-
active = false;
|
|
209
|
-
unsubscribe();
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
},
|
|
242
|
+
onSurveysLoaded: (callback)=>subscribe(callback, (notify)=>shared.onSurveysLoaded(notify)),
|
|
243
|
+
onActiveMatchingSurveysChanged: (callback)=>subscribe(callback, (notify)=>shared.onActiveMatchingSurveysChanged(notify)),
|
|
213
244
|
getElementSelectors: ()=>new Set(elementSelectors),
|
|
214
245
|
cancelPendingSurvey: (id)=>{
|
|
215
246
|
if (!disposed) shared.cancelPendingSurvey(id);
|
|
@@ -230,6 +261,7 @@ const createSurveys = (options, load)=>{
|
|
|
230
261
|
});
|
|
231
262
|
remoteSubscription?.dispose();
|
|
232
263
|
resetSubscription?.dispose();
|
|
264
|
+
seenSubscription?.dispose();
|
|
233
265
|
if ("u" > typeof window) window.removeEventListener('pagehide', pagehide);
|
|
234
266
|
teardownSubscription?.dispose();
|
|
235
267
|
shared.dispose();
|
|
@@ -8,6 +8,12 @@ export interface SurveysExtension extends BrowserExtension {
|
|
|
8
8
|
displaySurvey(id: string, options?: DisplaySurveyOptions): void;
|
|
9
9
|
canRenderSurvey(id: string, forceReload?: boolean): Promise<SurveyRenderReason>;
|
|
10
10
|
onSurveysLoaded(callback: SurveyCallback): Disposable;
|
|
11
|
+
/**
|
|
12
|
+
* Observe the set of active matching surveys. Delivers the current set once loaded, then changes after
|
|
13
|
+
* event and action triggers, captured pageviews, survey display and responses, feature-flag updates,
|
|
14
|
+
* definition refreshes and reset. Unchanged results are not delivered again.
|
|
15
|
+
*/
|
|
16
|
+
onActiveMatchingSurveysChanged(callback: SurveyCallback): Disposable;
|
|
11
17
|
cancelPendingSurvey(id: string): void;
|
|
12
18
|
reset(): void;
|
|
13
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/browser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "A small, extension-based PostHog client for modern browsers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,11 +33,6 @@
|
|
|
33
33
|
"require": "./dist/products/flags/flags.js",
|
|
34
34
|
"import": "./dist/products/flags/flags.mjs"
|
|
35
35
|
},
|
|
36
|
-
"./analytics": {
|
|
37
|
-
"types": "./dist/products/analytics/analytics.d.ts",
|
|
38
|
-
"require": "./dist/products/analytics/analytics.js",
|
|
39
|
-
"import": "./dist/products/analytics/analytics.mjs"
|
|
40
|
-
},
|
|
41
36
|
"./logs": {
|
|
42
37
|
"types": "./dist/products/logs/logs.d.ts",
|
|
43
38
|
"import": "./dist/products/logs/logs.mjs",
|
|
@@ -52,10 +47,15 @@
|
|
|
52
47
|
"types": "./dist/products/autocapture/autocapture.d.ts",
|
|
53
48
|
"require": "./dist/products/autocapture/autocapture.js",
|
|
54
49
|
"import": "./dist/products/autocapture/autocapture.mjs"
|
|
50
|
+
},
|
|
51
|
+
"./persistence/cookie": {
|
|
52
|
+
"types": "./dist/persistence/cookie.d.ts",
|
|
53
|
+
"require": "./dist/persistence/cookie.js",
|
|
54
|
+
"import": "./dist/persistence/cookie.mjs"
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@posthog/browser-common": "^0.
|
|
58
|
+
"@posthog/browser-common": "^0.14.0",
|
|
59
59
|
"@posthog/types": "^1.427.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { CaptureOptions, CapturedEventInfo, Disposable, Listener } from '@posthog/browser-common';
|
|
2
|
-
import type { BrowserExtension } from '../../core/context/browser-client';
|
|
3
|
-
import type { CaptureSummary } from '../../core/types';
|
|
4
|
-
/** Application-facing analytics operations on one installed product instance. */
|
|
5
|
-
export interface IAnalytics extends BrowserExtension {
|
|
6
|
-
readonly isRateLimited: boolean;
|
|
7
|
-
readonly onEvent: Listener<CapturedEventInfo>;
|
|
8
|
-
/**
|
|
9
|
-
* Synchronous capture. False signals rate-limit backpressure; true does not acknowledge admission or delivery.
|
|
10
|
-
* Consent, filtering, invalid properties and queue limits can suppress an event while returning true.
|
|
11
|
-
*/
|
|
12
|
-
capture(event: string, properties?: Record<string, unknown> | null, options?: CaptureOptions): boolean;
|
|
13
|
-
captureImmediate(event: string, properties?: Record<string, unknown> | null, options?: CaptureOptions): Promise<CaptureSummary>;
|
|
14
|
-
identify(distinctId: string, set?: Record<string, unknown>, setOnce?: Record<string, unknown>): Promise<void>;
|
|
15
|
-
alias(alias: string): void;
|
|
16
|
-
group(type: string, key: string, properties?: Record<string, unknown>): Promise<void>;
|
|
17
|
-
groupIdentify(type: string, key: string | number, properties?: Record<string, unknown>, options?: CaptureOptions): void;
|
|
18
|
-
resetGroups(): void;
|
|
19
|
-
reset(): void;
|
|
20
|
-
createPersonProfile(): void;
|
|
21
|
-
setPersonProperties(set?: Record<string, unknown>, setOnce?: Record<string, unknown>): void;
|
|
22
|
-
unsetPersonProperties(names: string | readonly string[]): void;
|
|
23
|
-
setInternalOrTestUser(): void;
|
|
24
|
-
register(properties: Record<string, unknown>): void;
|
|
25
|
-
registerOnce(properties: Record<string, unknown>, defaultValue?: unknown): void;
|
|
26
|
-
registerForSession(properties: Record<string, unknown>): void;
|
|
27
|
-
unregisterForSession(property: string): void;
|
|
28
|
-
unregister(property: string): void;
|
|
29
|
-
getProperty(property: string): unknown;
|
|
30
|
-
registerDynamicEventProperties(producer: () => Record<string, unknown>): Disposable;
|
|
31
|
-
flush(): Promise<void>;
|
|
32
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.r = (exports1)=>{
|
|
5
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
-
value: 'Module'
|
|
7
|
-
});
|
|
8
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
-
value: true
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
})();
|
|
13
|
-
var __webpack_exports__ = {};
|
|
14
|
-
__webpack_require__.r(__webpack_exports__);
|
|
15
|
-
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
|
-
Object.defineProperty(exports, '__esModule', {
|
|
17
|
-
value: true
|
|
18
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { AnalyticsDeliveryFactory, IAnalyticsExtension } from './analytics-internal';
|
|
2
|
-
import type { AutomaticAnalyticsOptions } from './analytics-options';
|
|
3
|
-
/** Creates one analytics instance, with delivery supplied statically or loaded later. */
|
|
4
|
-
export declare const createAnalyticsExtension: (options?: AutomaticAnalyticsOptions, load?: () => Promise<AnalyticsDeliveryFactory>, deliveryFactory?: AnalyticsDeliveryFactory) => IAnalyticsExtension;
|
|
@@ -1,41 +0,0 @@
|
|
|
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
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
createAnalyticsExtension: ()=>createAnalyticsExtension
|
|
32
|
-
});
|
|
33
|
-
const external_analytics_extension_js_namespaceObject = require("./analytics-extension.js");
|
|
34
|
-
const createAnalyticsExtension = (options = {}, load, deliveryFactory)=>new external_analytics_extension_js_namespaceObject.Analytics(options, load, deliveryFactory);
|
|
35
|
-
exports.createAnalyticsExtension = __webpack_exports__.createAnalyticsExtension;
|
|
36
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
37
|
-
"createAnalyticsExtension"
|
|
38
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
39
|
-
Object.defineProperty(exports, '__esModule', {
|
|
40
|
-
value: true
|
|
41
|
-
});
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import type { CaptureOptions, CapturedEventInfo, Disposable, Listener } from '@posthog/browser-common';
|
|
2
|
-
import { type AnalyticsCaptureHost, type AnalyticsDeliveryFactory, type IAnalyticsExtension, type CaptureHost } from './analytics-internal';
|
|
3
|
-
import type { IPostHogInternal } from '../../core/context/browser-client';
|
|
4
|
-
import type { AutomaticAnalyticsOptions } from './analytics-options';
|
|
5
|
-
import type { CaptureSummary } from '../../core/types';
|
|
6
|
-
/** One product instance owns analytics operations, admission, buffering and delivery coordination. */
|
|
7
|
-
export declare class Analytics implements IAnalyticsExtension {
|
|
8
|
-
readonly name: import("@posthog/browser-common").ExtensionToken<IAnalyticsExtension>;
|
|
9
|
-
readonly isRateLimited: boolean;
|
|
10
|
-
private _host;
|
|
11
|
-
private _client;
|
|
12
|
-
private _deliveryHost;
|
|
13
|
-
private _driver;
|
|
14
|
-
private _loading;
|
|
15
|
-
private _disposed;
|
|
16
|
-
private _isTearingDown;
|
|
17
|
-
private _failures;
|
|
18
|
-
private _kv;
|
|
19
|
-
private _registeredProperties;
|
|
20
|
-
private _sessionProperties;
|
|
21
|
-
private _lastPersonProperties;
|
|
22
|
-
private readonly _personProfiles;
|
|
23
|
-
private readonly _rateLimiter;
|
|
24
|
-
private readonly _dynamicEventProperties;
|
|
25
|
-
private readonly _disposalWaiters;
|
|
26
|
-
private readonly _teardownCallbacks;
|
|
27
|
-
private readonly _buffer;
|
|
28
|
-
private readonly _scheduling;
|
|
29
|
-
private readonly _eager;
|
|
30
|
-
private readonly _load;
|
|
31
|
-
private readonly _deliveryFactory;
|
|
32
|
-
constructor(options?: AutomaticAnalyticsOptions, load?: () => Promise<AnalyticsDeliveryFactory>, deliveryFactory?: AnalyticsDeliveryFactory);
|
|
33
|
-
readonly bindCaptureHost: (host: AnalyticsCaptureHost) => void;
|
|
34
|
-
readonly setup: (value: IPostHogInternal) => void;
|
|
35
|
-
readonly initialize: (host: CaptureHost) => void;
|
|
36
|
-
readonly start: () => Promise<void>;
|
|
37
|
-
readonly onBeforeTeardown: NonNullable<IAnalyticsExtension['onBeforeTeardown']>;
|
|
38
|
-
readonly flush: IAnalyticsExtension['flush'];
|
|
39
|
-
readonly purge: () => void;
|
|
40
|
-
readonly dispose: () => Promise<void> | undefined;
|
|
41
|
-
private readonly _beforeTeardown;
|
|
42
|
-
private _ensureDelivery;
|
|
43
|
-
private _deliverImmediate;
|
|
44
|
-
private _deliverUnload;
|
|
45
|
-
readonly onEvent: Listener<CapturedEventInfo>;
|
|
46
|
-
readonly captureInitialPageview: () => boolean;
|
|
47
|
-
readonly capture: (event: string, properties?: Record<string, unknown> | null, options?: CaptureOptions) => boolean;
|
|
48
|
-
private _captureUnload;
|
|
49
|
-
readonly captureImmediate: (event: string, properties?: Record<string, unknown> | null, options?: CaptureOptions) => Promise<CaptureSummary>;
|
|
50
|
-
private _capture;
|
|
51
|
-
private _admitCapture;
|
|
52
|
-
private _acceptRateLimit;
|
|
53
|
-
private _reportRateLimit;
|
|
54
|
-
private _dynamicProperties;
|
|
55
|
-
private _snapshotProperties;
|
|
56
|
-
private _prepareCapture;
|
|
57
|
-
private _enrichAndMeasure;
|
|
58
|
-
private _fitsUnavoidableProperties;
|
|
59
|
-
private _warnOversized;
|
|
60
|
-
private _enqueueCapture;
|
|
61
|
-
private _commitCapture;
|
|
62
|
-
private _publishCapture;
|
|
63
|
-
private _hasPersonProcessing;
|
|
64
|
-
private _requirePersonProcessing;
|
|
65
|
-
readonly createPersonProfile: () => void;
|
|
66
|
-
readonly setPersonProperties: (set?: Record<string, unknown>, setOnce?: Record<string, unknown>) => void;
|
|
67
|
-
private _setPersonProperties;
|
|
68
|
-
readonly unsetPersonProperties: (names: string | readonly string[]) => void;
|
|
69
|
-
readonly setInternalOrTestUser: () => void;
|
|
70
|
-
readonly identify: (distinctId: string, set?: Record<string, unknown>, setOnce?: Record<string, unknown>) => Promise<void>;
|
|
71
|
-
private _identifyOptions;
|
|
72
|
-
private _captureIdentification;
|
|
73
|
-
readonly alias: (alias: string) => void;
|
|
74
|
-
readonly group: (type: string, key: string, properties?: Record<string, unknown>) => Promise<void>;
|
|
75
|
-
readonly groupIdentify: (type: string, key: string | number, properties?: Record<string, unknown>, options?: CaptureOptions) => void;
|
|
76
|
-
readonly resetGroups: () => void;
|
|
77
|
-
readonly reset: () => void;
|
|
78
|
-
private _propertyStore;
|
|
79
|
-
private _prepareRegistration;
|
|
80
|
-
readonly register: (properties: Record<string, unknown>) => void;
|
|
81
|
-
readonly registerOnce: (properties: Record<string, unknown>, defaultValue?: unknown) => void;
|
|
82
|
-
readonly registerForSession: (properties: Record<string, unknown>) => void;
|
|
83
|
-
readonly unregisterForSession: (property: string) => void;
|
|
84
|
-
readonly unregister: (property: string) => void;
|
|
85
|
-
readonly getProperty: (property: string) => unknown;
|
|
86
|
-
readonly registerDynamicEventProperties: (producer: () => Record<string, unknown>) => Disposable;
|
|
87
|
-
}
|