posthog-node 5.72.0 → 5.73.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/client.d.ts +50 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +94 -19
- package/dist/client.mjs +94 -19
- package/dist/feature-flag-evaluations.d.ts +14 -0
- package/dist/feature-flag-evaluations.d.ts.map +1 -1
- package/dist/feature-flag-evaluations.js +2 -1
- package/dist/feature-flag-evaluations.mjs +2 -1
- package/dist/flag-events.d.ts +112 -0
- package/dist/flag-events.d.ts.map +1 -0
- package/dist/flag-events.js +230 -0
- package/dist/flag-events.mjs +174 -0
- package/dist/flags-response.d.ts +83 -0
- package/dist/flags-response.d.ts.map +1 -0
- package/dist/flags-response.js +255 -0
- package/dist/flags-response.mjs +208 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +5 -4
- package/src/client.ts +235 -43
- package/src/feature-flag-evaluations.ts +17 -0
- package/src/flag-events.ts +280 -0
- package/src/flags-response.ts +340 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
FLAGS_RESPONSE_WITHOUT_TYPED_VALUES_MESSAGE: ()=>FLAGS_RESPONSE_WITHOUT_TYPED_VALUES_MESSAGE,
|
|
32
|
+
isUnreadableFlagRecord: ()=>isUnreadableFlagRecord,
|
|
33
|
+
parsedFlagRecordOf: ()=>parsedFlagRecordOf,
|
|
34
|
+
readFlagRecords: ()=>readFlagRecords
|
|
35
|
+
});
|
|
36
|
+
const core_namespaceObject = require("@posthog/core");
|
|
37
|
+
const FLAGS_RESPONSE_WITHOUT_TYPED_VALUES_MESSAGE = "[FEATURE FLAGS] The /flags response has no typed flag values, so the server may not support /flags?v=4. Its flags are read as config version 1.";
|
|
38
|
+
const parsedRecords = new WeakMap();
|
|
39
|
+
class UnreadableField extends Error {
|
|
40
|
+
constructor(field){
|
|
41
|
+
super(field);
|
|
42
|
+
this.field = field;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function readFlagRecords(body) {
|
|
46
|
+
if (!(0, core_namespaceObject.isPlainObject)(body)) return {
|
|
47
|
+
body,
|
|
48
|
+
withoutTypedValues: false
|
|
49
|
+
};
|
|
50
|
+
const flags = body.flags;
|
|
51
|
+
if (!(0, core_namespaceObject.isPlainObject)(flags)) {
|
|
52
|
+
const featureFlags = body.featureFlags;
|
|
53
|
+
return {
|
|
54
|
+
body,
|
|
55
|
+
withoutTypedValues: (0, core_namespaceObject.isPlainObject)(featureFlags) && Object.keys(featureFlags).length > 0
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
let withoutTypedValues = false;
|
|
59
|
+
const rendered = Object.fromEntries(Object.entries(flags).map(([key, raw])=>{
|
|
60
|
+
if ((0, core_namespaceObject.isPlainObject)(raw) && !core_namespaceObject.hasOwnProperty.call(raw, 'value')) withoutTypedValues = true;
|
|
61
|
+
const { detail, record } = readRecord(key, raw);
|
|
62
|
+
parsedRecords.set(detail, record);
|
|
63
|
+
return [
|
|
64
|
+
key,
|
|
65
|
+
detail
|
|
66
|
+
];
|
|
67
|
+
}));
|
|
68
|
+
return {
|
|
69
|
+
body: {
|
|
70
|
+
...body,
|
|
71
|
+
flags: rendered
|
|
72
|
+
},
|
|
73
|
+
withoutTypedValues
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function parsedFlagRecordOf(detail) {
|
|
77
|
+
const record = parsedRecords.get(detail);
|
|
78
|
+
if (record) return record;
|
|
79
|
+
return {
|
|
80
|
+
value: detail.variant ?? detail.enabled ?? null,
|
|
81
|
+
failed: true === detail.failed,
|
|
82
|
+
reason: detail.reason && {
|
|
83
|
+
code: detail.reason.code,
|
|
84
|
+
conditionIndex: detail.reason.condition_index,
|
|
85
|
+
description: detail.reason.description
|
|
86
|
+
},
|
|
87
|
+
metadata: {
|
|
88
|
+
id: detail.metadata?.id,
|
|
89
|
+
version: detail.metadata?.version,
|
|
90
|
+
configVersion: 1,
|
|
91
|
+
description: detail.metadata?.description,
|
|
92
|
+
hasExperiment: detail.metadata?.has_experiment
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function isUnreadableFlagRecord(detail) {
|
|
97
|
+
return parsedRecords.get(detail)?.unreadableField !== void 0;
|
|
98
|
+
}
|
|
99
|
+
function readRecord(key, raw) {
|
|
100
|
+
try {
|
|
101
|
+
if ((0, core_namespaceObject.isPlainObject)(raw) && !core_namespaceObject.hasOwnProperty.call(raw, 'value')) return readOlderRecord(raw);
|
|
102
|
+
return readTypedRecord(key, raw);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
if (error instanceof UnreadableField) return unreadableRecord(key, error.field);
|
|
105
|
+
if (error instanceof RangeError) return unreadableRecord(key, 'value');
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function readTypedRecord(key, raw) {
|
|
110
|
+
if (!(0, core_namespaceObject.isPlainObject)(raw)) throw new UnreadableField('record');
|
|
111
|
+
readRecordKey(raw);
|
|
112
|
+
const sentValue = readValue(raw.value);
|
|
113
|
+
const failed = true === optional(raw.failed, 'failed', core_namespaceObject.isBoolean);
|
|
114
|
+
const reason = readReason(raw.reason);
|
|
115
|
+
const rawMetadata = optional(raw.metadata, 'metadata', core_namespaceObject.isPlainObject);
|
|
116
|
+
const metadata = {
|
|
117
|
+
...readMetadata(rawMetadata),
|
|
118
|
+
configVersion: optionalInteger(rawMetadata?.config_version, 'metadata.config_version'),
|
|
119
|
+
ruleType: optional(rawMetadata?.rule_type, 'metadata.rule_type', core_namespaceObject.isString),
|
|
120
|
+
ruleId: optional(rawMetadata?.rule_id, 'metadata.rule_id', core_namespaceObject.isString),
|
|
121
|
+
variantKey: optional(rawMetadata?.variant_key, 'metadata.variant_key', core_namespaceObject.isString),
|
|
122
|
+
forcedVariant: optional(rawMetadata?.forced_variant, 'metadata.forced_variant', core_namespaceObject.isBoolean)
|
|
123
|
+
};
|
|
124
|
+
optionalInteger(rawMetadata?.experiment_id, 'metadata.experiment_id');
|
|
125
|
+
const value = failed ? null : sentValue;
|
|
126
|
+
const { enabled, variant, payload } = renderValue(value);
|
|
127
|
+
const detail = {
|
|
128
|
+
key,
|
|
129
|
+
enabled,
|
|
130
|
+
variant,
|
|
131
|
+
reason: reason && {
|
|
132
|
+
code: reason.code,
|
|
133
|
+
condition_index: reason.conditionIndex,
|
|
134
|
+
description: reason.description
|
|
135
|
+
},
|
|
136
|
+
metadata: rawMetadata || void 0 !== payload ? {
|
|
137
|
+
id: metadata.id,
|
|
138
|
+
version: metadata.version,
|
|
139
|
+
description: metadata.description,
|
|
140
|
+
payload: failed ? null : payload ?? rawMetadata?.payload,
|
|
141
|
+
has_experiment: metadata.hasExperiment
|
|
142
|
+
} : void 0
|
|
143
|
+
};
|
|
144
|
+
if (failed) detail.failed = true;
|
|
145
|
+
return {
|
|
146
|
+
detail,
|
|
147
|
+
record: {
|
|
148
|
+
value,
|
|
149
|
+
failed,
|
|
150
|
+
reason,
|
|
151
|
+
metadata
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function readOlderRecord(raw) {
|
|
156
|
+
readRecordKey(raw);
|
|
157
|
+
const enabled = optional(raw.enabled, 'enabled', core_namespaceObject.isBoolean);
|
|
158
|
+
const variant = optional(raw.variant, 'variant', core_namespaceObject.isString);
|
|
159
|
+
const failed = true === optional(raw.failed, 'failed', core_namespaceObject.isBoolean);
|
|
160
|
+
const reason = readReason(raw.reason);
|
|
161
|
+
const metadata = readMetadata(optional(raw.metadata, 'metadata', core_namespaceObject.isPlainObject));
|
|
162
|
+
return {
|
|
163
|
+
detail: raw,
|
|
164
|
+
record: {
|
|
165
|
+
value: variant ?? enabled ?? null,
|
|
166
|
+
failed,
|
|
167
|
+
reason,
|
|
168
|
+
metadata: {
|
|
169
|
+
...metadata,
|
|
170
|
+
configVersion: 1
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function unreadableRecord(key, field) {
|
|
176
|
+
return {
|
|
177
|
+
detail: {
|
|
178
|
+
key,
|
|
179
|
+
enabled: false,
|
|
180
|
+
variant: void 0,
|
|
181
|
+
reason: void 0,
|
|
182
|
+
metadata: void 0,
|
|
183
|
+
failed: true
|
|
184
|
+
},
|
|
185
|
+
record: {
|
|
186
|
+
value: null,
|
|
187
|
+
failed: true,
|
|
188
|
+
unreadableField: field,
|
|
189
|
+
metadata: {}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function renderValue(value) {
|
|
194
|
+
if ((0, core_namespaceObject.isNull)(value) || (0, core_namespaceObject.isBoolean)(value)) return {
|
|
195
|
+
enabled: true === value,
|
|
196
|
+
variant: void 0,
|
|
197
|
+
payload: void 0
|
|
198
|
+
};
|
|
199
|
+
if ((0, core_namespaceObject.isString)(value)) return {
|
|
200
|
+
enabled: true,
|
|
201
|
+
variant: value,
|
|
202
|
+
payload: void 0
|
|
203
|
+
};
|
|
204
|
+
return {
|
|
205
|
+
enabled: true,
|
|
206
|
+
variant: void 0,
|
|
207
|
+
payload: JSON.stringify(value)
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function readValue(value) {
|
|
211
|
+
if ((0, core_namespaceObject.isNull)(value) || (0, core_namespaceObject.isBoolean)(value) || (0, core_namespaceObject.isString)(value) || (0, core_namespaceObject.isPlainObject)(value)) return value;
|
|
212
|
+
if ((0, core_namespaceObject.isNumber)(value) && Number.isFinite(value)) return value;
|
|
213
|
+
throw new UnreadableField('value');
|
|
214
|
+
}
|
|
215
|
+
function readRecordKey(raw) {
|
|
216
|
+
optional(raw.key, 'key', core_namespaceObject.isString);
|
|
217
|
+
}
|
|
218
|
+
function readReason(raw) {
|
|
219
|
+
const reason = optional(raw, 'reason', core_namespaceObject.isPlainObject);
|
|
220
|
+
if (void 0 === reason) return;
|
|
221
|
+
return {
|
|
222
|
+
code: optional(reason.code, 'reason.code', core_namespaceObject.isString),
|
|
223
|
+
conditionIndex: optionalInteger(reason.condition_index, 'reason.condition_index'),
|
|
224
|
+
description: optional(reason.description, "reason.description", core_namespaceObject.isString)
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function readMetadata(metadata) {
|
|
228
|
+
return {
|
|
229
|
+
id: optionalInteger(metadata?.id, 'metadata.id'),
|
|
230
|
+
version: optionalInteger(metadata?.version, 'metadata.version'),
|
|
231
|
+
description: optional(metadata?.description, "metadata.description", core_namespaceObject.isString),
|
|
232
|
+
hasExperiment: optional(metadata?.has_experiment, 'metadata.has_experiment', core_namespaceObject.isBoolean)
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function optional(value, field, is) {
|
|
236
|
+
if ((0, core_namespaceObject.isNullish)(value)) return;
|
|
237
|
+
if (is(value)) return value;
|
|
238
|
+
throw new UnreadableField(field);
|
|
239
|
+
}
|
|
240
|
+
function optionalInteger(value, field) {
|
|
241
|
+
return optional(value, field, (candidate)=>(0, core_namespaceObject.isNumber)(candidate) && Number.isInteger(candidate));
|
|
242
|
+
}
|
|
243
|
+
exports.FLAGS_RESPONSE_WITHOUT_TYPED_VALUES_MESSAGE = __webpack_exports__.FLAGS_RESPONSE_WITHOUT_TYPED_VALUES_MESSAGE;
|
|
244
|
+
exports.isUnreadableFlagRecord = __webpack_exports__.isUnreadableFlagRecord;
|
|
245
|
+
exports.parsedFlagRecordOf = __webpack_exports__.parsedFlagRecordOf;
|
|
246
|
+
exports.readFlagRecords = __webpack_exports__.readFlagRecords;
|
|
247
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
248
|
+
"FLAGS_RESPONSE_WITHOUT_TYPED_VALUES_MESSAGE",
|
|
249
|
+
"isUnreadableFlagRecord",
|
|
250
|
+
"parsedFlagRecordOf",
|
|
251
|
+
"readFlagRecords"
|
|
252
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
253
|
+
Object.defineProperty(exports, '__esModule', {
|
|
254
|
+
value: true
|
|
255
|
+
});
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { hasOwnProperty as core_hasOwnProperty, isBoolean, isNull, isNullish, isNumber, isPlainObject, isString } from "@posthog/core";
|
|
2
|
+
const FLAGS_RESPONSE_WITHOUT_TYPED_VALUES_MESSAGE = "[FEATURE FLAGS] The /flags response has no typed flag values, so the server may not support /flags?v=4. Its flags are read as config version 1.";
|
|
3
|
+
const parsedRecords = new WeakMap();
|
|
4
|
+
class UnreadableField extends Error {
|
|
5
|
+
constructor(field){
|
|
6
|
+
super(field);
|
|
7
|
+
this.field = field;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function readFlagRecords(body) {
|
|
11
|
+
if (!isPlainObject(body)) return {
|
|
12
|
+
body,
|
|
13
|
+
withoutTypedValues: false
|
|
14
|
+
};
|
|
15
|
+
const flags = body.flags;
|
|
16
|
+
if (!isPlainObject(flags)) {
|
|
17
|
+
const featureFlags = body.featureFlags;
|
|
18
|
+
return {
|
|
19
|
+
body,
|
|
20
|
+
withoutTypedValues: isPlainObject(featureFlags) && Object.keys(featureFlags).length > 0
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
let withoutTypedValues = false;
|
|
24
|
+
const rendered = Object.fromEntries(Object.entries(flags).map(([key, raw])=>{
|
|
25
|
+
if (isPlainObject(raw) && !core_hasOwnProperty.call(raw, 'value')) withoutTypedValues = true;
|
|
26
|
+
const { detail, record } = readRecord(key, raw);
|
|
27
|
+
parsedRecords.set(detail, record);
|
|
28
|
+
return [
|
|
29
|
+
key,
|
|
30
|
+
detail
|
|
31
|
+
];
|
|
32
|
+
}));
|
|
33
|
+
return {
|
|
34
|
+
body: {
|
|
35
|
+
...body,
|
|
36
|
+
flags: rendered
|
|
37
|
+
},
|
|
38
|
+
withoutTypedValues
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function parsedFlagRecordOf(detail) {
|
|
42
|
+
const record = parsedRecords.get(detail);
|
|
43
|
+
if (record) return record;
|
|
44
|
+
return {
|
|
45
|
+
value: detail.variant ?? detail.enabled ?? null,
|
|
46
|
+
failed: true === detail.failed,
|
|
47
|
+
reason: detail.reason && {
|
|
48
|
+
code: detail.reason.code,
|
|
49
|
+
conditionIndex: detail.reason.condition_index,
|
|
50
|
+
description: detail.reason.description
|
|
51
|
+
},
|
|
52
|
+
metadata: {
|
|
53
|
+
id: detail.metadata?.id,
|
|
54
|
+
version: detail.metadata?.version,
|
|
55
|
+
configVersion: 1,
|
|
56
|
+
description: detail.metadata?.description,
|
|
57
|
+
hasExperiment: detail.metadata?.has_experiment
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function isUnreadableFlagRecord(detail) {
|
|
62
|
+
return parsedRecords.get(detail)?.unreadableField !== void 0;
|
|
63
|
+
}
|
|
64
|
+
function readRecord(key, raw) {
|
|
65
|
+
try {
|
|
66
|
+
if (isPlainObject(raw) && !core_hasOwnProperty.call(raw, 'value')) return readOlderRecord(raw);
|
|
67
|
+
return readTypedRecord(key, raw);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (error instanceof UnreadableField) return unreadableRecord(key, error.field);
|
|
70
|
+
if (error instanceof RangeError) return unreadableRecord(key, 'value');
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function readTypedRecord(key, raw) {
|
|
75
|
+
if (!isPlainObject(raw)) throw new UnreadableField('record');
|
|
76
|
+
readRecordKey(raw);
|
|
77
|
+
const sentValue = readValue(raw.value);
|
|
78
|
+
const failed = true === optional(raw.failed, 'failed', isBoolean);
|
|
79
|
+
const reason = readReason(raw.reason);
|
|
80
|
+
const rawMetadata = optional(raw.metadata, 'metadata', isPlainObject);
|
|
81
|
+
const metadata = {
|
|
82
|
+
...readMetadata(rawMetadata),
|
|
83
|
+
configVersion: optionalInteger(rawMetadata?.config_version, 'metadata.config_version'),
|
|
84
|
+
ruleType: optional(rawMetadata?.rule_type, 'metadata.rule_type', isString),
|
|
85
|
+
ruleId: optional(rawMetadata?.rule_id, 'metadata.rule_id', isString),
|
|
86
|
+
variantKey: optional(rawMetadata?.variant_key, 'metadata.variant_key', isString),
|
|
87
|
+
forcedVariant: optional(rawMetadata?.forced_variant, 'metadata.forced_variant', isBoolean)
|
|
88
|
+
};
|
|
89
|
+
optionalInteger(rawMetadata?.experiment_id, 'metadata.experiment_id');
|
|
90
|
+
const value = failed ? null : sentValue;
|
|
91
|
+
const { enabled, variant, payload } = renderValue(value);
|
|
92
|
+
const detail = {
|
|
93
|
+
key,
|
|
94
|
+
enabled,
|
|
95
|
+
variant,
|
|
96
|
+
reason: reason && {
|
|
97
|
+
code: reason.code,
|
|
98
|
+
condition_index: reason.conditionIndex,
|
|
99
|
+
description: reason.description
|
|
100
|
+
},
|
|
101
|
+
metadata: rawMetadata || void 0 !== payload ? {
|
|
102
|
+
id: metadata.id,
|
|
103
|
+
version: metadata.version,
|
|
104
|
+
description: metadata.description,
|
|
105
|
+
payload: failed ? null : payload ?? rawMetadata?.payload,
|
|
106
|
+
has_experiment: metadata.hasExperiment
|
|
107
|
+
} : void 0
|
|
108
|
+
};
|
|
109
|
+
if (failed) detail.failed = true;
|
|
110
|
+
return {
|
|
111
|
+
detail,
|
|
112
|
+
record: {
|
|
113
|
+
value,
|
|
114
|
+
failed,
|
|
115
|
+
reason,
|
|
116
|
+
metadata
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function readOlderRecord(raw) {
|
|
121
|
+
readRecordKey(raw);
|
|
122
|
+
const enabled = optional(raw.enabled, 'enabled', isBoolean);
|
|
123
|
+
const variant = optional(raw.variant, 'variant', isString);
|
|
124
|
+
const failed = true === optional(raw.failed, 'failed', isBoolean);
|
|
125
|
+
const reason = readReason(raw.reason);
|
|
126
|
+
const metadata = readMetadata(optional(raw.metadata, 'metadata', isPlainObject));
|
|
127
|
+
return {
|
|
128
|
+
detail: raw,
|
|
129
|
+
record: {
|
|
130
|
+
value: variant ?? enabled ?? null,
|
|
131
|
+
failed,
|
|
132
|
+
reason,
|
|
133
|
+
metadata: {
|
|
134
|
+
...metadata,
|
|
135
|
+
configVersion: 1
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function unreadableRecord(key, field) {
|
|
141
|
+
return {
|
|
142
|
+
detail: {
|
|
143
|
+
key,
|
|
144
|
+
enabled: false,
|
|
145
|
+
variant: void 0,
|
|
146
|
+
reason: void 0,
|
|
147
|
+
metadata: void 0,
|
|
148
|
+
failed: true
|
|
149
|
+
},
|
|
150
|
+
record: {
|
|
151
|
+
value: null,
|
|
152
|
+
failed: true,
|
|
153
|
+
unreadableField: field,
|
|
154
|
+
metadata: {}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function renderValue(value) {
|
|
159
|
+
if (isNull(value) || isBoolean(value)) return {
|
|
160
|
+
enabled: true === value,
|
|
161
|
+
variant: void 0,
|
|
162
|
+
payload: void 0
|
|
163
|
+
};
|
|
164
|
+
if (isString(value)) return {
|
|
165
|
+
enabled: true,
|
|
166
|
+
variant: value,
|
|
167
|
+
payload: void 0
|
|
168
|
+
};
|
|
169
|
+
return {
|
|
170
|
+
enabled: true,
|
|
171
|
+
variant: void 0,
|
|
172
|
+
payload: JSON.stringify(value)
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function readValue(value) {
|
|
176
|
+
if (isNull(value) || isBoolean(value) || isString(value) || isPlainObject(value)) return value;
|
|
177
|
+
if (isNumber(value) && Number.isFinite(value)) return value;
|
|
178
|
+
throw new UnreadableField('value');
|
|
179
|
+
}
|
|
180
|
+
function readRecordKey(raw) {
|
|
181
|
+
optional(raw.key, 'key', isString);
|
|
182
|
+
}
|
|
183
|
+
function readReason(raw) {
|
|
184
|
+
const reason = optional(raw, 'reason', isPlainObject);
|
|
185
|
+
if (void 0 === reason) return;
|
|
186
|
+
return {
|
|
187
|
+
code: optional(reason.code, 'reason.code', isString),
|
|
188
|
+
conditionIndex: optionalInteger(reason.condition_index, 'reason.condition_index'),
|
|
189
|
+
description: optional(reason.description, "reason.description", isString)
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function readMetadata(metadata) {
|
|
193
|
+
return {
|
|
194
|
+
id: optionalInteger(metadata?.id, 'metadata.id'),
|
|
195
|
+
version: optionalInteger(metadata?.version, 'metadata.version'),
|
|
196
|
+
description: optional(metadata?.description, "metadata.description", isString),
|
|
197
|
+
hasExperiment: optional(metadata?.has_experiment, 'metadata.has_experiment', isBoolean)
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function optional(value, field, is) {
|
|
201
|
+
if (isNullish(value)) return;
|
|
202
|
+
if (is(value)) return value;
|
|
203
|
+
throw new UnreadableField(field);
|
|
204
|
+
}
|
|
205
|
+
function optionalInteger(value, field) {
|
|
206
|
+
return optional(value, field, (candidate)=>isNumber(candidate) && Number.isInteger(candidate));
|
|
207
|
+
}
|
|
208
|
+
export { FLAGS_RESPONSE_WITHOUT_TYPED_VALUES_MESSAGE, isUnreadableFlagRecord, parsedFlagRecordOf, readFlagRecords };
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "5.
|
|
1
|
+
export declare const version = "5.73.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
package/dist/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = "5.
|
|
1
|
+
const version = "5.73.0";
|
|
2
2
|
export { version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "posthog-node",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.73.0",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/PostHog/posthog-js/issues"
|
|
6
6
|
},
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"module": "dist/entrypoints/index.node.mjs",
|
|
30
30
|
"types": "dist/entrypoints/index.node.d.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@posthog/core": "^1.67.
|
|
32
|
+
"@posthog/core": "^1.67.3"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@edge-runtime/vm": "^5.0.0",
|
|
@@ -43,13 +43,14 @@
|
|
|
43
43
|
"@types/react": "^19.2.7",
|
|
44
44
|
"esbuild": "^0.25.0",
|
|
45
45
|
"@vitest/coverage-v8": "^1.6.1",
|
|
46
|
+
"ajv": "^8.18.0",
|
|
46
47
|
"react": "^19.2.1",
|
|
47
48
|
"react-dom": "^19.2.1",
|
|
48
49
|
"rxjs": "^7.8.0",
|
|
49
50
|
"typescript": "7.0.2",
|
|
50
51
|
"vitest": "^1.6.1",
|
|
51
|
-
"@posthog/
|
|
52
|
-
"@posthog
|
|
52
|
+
"@posthog-tooling/tsconfig-base": "1.1.1",
|
|
53
|
+
"@posthog/types": "^1.425.0"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
55
56
|
"@opentelemetry/api": "^1.2.0",
|