posthog-js 1.425.0 → 1.426.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/dist/all-external-dependencies.js +1 -1
- package/dist/all-external-dependencies.js.map +1 -1
- package/dist/array.full.es5.js +1 -1
- package/dist/array.full.es5.js.map +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.full.no-external.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/array.no-external.js.map +1 -1
- package/dist/conversations.js +1 -1
- package/dist/conversations.js.map +1 -1
- package/dist/crisp-chat-integration.js +1 -1
- package/dist/crisp-chat-integration.js.map +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/customizations.full.js.map +1 -1
- package/dist/customizations.js +1 -1
- package/dist/customizations.js.map +1 -1
- package/dist/dead-clicks-autocapture.js +1 -1
- package/dist/dead-clicks-autocapture.js.map +1 -1
- package/dist/default-extensions.js +1 -1
- package/dist/default-extensions.js.map +1 -1
- package/dist/element-inference.js +1 -1
- package/dist/element-inference.js.map +1 -1
- package/dist/exception-autocapture.js +1 -1
- package/dist/exception-autocapture.js.map +1 -1
- package/dist/extension-bundles.js +1 -1
- package/dist/extension-bundles.js.map +1 -1
- package/dist/external-scripts-loader.js +1 -1
- package/dist/external-scripts-loader.js.map +1 -1
- package/dist/intercom-integration.js +1 -1
- package/dist/intercom-integration.js.map +1 -1
- package/dist/lazy-recorder.js +1 -1
- package/dist/lazy-recorder.js.map +1 -1
- package/dist/logs.js +1 -1
- package/dist/logs.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.d.ts +7 -3
- package/dist/module.full.d.ts +7 -3
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.d.ts +7 -3
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/module.no-external.d.ts +7 -3
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/dist/module.slim.js +1 -1
- package/dist/module.slim.js.map +1 -1
- package/dist/module.slim.no-external.d.ts +7 -3
- package/dist/module.slim.no-external.js +1 -1
- package/dist/module.slim.no-external.js.map +1 -1
- package/dist/posthog-recorder.js +1 -1
- package/dist/posthog-recorder.js.map +1 -1
- package/dist/product-tours-preview.js +1 -1
- package/dist/product-tours-preview.js.map +1 -1
- package/dist/product-tours.js +1 -1
- package/dist/product-tours.js.map +1 -1
- package/dist/recorder-v2.js +1 -1
- package/dist/recorder-v2.js.map +1 -1
- package/dist/recorder.js +1 -1
- package/dist/recorder.js.map +1 -1
- package/dist/rrweb.d.ts +1 -0
- package/dist/rrweb.js +1 -1
- package/dist/rrweb.js.map +1 -1
- package/dist/src/constants.d.ts +2 -0
- package/dist/src/extensions/replay/external/lazy-loaded-session-recorder.d.ts +1 -0
- package/dist/src/posthog-core.d.ts +5 -2
- package/dist/src/posthog-persistence.d.ts +2 -1
- package/dist/surveys-preview.js +1 -1
- package/dist/surveys-preview.js.map +1 -1
- package/dist/surveys.js +1 -1
- package/dist/surveys.js.map +1 -1
- package/dist/tracing-headers.js +1 -1
- package/dist/tracing-headers.js.map +1 -1
- package/dist/web-vitals-soft-navs.js +1 -1
- package/dist/web-vitals-soft-navs.js.map +1 -1
- package/dist/web-vitals-with-attribution-soft-navs.js +1 -1
- package/dist/web-vitals-with-attribution-soft-navs.js.map +1 -1
- package/dist/web-vitals-with-attribution.js +1 -1
- package/dist/web-vitals-with-attribution.js.map +1 -1
- package/dist/web-vitals.js +1 -1
- package/dist/web-vitals.js.map +1 -1
- package/lib/package.json +6 -7
- package/lib/src/constants.d.ts +2 -0
- package/lib/src/constants.js +5 -3
- package/lib/src/constants.js.map +1 -1
- package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.d.ts +1 -0
- package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.js +24 -16
- package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.js.map +1 -1
- package/lib/src/persistence-key-policy.js +1 -0
- package/lib/src/persistence-key-policy.js.map +1 -1
- package/lib/src/posthog-core.d.ts +5 -2
- package/lib/src/posthog-core.js +109 -21
- package/lib/src/posthog-core.js.map +1 -1
- package/lib/src/posthog-persistence.d.ts +2 -1
- package/lib/src/posthog-persistence.js +22 -5
- package/lib/src/posthog-persistence.js.map +1 -1
- package/lib/src/scroll-manager.js +6 -4
- package/lib/src/scroll-manager.js.map +1 -1
- package/lib/src/storage.js +1 -0
- package/lib/src/storage.js.map +1 -1
- package/package.json +11 -20
- package/react/dist/esm/index.js +232 -256
- package/react/dist/esm/index.js.map +1 -1
- package/react/dist/esm/slim/index.js +205 -225
- package/react/dist/esm/slim/index.js.map +1 -1
- package/react/dist/esm/surveys/index.js +48 -74
- package/react/dist/esm/surveys/index.js.map +1 -1
- package/react/dist/types/index.d.ts +72 -65
- package/react/dist/types/slim/index.d.ts +67 -60
- package/react/dist/types/surveys/index.d.ts +15 -16
- package/react/dist/umd/index.js +287 -289
- package/react/dist/umd/index.js.map +1 -1
- package/react/dist/umd/slim/index.js +253 -255
- package/react/dist/umd/slim/index.js.map +1 -1
- package/react/dist/umd/surveys/index.js +91 -91
- package/react/dist/umd/surveys/index.js.map +1 -1
|
@@ -1,33 +1,89 @@
|
|
|
1
|
+
(function () {var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
var __assign = (this && this.__assign) || function () {
|
|
17
|
+
__assign = Object.assign || function(t) {
|
|
18
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
+
s = arguments[i];
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
+
t[p] = s[p];
|
|
22
|
+
}
|
|
23
|
+
return t;
|
|
24
|
+
};
|
|
25
|
+
return __assign.apply(this, arguments);
|
|
26
|
+
};
|
|
27
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
28
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
29
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
30
|
+
};
|
|
31
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
32
|
+
var t = {};
|
|
33
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
34
|
+
t[p] = s[p];
|
|
35
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
36
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
37
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
38
|
+
t[p[i]] = s[p[i]];
|
|
39
|
+
}
|
|
40
|
+
return t;
|
|
41
|
+
};
|
|
1
42
|
(function (global, factory) {
|
|
2
|
-
typeof exports ===
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
43
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react")) : typeof define === "function" && define.amd ? define(["exports", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.PosthogReactSlim = {}, global.React));
|
|
44
|
+
})(this, function (exports, react) {
|
|
45
|
+
"use strict";
|
|
46
|
+
var _a;
|
|
47
|
+
var __create = Object.create;
|
|
48
|
+
var __defProp = Object.defineProperty;
|
|
49
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
50
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
51
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
52
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
53
|
+
var __copyProps = function (to, from, except, desc) {
|
|
54
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
55
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
56
|
+
key = keys[i];
|
|
57
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
58
|
+
__defProp(to, key, {
|
|
59
|
+
get: (function (k) { return from[k]; }).bind(null, key),
|
|
60
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return to;
|
|
64
|
+
};
|
|
65
|
+
var __toESM = function (mod, isNodeMode, target) { return (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
66
|
+
value: mod,
|
|
67
|
+
enumerable: true
|
|
68
|
+
}) : target, mod)); };
|
|
69
|
+
react = __toESM(react);
|
|
70
|
+
var PostHogContext = (0, react.createContext)({
|
|
71
|
+
get client() { },
|
|
72
|
+
bootstrap: void 0
|
|
21
73
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
74
|
+
function PostHogProvider(_b) {
|
|
75
|
+
var client = _b.client, children = _b.children;
|
|
76
|
+
var value = (0, react.useMemo)(function () {
|
|
77
|
+
var _b;
|
|
78
|
+
return ({
|
|
79
|
+
client: client,
|
|
80
|
+
bootstrap: (_b = client.config) === null || _b === void 0 ? void 0 : _b.bootstrap
|
|
81
|
+
});
|
|
82
|
+
}, [client]);
|
|
83
|
+
return react.default.createElement(PostHogContext.Provider, { value: value }, children);
|
|
27
84
|
}
|
|
28
|
-
|
|
29
85
|
var isFunction = function (f) {
|
|
30
|
-
return typeof f ===
|
|
86
|
+
return typeof f === "function";
|
|
31
87
|
};
|
|
32
88
|
var isUndefined = function (x) {
|
|
33
89
|
return x === void 0;
|
|
@@ -35,189 +91,121 @@
|
|
|
35
91
|
var isNull = function (x) {
|
|
36
92
|
return x === null;
|
|
37
93
|
};
|
|
38
|
-
|
|
39
94
|
function useFeatureFlagEnabled(flag, defaultValue) {
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
|
|
95
|
+
var _b, _c;
|
|
96
|
+
var _d = (0, react.useContext)(PostHogContext), client = _d.client, bootstrap = _d.bootstrap;
|
|
97
|
+
var _e = (0, react.useState)(function () { return client.isFeatureEnabled(flag); }), featureEnabled = _e[0], setFeatureEnabled = _e[1];
|
|
98
|
+
(0, react.useEffect)(function () {
|
|
44
99
|
return client.onFeatureFlags(function () {
|
|
45
100
|
setFeatureEnabled(client.isFeatureEnabled(flag));
|
|
46
101
|
});
|
|
47
102
|
}, [client, flag]);
|
|
48
|
-
var bootstrapped = (
|
|
49
|
-
if (!((
|
|
103
|
+
var bootstrapped = (_b = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.featureFlags) === null || _b === void 0 ? void 0 : _b[flag];
|
|
104
|
+
if (!((_c = client === null || client === void 0 ? void 0 : client.featureFlags) === null || _c === void 0 ? void 0 : _c.hasLoadedFlags) && (bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.featureFlags))
|
|
50
105
|
return isUndefined(bootstrapped) ? defaultValue : !!bootstrapped;
|
|
51
|
-
}
|
|
52
106
|
return isUndefined(featureEnabled) ? defaultValue : featureEnabled;
|
|
53
107
|
}
|
|
54
|
-
|
|
55
108
|
function useFeatureFlagPayload(flag) {
|
|
56
|
-
var
|
|
57
|
-
var
|
|
58
|
-
var
|
|
59
|
-
|
|
109
|
+
var _b;
|
|
110
|
+
var _c = (0, react.useContext)(PostHogContext), client = _c.client, bootstrap = _c.bootstrap;
|
|
111
|
+
var _d = (0, react.useState)(function () { var _b; return (_b = client.getFeatureFlagResult(flag, { send_event: false })) === null || _b === void 0 ? void 0 : _b.payload; }), featureFlagPayload = _d[0], setFeatureFlagPayload = _d[1];
|
|
112
|
+
(0, react.useEffect)(function () {
|
|
60
113
|
return client.onFeatureFlags(function () {
|
|
61
|
-
var
|
|
62
|
-
setFeatureFlagPayload((
|
|
114
|
+
var _b;
|
|
115
|
+
setFeatureFlagPayload((_b = client.getFeatureFlagResult(flag, { send_event: false })) === null || _b === void 0 ? void 0 : _b.payload);
|
|
63
116
|
});
|
|
64
117
|
}, [client, flag]);
|
|
65
|
-
if (!((
|
|
118
|
+
if (!((_b = client === null || client === void 0 ? void 0 : client.featureFlags) === null || _b === void 0 ? void 0 : _b.hasLoadedFlags) && (bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.featureFlagPayloads))
|
|
66
119
|
return bootstrap.featureFlagPayloads[flag];
|
|
67
|
-
}
|
|
68
120
|
return featureFlagPayload;
|
|
69
121
|
}
|
|
70
|
-
|
|
71
122
|
function useFeatureFlagResult(flag) {
|
|
72
|
-
var
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
|
|
123
|
+
var _b, _c;
|
|
124
|
+
var _d = (0, react.useContext)(PostHogContext), client = _d.client, bootstrap = _d.bootstrap;
|
|
125
|
+
var _e = (0, react.useState)(function () { return client.getFeatureFlagResult(flag); }), result = _e[0], setResult = _e[1];
|
|
126
|
+
(0, react.useEffect)(function () {
|
|
76
127
|
return client.onFeatureFlags(function () {
|
|
77
128
|
setResult(client.getFeatureFlagResult(flag));
|
|
78
129
|
});
|
|
79
130
|
}, [client, flag]);
|
|
80
|
-
if (!((
|
|
131
|
+
if (!((_b = client === null || client === void 0 ? void 0 : client.featureFlags) === null || _b === void 0 ? void 0 : _b.hasLoadedFlags) && (bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.featureFlags)) {
|
|
81
132
|
var bootstrappedValue = bootstrap.featureFlags[flag];
|
|
82
|
-
if (isUndefined(bootstrappedValue))
|
|
83
|
-
return
|
|
84
|
-
}
|
|
133
|
+
if (isUndefined(bootstrappedValue))
|
|
134
|
+
return;
|
|
85
135
|
return {
|
|
86
136
|
key: flag,
|
|
87
|
-
enabled: typeof bootstrappedValue ===
|
|
88
|
-
variant: typeof bootstrappedValue ===
|
|
89
|
-
payload: (
|
|
137
|
+
enabled: typeof bootstrappedValue === "string" ? true : !!bootstrappedValue,
|
|
138
|
+
variant: typeof bootstrappedValue === "string" ? bootstrappedValue : void 0,
|
|
139
|
+
payload: (_c = bootstrap.featureFlagPayloads) === null || _c === void 0 ? void 0 : _c[flag]
|
|
90
140
|
};
|
|
91
141
|
}
|
|
92
142
|
return result;
|
|
93
143
|
}
|
|
94
|
-
|
|
95
144
|
function useActiveFeatureFlags() {
|
|
96
|
-
var
|
|
97
|
-
var
|
|
98
|
-
var
|
|
99
|
-
|
|
145
|
+
var _b;
|
|
146
|
+
var _c = (0, react.useContext)(PostHogContext), client = _c.client, bootstrap = _c.bootstrap;
|
|
147
|
+
var _d = (0, react.useState)(function () { return client.featureFlags.getFlags(); }), featureFlags = _d[0], setFeatureFlags = _d[1];
|
|
148
|
+
(0, react.useEffect)(function () {
|
|
100
149
|
return client.onFeatureFlags(function (flags) {
|
|
101
150
|
setFeatureFlags(flags);
|
|
102
151
|
});
|
|
103
152
|
}, [client]);
|
|
104
|
-
if (!((
|
|
105
|
-
return Object.entries(bootstrap.featureFlags)
|
|
106
|
-
|
|
107
|
-
var value = _a[1];
|
|
153
|
+
if (!((_b = client === null || client === void 0 ? void 0 : client.featureFlags) === null || _b === void 0 ? void 0 : _b.hasLoadedFlags) && (bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.featureFlags))
|
|
154
|
+
return Object.entries(bootstrap.featureFlags).filter(function (_b) {
|
|
155
|
+
var value = _b[1];
|
|
108
156
|
return value;
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
var key = _a[0];
|
|
157
|
+
}).map(function (_b) {
|
|
158
|
+
var key = _b[0];
|
|
112
159
|
return key;
|
|
113
160
|
});
|
|
114
|
-
}
|
|
115
161
|
return featureFlags;
|
|
116
162
|
}
|
|
117
|
-
|
|
118
163
|
function useFeatureFlagVariantKey(flag) {
|
|
119
|
-
var
|
|
120
|
-
var
|
|
121
|
-
var
|
|
122
|
-
|
|
123
|
-
}), featureFlagVariantKey = _c[0], setFeatureFlagVariantKey = _c[1];
|
|
124
|
-
React.useEffect(function () {
|
|
164
|
+
var _b;
|
|
165
|
+
var _c = (0, react.useContext)(PostHogContext), client = _c.client, bootstrap = _c.bootstrap;
|
|
166
|
+
var _d = (0, react.useState)(function () { return client.getFeatureFlag(flag); }), featureFlagVariantKey = _d[0], setFeatureFlagVariantKey = _d[1];
|
|
167
|
+
(0, react.useEffect)(function () {
|
|
125
168
|
return client.onFeatureFlags(function () {
|
|
126
169
|
setFeatureFlagVariantKey(client.getFeatureFlag(flag));
|
|
127
170
|
});
|
|
128
171
|
}, [client, flag]);
|
|
129
|
-
if (!((
|
|
172
|
+
if (!((_b = client === null || client === void 0 ? void 0 : client.featureFlags) === null || _b === void 0 ? void 0 : _b.hasLoadedFlags) && (bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.featureFlags))
|
|
130
173
|
return bootstrap.featureFlags[flag];
|
|
131
|
-
}
|
|
132
174
|
return featureFlagVariantKey;
|
|
133
175
|
}
|
|
134
|
-
|
|
135
176
|
var usePostHog = function () {
|
|
136
|
-
var client =
|
|
177
|
+
var client = (0, react.useContext)(PostHogContext).client;
|
|
137
178
|
return client;
|
|
138
179
|
};
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
149
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
150
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
151
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
152
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
153
|
-
***************************************************************************** */
|
|
154
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
155
|
-
|
|
156
|
-
var extendStatics = function(d, b) {
|
|
157
|
-
extendStatics = Object.setPrototypeOf ||
|
|
158
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
159
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
160
|
-
return extendStatics(d, b);
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
function __extends(d, b) {
|
|
164
|
-
if (typeof b !== "function" && b !== null)
|
|
165
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
166
|
-
extendStatics(d, b);
|
|
167
|
-
function __() { this.constructor = d; }
|
|
168
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
var __assign = function() {
|
|
172
|
-
__assign = Object.assign || function __assign(t) {
|
|
173
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
174
|
-
s = arguments[i];
|
|
175
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
176
|
-
}
|
|
177
|
-
return t;
|
|
178
|
-
};
|
|
179
|
-
return __assign.apply(this, arguments);
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
function __rest(s, e) {
|
|
183
|
-
var t = {};
|
|
184
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
185
|
-
t[p] = s[p];
|
|
186
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
187
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
188
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
189
|
-
t[p[i]] = s[p[i]];
|
|
190
|
-
}
|
|
191
|
-
return t;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
195
|
-
var e = new Error(message);
|
|
196
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
function VisibilityAndClickTracker(_a) {
|
|
200
|
-
var children = _a.children, onIntersect = _a.onIntersect, onClick = _a.onClick, trackView = _a.trackView, options = _a.options, props = __rest(_a, ["children", "onIntersect", "onClick", "trackView", "options"]);
|
|
201
|
-
var ref = React.useRef(null);
|
|
202
|
-
var observerOptions = React.useMemo(function () { return (__assign({ threshold: 0.1 }, options)); }, [options === null || options === void 0 ? void 0 : options.threshold, options === null || options === void 0 ? void 0 : options.root, options === null || options === void 0 ? void 0 : options.rootMargin]);
|
|
203
|
-
React.useEffect(function () {
|
|
180
|
+
function VisibilityAndClickTracker(_b) {
|
|
181
|
+
var children = _b.children, onIntersect = _b.onIntersect, onClick = _b.onClick, trackView = _b.trackView, options = _b.options, props = __rest(_b, ["children", "onIntersect", "onClick", "trackView", "options"]);
|
|
182
|
+
var ref = (0, react.useRef)(null);
|
|
183
|
+
var observerOptions = (0, react.useMemo)(function () { return (__assign({ threshold: .1 }, options)); }, [
|
|
184
|
+
options === null || options === void 0 ? void 0 : options.threshold,
|
|
185
|
+
options === null || options === void 0 ? void 0 : options.root,
|
|
186
|
+
options === null || options === void 0 ? void 0 : options.rootMargin
|
|
187
|
+
]);
|
|
188
|
+
(0, react.useEffect)(function () {
|
|
204
189
|
if (isNull(ref.current) || !trackView)
|
|
205
190
|
return;
|
|
206
|
-
var observer = new IntersectionObserver(function (
|
|
207
|
-
var entry =
|
|
191
|
+
var observer = new IntersectionObserver(function (_b) {
|
|
192
|
+
var entry = _b[0];
|
|
208
193
|
return onIntersect(entry);
|
|
209
194
|
}, observerOptions);
|
|
210
195
|
observer.observe(ref.current);
|
|
211
196
|
return function () { return observer.disconnect(); };
|
|
212
|
-
}, [
|
|
213
|
-
|
|
197
|
+
}, [
|
|
198
|
+
observerOptions,
|
|
199
|
+
trackView,
|
|
200
|
+
onIntersect
|
|
201
|
+
]);
|
|
202
|
+
return react.default.createElement("div", __assign(__assign({ ref: ref }, props), { onClick: onClick }), children);
|
|
214
203
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
var
|
|
218
|
-
var
|
|
219
|
-
var
|
|
220
|
-
var cachedOnClick = React.useCallback(function () {
|
|
204
|
+
function VisibilityAndClickTrackers(_b) {
|
|
205
|
+
var children = _b.children, trackInteraction = _b.trackInteraction, trackView = _b.trackView, options = _b.options, onInteract = _b.onInteract, onView = _b.onView, props = __rest(_b, ["children", "trackInteraction", "trackView", "options", "onInteract", "onView"]);
|
|
206
|
+
var clickTrackedRef = (0, react.useRef)(false);
|
|
207
|
+
var visibilityTrackedRef = (0, react.useRef)(false);
|
|
208
|
+
var cachedOnClick = (0, react.useCallback)(function () {
|
|
221
209
|
if (!clickTrackedRef.current && trackInteraction && onInteract) {
|
|
222
210
|
onInteract();
|
|
223
211
|
clickTrackedRef.current = true;
|
|
@@ -229,14 +217,13 @@
|
|
|
229
217
|
visibilityTrackedRef.current = true;
|
|
230
218
|
}
|
|
231
219
|
};
|
|
232
|
-
var trackedChildren =
|
|
233
|
-
return
|
|
220
|
+
var trackedChildren = react.Children.map(children, function (child) {
|
|
221
|
+
return react.default.createElement(VisibilityAndClickTracker, __assign({ onClick: cachedOnClick, onIntersect: onIntersect, trackView: trackView, options: options }, props), child);
|
|
234
222
|
});
|
|
235
|
-
return
|
|
223
|
+
return react.default.createElement(react.default.Fragment, null, trackedChildren);
|
|
236
224
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
var flag = _a.flag, match = _a.match, children = _a.children, fallback = _a.fallback, visibilityObserverOptions = _a.visibilityObserverOptions, trackInteraction = _a.trackInteraction, trackView = _a.trackView, props = __rest(_a, ["flag", "match", "children", "fallback", "visibilityObserverOptions", "trackInteraction", "trackView"]);
|
|
225
|
+
function PostHogFeature(_b) {
|
|
226
|
+
var flag = _b.flag, match = _b.match, children = _b.children, fallback = _b.fallback, visibilityObserverOptions = _b.visibilityObserverOptions, trackInteraction = _b.trackInteraction, trackView = _b.trackView, props = __rest(_b, ["flag", "match", "children", "fallback", "visibilityObserverOptions", "trackInteraction", "trackView"]);
|
|
240
227
|
var payload = useFeatureFlagPayload(flag);
|
|
241
228
|
var variant = useFeatureFlagVariantKey(flag);
|
|
242
229
|
var posthog = usePostHog();
|
|
@@ -245,68 +232,89 @@
|
|
|
245
232
|
if (!isUndefined(variant)) {
|
|
246
233
|
if (isUndefined(match) || variant === match) {
|
|
247
234
|
var childNode = isFunction(children) ? children(payload) : children;
|
|
248
|
-
return
|
|
235
|
+
return react.default.createElement(VisibilityAndClickTrackers, __assign({ flag: flag, options: visibilityObserverOptions, trackInteraction: shouldTrackInteraction, trackView: shouldTrackView, onInteract: function () { return captureFeatureInteraction({
|
|
236
|
+
flag: flag,
|
|
237
|
+
posthog: posthog,
|
|
238
|
+
flagVariant: variant
|
|
239
|
+
}); }, onView: function () { return captureFeatureView({
|
|
240
|
+
flag: flag,
|
|
241
|
+
posthog: posthog,
|
|
242
|
+
flagVariant: variant
|
|
243
|
+
}); } }, props), childNode);
|
|
249
244
|
}
|
|
250
245
|
}
|
|
251
|
-
return
|
|
246
|
+
return react.default.createElement(react.default.Fragment, null, fallback);
|
|
252
247
|
}
|
|
253
|
-
function captureFeatureEvent(event,
|
|
254
|
-
var
|
|
255
|
-
var flag =
|
|
248
|
+
function captureFeatureEvent(event, _b) {
|
|
249
|
+
var _c;
|
|
250
|
+
var flag = _b.flag, posthog = _b.posthog, flagVariant = _b.flagVariant;
|
|
256
251
|
var properties = {
|
|
257
252
|
feature_flag: flag,
|
|
258
|
-
$set: (
|
|
253
|
+
$set: (_c = {}, _c["".concat(event, "/").concat(flag)] = flagVariant !== null && flagVariant !== void 0 ? flagVariant : true, _c)
|
|
259
254
|
};
|
|
260
|
-
if (typeof flagVariant ===
|
|
255
|
+
if (typeof flagVariant === "string")
|
|
261
256
|
properties.feature_flag_variant = flagVariant;
|
|
262
|
-
}
|
|
263
257
|
posthog.capture(event, properties);
|
|
264
258
|
}
|
|
265
259
|
function captureFeatureInteraction(options) {
|
|
266
|
-
captureFeatureEvent(
|
|
260
|
+
captureFeatureEvent("$feature_interaction", options);
|
|
267
261
|
}
|
|
268
262
|
function captureFeatureView(options) {
|
|
269
|
-
captureFeatureEvent(
|
|
263
|
+
captureFeatureEvent("$feature_view", options);
|
|
270
264
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
var
|
|
274
|
-
var trackedRef = React.useRef(false);
|
|
265
|
+
function TrackedChild(_b) {
|
|
266
|
+
var child = _b.child, index = _b.index, name = _b.name, properties = _b.properties, observerOptions = _b.observerOptions;
|
|
267
|
+
var trackedRef = (0, react.useRef)(false);
|
|
275
268
|
var posthog = usePostHog();
|
|
276
|
-
var onIntersect =
|
|
269
|
+
var onIntersect = (0, react.useCallback)(function (entry) {
|
|
277
270
|
if (entry.isIntersecting && !trackedRef.current) {
|
|
278
|
-
posthog.capture(
|
|
271
|
+
posthog.capture("$element_viewed", __assign({ element_name: name, child_index: index }, properties));
|
|
279
272
|
trackedRef.current = true;
|
|
280
273
|
}
|
|
281
|
-
}, [
|
|
282
|
-
|
|
274
|
+
}, [
|
|
275
|
+
posthog,
|
|
276
|
+
name,
|
|
277
|
+
index,
|
|
278
|
+
properties
|
|
279
|
+
]);
|
|
280
|
+
return react.default.createElement(VisibilityAndClickTracker, {
|
|
281
|
+
onIntersect: onIntersect,
|
|
282
|
+
trackView: true,
|
|
283
|
+
options: observerOptions
|
|
284
|
+
}, child);
|
|
283
285
|
}
|
|
284
|
-
function PostHogCaptureOnViewed(
|
|
285
|
-
var name =
|
|
286
|
-
var trackedRef =
|
|
286
|
+
function PostHogCaptureOnViewed(_b) {
|
|
287
|
+
var name = _b.name, properties = _b.properties, observerOptions = _b.observerOptions, trackAllChildren = _b.trackAllChildren, children = _b.children, props = __rest(_b, ["name", "properties", "observerOptions", "trackAllChildren", "children"]);
|
|
288
|
+
var trackedRef = (0, react.useRef)(false);
|
|
287
289
|
var posthog = usePostHog();
|
|
288
|
-
var onIntersect =
|
|
290
|
+
var onIntersect = (0, react.useCallback)(function (entry) {
|
|
289
291
|
if (entry.isIntersecting && !trackedRef.current) {
|
|
290
|
-
posthog.capture(
|
|
292
|
+
posthog.capture("$element_viewed", __assign({ element_name: name }, properties));
|
|
291
293
|
trackedRef.current = true;
|
|
292
294
|
}
|
|
293
|
-
}, [
|
|
295
|
+
}, [
|
|
296
|
+
posthog,
|
|
297
|
+
name,
|
|
298
|
+
properties
|
|
299
|
+
]);
|
|
294
300
|
if (trackAllChildren) {
|
|
295
|
-
var trackedChildren =
|
|
296
|
-
return
|
|
301
|
+
var trackedChildren = react.Children.map(children, function (child, index) {
|
|
302
|
+
return react.default.createElement(TrackedChild, {
|
|
303
|
+
key: index,
|
|
304
|
+
child: child,
|
|
305
|
+
index: index,
|
|
306
|
+
name: name,
|
|
307
|
+
properties: properties,
|
|
308
|
+
observerOptions: observerOptions
|
|
309
|
+
});
|
|
297
310
|
});
|
|
298
|
-
return
|
|
311
|
+
return react.default.createElement("div", props, trackedChildren);
|
|
299
312
|
}
|
|
300
|
-
return
|
|
313
|
+
return react.default.createElement(VisibilityAndClickTracker, __assign({ onIntersect: onIntersect, trackView: true, options: observerOptions }, props), children);
|
|
301
314
|
}
|
|
302
|
-
|
|
303
315
|
var isError = function (value) {
|
|
304
316
|
var tag = Object.prototype.toString.call(value);
|
|
305
|
-
return
|
|
306
|
-
tag === '[object Error]' ||
|
|
307
|
-
tag === '[object Exception]' ||
|
|
308
|
-
tag === '[object DOMException]' ||
|
|
309
|
-
tag === '[object DOMError]');
|
|
317
|
+
return value instanceof Error || tag === "[object Error]" || tag === "[object Exception]" || tag === "[object DOMException]" || tag === "[object DOMError]";
|
|
310
318
|
};
|
|
311
319
|
var setCause = function (error, cause) {
|
|
312
320
|
var seenErrors = new WeakSet();
|
|
@@ -314,9 +322,8 @@
|
|
|
314
322
|
while (!seenErrors.has(currentError)) {
|
|
315
323
|
seenErrors.add(currentError);
|
|
316
324
|
if (!isError(currentError.cause)) {
|
|
317
|
-
if (!isUndefined(currentError.cause))
|
|
325
|
+
if (!isUndefined(currentError.cause))
|
|
318
326
|
cause.cause = currentError.cause;
|
|
319
|
-
}
|
|
320
327
|
currentError.cause = cause;
|
|
321
328
|
return;
|
|
322
329
|
}
|
|
@@ -324,11 +331,10 @@
|
|
|
324
331
|
}
|
|
325
332
|
};
|
|
326
333
|
var addReactComponentStack = function (error, componentStack) {
|
|
327
|
-
if (!componentStack)
|
|
334
|
+
if (!componentStack)
|
|
328
335
|
return error;
|
|
329
|
-
}
|
|
330
336
|
var componentStackError = new Error(isError(error) ? error.message : "Primitive value captured as exception: ".concat(String(error)));
|
|
331
|
-
componentStackError.name = "React ErrorBoundary ".concat(isError(error) ? error.name :
|
|
337
|
+
componentStackError.name = "React ErrorBoundary ".concat(isError(error) ? error.name : "Error");
|
|
332
338
|
componentStackError.stack = componentStack;
|
|
333
339
|
if (isError(error)) {
|
|
334
340
|
setCause(error, componentStackError);
|
|
@@ -336,72 +342,64 @@
|
|
|
336
342
|
}
|
|
337
343
|
return componentStackError;
|
|
338
344
|
};
|
|
339
|
-
|
|
340
345
|
var INITIAL_STATE = {
|
|
341
346
|
componentStack: null,
|
|
342
347
|
exceptionEvent: null,
|
|
343
|
-
error: null
|
|
348
|
+
error: null
|
|
344
349
|
};
|
|
345
|
-
var __POSTHOG_ERROR_MESSAGES = {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
_this.state = INITIAL_STATE;
|
|
353
|
-
return _this;
|
|
354
|
-
}
|
|
355
|
-
PostHogErrorBoundary.prototype.componentDidCatch = function (error, errorInfo) {
|
|
356
|
-
var additionalProperties = this.props.additionalProperties;
|
|
357
|
-
var currentProperties;
|
|
358
|
-
if (isFunction(additionalProperties)) {
|
|
359
|
-
currentProperties = additionalProperties(error, errorInfo);
|
|
350
|
+
var __POSTHOG_ERROR_MESSAGES = { INVALID_FALLBACK: "[PostHog.js][PostHogErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element." };
|
|
351
|
+
var PostHogErrorBoundary = (_a = (function (_super) {
|
|
352
|
+
__extends(class_1, _super);
|
|
353
|
+
function class_1(props) {
|
|
354
|
+
var _this = _super.call(this, props) || this;
|
|
355
|
+
_this.state = INITIAL_STATE;
|
|
356
|
+
return _this;
|
|
360
357
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
exceptionEvent
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
358
|
+
class_1.prototype.componentDidCatch = function (error, errorInfo) {
|
|
359
|
+
var additionalProperties = this.props.additionalProperties;
|
|
360
|
+
var currentProperties;
|
|
361
|
+
if (isFunction(additionalProperties))
|
|
362
|
+
currentProperties = additionalProperties(error, errorInfo);
|
|
363
|
+
else if (typeof additionalProperties === "object")
|
|
364
|
+
currentProperties = additionalProperties;
|
|
365
|
+
var client = this.context.client;
|
|
366
|
+
var componentStack = errorInfo.componentStack;
|
|
367
|
+
var exceptionEvent = client.captureException(addReactComponentStack(error, componentStack), currentProperties);
|
|
368
|
+
this.setState({
|
|
369
|
+
error: error,
|
|
370
|
+
componentStack: componentStack !== null && componentStack !== void 0 ? componentStack : null,
|
|
371
|
+
exceptionEvent: exceptionEvent
|
|
372
|
+
});
|
|
373
|
+
};
|
|
374
|
+
class_1.prototype.render = function () {
|
|
375
|
+
var _b = this.props, children = _b.children, fallback = _b.fallback;
|
|
376
|
+
var state = this.state;
|
|
377
|
+
if (state.componentStack == null)
|
|
378
|
+
return isFunction(children) ? children() : children;
|
|
379
|
+
var element = isFunction(fallback) ? react.default.createElement(fallback, {
|
|
381
380
|
error: state.error,
|
|
382
381
|
componentStack: state.componentStack,
|
|
383
|
-
exceptionEvent: state.exceptionEvent
|
|
384
|
-
})
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
return
|
|
391
|
-
}
|
|
392
|
-
PostHogErrorBoundary
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
382
|
+
exceptionEvent: state.exceptionEvent
|
|
383
|
+
}) : fallback;
|
|
384
|
+
if (react.default.isValidElement(element))
|
|
385
|
+
return element;
|
|
386
|
+
console.warn(__POSTHOG_ERROR_MESSAGES.INVALID_FALLBACK);
|
|
387
|
+
return react.default.createElement(react.default.Fragment, null);
|
|
388
|
+
};
|
|
389
|
+
return class_1;
|
|
390
|
+
}(react.default.Component)),
|
|
391
|
+
__setFunctionName(_a, "PostHogErrorBoundary"),
|
|
392
|
+
(function () {
|
|
393
|
+
_a.contextType = PostHogContext;
|
|
394
|
+
})(),
|
|
395
|
+
_a);
|
|
396
396
|
var setupReactErrorHandler = function (client, callback) {
|
|
397
397
|
return function (error, errorInfo) {
|
|
398
398
|
var event = client.captureException(addReactComponentStack(error, errorInfo.componentStack));
|
|
399
|
-
if (callback)
|
|
399
|
+
if (callback)
|
|
400
400
|
callback(event, error, errorInfo);
|
|
401
|
-
}
|
|
402
401
|
};
|
|
403
402
|
};
|
|
404
|
-
|
|
405
403
|
exports.PostHogCaptureOnViewed = PostHogCaptureOnViewed;
|
|
406
404
|
exports.PostHogContext = PostHogContext;
|
|
407
405
|
exports.PostHogErrorBoundary = PostHogErrorBoundary;
|
|
@@ -416,6 +414,6 @@
|
|
|
416
414
|
exports.useFeatureFlagResult = useFeatureFlagResult;
|
|
417
415
|
exports.useFeatureFlagVariantKey = useFeatureFlagVariantKey;
|
|
418
416
|
exports.usePostHog = usePostHog;
|
|
419
|
-
|
|
420
|
-
}));
|
|
421
|
-
//# sourceMappingURL=index.js.map
|
|
417
|
+
});
|
|
418
|
+
}).call(this);
|
|
419
|
+
//# sourceMappingURL=index.js.map
|