@leanbase-giangnd/js 0.1.0 → 0.1.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/dist/index.cjs +190 -172
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4990 -313
- package/dist/index.mjs +191 -173
- package/dist/index.mjs.map +1 -1
- package/dist/leanbase.iife.js +190 -172
- package/dist/leanbase.iife.js.map +1 -1
- package/package.json +1 -1
- package/src/extensions/replay/extension-shim.ts +35 -0
- package/src/extensions/replay/external/lazy-loaded-session-recorder.ts +12 -1
- package/src/extensions/replay/session-recording.ts +11 -29
- package/src/leanbase.ts +8 -0
- package/src/types.ts +9 -0
- package/src/version.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isArray,
|
|
1
|
+
import { isArray, isNullish, isFormData, hasOwnProperty, isString, isNull, isNumber, PostHogPersistedProperty, isUndefined, isFile, isFunction, includes, stripLeadingDollar, isObject, isEmptyObject, trim, isBoolean, clampToRange, BucketedRateLimiter, PostHogCore, getFetch, isEmptyString } from '@posthog/core';
|
|
2
2
|
import { record } from '@rrweb/record';
|
|
3
3
|
import { strFromU8, gzipSync, strToU8 } from 'fflate';
|
|
4
4
|
|
|
@@ -1183,7 +1183,7 @@ const detectDeviceType = function (user_agent) {
|
|
|
1183
1183
|
}
|
|
1184
1184
|
};
|
|
1185
1185
|
|
|
1186
|
-
var version = "0.1.
|
|
1186
|
+
var version = "0.1.1";
|
|
1187
1187
|
var packageInfo = {
|
|
1188
1188
|
version: version};
|
|
1189
1189
|
|
|
@@ -3121,89 +3121,6 @@ const isLikelyBot = function (navigator, customBlockedUserAgents) {
|
|
|
3121
3121
|
// It would be very bad if posthog-js caused a permission prompt to appear on every page load.
|
|
3122
3122
|
};
|
|
3123
3123
|
|
|
3124
|
-
// Type definitions copied from @rrweb/types@2.0.0-alpha.17 and rrweb-snapshot@2.0.0-alpha.17
|
|
3125
|
-
// Both packages are MIT licensed: https://github.com/rrweb-io/rrweb
|
|
3126
|
-
//
|
|
3127
|
-
// These types are copied here to avoid requiring users to install peer dependencies
|
|
3128
|
-
// solely for TypeScript type information.
|
|
3129
|
-
//
|
|
3130
|
-
// Original sources:
|
|
3131
|
-
// - @rrweb/types: https://github.com/rrweb-io/rrweb/tree/main/packages/@rrweb/types
|
|
3132
|
-
// - rrweb-snapshot: https://github.com/rrweb-io/rrweb/tree/main/packages/rrweb-snapshot
|
|
3133
|
-
var NodeType;
|
|
3134
|
-
(function (NodeType) {
|
|
3135
|
-
NodeType[NodeType["Document"] = 0] = "Document";
|
|
3136
|
-
NodeType[NodeType["DocumentType"] = 1] = "DocumentType";
|
|
3137
|
-
NodeType[NodeType["Element"] = 2] = "Element";
|
|
3138
|
-
NodeType[NodeType["Text"] = 3] = "Text";
|
|
3139
|
-
NodeType[NodeType["CDATA"] = 4] = "CDATA";
|
|
3140
|
-
NodeType[NodeType["Comment"] = 5] = "Comment";
|
|
3141
|
-
})(NodeType || (NodeType = {}));
|
|
3142
|
-
var EventType;
|
|
3143
|
-
(function (EventType) {
|
|
3144
|
-
EventType[EventType["DomContentLoaded"] = 0] = "DomContentLoaded";
|
|
3145
|
-
EventType[EventType["Load"] = 1] = "Load";
|
|
3146
|
-
EventType[EventType["FullSnapshot"] = 2] = "FullSnapshot";
|
|
3147
|
-
EventType[EventType["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
|
|
3148
|
-
EventType[EventType["Meta"] = 4] = "Meta";
|
|
3149
|
-
EventType[EventType["Custom"] = 5] = "Custom";
|
|
3150
|
-
EventType[EventType["Plugin"] = 6] = "Plugin";
|
|
3151
|
-
})(EventType || (EventType = {}));
|
|
3152
|
-
var IncrementalSource;
|
|
3153
|
-
(function (IncrementalSource) {
|
|
3154
|
-
IncrementalSource[IncrementalSource["Mutation"] = 0] = "Mutation";
|
|
3155
|
-
IncrementalSource[IncrementalSource["MouseMove"] = 1] = "MouseMove";
|
|
3156
|
-
IncrementalSource[IncrementalSource["MouseInteraction"] = 2] = "MouseInteraction";
|
|
3157
|
-
IncrementalSource[IncrementalSource["Scroll"] = 3] = "Scroll";
|
|
3158
|
-
IncrementalSource[IncrementalSource["ViewportResize"] = 4] = "ViewportResize";
|
|
3159
|
-
IncrementalSource[IncrementalSource["Input"] = 5] = "Input";
|
|
3160
|
-
IncrementalSource[IncrementalSource["TouchMove"] = 6] = "TouchMove";
|
|
3161
|
-
IncrementalSource[IncrementalSource["MediaInteraction"] = 7] = "MediaInteraction";
|
|
3162
|
-
IncrementalSource[IncrementalSource["StyleSheetRule"] = 8] = "StyleSheetRule";
|
|
3163
|
-
IncrementalSource[IncrementalSource["CanvasMutation"] = 9] = "CanvasMutation";
|
|
3164
|
-
IncrementalSource[IncrementalSource["Font"] = 10] = "Font";
|
|
3165
|
-
IncrementalSource[IncrementalSource["Log"] = 11] = "Log";
|
|
3166
|
-
IncrementalSource[IncrementalSource["Drag"] = 12] = "Drag";
|
|
3167
|
-
IncrementalSource[IncrementalSource["StyleDeclaration"] = 13] = "StyleDeclaration";
|
|
3168
|
-
IncrementalSource[IncrementalSource["Selection"] = 14] = "Selection";
|
|
3169
|
-
IncrementalSource[IncrementalSource["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
|
|
3170
|
-
IncrementalSource[IncrementalSource["CustomElement"] = 16] = "CustomElement";
|
|
3171
|
-
})(IncrementalSource || (IncrementalSource = {}));
|
|
3172
|
-
var MouseInteractions;
|
|
3173
|
-
(function (MouseInteractions) {
|
|
3174
|
-
MouseInteractions[MouseInteractions["MouseUp"] = 0] = "MouseUp";
|
|
3175
|
-
MouseInteractions[MouseInteractions["MouseDown"] = 1] = "MouseDown";
|
|
3176
|
-
MouseInteractions[MouseInteractions["Click"] = 2] = "Click";
|
|
3177
|
-
MouseInteractions[MouseInteractions["ContextMenu"] = 3] = "ContextMenu";
|
|
3178
|
-
MouseInteractions[MouseInteractions["DblClick"] = 4] = "DblClick";
|
|
3179
|
-
MouseInteractions[MouseInteractions["Focus"] = 5] = "Focus";
|
|
3180
|
-
MouseInteractions[MouseInteractions["Blur"] = 6] = "Blur";
|
|
3181
|
-
MouseInteractions[MouseInteractions["TouchStart"] = 7] = "TouchStart";
|
|
3182
|
-
MouseInteractions[MouseInteractions["TouchMove_Departed"] = 8] = "TouchMove_Departed";
|
|
3183
|
-
MouseInteractions[MouseInteractions["TouchEnd"] = 9] = "TouchEnd";
|
|
3184
|
-
MouseInteractions[MouseInteractions["TouchCancel"] = 10] = "TouchCancel";
|
|
3185
|
-
})(MouseInteractions || (MouseInteractions = {}));
|
|
3186
|
-
var PointerTypes;
|
|
3187
|
-
(function (PointerTypes) {
|
|
3188
|
-
PointerTypes[PointerTypes["Mouse"] = 0] = "Mouse";
|
|
3189
|
-
PointerTypes[PointerTypes["Pen"] = 1] = "Pen";
|
|
3190
|
-
PointerTypes[PointerTypes["Touch"] = 2] = "Touch";
|
|
3191
|
-
})(PointerTypes || (PointerTypes = {}));
|
|
3192
|
-
var MediaInteractions;
|
|
3193
|
-
(function (MediaInteractions) {
|
|
3194
|
-
MediaInteractions[MediaInteractions["Play"] = 0] = "Play";
|
|
3195
|
-
MediaInteractions[MediaInteractions["Pause"] = 1] = "Pause";
|
|
3196
|
-
MediaInteractions[MediaInteractions["Seeked"] = 2] = "Seeked";
|
|
3197
|
-
MediaInteractions[MediaInteractions["VolumeChange"] = 3] = "VolumeChange";
|
|
3198
|
-
MediaInteractions[MediaInteractions["RateChange"] = 4] = "RateChange";
|
|
3199
|
-
})(MediaInteractions || (MediaInteractions = {}));
|
|
3200
|
-
var CanvasContext;
|
|
3201
|
-
(function (CanvasContext) {
|
|
3202
|
-
CanvasContext[CanvasContext["2D"] = 0] = "2D";
|
|
3203
|
-
CanvasContext[CanvasContext["WebGL"] = 1] = "WebGL";
|
|
3204
|
-
CanvasContext[CanvasContext["WebGL2"] = 2] = "WebGL2";
|
|
3205
|
-
})(CanvasContext || (CanvasContext = {}));
|
|
3206
|
-
|
|
3207
3124
|
const _createLogger = prefix => {
|
|
3208
3125
|
return {
|
|
3209
3126
|
info: (...args) => logger$3.info(prefix, ...args),
|
|
@@ -3219,6 +3136,69 @@ const _createLogger = prefix => {
|
|
|
3219
3136
|
const logger$2 = _createLogger('[Leanbase]');
|
|
3220
3137
|
const createLogger = _createLogger;
|
|
3221
3138
|
|
|
3139
|
+
function patch(source, name, replacement) {
|
|
3140
|
+
try {
|
|
3141
|
+
if (!(name in source)) {
|
|
3142
|
+
return () => {
|
|
3143
|
+
//
|
|
3144
|
+
};
|
|
3145
|
+
}
|
|
3146
|
+
const original = source[name];
|
|
3147
|
+
const wrapped = replacement(original);
|
|
3148
|
+
if (isFunction(wrapped)) {
|
|
3149
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
3150
|
+
wrapped.prototype = wrapped.prototype || {};
|
|
3151
|
+
Object.defineProperties(wrapped, {
|
|
3152
|
+
__posthog_wrapped__: {
|
|
3153
|
+
enumerable: false,
|
|
3154
|
+
value: true
|
|
3155
|
+
}
|
|
3156
|
+
});
|
|
3157
|
+
}
|
|
3158
|
+
source[name] = wrapped;
|
|
3159
|
+
return () => {
|
|
3160
|
+
source[name] = original;
|
|
3161
|
+
};
|
|
3162
|
+
} catch {
|
|
3163
|
+
return () => {
|
|
3164
|
+
//
|
|
3165
|
+
};
|
|
3166
|
+
}
|
|
3167
|
+
}
|
|
3168
|
+
|
|
3169
|
+
function hostnameFromURL(url) {
|
|
3170
|
+
try {
|
|
3171
|
+
if (typeof url === 'string') {
|
|
3172
|
+
return new URL(url).hostname;
|
|
3173
|
+
}
|
|
3174
|
+
if ('url' in url) {
|
|
3175
|
+
return new URL(url.url).hostname;
|
|
3176
|
+
}
|
|
3177
|
+
return url.hostname;
|
|
3178
|
+
} catch {
|
|
3179
|
+
return null;
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3182
|
+
function isHostOnDenyList(url, options) {
|
|
3183
|
+
const hostname = hostnameFromURL(url);
|
|
3184
|
+
const defaultNotDenied = {
|
|
3185
|
+
hostname,
|
|
3186
|
+
isHostDenied: false
|
|
3187
|
+
};
|
|
3188
|
+
if (!options.payloadHostDenyList?.length || !hostname?.trim().length) {
|
|
3189
|
+
return defaultNotDenied;
|
|
3190
|
+
}
|
|
3191
|
+
for (const deny of options.payloadHostDenyList) {
|
|
3192
|
+
if (hostname.endsWith(deny)) {
|
|
3193
|
+
return {
|
|
3194
|
+
hostname,
|
|
3195
|
+
isHostDenied: true
|
|
3196
|
+
};
|
|
3197
|
+
}
|
|
3198
|
+
}
|
|
3199
|
+
return defaultNotDenied;
|
|
3200
|
+
}
|
|
3201
|
+
|
|
3222
3202
|
const LOGGER_PREFIX$2 = '[SessionRecording]';
|
|
3223
3203
|
const REDACTED = 'redacted';
|
|
3224
3204
|
const defaultNetworkOptions = {
|
|
@@ -3375,69 +3355,6 @@ const buildNetworkRequestOptions = (instanceConfig, remoteNetworkOptions = {}) =
|
|
|
3375
3355
|
};
|
|
3376
3356
|
};
|
|
3377
3357
|
|
|
3378
|
-
function patch(source, name, replacement) {
|
|
3379
|
-
try {
|
|
3380
|
-
if (!(name in source)) {
|
|
3381
|
-
return () => {
|
|
3382
|
-
//
|
|
3383
|
-
};
|
|
3384
|
-
}
|
|
3385
|
-
const original = source[name];
|
|
3386
|
-
const wrapped = replacement(original);
|
|
3387
|
-
if (isFunction(wrapped)) {
|
|
3388
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
3389
|
-
wrapped.prototype = wrapped.prototype || {};
|
|
3390
|
-
Object.defineProperties(wrapped, {
|
|
3391
|
-
__posthog_wrapped__: {
|
|
3392
|
-
enumerable: false,
|
|
3393
|
-
value: true
|
|
3394
|
-
}
|
|
3395
|
-
});
|
|
3396
|
-
}
|
|
3397
|
-
source[name] = wrapped;
|
|
3398
|
-
return () => {
|
|
3399
|
-
source[name] = original;
|
|
3400
|
-
};
|
|
3401
|
-
} catch {
|
|
3402
|
-
return () => {
|
|
3403
|
-
//
|
|
3404
|
-
};
|
|
3405
|
-
}
|
|
3406
|
-
}
|
|
3407
|
-
|
|
3408
|
-
function hostnameFromURL(url) {
|
|
3409
|
-
try {
|
|
3410
|
-
if (typeof url === 'string') {
|
|
3411
|
-
return new URL(url).hostname;
|
|
3412
|
-
}
|
|
3413
|
-
if ('url' in url) {
|
|
3414
|
-
return new URL(url.url).hostname;
|
|
3415
|
-
}
|
|
3416
|
-
return url.hostname;
|
|
3417
|
-
} catch {
|
|
3418
|
-
return null;
|
|
3419
|
-
}
|
|
3420
|
-
}
|
|
3421
|
-
function isHostOnDenyList(url, options) {
|
|
3422
|
-
const hostname = hostnameFromURL(url);
|
|
3423
|
-
const defaultNotDenied = {
|
|
3424
|
-
hostname,
|
|
3425
|
-
isHostDenied: false
|
|
3426
|
-
};
|
|
3427
|
-
if (!options.payloadHostDenyList?.length || !hostname?.trim().length) {
|
|
3428
|
-
return defaultNotDenied;
|
|
3429
|
-
}
|
|
3430
|
-
for (const deny of options.payloadHostDenyList) {
|
|
3431
|
-
if (hostname.endsWith(deny)) {
|
|
3432
|
-
return {
|
|
3433
|
-
hostname,
|
|
3434
|
-
isHostDenied: true
|
|
3435
|
-
};
|
|
3436
|
-
}
|
|
3437
|
-
}
|
|
3438
|
-
return defaultNotDenied;
|
|
3439
|
-
}
|
|
3440
|
-
|
|
3441
3358
|
/// <reference lib="dom" />
|
|
3442
3359
|
const logger$1 = createLogger('[Recorder]');
|
|
3443
3360
|
const isNavigationTiming = entry => entry.entryType === 'navigation';
|
|
@@ -3996,6 +3913,108 @@ const getRecordNetworkPlugin = options => {
|
|
|
3996
3913
|
};
|
|
3997
3914
|
// rrweb/networ@1 ends
|
|
3998
3915
|
|
|
3916
|
+
// Use a safe global target (prefer `win`, fallback to globalThis)
|
|
3917
|
+
const _target = win ?? globalThis;
|
|
3918
|
+
_target.__PosthogExtensions__ = _target.__PosthogExtensions__ || {};
|
|
3919
|
+
// Expose rrweb.record under the same contract
|
|
3920
|
+
_target.__PosthogExtensions__.rrweb = _target.__PosthogExtensions__.rrweb || {
|
|
3921
|
+
record: record
|
|
3922
|
+
};
|
|
3923
|
+
// Provide initSessionRecording if not present — return a new LazyLoadedSessionRecording when called
|
|
3924
|
+
_target.__PosthogExtensions__.initSessionRecording = _target.__PosthogExtensions__.initSessionRecording || (instance => {
|
|
3925
|
+
return new LazyLoadedSessionRecording(instance);
|
|
3926
|
+
});
|
|
3927
|
+
// Provide a no-op loadExternalDependency that calls the callback immediately (since rrweb is bundled)
|
|
3928
|
+
_target.__PosthogExtensions__.loadExternalDependency = _target.__PosthogExtensions__.loadExternalDependency || ((instance, scriptName, cb) => {
|
|
3929
|
+
if (cb) cb(undefined);
|
|
3930
|
+
});
|
|
3931
|
+
// Provide rrwebPlugins object with network plugin factory if not present
|
|
3932
|
+
_target.__PosthogExtensions__.rrwebPlugins = _target.__PosthogExtensions__.rrwebPlugins || {};
|
|
3933
|
+
_target.__PosthogExtensions__.rrwebPlugins.getRecordNetworkPlugin = _target.__PosthogExtensions__.rrwebPlugins.getRecordNetworkPlugin || (() => getRecordNetworkPlugin);
|
|
3934
|
+
|
|
3935
|
+
// Type definitions copied from @rrweb/types@2.0.0-alpha.17 and rrweb-snapshot@2.0.0-alpha.17
|
|
3936
|
+
// Both packages are MIT licensed: https://github.com/rrweb-io/rrweb
|
|
3937
|
+
//
|
|
3938
|
+
// These types are copied here to avoid requiring users to install peer dependencies
|
|
3939
|
+
// solely for TypeScript type information.
|
|
3940
|
+
//
|
|
3941
|
+
// Original sources:
|
|
3942
|
+
// - @rrweb/types: https://github.com/rrweb-io/rrweb/tree/main/packages/@rrweb/types
|
|
3943
|
+
// - rrweb-snapshot: https://github.com/rrweb-io/rrweb/tree/main/packages/rrweb-snapshot
|
|
3944
|
+
var NodeType;
|
|
3945
|
+
(function (NodeType) {
|
|
3946
|
+
NodeType[NodeType["Document"] = 0] = "Document";
|
|
3947
|
+
NodeType[NodeType["DocumentType"] = 1] = "DocumentType";
|
|
3948
|
+
NodeType[NodeType["Element"] = 2] = "Element";
|
|
3949
|
+
NodeType[NodeType["Text"] = 3] = "Text";
|
|
3950
|
+
NodeType[NodeType["CDATA"] = 4] = "CDATA";
|
|
3951
|
+
NodeType[NodeType["Comment"] = 5] = "Comment";
|
|
3952
|
+
})(NodeType || (NodeType = {}));
|
|
3953
|
+
var EventType;
|
|
3954
|
+
(function (EventType) {
|
|
3955
|
+
EventType[EventType["DomContentLoaded"] = 0] = "DomContentLoaded";
|
|
3956
|
+
EventType[EventType["Load"] = 1] = "Load";
|
|
3957
|
+
EventType[EventType["FullSnapshot"] = 2] = "FullSnapshot";
|
|
3958
|
+
EventType[EventType["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
|
|
3959
|
+
EventType[EventType["Meta"] = 4] = "Meta";
|
|
3960
|
+
EventType[EventType["Custom"] = 5] = "Custom";
|
|
3961
|
+
EventType[EventType["Plugin"] = 6] = "Plugin";
|
|
3962
|
+
})(EventType || (EventType = {}));
|
|
3963
|
+
var IncrementalSource;
|
|
3964
|
+
(function (IncrementalSource) {
|
|
3965
|
+
IncrementalSource[IncrementalSource["Mutation"] = 0] = "Mutation";
|
|
3966
|
+
IncrementalSource[IncrementalSource["MouseMove"] = 1] = "MouseMove";
|
|
3967
|
+
IncrementalSource[IncrementalSource["MouseInteraction"] = 2] = "MouseInteraction";
|
|
3968
|
+
IncrementalSource[IncrementalSource["Scroll"] = 3] = "Scroll";
|
|
3969
|
+
IncrementalSource[IncrementalSource["ViewportResize"] = 4] = "ViewportResize";
|
|
3970
|
+
IncrementalSource[IncrementalSource["Input"] = 5] = "Input";
|
|
3971
|
+
IncrementalSource[IncrementalSource["TouchMove"] = 6] = "TouchMove";
|
|
3972
|
+
IncrementalSource[IncrementalSource["MediaInteraction"] = 7] = "MediaInteraction";
|
|
3973
|
+
IncrementalSource[IncrementalSource["StyleSheetRule"] = 8] = "StyleSheetRule";
|
|
3974
|
+
IncrementalSource[IncrementalSource["CanvasMutation"] = 9] = "CanvasMutation";
|
|
3975
|
+
IncrementalSource[IncrementalSource["Font"] = 10] = "Font";
|
|
3976
|
+
IncrementalSource[IncrementalSource["Log"] = 11] = "Log";
|
|
3977
|
+
IncrementalSource[IncrementalSource["Drag"] = 12] = "Drag";
|
|
3978
|
+
IncrementalSource[IncrementalSource["StyleDeclaration"] = 13] = "StyleDeclaration";
|
|
3979
|
+
IncrementalSource[IncrementalSource["Selection"] = 14] = "Selection";
|
|
3980
|
+
IncrementalSource[IncrementalSource["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
|
|
3981
|
+
IncrementalSource[IncrementalSource["CustomElement"] = 16] = "CustomElement";
|
|
3982
|
+
})(IncrementalSource || (IncrementalSource = {}));
|
|
3983
|
+
var MouseInteractions;
|
|
3984
|
+
(function (MouseInteractions) {
|
|
3985
|
+
MouseInteractions[MouseInteractions["MouseUp"] = 0] = "MouseUp";
|
|
3986
|
+
MouseInteractions[MouseInteractions["MouseDown"] = 1] = "MouseDown";
|
|
3987
|
+
MouseInteractions[MouseInteractions["Click"] = 2] = "Click";
|
|
3988
|
+
MouseInteractions[MouseInteractions["ContextMenu"] = 3] = "ContextMenu";
|
|
3989
|
+
MouseInteractions[MouseInteractions["DblClick"] = 4] = "DblClick";
|
|
3990
|
+
MouseInteractions[MouseInteractions["Focus"] = 5] = "Focus";
|
|
3991
|
+
MouseInteractions[MouseInteractions["Blur"] = 6] = "Blur";
|
|
3992
|
+
MouseInteractions[MouseInteractions["TouchStart"] = 7] = "TouchStart";
|
|
3993
|
+
MouseInteractions[MouseInteractions["TouchMove_Departed"] = 8] = "TouchMove_Departed";
|
|
3994
|
+
MouseInteractions[MouseInteractions["TouchEnd"] = 9] = "TouchEnd";
|
|
3995
|
+
MouseInteractions[MouseInteractions["TouchCancel"] = 10] = "TouchCancel";
|
|
3996
|
+
})(MouseInteractions || (MouseInteractions = {}));
|
|
3997
|
+
var PointerTypes;
|
|
3998
|
+
(function (PointerTypes) {
|
|
3999
|
+
PointerTypes[PointerTypes["Mouse"] = 0] = "Mouse";
|
|
4000
|
+
PointerTypes[PointerTypes["Pen"] = 1] = "Pen";
|
|
4001
|
+
PointerTypes[PointerTypes["Touch"] = 2] = "Touch";
|
|
4002
|
+
})(PointerTypes || (PointerTypes = {}));
|
|
4003
|
+
var MediaInteractions;
|
|
4004
|
+
(function (MediaInteractions) {
|
|
4005
|
+
MediaInteractions[MediaInteractions["Play"] = 0] = "Play";
|
|
4006
|
+
MediaInteractions[MediaInteractions["Pause"] = 1] = "Pause";
|
|
4007
|
+
MediaInteractions[MediaInteractions["Seeked"] = 2] = "Seeked";
|
|
4008
|
+
MediaInteractions[MediaInteractions["VolumeChange"] = 3] = "VolumeChange";
|
|
4009
|
+
MediaInteractions[MediaInteractions["RateChange"] = 4] = "RateChange";
|
|
4010
|
+
})(MediaInteractions || (MediaInteractions = {}));
|
|
4011
|
+
var CanvasContext;
|
|
4012
|
+
(function (CanvasContext) {
|
|
4013
|
+
CanvasContext[CanvasContext["2D"] = 0] = "2D";
|
|
4014
|
+
CanvasContext[CanvasContext["WebGL"] = 1] = "WebGL";
|
|
4015
|
+
CanvasContext[CanvasContext["WebGL2"] = 2] = "WebGL2";
|
|
4016
|
+
})(CanvasContext || (CanvasContext = {}));
|
|
4017
|
+
|
|
3999
4018
|
const DISABLED = 'disabled';
|
|
4000
4019
|
const SAMPLED = 'sampled';
|
|
4001
4020
|
const ACTIVE = 'active';
|
|
@@ -4452,6 +4471,15 @@ const newQueuedEvent = rrwebMethod => ({
|
|
|
4452
4471
|
attempt: 1
|
|
4453
4472
|
});
|
|
4454
4473
|
function getRRWebRecord() {
|
|
4474
|
+
try {
|
|
4475
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4476
|
+
const ext = globalThis.__PosthogExtensions__;
|
|
4477
|
+
if (ext && ext.rrweb && ext.rrweb.record) {
|
|
4478
|
+
return ext.rrweb.record;
|
|
4479
|
+
}
|
|
4480
|
+
} catch {
|
|
4481
|
+
// ignore
|
|
4482
|
+
}
|
|
4455
4483
|
return record;
|
|
4456
4484
|
}
|
|
4457
4485
|
function gzipToString(data) {
|
|
@@ -5163,7 +5191,7 @@ class LazyLoadedSessionRecording {
|
|
|
5163
5191
|
_captureSnapshot(properties) {
|
|
5164
5192
|
// :TRICKY: Make sure we batch these requests, use a custom endpoint and don't truncate the strings.
|
|
5165
5193
|
this._instance.capture('$snapshot', properties, {
|
|
5166
|
-
_url: this.
|
|
5194
|
+
_url: this._instance.requestRouter.endpointFor('api', this._endpoint),
|
|
5167
5195
|
_noTruncate: true,
|
|
5168
5196
|
_batchKey: SESSION_RECORDING_BATCH_KEY,
|
|
5169
5197
|
skip_client_rate_limiting: true
|
|
@@ -5495,35 +5523,22 @@ class SessionRecording {
|
|
|
5495
5523
|
}
|
|
5496
5524
|
}
|
|
5497
5525
|
get _isRecordingEnabled() {
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
return false;
|
|
5503
|
-
}
|
|
5504
|
-
if (this._instance.config.disable_session_recording) {
|
|
5505
|
-
return false;
|
|
5506
|
-
}
|
|
5507
|
-
return true;
|
|
5526
|
+
const enabled_server_side = !!this._instance.get_property(SESSION_RECORDING_REMOTE_CONFIG)?.enabled;
|
|
5527
|
+
const enabled_client_side = !this._instance.config.disable_session_recording;
|
|
5528
|
+
const isDisabled = this._instance.config.disable_session_recording || this._instance.consent?.isOptedOut?.();
|
|
5529
|
+
return win && enabled_server_side && enabled_client_side && !isDisabled;
|
|
5508
5530
|
}
|
|
5509
5531
|
startIfEnabledOrStop(startReason) {
|
|
5510
|
-
|
|
5511
|
-
if (!this._isRecordingEnabled || !canRunReplay) {
|
|
5512
|
-
this.stopRecording();
|
|
5532
|
+
if (this._isRecordingEnabled && this._lazyLoadedSessionRecording?.isStarted) {
|
|
5513
5533
|
return;
|
|
5514
5534
|
}
|
|
5515
|
-
|
|
5516
|
-
|
|
5535
|
+
const canRunReplay = !isUndefined(Object.assign) && !isUndefined(Array.from);
|
|
5536
|
+
if (this._isRecordingEnabled && canRunReplay) {
|
|
5537
|
+
this._lazyLoadAndStart(startReason);
|
|
5538
|
+
log.info('starting');
|
|
5539
|
+
} else {
|
|
5540
|
+
this.stopRecording();
|
|
5517
5541
|
}
|
|
5518
|
-
// According to the rrweb docs, rrweb is not supported on IE11 and below:
|
|
5519
|
-
// "rrweb does not support IE11 and below because it uses the MutationObserver API, which was supported by these browsers."
|
|
5520
|
-
// https://github.com/rrweb-io/rrweb/blob/master/guide.md#compatibility-note
|
|
5521
|
-
//
|
|
5522
|
-
// However, MutationObserver does exist on IE11, it just doesn't work well and does not detect all changes.
|
|
5523
|
-
// Instead, when we load "recorder.js", the first JS error is about "Object.assign" and "Array.from" being undefined.
|
|
5524
|
-
// Thus instead of MutationObserver, we look for this function and block recording if it's undefined.
|
|
5525
|
-
this._lazyLoadAndStart(startReason);
|
|
5526
|
-
log.info('starting');
|
|
5527
5542
|
}
|
|
5528
5543
|
/**
|
|
5529
5544
|
* session recording waits until it receives remote config before loading the script
|
|
@@ -5828,6 +5843,9 @@ class Leanbase extends PostHogCore {
|
|
|
5828
5843
|
};
|
|
5829
5844
|
if (isObject(config)) {
|
|
5830
5845
|
extend(this.config, config);
|
|
5846
|
+
if (!this.config.api_host && this.config.host) {
|
|
5847
|
+
this.config.api_host = this.config.host;
|
|
5848
|
+
}
|
|
5831
5849
|
this.persistence?.update_config(this.config, oldConfig);
|
|
5832
5850
|
this.replayAutocapture?.startIfEnabled();
|
|
5833
5851
|
this.sessionRecording?.startIfEnabledOrStop();
|