@posthog/core 1.48.11 → 1.48.12
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/featureFlagLocalEvaluation.js +4 -6
- package/dist/featureFlagLocalEvaluation.mjs +4 -6
- package/dist/vendor/uuidv7.d.ts.map +1 -1
- package/dist/vendor/uuidv7.js +1 -1
- package/dist/vendor/uuidv7.mjs +1 -1
- package/package.json +2 -2
- package/src/featureFlagLocalEvaluation.ts +3 -3
- package/src/vendor/uuidv7.spec.ts +26 -0
- package/src/vendor/uuidv7.ts +8 -2
|
@@ -195,12 +195,10 @@ function matchFeatureFlagProperty(property, propertyValues, options = {}) {
|
|
|
195
195
|
const value = property.value;
|
|
196
196
|
const operator = property.operator || 'exact';
|
|
197
197
|
const parsingPolicy = options.semverParsingPolicy ?? 'strict';
|
|
198
|
-
|
|
198
|
+
const hasProperty = Object.prototype.hasOwnProperty.call(propertyValues, key);
|
|
199
|
+
if (hasProperty) {
|
|
199
200
|
if ('is_not_set' === operator) return false;
|
|
200
|
-
} else {
|
|
201
|
-
if ('is_not_set' === operator) return true;
|
|
202
|
-
throw new InconclusiveMatchError(`Property ${key} not found in propertyValues`);
|
|
203
|
-
}
|
|
201
|
+
} else throw new InconclusiveMatchError(`Property ${key} not found in propertyValues`);
|
|
204
202
|
const overrideValue = propertyValues[key];
|
|
205
203
|
if (null == overrideValue && !NULL_VALUES_ALLOWED_OPERATORS.includes(operator)) {
|
|
206
204
|
options.warnFunction?.(`Property ${key} cannot have a value of null/undefined with the ${operator} operator`);
|
|
@@ -223,7 +221,7 @@ function matchFeatureFlagProperty(property, propertyValues, options = {}) {
|
|
|
223
221
|
case 'is_not':
|
|
224
222
|
return !computeExactMatch(value, overrideValue);
|
|
225
223
|
case 'is_set':
|
|
226
|
-
return
|
|
224
|
+
return true;
|
|
227
225
|
case 'icontains':
|
|
228
226
|
return String(overrideValue).toLowerCase().includes(String(value).toLowerCase());
|
|
229
227
|
case 'not_icontains':
|
|
@@ -159,12 +159,10 @@ function matchFeatureFlagProperty(property, propertyValues, options = {}) {
|
|
|
159
159
|
const value = property.value;
|
|
160
160
|
const operator = property.operator || 'exact';
|
|
161
161
|
const parsingPolicy = options.semverParsingPolicy ?? 'strict';
|
|
162
|
-
|
|
162
|
+
const hasProperty = Object.prototype.hasOwnProperty.call(propertyValues, key);
|
|
163
|
+
if (hasProperty) {
|
|
163
164
|
if ('is_not_set' === operator) return false;
|
|
164
|
-
} else {
|
|
165
|
-
if ('is_not_set' === operator) return true;
|
|
166
|
-
throw new InconclusiveMatchError(`Property ${key} not found in propertyValues`);
|
|
167
|
-
}
|
|
165
|
+
} else throw new InconclusiveMatchError(`Property ${key} not found in propertyValues`);
|
|
168
166
|
const overrideValue = propertyValues[key];
|
|
169
167
|
if (null == overrideValue && !NULL_VALUES_ALLOWED_OPERATORS.includes(operator)) {
|
|
170
168
|
options.warnFunction?.(`Property ${key} cannot have a value of null/undefined with the ${operator} operator`);
|
|
@@ -187,7 +185,7 @@ function matchFeatureFlagProperty(property, propertyValues, options = {}) {
|
|
|
187
185
|
case 'is_not':
|
|
188
186
|
return !computeExactMatch(value, overrideValue);
|
|
189
187
|
case 'is_set':
|
|
190
|
-
return
|
|
188
|
+
return true;
|
|
191
189
|
case 'icontains':
|
|
192
190
|
return String(overrideValue).toLowerCase().includes(String(value).toLowerCase());
|
|
193
191
|
case 'not_icontains':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuidv7.d.ts","sourceRoot":"","sources":["../../src/vendor/uuidv7.ts"],"names":[],"mappings":"AAaA,iDAAiD;AACjD,qBAAa,IAAI;IAEK,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC;IADxD,4DAA4D;IAC5D,OAAO;IAEP;;;;;;;;OAQG;IACH,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,IAAI;IAQjD;;;;;;;;OAQG;IACH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;gBACS,qBAAqB,CAAC,EAAE;QAClC,gDAAgD;QAChD,UAAU,IAAI,MAAM,CAAC;KACtB;IAID;;;;;;;;;;;;;OAaG;IACH,QAAQ,IAAI,IAAI;IAIhB;;;;;;;;;;;;OAYG;IACH,eAAe,IAAI,IAAI,GAAG,SAAS;IAInC;;;;;;;;;;OAUG;IACH,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,IAAI;IAUtE;;;;;;;;;;OAUG;IACH,mBAAmB,CACjB,QAAQ,EAAE,MAAM,EAChB,iBAAiB,EAAE,MAAM,GACxB,IAAI,GAAG,SAAS;IAqCnB,0DAA0D;IAC1D,OAAO,CAAC,YAAY;IAKpB;;;;OAIG;IACH,UAAU,IAAI,IAAI;CAanB;AA0DD;;;;;GAKG;AACH,eAAO,MAAM,MAAM,QAAO,MAAgC,CAAC;AAE3D,iCAAiC;AACjC,eAAO,MAAM,SAAS,QAAO,IAC4C,CAAC;AAE1E;;;;;GAKG;AACH,eAAO,MAAM,MAAM,QAAO,MAAgC,CAAC;AAE3D,iCAAiC;AACjC,eAAO,MAAM,SAAS,QAAO,IAC8C,CAAC"}
|
package/dist/vendor/uuidv7.js
CHANGED
|
@@ -193,7 +193,7 @@ class V7Generator {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
const getDefaultRandom = ()=>({
|
|
196
|
-
nextUint32: ()=>0x10000 * Math.trunc(0x10000 * Math.random()) + Math.trunc(0x10000 * Math.random())
|
|
196
|
+
nextUint32: ()=>0x10000 * Math.trunc(0x10000 * Math.random()) + Math.trunc(0x10000 * Math.random()) >>> 0
|
|
197
197
|
});
|
|
198
198
|
let defaultGenerator;
|
|
199
199
|
const uuidv7 = ()=>uuidv7obj().toString();
|
package/dist/vendor/uuidv7.mjs
CHANGED
|
@@ -160,7 +160,7 @@ class V7Generator {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
const getDefaultRandom = ()=>({
|
|
163
|
-
nextUint32: ()=>0x10000 * Math.trunc(0x10000 * Math.random()) + Math.trunc(0x10000 * Math.random())
|
|
163
|
+
nextUint32: ()=>0x10000 * Math.trunc(0x10000 * Math.random()) + Math.trunc(0x10000 * Math.random()) >>> 0
|
|
164
164
|
});
|
|
165
165
|
let defaultGenerator;
|
|
166
166
|
const uuidv7 = ()=>uuidv7obj().toString();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/core",
|
|
3
|
-
"version": "1.48.
|
|
3
|
+
"version": "1.48.12",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/PostHog/posthog-js/issues"
|
|
6
6
|
},
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@posthog/types": "^1.
|
|
73
|
+
"@posthog/types": "^1.407.0"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@rslib/core": "0.10.6",
|
|
@@ -185,8 +185,8 @@ export function matchFeatureFlagProperty(
|
|
|
185
185
|
const operator = property.operator || 'exact'
|
|
186
186
|
const parsingPolicy = options.semverParsingPolicy ?? 'strict'
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
const hasProperty = Object.prototype.hasOwnProperty.call(propertyValues, key)
|
|
189
|
+
if (!hasProperty) {
|
|
190
190
|
throw new InconclusiveMatchError(`Property ${key} not found in propertyValues`)
|
|
191
191
|
} else if (operator === 'is_not_set') {
|
|
192
192
|
return false
|
|
@@ -219,7 +219,7 @@ export function matchFeatureFlagProperty(
|
|
|
219
219
|
case 'is_not':
|
|
220
220
|
return !computeExactMatch(value, overrideValue)
|
|
221
221
|
case 'is_set':
|
|
222
|
-
return
|
|
222
|
+
return true
|
|
223
223
|
case 'icontains':
|
|
224
224
|
return String(overrideValue).toLowerCase().includes(String(value).toLowerCase())
|
|
225
225
|
case 'not_icontains':
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { V7Generator } from './uuidv7'
|
|
2
|
+
|
|
3
|
+
describe('uuidv7 default RNG', () => {
|
|
4
|
+
const realRandom = Math.random
|
|
5
|
+
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
Math.random = realRandom
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
it.each([
|
|
11
|
+
['exactly 1.0', 1.0],
|
|
12
|
+
['greater than 1', 1.5],
|
|
13
|
+
['NaN', NaN],
|
|
14
|
+
])('does not throw when Math.random() returns %s', (_label, value) => {
|
|
15
|
+
Math.random = () => value
|
|
16
|
+
const generator = new V7Generator()
|
|
17
|
+
const uuid = generator.generate().toString()
|
|
18
|
+
expect(uuid).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('still generates well-formed v7 UUIDs with the real Math.random', () => {
|
|
22
|
+
const generator = new V7Generator()
|
|
23
|
+
const uuid = generator.generate().toString()
|
|
24
|
+
expect(uuid).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)
|
|
25
|
+
})
|
|
26
|
+
})
|
package/src/vendor/uuidv7.ts
CHANGED
|
@@ -429,9 +429,15 @@ const getDefaultRandom = (): { nextUint32(): number } => {
|
|
|
429
429
|
// };
|
|
430
430
|
// }
|
|
431
431
|
return {
|
|
432
|
+
// Clamp to a valid uint32: a nonconformant Math.random() that returns >= 1 or NaN
|
|
433
|
+
// (e.g. Hermes on Android implements Math.random with C++ std::uniform_real_distribution,
|
|
434
|
+
// which is documented to occasionally return its upper bound) would otherwise overflow the
|
|
435
|
+
// field ranges and make fromFieldsV7 throw `RangeError: invalid field value` on every
|
|
436
|
+
// generate call, crashing React Native apps during the internal event-queue flush.
|
|
432
437
|
nextUint32: (): number =>
|
|
433
|
-
Math.trunc(Math.random() * 0x1_0000) * 0x1_0000 +
|
|
434
|
-
|
|
438
|
+
(Math.trunc(Math.random() * 0x1_0000) * 0x1_0000 +
|
|
439
|
+
Math.trunc(Math.random() * 0x1_0000)) >>>
|
|
440
|
+
0,
|
|
435
441
|
};
|
|
436
442
|
};
|
|
437
443
|
|