posthog-node 5.73.1 → 6.0.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/MIGRATION.md +556 -0
- package/README.md +3 -1
- package/dist/ai-capture/routing.d.ts +0 -3
- package/dist/ai-capture/routing.d.ts.map +1 -1
- package/dist/ai-capture/routing.js +2 -14
- package/dist/ai-capture/routing.mjs +1 -4
- package/dist/capture-lane/lane.d.ts +109 -0
- package/dist/capture-lane/lane.d.ts.map +1 -0
- package/dist/capture-lane/lane.js +308 -0
- package/dist/capture-lane/lane.mjs +270 -0
- package/dist/capture-lane/limits.d.ts +7 -0
- package/dist/capture-lane/limits.d.ts.map +1 -0
- package/dist/{capture-v1/config.js → capture-lane/limits.js} +13 -11
- package/dist/capture-lane/limits.mjs +4 -0
- package/dist/capture-lane/settings.d.ts +30 -0
- package/dist/capture-lane/settings.d.ts.map +1 -0
- package/dist/capture-lane/settings.js +100 -0
- package/dist/capture-lane/settings.mjs +47 -0
- package/dist/capture-v1/compression.d.ts +18 -0
- package/dist/capture-v1/compression.d.ts.map +1 -0
- package/dist/capture-v1/compression.js +70 -0
- package/dist/capture-v1/compression.mjs +26 -0
- package/dist/capture-v1/errors.d.ts +23 -7
- package/dist/capture-v1/errors.d.ts.map +1 -1
- package/dist/capture-v1/errors.js +37 -8
- package/dist/capture-v1/errors.mjs +29 -6
- package/dist/capture-v1/sender.d.ts +63 -23
- package/dist/capture-v1/sender.d.ts.map +1 -1
- package/dist/capture-v1/sender.js +281 -74
- package/dist/capture-v1/sender.mjs +275 -77
- package/dist/capture-v1/serialize.d.ts +28 -0
- package/dist/capture-v1/serialize.d.ts.map +1 -0
- package/dist/capture-v1/serialize.js +82 -0
- package/dist/capture-v1/serialize.mjs +38 -0
- package/dist/capture-v1/transform.d.ts +10 -25
- package/dist/capture-v1/transform.d.ts.map +1 -1
- package/dist/capture-v1/transform.js +33 -64
- package/dist/capture-v1/transform.mjs +28 -53
- package/dist/capture-v1/types.d.ts +16 -14
- package/dist/capture-v1/types.d.ts.map +1 -1
- package/dist/capture-v1/types.js +27 -1
- package/dist/capture-v1/types.mjs +3 -1
- package/dist/capture-v1/uuid.d.ts +9 -0
- package/dist/capture-v1/uuid.d.ts.map +1 -0
- package/dist/capture-v1/uuid.js +75 -0
- package/dist/capture-v1/uuid.mjs +34 -0
- package/dist/client.d.ts +201 -94
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +485 -246
- package/dist/client.mjs +485 -246
- package/dist/compression.node.d.ts +13 -0
- package/dist/compression.node.d.ts.map +1 -0
- package/dist/{capture-v1/routing.js → compression.node.js} +23 -16
- package/dist/compression.node.mjs +18 -0
- package/dist/entrypoints/index.node.d.ts +2 -0
- package/dist/entrypoints/index.node.d.ts.map +1 -1
- package/dist/entrypoints/index.node.js +11 -4
- package/dist/entrypoints/index.node.mjs +4 -0
- package/dist/event-defaults.d.ts +46 -0
- package/dist/event-defaults.d.ts.map +1 -0
- package/dist/event-defaults.js +141 -0
- package/dist/event-defaults.mjs +79 -0
- package/dist/exports.d.ts +3 -0
- package/dist/exports.d.ts.map +1 -1
- package/dist/exports.js +22 -11
- package/dist/exports.mjs +1 -0
- package/dist/extensions/context/context.d.ts +0 -1
- package/dist/extensions/context/context.d.ts.map +1 -1
- package/dist/extensions/context/context.js +4 -3
- package/dist/extensions/context/context.mjs +4 -3
- package/dist/extensions/context/event-context.d.ts.map +1 -1
- package/dist/extensions/context/event-context.js +3 -0
- package/dist/extensions/context/event-context.mjs +3 -0
- package/dist/extensions/context/types.d.ts +9 -1
- package/dist/extensions/context/types.d.ts.map +1 -1
- package/dist/extensions/error-tracking/index.d.ts +1 -1
- package/dist/extensions/error-tracking/index.d.ts.map +1 -1
- package/dist/extensions/error-tracking/index.js +71 -7
- package/dist/extensions/error-tracking/index.mjs +75 -11
- package/dist/extensions/express.d.ts +8 -0
- package/dist/extensions/express.d.ts.map +1 -1
- package/dist/extensions/express.js +3 -3
- package/dist/extensions/express.mjs +4 -4
- package/dist/extensions/fetch-request.d.ts.map +1 -1
- package/dist/extensions/fetch-request.js +2 -2
- package/dist/extensions/fetch-request.mjs +3 -3
- package/dist/extensions/nestjs.d.ts.map +1 -1
- package/dist/extensions/nestjs.js +7 -4
- package/dist/extensions/nestjs.mjs +8 -5
- package/dist/extensions/tracing-headers.d.ts +7 -0
- package/dist/extensions/tracing-headers.d.ts.map +1 -1
- package/dist/extensions/tracing-headers.js +11 -1
- package/dist/extensions/tracing-headers.mjs +9 -2
- package/dist/feature-flag-evaluations.d.ts +5 -5
- package/dist/feature-flag-evaluations.d.ts.map +1 -1
- package/dist/feature-flag-evaluations.js +16 -9
- package/dist/feature-flag-evaluations.mjs +16 -9
- package/dist/flag-events.d.ts +1 -1
- package/dist/flag-events.d.ts.map +1 -1
- package/dist/flag-events.js +2 -2
- package/dist/flag-events.mjs +2 -2
- package/dist/flags-response.d.ts +2 -0
- package/dist/flags-response.d.ts.map +1 -1
- package/dist/flags-response.js +6 -0
- package/dist/flags-response.mjs +4 -1
- package/dist/types.d.ts +192 -27
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/types.mjs +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +5 -4
- package/src/ai-capture/routing.ts +0 -6
- package/src/capture-lane/lane.ts +414 -0
- package/src/capture-lane/limits.ts +8 -0
- package/src/capture-lane/settings.ts +119 -0
- package/src/capture-v1/compression.ts +50 -0
- package/src/capture-v1/errors.ts +50 -11
- package/src/capture-v1/sender.ts +405 -111
- package/src/capture-v1/serialize.ts +77 -0
- package/src/capture-v1/transform.ts +59 -92
- package/src/capture-v1/types.ts +19 -15
- package/src/capture-v1/uuid.ts +53 -0
- package/src/client.ts +885 -446
- package/src/compression.node.ts +30 -0
- package/src/entrypoints/index.node.ts +6 -0
- package/src/event-defaults.ts +177 -0
- package/src/exports.ts +3 -0
- package/src/extensions/context/context.ts +4 -4
- package/src/extensions/context/event-context.ts +3 -1
- package/src/extensions/context/types.ts +10 -1
- package/src/extensions/error-tracking/index.ts +51 -7
- package/src/extensions/express.ts +12 -3
- package/src/extensions/fetch-request.ts +7 -3
- package/src/extensions/nestjs.ts +9 -5
- package/src/extensions/tracing-headers.ts +26 -7
- package/src/feature-flag-evaluations.ts +31 -23
- package/src/flag-events.ts +5 -2
- package/src/flags-response.ts +6 -1
- package/src/types.ts +212 -44
- package/src/version.ts +1 -1
- package/dist/ai-capture/batching.d.ts +0 -11
- package/dist/ai-capture/batching.d.ts.map +0 -1
- package/dist/ai-capture/batching.js +0 -77
- package/dist/ai-capture/batching.mjs +0 -36
- package/dist/capture-v1/config.d.ts +0 -11
- package/dist/capture-v1/config.d.ts.map +0 -1
- package/dist/capture-v1/config.mjs +0 -8
- package/dist/capture-v1/routing.d.ts +0 -21
- package/dist/capture-v1/routing.d.ts.map +0 -1
- package/dist/capture-v1/routing.mjs +0 -7
- package/src/ai-capture/batching.ts +0 -47
- package/src/capture-v1/config.ts +0 -18
- package/src/capture-v1/routing.ts +0 -28
|
@@ -30,6 +30,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
FeatureFlagEvaluations: ()=>FeatureFlagEvaluations
|
|
32
32
|
});
|
|
33
|
+
const external_flags_response_js_namespaceObject = require("./flags-response.js");
|
|
33
34
|
const external_types_js_namespaceObject = require("./types.js");
|
|
34
35
|
class FeatureFlagEvaluations {
|
|
35
36
|
constructor(init){
|
|
@@ -37,7 +38,10 @@ class FeatureFlagEvaluations {
|
|
|
37
38
|
this._distinctId = init.distinctId;
|
|
38
39
|
this._groups = init.groups;
|
|
39
40
|
this._disableGeoip = init.disableGeoip;
|
|
40
|
-
this._flags =
|
|
41
|
+
this._flags = Object.create(null);
|
|
42
|
+
this._failedFlags = Object.create(null);
|
|
43
|
+
for (const [key, flag] of Object.entries(init.flags))if (flag.parsed && (0, external_flags_response_js_namespaceObject.isServerFailedFlagRecord)(flag.parsed)) this._failedFlags[key] = flag;
|
|
44
|
+
else this._flags[key] = flag;
|
|
41
45
|
this._unresolvedFlags = Object.freeze({
|
|
42
46
|
...init.unresolvedFlags
|
|
43
47
|
});
|
|
@@ -65,18 +69,18 @@ class FeatureFlagEvaluations {
|
|
|
65
69
|
return this._flags[key]?.payload;
|
|
66
70
|
}
|
|
67
71
|
onlyAccessed() {
|
|
68
|
-
const filtered =
|
|
72
|
+
const filtered = Object.create(null);
|
|
69
73
|
for (const key of this._accessed){
|
|
70
|
-
const flag = this._flags[key];
|
|
74
|
+
const flag = this._flags[key] ?? this._failedFlags[key];
|
|
71
75
|
if (flag) filtered[key] = flag;
|
|
72
76
|
}
|
|
73
77
|
return this._cloneWith(filtered);
|
|
74
78
|
}
|
|
75
79
|
only(keys) {
|
|
76
|
-
const filtered =
|
|
80
|
+
const filtered = Object.create(null);
|
|
77
81
|
const missing = [];
|
|
78
82
|
for (const key of keys){
|
|
79
|
-
const flag = this._flags[key];
|
|
83
|
+
const flag = this._flags[key] ?? this._failedFlags[key];
|
|
80
84
|
if (flag) filtered[key] = flag;
|
|
81
85
|
else missing.push(key);
|
|
82
86
|
}
|
|
@@ -123,9 +127,10 @@ class FeatureFlagEvaluations {
|
|
|
123
127
|
this._accessed.add(key);
|
|
124
128
|
if (!this._host.resolveSendFeatureFlagEvents(sendFeatureFlagEvents)) return;
|
|
125
129
|
if ('' === this._distinctId) return;
|
|
126
|
-
if (this._isSlice && !(key in this._flags)) return;
|
|
127
|
-
const
|
|
128
|
-
const
|
|
130
|
+
if (this._isSlice && !(key in this._flags) && !(key in this._failedFlags)) return;
|
|
131
|
+
const failed = key in this._failedFlags;
|
|
132
|
+
const flag = this._flags[key] ?? this._failedFlags[key];
|
|
133
|
+
const response = void 0 === flag || failed ? void 0 : false === flag.enabled ? false : flag.variant ?? true;
|
|
129
134
|
const properties = {
|
|
130
135
|
$feature_flag: key,
|
|
131
136
|
$feature_flag_response: response,
|
|
@@ -142,7 +147,9 @@ class FeatureFlagEvaluations {
|
|
|
142
147
|
const errors = [];
|
|
143
148
|
if (this._errorsWhileComputing) errors.push(external_types_js_namespaceObject.FeatureFlagError.ERRORS_WHILE_COMPUTING);
|
|
144
149
|
if (this._quotaLimited) errors.push(external_types_js_namespaceObject.FeatureFlagError.QUOTA_LIMITED);
|
|
145
|
-
if (
|
|
150
|
+
if (failed) errors.push(external_types_js_namespaceObject.FeatureFlagError.EVALUATION_FAILED);
|
|
151
|
+
if (Object.prototype.hasOwnProperty.call(this._unresolvedFlags, key)) errors.push(external_types_js_namespaceObject.FeatureFlagError.LOCAL_EVALUATION_INCONCLUSIVE);
|
|
152
|
+
else if (void 0 === flag) errors.push(external_types_js_namespaceObject.FeatureFlagError.FLAG_MISSING);
|
|
146
153
|
if (errors.length > 0) properties.$feature_flag_error = errors.join(',');
|
|
147
154
|
this._host.captureFlagCalledEventIfNeeded({
|
|
148
155
|
distinctId: this._distinctId,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isServerFailedFlagRecord } from "./flags-response.mjs";
|
|
1
2
|
import { FeatureFlagError } from "./types.mjs";
|
|
2
3
|
class FeatureFlagEvaluations {
|
|
3
4
|
constructor(init){
|
|
@@ -5,7 +6,10 @@ class FeatureFlagEvaluations {
|
|
|
5
6
|
this._distinctId = init.distinctId;
|
|
6
7
|
this._groups = init.groups;
|
|
7
8
|
this._disableGeoip = init.disableGeoip;
|
|
8
|
-
this._flags =
|
|
9
|
+
this._flags = Object.create(null);
|
|
10
|
+
this._failedFlags = Object.create(null);
|
|
11
|
+
for (const [key, flag] of Object.entries(init.flags))if (flag.parsed && isServerFailedFlagRecord(flag.parsed)) this._failedFlags[key] = flag;
|
|
12
|
+
else this._flags[key] = flag;
|
|
9
13
|
this._unresolvedFlags = Object.freeze({
|
|
10
14
|
...init.unresolvedFlags
|
|
11
15
|
});
|
|
@@ -33,18 +37,18 @@ class FeatureFlagEvaluations {
|
|
|
33
37
|
return this._flags[key]?.payload;
|
|
34
38
|
}
|
|
35
39
|
onlyAccessed() {
|
|
36
|
-
const filtered =
|
|
40
|
+
const filtered = Object.create(null);
|
|
37
41
|
for (const key of this._accessed){
|
|
38
|
-
const flag = this._flags[key];
|
|
42
|
+
const flag = this._flags[key] ?? this._failedFlags[key];
|
|
39
43
|
if (flag) filtered[key] = flag;
|
|
40
44
|
}
|
|
41
45
|
return this._cloneWith(filtered);
|
|
42
46
|
}
|
|
43
47
|
only(keys) {
|
|
44
|
-
const filtered =
|
|
48
|
+
const filtered = Object.create(null);
|
|
45
49
|
const missing = [];
|
|
46
50
|
for (const key of keys){
|
|
47
|
-
const flag = this._flags[key];
|
|
51
|
+
const flag = this._flags[key] ?? this._failedFlags[key];
|
|
48
52
|
if (flag) filtered[key] = flag;
|
|
49
53
|
else missing.push(key);
|
|
50
54
|
}
|
|
@@ -91,9 +95,10 @@ class FeatureFlagEvaluations {
|
|
|
91
95
|
this._accessed.add(key);
|
|
92
96
|
if (!this._host.resolveSendFeatureFlagEvents(sendFeatureFlagEvents)) return;
|
|
93
97
|
if ('' === this._distinctId) return;
|
|
94
|
-
if (this._isSlice && !(key in this._flags)) return;
|
|
95
|
-
const
|
|
96
|
-
const
|
|
98
|
+
if (this._isSlice && !(key in this._flags) && !(key in this._failedFlags)) return;
|
|
99
|
+
const failed = key in this._failedFlags;
|
|
100
|
+
const flag = this._flags[key] ?? this._failedFlags[key];
|
|
101
|
+
const response = void 0 === flag || failed ? void 0 : false === flag.enabled ? false : flag.variant ?? true;
|
|
97
102
|
const properties = {
|
|
98
103
|
$feature_flag: key,
|
|
99
104
|
$feature_flag_response: response,
|
|
@@ -110,7 +115,9 @@ class FeatureFlagEvaluations {
|
|
|
110
115
|
const errors = [];
|
|
111
116
|
if (this._errorsWhileComputing) errors.push(FeatureFlagError.ERRORS_WHILE_COMPUTING);
|
|
112
117
|
if (this._quotaLimited) errors.push(FeatureFlagError.QUOTA_LIMITED);
|
|
113
|
-
if (
|
|
118
|
+
if (failed) errors.push(FeatureFlagError.EVALUATION_FAILED);
|
|
119
|
+
if (Object.prototype.hasOwnProperty.call(this._unresolvedFlags, key)) errors.push(FeatureFlagError.LOCAL_EVALUATION_INCONCLUSIVE);
|
|
120
|
+
else if (void 0 === flag) errors.push(FeatureFlagError.FLAG_MISSING);
|
|
114
121
|
if (errors.length > 0) properties.$feature_flag_error = errors.join(',');
|
|
115
122
|
this._host.captureFlagCalledEventIfNeeded({
|
|
116
123
|
distinctId: this._distinctId,
|
package/dist/flag-events.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export declare function applyFlagEventCapture(properties: Record<string, any>, c
|
|
|
66
66
|
*
|
|
67
67
|
* @internal
|
|
68
68
|
*/
|
|
69
|
-
export declare function minimizeConfigVersion2FlagCalledProperties(properties: Record<string, any
|
|
69
|
+
export declare function minimizeConfigVersion2FlagCalledProperties(properties: Record<string, any>, transportKeys?: readonly string[]): Record<string, any>;
|
|
70
70
|
/**
|
|
71
71
|
* One flag event of a read, sent once per key in its own dedupe namespace.
|
|
72
72
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flag-events.d.ts","sourceRoot":"","sources":["../src/flag-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAqC,MAAM,eAAe,CAAA;AAEnF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAExD;;;;;;;;;GASG;AAEH,eAAO,MAAM,yBAAyB,yBAAyB,CAAA;AAC/D,eAAO,MAAM,yBAAyB,yBAAyB,CAAA;AAkB/D,mGAAmG;AACnG,eAAO,MAAM,uCAAuC,EAAE,SAAS,MAAM,EAMpE,CAAA;AAkCD;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,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G,SAAS,CAAA;CACzC,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE;IACpD,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,gBAAgB,GAAG,SAAS,CAAA;IACtC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,SAAS,CAAA;IACnD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAAA;CACrC,GAAG,wBAAwB,GAAG,SAAS,CAsEvC"}
|
package/dist/flag-events.js
CHANGED
|
@@ -136,8 +136,8 @@ function applyFlagEventCapture(properties, capture) {
|
|
|
136
136
|
...capture.pinned
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
|
-
function minimizeConfigVersion2FlagCalledProperties(properties) {
|
|
140
|
-
const minimal = (0, core_namespaceObject.minimizeFlagCalledEventProperties)(properties);
|
|
139
|
+
function minimizeConfigVersion2FlagCalledProperties(properties, transportKeys = []) {
|
|
140
|
+
const minimal = (0, core_namespaceObject.minimizeFlagCalledEventProperties)(properties, transportKeys);
|
|
141
141
|
for (const name of CONFIG_VERSION_2_ATTRIBUTION_PROPERTIES)if (void 0 !== properties[name]) minimal[name] = properties[name];
|
|
142
142
|
return minimal;
|
|
143
143
|
}
|
package/dist/flag-events.mjs
CHANGED
|
@@ -98,8 +98,8 @@ function applyFlagEventCapture(properties, capture) {
|
|
|
98
98
|
...capture.pinned
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
-
function minimizeConfigVersion2FlagCalledProperties(properties) {
|
|
102
|
-
const minimal = minimizeFlagCalledEventProperties(properties);
|
|
101
|
+
function minimizeConfigVersion2FlagCalledProperties(properties, transportKeys = []) {
|
|
102
|
+
const minimal = minimizeFlagCalledEventProperties(properties, transportKeys);
|
|
103
103
|
for (const name of CONFIG_VERSION_2_ATTRIBUTION_PROPERTIES)if (void 0 !== properties[name]) minimal[name] = properties[name];
|
|
104
104
|
return minimal;
|
|
105
105
|
}
|
package/dist/flags-response.d.ts
CHANGED
|
@@ -78,6 +78,8 @@ export declare function readFlagRecords(body: unknown): {
|
|
|
78
78
|
* @internal
|
|
79
79
|
*/
|
|
80
80
|
export declare function parsedFlagRecordOf(detail: FeatureFlagDetail): ParsedFlagRecord;
|
|
81
|
+
/** Whether a readable record reports a server evaluation failure, rather than a parser failure. */
|
|
82
|
+
export declare function isServerFailedFlagRecord(record: ParsedFlagRecord): boolean;
|
|
81
83
|
/** Whether a flag's record had a known field with the wrong JSON type, so it could not be read. */
|
|
82
84
|
export declare function isUnreadableFlagRecord(detail: FeatureFlagDetail): boolean;
|
|
83
85
|
//# sourceMappingURL=flags-response.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flags-response.d.ts","sourceRoot":"","sources":["../src/flags-response.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAQjB,QAAQ,EACT,MAAM,eAAe,CAAA;AAEtB;;;;;;;;;;;GAWG;AAEH;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,GAAG,IAAI,CAAA;AAE5F;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAA;IAC/B,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAChB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;QAChC,QAAQ,CAAC,WAAW,C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KG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,GAAG,gBAAgB,CAqB9E;AAED,mGAAmG;AACnG,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAE1E;AAED,mGAAmG;AACnG,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAEzE"}
|
package/dist/flags-response.js
CHANGED
|
@@ -29,6 +29,7 @@ var __webpack_exports__ = {};
|
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
FLAGS_RESPONSE_WITHOUT_TYPED_VALUES_MESSAGE: ()=>FLAGS_RESPONSE_WITHOUT_TYPED_VALUES_MESSAGE,
|
|
32
|
+
isServerFailedFlagRecord: ()=>isServerFailedFlagRecord,
|
|
32
33
|
isUnreadableFlagRecord: ()=>isUnreadableFlagRecord,
|
|
33
34
|
parsedFlagRecordOf: ()=>parsedFlagRecordOf,
|
|
34
35
|
readFlagRecords: ()=>readFlagRecords
|
|
@@ -93,6 +94,9 @@ function parsedFlagRecordOf(detail) {
|
|
|
93
94
|
}
|
|
94
95
|
};
|
|
95
96
|
}
|
|
97
|
+
function isServerFailedFlagRecord(record) {
|
|
98
|
+
return record.failed && void 0 === record.unreadableField;
|
|
99
|
+
}
|
|
96
100
|
function isUnreadableFlagRecord(detail) {
|
|
97
101
|
return parsedRecords.get(detail)?.unreadableField !== void 0;
|
|
98
102
|
}
|
|
@@ -241,11 +245,13 @@ function optionalInteger(value, field) {
|
|
|
241
245
|
return optional(value, field, (candidate)=>(0, core_namespaceObject.isNumber)(candidate) && Number.isInteger(candidate));
|
|
242
246
|
}
|
|
243
247
|
exports.FLAGS_RESPONSE_WITHOUT_TYPED_VALUES_MESSAGE = __webpack_exports__.FLAGS_RESPONSE_WITHOUT_TYPED_VALUES_MESSAGE;
|
|
248
|
+
exports.isServerFailedFlagRecord = __webpack_exports__.isServerFailedFlagRecord;
|
|
244
249
|
exports.isUnreadableFlagRecord = __webpack_exports__.isUnreadableFlagRecord;
|
|
245
250
|
exports.parsedFlagRecordOf = __webpack_exports__.parsedFlagRecordOf;
|
|
246
251
|
exports.readFlagRecords = __webpack_exports__.readFlagRecords;
|
|
247
252
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
248
253
|
"FLAGS_RESPONSE_WITHOUT_TYPED_VALUES_MESSAGE",
|
|
254
|
+
"isServerFailedFlagRecord",
|
|
249
255
|
"isUnreadableFlagRecord",
|
|
250
256
|
"parsedFlagRecordOf",
|
|
251
257
|
"readFlagRecords"
|
package/dist/flags-response.mjs
CHANGED
|
@@ -58,6 +58,9 @@ function parsedFlagRecordOf(detail) {
|
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
+
function isServerFailedFlagRecord(record) {
|
|
62
|
+
return record.failed && void 0 === record.unreadableField;
|
|
63
|
+
}
|
|
61
64
|
function isUnreadableFlagRecord(detail) {
|
|
62
65
|
return parsedRecords.get(detail)?.unreadableField !== void 0;
|
|
63
66
|
}
|
|
@@ -205,4 +208,4 @@ function optional(value, field, is) {
|
|
|
205
208
|
function optionalInteger(value, field) {
|
|
206
209
|
return optional(value, field, (candidate)=>isNumber(candidate) && Number.isInteger(candidate));
|
|
207
210
|
}
|
|
208
|
-
export { FLAGS_RESPONSE_WITHOUT_TYPED_VALUES_MESSAGE, isUnreadableFlagRecord, parsedFlagRecordOf, readFlagRecords };
|
|
211
|
+
export { FLAGS_RESPONSE_WITHOUT_TYPED_VALUES_MESSAGE, isServerFailedFlagRecord, isUnreadableFlagRecord, parsedFlagRecordOf, readFlagRecords };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import type { PostHogCoreOptions, ExceptionRateLimiterConfig, FeatureFlagValue, JsonType, Metrics, MetricsConfig, PostHogLogsConfig, PostHogFetchOptions, PostHogFetchResponse, PostHogFlagsAndPayloadsResponse, Properties, Span, StartSpanOptions, TracesConfig } from '@posthog/core';
|
|
1
|
+
import type { ErrorTracking, PostHogCoreOptions, ExceptionRateLimiterConfig, FeatureFlagValue, JsonType, Metrics, MetricsConfig, PostHogLogsConfig, PostHogFetchOptions, PostHogFetchResponse, PostHogEventProperties, PostHogFlagsAndPayloadsResponse, Properties, Span, StartSpanOptions, TracesConfig } from '@posthog/core';
|
|
2
2
|
import { ContextData, ContextOptions } from './extensions/context/types';
|
|
3
|
+
import type { V1EventOptions } from './capture-v1/types';
|
|
4
|
+
/** Processing options sent with an event to capture v1. */
|
|
5
|
+
export type EventOptions = V1EventOptions;
|
|
3
6
|
import type { Emails } from './emails/types';
|
|
4
7
|
import type { FeatureFlagEvaluations } from './feature-flag-evaluations';
|
|
5
8
|
import type { FlagDefinitionCacheInput, FlagDefinitionCacheProvider } from './extensions/feature-flags/cache';
|
|
@@ -7,15 +10,27 @@ export type IdentifyMessage = {
|
|
|
7
10
|
distinctId: string;
|
|
8
11
|
properties?: Record<string | number, any>;
|
|
9
12
|
disableGeoip?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Processing options sent with this event to capture v1.
|
|
15
|
+
*/
|
|
16
|
+
options?: EventOptions;
|
|
10
17
|
};
|
|
11
18
|
export type SetPersonPropertiesMessage = {
|
|
12
19
|
distinctId: string;
|
|
13
20
|
properties?: Record<string | number, any>;
|
|
14
21
|
propertiesOnce?: Record<string | number, any>;
|
|
22
|
+
/**
|
|
23
|
+
* Processing options sent with this event to capture v1.
|
|
24
|
+
*/
|
|
25
|
+
options?: EventOptions;
|
|
15
26
|
};
|
|
16
27
|
export type UnsetPersonPropertiesMessage = {
|
|
17
28
|
distinctId: string;
|
|
18
29
|
properties: string | string[];
|
|
30
|
+
/**
|
|
31
|
+
* Processing options sent with this event to capture v1.
|
|
32
|
+
*/
|
|
33
|
+
options?: EventOptions;
|
|
19
34
|
};
|
|
20
35
|
export type SendFeatureFlagsOptions = {
|
|
21
36
|
onlyEvaluateLocally?: boolean;
|
|
@@ -24,6 +39,10 @@ export type SendFeatureFlagsOptions = {
|
|
|
24
39
|
flagKeys?: string[];
|
|
25
40
|
};
|
|
26
41
|
export type EventMessage = Omit<IdentifyMessage, 'distinctId'> & {
|
|
42
|
+
/**
|
|
43
|
+
* The event's distinct id. When it is missing, empty or only whitespace, the context distinct id
|
|
44
|
+
* is used; without one, the event gets a generated id and `options.process_person_profile: false`.
|
|
45
|
+
*/
|
|
27
46
|
distinctId?: string;
|
|
28
47
|
event: string;
|
|
29
48
|
groups?: Record<string, string | number>;
|
|
@@ -50,12 +69,56 @@ export type EventMessage = Omit<IdentifyMessage, 'distinctId'> & {
|
|
|
50
69
|
*/
|
|
51
70
|
_originatedFromCaptureException?: boolean;
|
|
52
71
|
};
|
|
72
|
+
/** Options for `captureException()` and `captureExceptionImmediate()`. */
|
|
73
|
+
export type CaptureExceptionOptions = {
|
|
74
|
+
/** The event's distinct id. Without one, the context distinct id is used, else a personless id. */
|
|
75
|
+
distinctId?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Properties to add to the event. Exception properties the SDK or PostHog owns, such as
|
|
78
|
+
* `$exception_list` and `$exception_level`, are ignored: use `level` to set the level.
|
|
79
|
+
*/
|
|
80
|
+
properties?: Record<string | number, any>;
|
|
81
|
+
/** Per-event options, as in `capture()`. */
|
|
82
|
+
options?: EventOptions;
|
|
83
|
+
/** Overrides the generated event UUID. Must be a valid UUID. */
|
|
84
|
+
uuid?: string;
|
|
85
|
+
/** A `FeatureFlagEvaluations` snapshot to attach the same flag context as your other events. */
|
|
86
|
+
flags?: FeatureFlagEvaluations;
|
|
87
|
+
/**
|
|
88
|
+
* The exception's severity, sent as `$exception_level`. An unknown value is ignored.
|
|
89
|
+
*
|
|
90
|
+
* @default 'error'
|
|
91
|
+
*/
|
|
92
|
+
level?: ErrorTracking.SeverityLevel;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* An event as `prepareEventMessage()` builds it: the shape of `EventMessage`, with the distinct id
|
|
96
|
+
* resolved and the properties and options filled from every layer, after `beforeSend`.
|
|
97
|
+
*/
|
|
98
|
+
export type PreparedEventMessage = {
|
|
99
|
+
distinctId: string;
|
|
100
|
+
event: string;
|
|
101
|
+
properties: PostHogEventProperties;
|
|
102
|
+
/** The event's options, sent to capture unchanged. */
|
|
103
|
+
options?: EventOptions;
|
|
104
|
+
uuid?: string;
|
|
105
|
+
timestamp?: Date;
|
|
106
|
+
disableGeoip?: boolean;
|
|
107
|
+
};
|
|
53
108
|
export type GroupIdentifyMessage = {
|
|
54
109
|
groupType: string;
|
|
55
110
|
groupKey: string;
|
|
56
111
|
properties?: Record<string | number, any>;
|
|
112
|
+
/**
|
|
113
|
+
* The event's distinct id. When it is missing, empty or only whitespace, the context distinct id
|
|
114
|
+
* is used, then `$<groupType>_<groupKey>`.
|
|
115
|
+
*/
|
|
57
116
|
distinctId?: string;
|
|
58
117
|
disableGeoip?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Processing options sent with this event to capture v1.
|
|
120
|
+
*/
|
|
121
|
+
options?: EventOptions;
|
|
59
122
|
};
|
|
60
123
|
export type PropertyGroup = {
|
|
61
124
|
type: 'AND' | 'OR';
|
|
@@ -130,8 +193,23 @@ export type FeatureFlagBucketingIdentifier = 'distinct_id' | 'device_id' | '' |
|
|
|
130
193
|
*/
|
|
131
194
|
export type FeatureFlagEvaluationRuntime = 'all' | 'client' | 'server';
|
|
132
195
|
export type BeforeSendFn = (event: EventMessage) => EventMessage | null;
|
|
133
|
-
export type PostHogOptions = Omit<PostHogCoreOptions, 'before_send' | 'flushInterval' | 'maxQueueSize'> & {
|
|
196
|
+
export type PostHogOptions = Omit<PostHogCoreOptions, 'before_send' | 'disable_capture_url_hashes' | 'disableGeoip' | 'flushInterval' | 'maxQueueSize' | 'fetchRetryCount' | 'fetchRetryDelay' | 'disableCompression' | 'requestTimeout'> & {
|
|
134
197
|
persistence?: 'memory';
|
|
198
|
+
/**
|
|
199
|
+
* Whether to strip URL fragments (`#...`) from automatically captured request URLs.
|
|
200
|
+
*
|
|
201
|
+
* @default false
|
|
202
|
+
*/
|
|
203
|
+
disableCaptureUrlHashes?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Whether to disable GeoIP lookups for events and feature flag requests. When on, every event
|
|
206
|
+
* gets `$geoip_disable: true` unless the event, its context or `register()` sets
|
|
207
|
+
* `$geoip_disable`. A per-call `disableGeoip` argument sets it for that event, under the event's
|
|
208
|
+
* own `$geoip_disable` property.
|
|
209
|
+
*
|
|
210
|
+
* @default true
|
|
211
|
+
*/
|
|
212
|
+
disableGeoip?: boolean;
|
|
135
213
|
/**
|
|
136
214
|
* The interval in milliseconds between periodic flushes
|
|
137
215
|
*
|
|
@@ -139,13 +217,88 @@ export type PostHogOptions = Omit<PostHogCoreOptions, 'before_send' | 'flushInte
|
|
|
139
217
|
*/
|
|
140
218
|
flushInterval?: number;
|
|
141
219
|
/**
|
|
142
|
-
* The maximum number of
|
|
220
|
+
* The maximum number of analytics events held in memory waiting to be sent (must be higher than `flushAt`).
|
|
221
|
+
* When the queue is full, the oldest event is dropped and reported through the `'error'` event.
|
|
222
|
+
* `captureAi` events have their own queue, sized by `captureAiMaxQueueSize`, and do not count toward this limit.
|
|
143
223
|
*
|
|
144
224
|
* @default 10000
|
|
145
225
|
*/
|
|
146
226
|
maxQueueSize?: number;
|
|
147
227
|
/**
|
|
148
|
-
*
|
|
228
|
+
* Whether the Express, NestJS, Hono, and `instrumentRequest` integrations read the `X-POSTHOG-DISTINCT-ID` and
|
|
229
|
+
* `X-POSTHOG-SESSION-ID` request headers into the request context. A distinct id or session id
|
|
230
|
+
* you pass explicitly always wins over these headers, and they are never used for authentication.
|
|
231
|
+
* Turning it off does not turn off `readPostHogCookie`. To stop all request linking, set
|
|
232
|
+
* `captureTracingHeaders: false` and leave `readPostHogCookie` off (its default).
|
|
233
|
+
*
|
|
234
|
+
* @default true
|
|
235
|
+
*/
|
|
236
|
+
captureTracingHeaders?: boolean;
|
|
237
|
+
/**
|
|
238
|
+
* How many times a capture request is retried after its first attempt, on both capture lanes.
|
|
239
|
+
* Waits start at 100 ms and double each retry, with jitter, up to 30 seconds; a `Retry-After`
|
|
240
|
+
* header can raise a wait. Only HTTP 404, 408, 429, 500, 502, 503 and 504 and network errors are retried.
|
|
241
|
+
* When not set, `fetchRetryCount` is used.
|
|
242
|
+
*
|
|
243
|
+
* @default 3
|
|
244
|
+
*/
|
|
245
|
+
captureMaxRetries?: number;
|
|
246
|
+
/**
|
|
247
|
+
* How many times HTTP requests are retried. Capture requests use `captureMaxRetries` when it is set.
|
|
248
|
+
*
|
|
249
|
+
* @default 3
|
|
250
|
+
*/
|
|
251
|
+
fetchRetryCount?: number;
|
|
252
|
+
/**
|
|
253
|
+
* The delay between HTTP request retries in milliseconds. Capture requests do not use it:
|
|
254
|
+
* see `captureMaxRetries` for their retry waits.
|
|
255
|
+
*
|
|
256
|
+
* @default 3000
|
|
257
|
+
*/
|
|
258
|
+
fetchRetryDelay?: number;
|
|
259
|
+
/**
|
|
260
|
+
* How analytics capture requests compress their body. `'deflate'` is zlib-wrapped. `'zstd'` needs
|
|
261
|
+
* Node 22.15 or later and falls back to `'gzip'` elsewhere, including the edge build. When not set,
|
|
262
|
+
* `disableCompression: true` means `'none'`.
|
|
263
|
+
*
|
|
264
|
+
* @default 'gzip'
|
|
265
|
+
*/
|
|
266
|
+
captureCompression?: 'none' | 'gzip' | 'deflate' | 'zstd';
|
|
267
|
+
/**
|
|
268
|
+
* How `captureAi` requests compress their body, with the same values as `captureCompression`.
|
|
269
|
+
* It does not read `captureCompression` or `disableCompression`.
|
|
270
|
+
*
|
|
271
|
+
* @default 'gzip'
|
|
272
|
+
*/
|
|
273
|
+
captureAiCompression?: 'none' | 'gzip' | 'deflate' | 'zstd';
|
|
274
|
+
/**
|
|
275
|
+
* Timeout in milliseconds for any calls. `captureAi` requests use `captureAiRequestTimeoutMs`.
|
|
276
|
+
*
|
|
277
|
+
* @default 10000
|
|
278
|
+
*/
|
|
279
|
+
requestTimeout?: number;
|
|
280
|
+
/**
|
|
281
|
+
* The maximum number of `captureAi` events held in memory waiting to be sent. When the queue is
|
|
282
|
+
* full, the oldest AI event is dropped and reported through the `'error'` event.
|
|
283
|
+
*
|
|
284
|
+
* @default 1000
|
|
285
|
+
*/
|
|
286
|
+
captureAiMaxQueueSize?: number;
|
|
287
|
+
/**
|
|
288
|
+
* Timeout in milliseconds for each `captureAi` request. Analytics capture requests use `requestTimeout`.
|
|
289
|
+
*
|
|
290
|
+
* @default 30000
|
|
291
|
+
*/
|
|
292
|
+
captureAiRequestTimeoutMs?: number;
|
|
293
|
+
/**
|
|
294
|
+
* Whether to disable GZIP compression. Analytics capture requests use `captureCompression` when it
|
|
295
|
+
* is set, and `captureAi` requests use `captureAiCompression`.
|
|
296
|
+
*
|
|
297
|
+
* @default false
|
|
298
|
+
*/
|
|
299
|
+
disableCompression?: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Lets the Express, NestJS, Hono, and `instrumentRequest` integrations read the session ID, and the distinct ID of an identified user, from the
|
|
149
302
|
* posthog-js cookie when a request has neither tracing header.
|
|
150
303
|
*
|
|
151
304
|
* Turn it on only when posthog-js stores opt-out consent in a cookie, or when you do not use opt-out: the server
|
|
@@ -157,7 +310,8 @@ export type PostHogOptions = Omit<PostHogCoreOptions, 'before_send' | 'flushInte
|
|
|
157
310
|
* `optOutCapturingByDefault` when posthog-js uses `opt_out_capturing_by_default`, so a visitor with no consent cookie
|
|
158
311
|
* counts as opted out. A request sent right
|
|
159
312
|
* after `identify()` or `reset()` can still carry the previous identity, because posthog-js saves the cookie with a
|
|
160
|
-
* short delay.
|
|
313
|
+
* short delay. When `captureTracingHeaders` is `false`, the tracing headers are ignored and every request falls
|
|
314
|
+
* back to the cookie. To stop all request linking, also leave this option off.
|
|
161
315
|
*
|
|
162
316
|
* @default false
|
|
163
317
|
*/
|
|
@@ -266,10 +420,15 @@ export type PostHogOptions = Omit<PostHogCoreOptions, 'before_send' | 'flushInte
|
|
|
266
420
|
enableExceptionAutocapture?: boolean;
|
|
267
421
|
/**
|
|
268
422
|
* The interval in milliseconds between polls for refreshing feature flag definitions. Defaults to 30 seconds.
|
|
423
|
+
* The minimum is 100 ms, and a lower value is raised to it.
|
|
269
424
|
* Set to null to disable automatic polling. Definitions are still loaded on initialization;
|
|
270
425
|
* call reloadFeatureFlags() to refresh them manually. Until refreshed, local evaluation uses the last loaded definitions.
|
|
271
426
|
*/
|
|
272
427
|
featureFlagsPollingInterval?: number | null;
|
|
428
|
+
/**
|
|
429
|
+
* Maximum number of distinct ids held in the cache that deduplicates $feature_flag_called calls
|
|
430
|
+
* per user. When the cache is full the least recently used distinct ids are evicted. Defaults to 50000.
|
|
431
|
+
*/
|
|
273
432
|
maxCacheSize?: number;
|
|
274
433
|
fetch?: (url: string, options: PostHogFetchOptions) => Promise<PostHogFetchResponse>;
|
|
275
434
|
enableLocalEvaluation?: boolean;
|
|
@@ -305,8 +464,21 @@ export type PostHogOptions = Omit<PostHogCoreOptions, 'before_send' | 'flushInte
|
|
|
305
464
|
* Allows modification or dropping of events before they're sent to PostHog.
|
|
306
465
|
* If an array is provided, the functions are run in order.
|
|
307
466
|
* If a function returns null, the event will be dropped.
|
|
467
|
+
*
|
|
468
|
+
* @remarks
|
|
469
|
+
* The hook gets a copy of the finished event: the event's own values, then the values filled
|
|
470
|
+
* from context, `register()` and `registerOptions()`, then the values the SDK adds (such as
|
|
471
|
+
* `$is_server`, `$geoip_disable`, feature flag properties and `options.process_person_profile`).
|
|
472
|
+
* It has the final say: it can change or remove any of them, and nothing is added after it.
|
|
473
|
+
* Set `$geoip_disable` in `properties` to change GeoIP; the `disableGeoip` and `groups` fields
|
|
474
|
+
* are already applied to the properties it sees.
|
|
475
|
+
*
|
|
476
|
+
* On `$identify`, `$create_alias`, `$merge_dangerously`, `$groupidentify`, `$set` and `$set_once`
|
|
477
|
+
* events it sees `options.process_person_profile` and no `$process_person_profile` property.
|
|
478
|
+
* Those events get their default from the event name the call used, so a hook that renames an
|
|
479
|
+
* event to one of them must set `options.process_person_profile` itself.
|
|
308
480
|
*/
|
|
309
|
-
|
|
481
|
+
beforeSend?: BeforeSendFn | BeforeSendFn[];
|
|
310
482
|
/**
|
|
311
483
|
* Evaluation contexts for feature flags.
|
|
312
484
|
* When set, only feature flags that have at least one matching evaluation tag
|
|
@@ -329,7 +501,7 @@ export type PostHogOptions = Omit<PostHogCoreOptions, 'before_send' | 'flushInte
|
|
|
329
501
|
*
|
|
330
502
|
* @default []
|
|
331
503
|
*/
|
|
332
|
-
|
|
504
|
+
customBlockedUserAgents?: string[];
|
|
333
505
|
/**
|
|
334
506
|
* PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION
|
|
335
507
|
* Enables collection of bot traffic as $bot_pageview events instead of dropping them.
|
|
@@ -347,7 +519,7 @@ export type PostHogOptions = Omit<PostHogCoreOptions, 'before_send' | 'flushInte
|
|
|
347
519
|
* })
|
|
348
520
|
* ```
|
|
349
521
|
*/
|
|
350
|
-
|
|
522
|
+
__previewCaptureBotPageviews?: boolean;
|
|
351
523
|
/**
|
|
352
524
|
* When enabled, all feature flag evaluations will use local evaluation only,
|
|
353
525
|
* never falling back to server-side evaluation. This prevents unexpected server
|
|
@@ -405,7 +577,8 @@ export type PostHogOptions = Omit<PostHogCoreOptions, 'before_send' | 'flushInte
|
|
|
405
577
|
* react-native events. Set this to `false` when running the SDK as a
|
|
406
578
|
* client/CLI so the event is attributed to the device OS normally instead of
|
|
407
579
|
* being marked as a server event. When `false`, the `$is_server` property is
|
|
408
|
-
* omitted entirely.
|
|
580
|
+
* omitted entirely. A `$is_server` value set on the event, in context or with
|
|
581
|
+
* `register()` wins over this setting.
|
|
409
582
|
*
|
|
410
583
|
* @default true
|
|
411
584
|
* @example
|
|
@@ -484,6 +657,7 @@ export type PostHogFeatureFlag = {
|
|
|
484
657
|
export declare const FeatureFlagError: {
|
|
485
658
|
readonly ERRORS_WHILE_COMPUTING: 'errors_while_computing_flags';
|
|
486
659
|
readonly FLAG_MISSING: 'flag_missing';
|
|
660
|
+
readonly EVALUATION_FAILED: 'evaluation_failed';
|
|
487
661
|
readonly LOCAL_EVALUATION_INCONCLUSIVE: 'local_evaluation_inconclusive';
|
|
488
662
|
readonly QUOTA_LIMITED: 'quota_limited';
|
|
489
663
|
readonly UNKNOWN_ERROR: 'unknown_error';
|
|
@@ -530,20 +704,15 @@ export interface IPostHog {
|
|
|
530
704
|
/**
|
|
531
705
|
* @description Capture an exception as a $exception event.
|
|
532
706
|
* @param error The error to capture.
|
|
533
|
-
* @param
|
|
534
|
-
* @param additionalProperties Optional additional properties to include.
|
|
535
|
-
* @param uuid Optional event UUID.
|
|
536
|
-
* @param flags Optional `FeatureFlagEvaluations` snapshot to attach to the event.
|
|
707
|
+
* @param options Optional distinct id, properties, options, uuid, flags snapshot and level.
|
|
537
708
|
*/
|
|
538
|
-
captureException(error: unknown,
|
|
709
|
+
captureException(error: unknown, options?: CaptureExceptionOptions): void;
|
|
539
710
|
/**
|
|
540
711
|
* @description Capture an exception as a $exception event immediately.
|
|
541
712
|
* @param error The error to capture.
|
|
542
|
-
* @param
|
|
543
|
-
* @param additionalProperties Optional additional properties to include.
|
|
544
|
-
* @param flags Optional `FeatureFlagEvaluations` snapshot to attach to the event.
|
|
713
|
+
* @param options Optional distinct id, properties, options, uuid, flags snapshot and level.
|
|
545
714
|
*/
|
|
546
|
-
captureExceptionImmediate(error: unknown,
|
|
715
|
+
captureExceptionImmediate(error: unknown, options?: CaptureExceptionOptions): Promise<void>;
|
|
547
716
|
/**
|
|
548
717
|
* @description Capture an AI event on the dedicated AI capture endpoint.
|
|
549
718
|
* Beta: the signature is stable; operational limits (per-event size cap, batching, endpoint) may change without notice. Delivery is async, and no redaction or truncation is applied to the payload.
|
|
@@ -609,6 +778,8 @@ export interface IPostHog {
|
|
|
609
778
|
alias(data: {
|
|
610
779
|
distinctId: string;
|
|
611
780
|
alias: string;
|
|
781
|
+
disableGeoip?: boolean;
|
|
782
|
+
options?: EventOptions;
|
|
612
783
|
}): void;
|
|
613
784
|
/**
|
|
614
785
|
* @description To marry up whatever a user does before they sign up or log in with what they do after you need to make an alias call.
|
|
@@ -619,6 +790,8 @@ export interface IPostHog {
|
|
|
619
790
|
aliasImmediate(data: {
|
|
620
791
|
distinctId: string;
|
|
621
792
|
alias: string;
|
|
793
|
+
disableGeoip?: boolean;
|
|
794
|
+
options?: EventOptions;
|
|
622
795
|
}): Promise<void>;
|
|
623
796
|
/**
|
|
624
797
|
* @description PostHog feature flags (https://posthog.com/docs/features/feature-flags)
|
|
@@ -834,20 +1007,12 @@ export interface IPostHog {
|
|
|
834
1007
|
overrideFeatureFlags(overrides: OverrideFeatureFlagsOptions): void;
|
|
835
1008
|
/**
|
|
836
1009
|
* @description Run a function with specific context that will be applied to all events captured within that context.
|
|
837
|
-
* @param data Context data to apply (sessionId, distinctId, properties,
|
|
1010
|
+
* @param data Context data to apply (sessionId, distinctId, properties, options)
|
|
838
1011
|
* @param fn Function to run with the context
|
|
839
1012
|
* @param options Context options (fresh)
|
|
840
1013
|
* @returns The return value of the function
|
|
841
1014
|
*/
|
|
842
1015
|
withContext<T>(data: Partial<ContextData>, fn: () => T, options?: ContextOptions): T;
|
|
843
|
-
/**
|
|
844
|
-
* @description Set context without a callback wrapper. Must be called in the same
|
|
845
|
-
* async scope that makes PostHog calls. Prefer `withContext()` when you can wrap
|
|
846
|
-
* code in a callback.
|
|
847
|
-
* @param data Context data to apply (distinctId, sessionId, properties)
|
|
848
|
-
* @param options Context options (fresh)
|
|
849
|
-
*/
|
|
850
|
-
enterContext(data: Partial<ContextData>, options?: ContextOptions): void;
|
|
851
1016
|
/**
|
|
852
1017
|
* @description Get the current context data.
|
|
853
1018
|
* @returns The current context data, or undefined if no context is set
|