posthog-node 6.3.0 → 6.4.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.
@@ -32,6 +32,7 @@ __webpack_require__.d(__webpack_exports__, {
32
32
  FeatureFlagsPoller: ()=>FeatureFlagsPoller,
33
33
  InconclusiveMatchError: ()=>core_namespaceObject.InconclusiveMatchError,
34
34
  RequiresServerEvaluation: ()=>RequiresServerEvaluation,
35
+ isUsableGroupKey: ()=>isUsableGroupKey,
35
36
  matchProperty: ()=>matchProperty,
36
37
  parseSemver: ()=>parseSemver,
37
38
  relativeDateParseForFeatureFlagMatching: ()=>core_namespaceObject.relativeDateParseForFeatureFlagMatching
@@ -219,6 +220,7 @@ class FeatureFlagsPoller {
219
220
  const record = await (0, external_feature_flags_v2_js_namespaceObject.evaluateConfigV2Definition)(flag, parsed, {
220
221
  distinctId: evaluationContext.distinctId,
221
222
  properties: evaluationContext.personProperties,
223
+ knownAbsentKeys: evaluationContext.personPropertyKeysKnownAbsent,
222
224
  propertyMatchingVersion: evaluationContext.definitions.propertyMatchingVersion
223
225
  });
224
226
  if (void 0 !== matchValue) return {
@@ -244,7 +246,7 @@ class FeatureFlagsPoller {
244
246
  if (!flag.active) return false;
245
247
  if (flag.ensure_experience_continuity) throw new core_namespaceObject.InconclusiveMatchError('Flag has experience continuity enabled', 'experience_continuity');
246
248
  const flagFilters = flag.filters || {};
247
- if (true === flagFilters.feature_enrollment) return matchFeatureEnrollment(flag, personProperties);
249
+ if (true === flagFilters.feature_enrollment && !evaluationContext.personPropertyKeysKnownAbsent?.has(featureEnrollmentKey(flag))) return matchFeatureEnrollment(flag, personProperties);
248
250
  const aggregation_group_type_index = flagFilters.aggregation_group_type_index;
249
251
  if (void 0 != aggregation_group_type_index) {
250
252
  const groupName = evaluationContext.definitions.groupTypeMapping[String(aggregation_group_type_index)];
@@ -252,25 +254,25 @@ class FeatureFlagsPoller {
252
254
  this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${aggregation_group_type_index} for feature flag ${flag.key}`));
253
255
  throw new core_namespaceObject.InconclusiveMatchError('Flag has unknown group type index');
254
256
  }
255
- if (!(groupName in groups)) {
256
- this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${flag.key} without group names passed in`));
257
- return false;
258
- }
259
- if ('device_id' === flag.bucketing_identifier && (personProperties?.$device_id === void 0 || personProperties?.$device_id === null || personProperties?.$device_id === '')) this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Ignoring bucketing_identifier for group flag: ${flag.key}`));
257
+ const groupKey = usableGroupKey(groups, groupName);
258
+ if (void 0 !== groupKey && 'device_id' === flag.bucketing_identifier && (personProperties?.$device_id === void 0 || personProperties?.$device_id === null || personProperties?.$device_id === '')) this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Ignoring bucketing_identifier for group flag: ${flag.key}`));
260
259
  const focusedGroupProperties = groupProperties[groupName];
261
- return await this.matchFeatureFlagProperties(flag, groups[groupName], focusedGroupProperties, evaluationContext);
260
+ return await this.matchFeatureFlagProperties(flag, groupKey ?? '', focusedGroupProperties, evaluationContext, evaluationContext.groupPropertyKeysKnownAbsent?.[groupName]);
262
261
  }
263
262
  {
264
263
  const bucketingValue = this.getBucketingValueForFlag(flag, distinctId, personProperties);
265
264
  if (void 0 === bucketingValue) {
266
265
  this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute feature flag: ${flag.key} without $device_id, falling back to server evaluation`));
267
- throw new core_namespaceObject.InconclusiveMatchError(`Can't compute feature flag: ${flag.key} without $device_id`, getDefinitionUnresolvedReason(flag, evaluationContext.definitions) ?? 'missing_context');
266
+ throw new core_namespaceObject.InconclusiveMatchError(`Can't compute feature flag: ${flag.key} without $device_id`, getDefinitionUnresolvedReason(flag, evaluationContext.definitions, true) ?? 'missing_context');
268
267
  }
269
- return await this.matchFeatureFlagProperties(flag, bucketingValue, personProperties, evaluationContext);
268
+ return await this.matchFeatureFlagProperties(flag, bucketingValue, personProperties, evaluationContext, evaluationContext.personPropertyKeysKnownAbsent);
270
269
  }
271
270
  }
272
271
  getBucketingValueForFlag(flag, distinctId, properties) {
273
272
  if (flag.filters?.aggregation_group_type_index != void 0) return distinctId;
273
+ return this.getPersonBucketingValue(flag, distinctId, properties);
274
+ }
275
+ getPersonBucketingValue(flag, distinctId, properties) {
274
276
  if ('device_id' === flag.bucketing_identifier) {
275
277
  const deviceId = properties?.$device_id;
276
278
  if (null == deviceId || '' === deviceId) return;
@@ -317,15 +319,25 @@ class FeatureFlagsPoller {
317
319
  if ('string' == typeof expectedValue) return flagValue === expectedValue;
318
320
  return false;
319
321
  }
320
- async matchFeatureFlagProperties(flag, bucketingValue, properties, evaluationContext) {
322
+ async matchFeatureFlagProperties(flag, bucketingValue, properties, evaluationContext, knownAbsentKeys) {
321
323
  evaluationContext = this.withEvaluationSnapshot(evaluationContext);
322
324
  const flagFilters = flag.filters || {};
325
+ const flagAggregation = flagFilters.aggregation_group_type_index;
326
+ const { distinctId, groups, groupProperties, personProperties } = evaluationContext;
327
+ if (void 0 != flagAggregation && holdoutCanExclude(flagFilters.holdout)) {
328
+ const flagGroupName = evaluationContext.definitions.groupTypeMapping[String(flagAggregation)];
329
+ if (!flagGroupName || void 0 === usableGroupKey(groups, flagGroupName)) {
330
+ let definitionReason;
331
+ try {
332
+ definitionReason = getDefinitionUnresolvedReason(flag, evaluationContext.definitions, true);
333
+ } catch {}
334
+ throw new core_namespaceObject.InconclusiveMatchError(`Can't compute the holdout of group feature flag ${flag.key} without a group key`, definitionReason ?? 'missing_context');
335
+ }
336
+ }
323
337
  const holdoutVariant = await (0, core_namespaceObject.getHoldoutVariant)(flagFilters.holdout, bucketingValue);
324
338
  if (void 0 !== holdoutVariant) return holdoutVariant;
325
339
  const flagConditions = flagFilters.groups || [];
326
- const flagAggregation = flagFilters.aggregation_group_type_index;
327
340
  const earlyExitEnabled = flagFilters.early_exit ?? false;
328
- const { groups, groupProperties } = evaluationContext;
329
341
  let inconclusiveReason;
330
342
  let regexError;
331
343
  const deferredRegexValues = new Set();
@@ -333,24 +345,34 @@ class FeatureFlagsPoller {
333
345
  for (const condition of flagConditions){
334
346
  let effectiveBucketingValue = bucketingValue;
335
347
  try {
336
- const conditionAggregation = void 0 !== condition.aggregation_group_type_index ? condition.aggregation_group_type_index : flagAggregation;
348
+ const conditionAggregation = conditionAggregationOf(condition, flagAggregation);
337
349
  let effectiveProperties = properties;
338
- if (conditionAggregation !== flagAggregation) {
339
- if (null != conditionAggregation) {
340
- const groupName = evaluationContext.definitions.groupTypeMapping[String(conditionAggregation)];
341
- if (!groupName || !(groupName in groups)) {
342
- this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Skipping group condition for flag '${flag.key}': group type index ${conditionAggregation} not available`));
343
- continue;
344
- }
350
+ let effectiveKnownAbsentKeys = knownAbsentKeys;
351
+ let knownAbsentKeysGroupTypeIndex = flagAggregation;
352
+ if (void 0 != conditionAggregation) {
353
+ const groupName = evaluationContext.definitions.groupTypeMapping[String(conditionAggregation)];
354
+ const groupKey = groupName ? usableGroupKey(groups, groupName) : void 0;
355
+ if (!groupName || void 0 === groupKey) {
356
+ this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Skipping group condition for flag '${flag.key}': group type index ${conditionAggregation} not available`));
357
+ continue;
358
+ }
359
+ if (conditionAggregation !== flagAggregation) {
345
360
  if (!(groupName in groupProperties)) {
346
361
  inconclusiveReason = pickUnresolvedReason(inconclusiveReason, 'missing_context');
347
362
  continue;
348
363
  }
349
364
  effectiveProperties = groupProperties[groupName];
350
- effectiveBucketingValue = groups[groupName];
365
+ effectiveKnownAbsentKeys = evaluationContext.groupPropertyKeysKnownAbsent?.[groupName];
366
+ knownAbsentKeysGroupTypeIndex = conditionAggregation;
367
+ effectiveBucketingValue = groupKey;
351
368
  }
369
+ } else if (void 0 != flagAggregation) {
370
+ effectiveProperties = personProperties;
371
+ effectiveKnownAbsentKeys = evaluationContext.personPropertyKeysKnownAbsent;
372
+ knownAbsentKeysGroupTypeIndex = null;
373
+ effectiveBucketingValue = this.getPersonBucketingValue(flag, distinctId, personProperties);
352
374
  }
353
- const matchResult = await this.isConditionMatch(flag, effectiveBucketingValue, condition, effectiveProperties, evaluationContext);
375
+ const matchResult = await this.isConditionMatch(flag, effectiveBucketingValue, condition, effectiveProperties, evaluationContext, effectiveKnownAbsentKeys, knownAbsentKeysGroupTypeIndex);
354
376
  if ('match' === matchResult) {
355
377
  const variantOverride = condition.variant;
356
378
  const flagVariants = flagFilters.multivariate?.variants || [];
@@ -365,14 +387,14 @@ class FeatureFlagsPoller {
365
387
  if (e instanceof RequiresServerEvaluation) {
366
388
  let definitionReason;
367
389
  try {
368
- definitionReason = getDefinitionUnresolvedReason(flag, evaluationContext.definitions);
390
+ definitionReason = getDefinitionUnresolvedReason(flag, evaluationContext.definitions, true);
369
391
  } catch {}
370
392
  const reason = pickUnresolvedReason(pickUnresolvedReason(inconclusiveReason, e.reason), definitionReason ?? e.reason);
371
393
  throw reason === e.reason ? e : new RequiresServerEvaluation(e.message, reason);
372
394
  }
373
395
  if (e instanceof core_namespaceObject.InconclusiveMatchError) {
374
396
  inconclusiveReason = pickUnresolvedReason(inconclusiveReason, e.reason);
375
- if (Symbol.for('posthog.requiresServerRegexEvaluation') in e) {
397
+ if (Symbol.for('posthog.requiresServerRegexEvaluation') in e && void 0 !== effectiveBucketingValue) {
376
398
  regexError = e;
377
399
  if (earlyExitEnabled && void 0 != condition.rollout_percentage && await (0, core_namespaceObject.getFeatureFlagHash)(flag.key, effectiveBucketingValue) > condition.rollout_percentage / 100.0) deferredRegexValues.add(false);
378
400
  else {
@@ -390,7 +412,7 @@ class FeatureFlagsPoller {
390
412
  if (inconclusiveReason) throw preserveRegexUncertainty(new core_namespaceObject.InconclusiveMatchError("Can't determine if feature flag is enabled or not with given properties", inconclusiveReason), regexError);
391
413
  return false;
392
414
  }
393
- async isConditionMatch(flag, bucketingValue, condition, properties, evaluationContext) {
415
+ async isConditionMatch(flag, bucketingValue, condition, properties, evaluationContext, knownAbsentKeys, knownAbsentKeysGroupTypeIndex) {
394
416
  evaluationContext = this.withEvaluationSnapshot(evaluationContext);
395
417
  const definitions = evaluationContext.definitions;
396
418
  const rolloutPercentage = condition.rollout_percentage;
@@ -401,13 +423,29 @@ class FeatureFlagsPoller {
401
423
  let inconclusiveReason;
402
424
  let regexError;
403
425
  let serverEvaluationError;
426
+ const conditionAggregation = conditionAggregationOf(condition, flag.filters?.aggregation_group_type_index);
427
+ const personFilterScope = null != conditionAggregation ? {
428
+ properties: evaluationContext.personProperties,
429
+ knownAbsentKeys: evaluationContext.personPropertyKeysKnownAbsent
430
+ } : void 0;
404
431
  for (const prop of condition.properties){
405
432
  const propertyType = prop.type;
433
+ const readsPerson = void 0 !== personFilterScope && 'person' === propertyType;
434
+ let filterProperties = readsPerson ? personFilterScope.properties : properties;
435
+ let filterKnownAbsentKeys = readsPerson ? personFilterScope.knownAbsentKeys : knownAbsentKeysForFilter(prop, knownAbsentKeys, knownAbsentKeysGroupTypeIndex);
406
436
  let matches = false;
407
437
  try {
408
- if ('cohort' === propertyType) matches = await matchCohort(prop, properties, definitions.cohorts, this.debugMode, (depProp)=>this.evaluateFlagDependency(depProp, properties, evaluationContext), definitions.propertyMatchingVersion);
438
+ const groupSource = 'group' === propertyType ? groupFilterSource(prop, conditionAggregation, evaluationContext) : void 0;
439
+ if ('no_match' === groupSource) return 'no_match';
440
+ if (void 0 !== groupSource) {
441
+ filterProperties = groupSource.properties;
442
+ filterKnownAbsentKeys = groupSource.missingIsAbsent && !Object.prototype.hasOwnProperty.call(filterProperties, prop.key) ? new Set([
443
+ prop.key
444
+ ]) : groupSource.knownAbsentKeys;
445
+ }
446
+ if ('cohort' === propertyType) matches = await matchCohort(prop, properties, definitions.cohorts, this.debugMode, (depProp)=>this.evaluateFlagDependency(depProp, properties, evaluationContext), definitions.propertyMatchingVersion, personFilterScope ? void 0 : knownAbsentKeys, personFilterScope);
409
447
  else if ('flag' === propertyType) matches = await this.evaluateFlagDependency(prop, properties, evaluationContext);
410
- else if (Object.prototype.hasOwnProperty.call(properties, prop.key)) matches = matchProperty(prop, properties, warnFunction, definitions.propertyMatchingVersion);
448
+ else if (filterKnownAbsentKeys?.has(prop.key) || Object.prototype.hasOwnProperty.call(filterProperties, prop.key)) matches = matchProperty(prop, filterProperties, warnFunction, definitions.propertyMatchingVersion, filterKnownAbsentKeys);
411
449
  else {
412
450
  assertPropertyFilterTypeSupported(prop);
413
451
  (0, core_namespaceObject.assertFeatureFlagFilterSupported)(prop);
@@ -431,9 +469,13 @@ class FeatureFlagsPoller {
431
469
  if (!matches) return 'no_match';
432
470
  }
433
471
  if (serverEvaluationError) throw serverEvaluationError;
434
- if (inconclusiveReason) throw preserveRegexUncertainty(new core_namespaceObject.InconclusiveMatchError(`Can't determine if a condition of flag ${flag.key} matches`, inconclusiveReason), regexError);
435
- if (void 0 == rolloutPercentage) return 'match';
472
+ if (inconclusiveReason) {
473
+ const error = new core_namespaceObject.InconclusiveMatchError(`Can't determine if a condition of flag ${flag.key} matches`, void 0 === bucketingValue ? pickUnresolvedReason(inconclusiveReason, 'missing_context') : inconclusiveReason);
474
+ throw void 0 === bucketingValue ? error : preserveRegexUncertainty(error, regexError);
475
+ }
436
476
  }
477
+ if (void 0 === bucketingValue) throw new core_namespaceObject.InconclusiveMatchError(`Can't compute feature flag: ${flag.key} without $device_id`, 'missing_context');
478
+ if ((condition.properties || []).length > 0 && void 0 == rolloutPercentage) return 'match';
437
479
  if (void 0 != rolloutPercentage && await (0, core_namespaceObject.getFeatureFlagHash)(flag.key, bucketingValue) > rolloutPercentage / 100.0) return 'out_of_rollout_bound';
438
480
  return 'match';
439
481
  }
@@ -707,19 +749,37 @@ class FeatureFlagsPoller {
707
749
  }
708
750
  }
709
751
  }
710
- function getDefinitionUnresolvedReason(flag, definitions) {
752
+ function isUsableGroupKey(groupKey) {
753
+ return 'string' == typeof groupKey && '' !== groupKey || 'number' == typeof groupKey && Number.isFinite(groupKey);
754
+ }
755
+ function usableGroupKey(groups, groupName) {
756
+ const groupKey = groups[groupName];
757
+ return isUsableGroupKey(groupKey) ? String(groupKey) : void 0;
758
+ }
759
+ function conditionAggregationOf(condition, flagAggregation) {
760
+ return void 0 !== condition.aggregation_group_type_index ? condition.aggregation_group_type_index : flagAggregation;
761
+ }
762
+ function holdoutCanExclude(holdout) {
763
+ if (null == holdout || null == holdout.id || null == holdout.exclusion_percentage) return false;
764
+ const percentage = Number(holdout.exclusion_percentage);
765
+ return Number.isFinite(percentage) && percentage > 0;
766
+ }
767
+ function getDefinitionUnresolvedReason(flag, definitions, ignoreFeatureEnrollment = false) {
711
768
  if (!(0, external_feature_flags_v2_js_namespaceObject.isConfigVersion1)(flag)) return (0, external_feature_flags_v2_js_namespaceObject.configV2UnresolvedReason)(flag, definitions.parsedConfigV2Definitions);
712
769
  if (!flag.active) return;
713
770
  if (flag.ensure_experience_continuity) return 'experience_continuity';
714
771
  const flagFilters = flag.filters || {};
715
- if (true === flagFilters.feature_enrollment) return;
772
+ if (true === flagFilters.feature_enrollment && !ignoreFeatureEnrollment) return;
716
773
  const aggregation = flagFilters.aggregation_group_type_index;
717
774
  if (void 0 != aggregation && !definitions.groupTypeMapping[String(aggregation)]) return 'unsupported_definition';
718
- const usesUnsupportedProperty = (flagFilters.groups || []).some((condition)=>(condition.properties || []).some((property)=>isUnsupportedProperty(property, definitions, new Set())));
775
+ const usesUnsupportedProperty = (flagFilters.groups || []).some((condition)=>(condition.properties || []).some((property)=>isUnsupportedProperty(property, definitions, new Set()) || isGroupFilterWithoutGroupType(property, conditionAggregationOf(condition, aggregation))));
719
776
  return usesUnsupportedProperty ? 'unsupported_definition' : void 0;
720
777
  }
778
+ function featureEnrollmentKey(flag) {
779
+ return `$feature_enrollment/${flag.key}`;
780
+ }
721
781
  function matchFeatureEnrollment(flag, personProperties) {
722
- const enrollmentKey = `$feature_enrollment/${flag.key}`;
782
+ const enrollmentKey = featureEnrollmentKey(flag);
723
783
  const enrollment = personProperties[enrollmentKey];
724
784
  if (void 0 === enrollment) throw new core_namespaceObject.InconclusiveMatchError(`Flag has feature enrollment and '${enrollmentKey}' was not passed`, 'missing_context');
725
785
  return true === enrollment || 'true' === enrollment;
@@ -751,6 +811,32 @@ function isUnsupportedProperty(property, definitions, visitedCohortIds) {
751
811
  function isUnsupportedPropertyGroup(group, definitions, visitedCohortIds) {
752
812
  return (group?.values ?? []).some((value)=>'values' in value ? isUnsupportedPropertyGroup(value, definitions, visitedCohortIds) : isUnsupportedProperty(value, definitions, visitedCohortIds));
753
813
  }
814
+ function isGroupFilterWithoutGroupType(property, conditionAggregation) {
815
+ return 'group' === property.type && null == property.group_type_index && null == conditionAggregation;
816
+ }
817
+ function groupFilterSource(property, conditionAggregation, evaluationContext) {
818
+ if (isGroupFilterWithoutGroupType(property, conditionAggregation)) throw new core_namespaceObject.InconclusiveMatchError(`Can't evaluate group filter '${property.key}' without a group_type_index in a person condition locally`, 'unsupported_definition');
819
+ const index = property.group_type_index;
820
+ if (null == index || index === conditionAggregation) return;
821
+ const { groups, groupProperties, groupPropertyKeysKnownAbsent } = evaluationContext;
822
+ const groupName = evaluationContext.definitions.groupTypeMapping[String(index)];
823
+ if (!groupName) return hasGroupContext(groups, groupProperties) ? 'no_match' : {
824
+ properties: {},
825
+ missingIsAbsent: true
826
+ };
827
+ return {
828
+ properties: (Object.prototype.hasOwnProperty.call(groupProperties, groupName) ? groupProperties[groupName] : void 0) ?? {},
829
+ knownAbsentKeys: groupPropertyKeysKnownAbsent?.[groupName],
830
+ missingIsAbsent: void 0 === usableGroupKey(groups, groupName)
831
+ };
832
+ }
833
+ function hasGroupContext(groups, groupProperties) {
834
+ return Object.values(groups).some(isUsableGroupKey) || Object.values(groupProperties).some((properties)=>Object.entries(properties || {}).some(([key, value])=>void 0 !== value && 'function' != typeof value && 'symbol' != typeof value && ('$group_key' !== key || isUsableGroupKey(value))));
835
+ }
836
+ function knownAbsentKeysForFilter(property, knownAbsentKeys, knownAbsentKeysGroupTypeIndex) {
837
+ if (null == knownAbsentKeysGroupTypeIndex) return 'person' === property.type ? knownAbsentKeys : void 0;
838
+ return 'group' === property.type && (property.group_type_index ?? knownAbsentKeysGroupTypeIndex) === knownAbsentKeysGroupTypeIndex ? knownAbsentKeys : void 0;
839
+ }
754
840
  const PROPERTY_FILTER_TYPES = new Set([
755
841
  void 0,
756
842
  null,
@@ -761,11 +847,12 @@ const PROPERTY_FILTER_TYPES = new Set([
761
847
  function assertPropertyFilterTypeSupported(property) {
762
848
  if (!PROPERTY_FILTER_TYPES.has(property.type)) throw new core_namespaceObject.InconclusiveMatchError(`Can't evaluate a '${property.type}' filter on '${property.key}' locally`, 'unsupported_definition');
763
849
  }
764
- function matchProperty(property, propertyValues, warnFunction, propertyMatchingVersion) {
850
+ function matchProperty(property, propertyValues, warnFunction, propertyMatchingVersion, knownAbsentKeys) {
765
851
  assertPropertyFilterTypeSupported(property);
766
852
  return (0, core_namespaceObject.matchFeatureFlagProperty)(property, propertyValues, {
767
853
  warnFunction,
768
- propertyMatchingVersion
854
+ propertyMatchingVersion,
855
+ knownAbsentKeys
769
856
  });
770
857
  }
771
858
  function parseSemver(value) {
@@ -774,14 +861,14 @@ function parseSemver(value) {
774
861
  function checkCohortExists(cohortId, cohortProperties) {
775
862
  if (!(cohortId in cohortProperties)) throw new RequiresServerEvaluation(`cohort ${cohortId} not found in local cohorts - likely a static cohort that requires server evaluation`);
776
863
  }
777
- async function matchCohort(property, propertyValues, cohortProperties, debugMode = false, flagDependencyEvaluator, propertyMatchingVersion) {
864
+ async function matchCohort(property, propertyValues, cohortProperties, debugMode = false, flagDependencyEvaluator, propertyMatchingVersion, knownAbsentKeys, personFilterScope) {
778
865
  const cohortId = String(property.value);
779
866
  checkCohortExists(cohortId, cohortProperties);
780
867
  const propertyGroup = cohortProperties[cohortId];
781
- const inCohort = await matchPropertyGroup(propertyGroup, propertyValues, cohortProperties, debugMode, flagDependencyEvaluator, propertyMatchingVersion);
868
+ const inCohort = await matchPropertyGroup(propertyGroup, propertyValues, cohortProperties, debugMode, flagDependencyEvaluator, propertyMatchingVersion, knownAbsentKeys, personFilterScope);
782
869
  return 'not_in' === property.operator ? !inCohort : inCohort;
783
870
  }
784
- async function matchPropertyGroup(propertyGroup, propertyValues, cohortProperties, debugMode = false, flagDependencyEvaluator, propertyMatchingVersion) {
871
+ async function matchPropertyGroup(propertyGroup, propertyValues, cohortProperties, debugMode = false, flagDependencyEvaluator, propertyMatchingVersion, knownAbsentKeys, personFilterScope) {
785
872
  if (!propertyGroup || 0 === Object.keys(propertyGroup).length) return true;
786
873
  const propertyGroupType = 'property' === propertyGroup.type ? 'AND' : propertyGroup.type;
787
874
  if ('AND' !== propertyGroupType && 'OR' !== propertyGroupType) throw new RequiresServerEvaluation(`Unsupported cohort property group type: ${propertyGroup.type}`);
@@ -791,7 +878,7 @@ async function matchPropertyGroup(propertyGroup, propertyValues, cohortPropertie
791
878
  let regexError;
792
879
  if ('values' in properties[0]) {
793
880
  for (const prop of properties)try {
794
- const matches = await matchPropertyGroup(prop, propertyValues, cohortProperties, debugMode, flagDependencyEvaluator, propertyMatchingVersion);
881
+ const matches = await matchPropertyGroup(prop, propertyValues, cohortProperties, debugMode, flagDependencyEvaluator, propertyMatchingVersion, knownAbsentKeys, personFilterScope);
795
882
  if ('AND' === propertyGroupType) {
796
883
  if (!matches) return false;
797
884
  } else if (matches) return true;
@@ -808,11 +895,11 @@ async function matchPropertyGroup(propertyGroup, propertyValues, cohortPropertie
808
895
  }
809
896
  for (const prop of properties)try {
810
897
  let matches;
811
- if ('cohort' === prop.type) matches = await matchCohort(prop, propertyValues, cohortProperties, debugMode, flagDependencyEvaluator, propertyMatchingVersion);
898
+ if ('cohort' === prop.type) matches = await matchCohort(prop, propertyValues, cohortProperties, debugMode, flagDependencyEvaluator, propertyMatchingVersion, knownAbsentKeys, personFilterScope);
812
899
  else if ('flag' === prop.type) {
813
900
  if (!flagDependencyEvaluator) throw new core_namespaceObject.InconclusiveMatchError(`Flag dependency '${prop.key || 'unknown'}' cannot be evaluated without a flag dependency evaluator`);
814
901
  matches = await flagDependencyEvaluator(prop);
815
- } else matches = matchProperty(prop, propertyValues, void 0, propertyMatchingVersion);
902
+ } else matches = personFilterScope && 'person' === prop.type ? matchProperty(prop, personFilterScope.properties, void 0, propertyMatchingVersion, personFilterScope.knownAbsentKeys) : matchProperty(prop, propertyValues, void 0, propertyMatchingVersion, knownAbsentKeysForFilter(prop, knownAbsentKeys, null));
816
903
  const negation = prop.negation || false;
817
904
  if ('AND' === propertyGroupType) {
818
905
  if (!matches && !negation) return false;
@@ -836,6 +923,7 @@ exports.ClientError = __webpack_exports__.ClientError;
836
923
  exports.FeatureFlagsPoller = __webpack_exports__.FeatureFlagsPoller;
837
924
  exports.InconclusiveMatchError = __webpack_exports__.InconclusiveMatchError;
838
925
  exports.RequiresServerEvaluation = __webpack_exports__.RequiresServerEvaluation;
926
+ exports.isUsableGroupKey = __webpack_exports__.isUsableGroupKey;
839
927
  exports.matchProperty = __webpack_exports__.matchProperty;
840
928
  exports.parseSemver = __webpack_exports__.parseSemver;
841
929
  exports.relativeDateParseForFeatureFlagMatching = __webpack_exports__.relativeDateParseForFeatureFlagMatching;
@@ -844,6 +932,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
844
932
  "FeatureFlagsPoller",
845
933
  "InconclusiveMatchError",
846
934
  "RequiresServerEvaluation",
935
+ "isUsableGroupKey",
847
936
  "matchProperty",
848
937
  "parseSemver",
849
938
  "relativeDateParseForFeatureFlagMatching"