posthog-node 5.56.4 → 5.57.1
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 +3 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +4 -0
- package/dist/client.mjs +4 -0
- package/dist/exports.d.ts +1 -1
- package/dist/exports.d.ts.map +1 -1
- package/dist/extensions/feature-flags/feature-flags.d.ts +9 -5
- package/dist/extensions/feature-flags/feature-flags.d.ts.map +1 -1
- package/dist/extensions/feature-flags/feature-flags.js +182 -64
- package/dist/extensions/feature-flags/feature-flags.mjs +183 -65
- package/dist/feature-flag-evaluations.d.ts +12 -1
- package/dist/feature-flag-evaluations.d.ts.map +1 -1
- package/dist/feature-flag-evaluations.js +7 -1
- package/dist/feature-flag-evaluations.mjs +7 -1
- package/dist/types.d.ts +7 -0
- 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.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +2 -2
- package/src/client.ts +21 -2
- package/src/exports.ts +1 -1
- package/src/extensions/feature-flags/feature-flags.ts +319 -71
- package/src/feature-flag-evaluations.ts +24 -3
- package/src/types.ts +7 -0
- package/src/version.ts +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export declare abstract class PostHogBackendClient extends PostHogCoreStateless
|
|
|
22
22
|
private _v1Sender?;
|
|
23
23
|
/** Whether this client captures full AI content: see `enableFullAiCapture` in `PostHogOptions`. */
|
|
24
24
|
readonly enableFullAiCapture: boolean;
|
|
25
|
+
/** Whether PostHog AI integrations redact content: see `privacyMode` in `PostHogOptions`. */
|
|
26
|
+
readonly privacyMode: boolean;
|
|
25
27
|
private _aiCaptureRouteActive;
|
|
26
28
|
private _flagOverrides?;
|
|
27
29
|
private _payloadOverrides?;
|
|
@@ -1055,7 +1057,7 @@ export declare abstract class PostHogBackendClient extends PostHogCoreStateless
|
|
|
1055
1057
|
* {@label Feature flags}
|
|
1056
1058
|
*
|
|
1057
1059
|
* @param distinctIdOrOptions - The user's distinct ID, or options when the distinctId comes from `withContext()`
|
|
1058
|
-
* @param options - Optional configuration for flag evaluation. Supports the same fields as `getAllFlags()`. `flagKeys` scopes local evaluation, the `/flags` request, and the returned snapshot. `onlyEvaluateLocally` prevents fallback and leaves unresolved keys absent.
|
|
1060
|
+
* @param options - Optional configuration for flag evaluation. Supports the same fields as `getAllFlags()`. `flagKeys` scopes local evaluation, the `/flags` request, and the returned snapshot. `onlyEvaluateLocally` prevents fallback and leaves unresolved keys absent; the snapshot's `unresolvedFlags` lists them with a reason.
|
|
1059
1061
|
* @returns Promise that resolves to a `FeatureFlagEvaluations` snapshot
|
|
1060
1062
|
*/
|
|
1061
1063
|
evaluateFlags(options?: AllFlagsOptions): Promise<FeatureFlagEvaluations>;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,gBAAgB,EAKhB,QAAQ,EAER,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,+BAA+B,EAG/B,wBAAwB,EAGxB,UAAU,EAIV,gBAAgB,EAKjB,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,gBAAgB,EAKhB,QAAQ,EAER,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,+BAA+B,EAG/B,wBAAwB,EAGxB,UAAU,EAIV,gBAAgB,EAKjB,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EACV,OAAO,EACP,IAAI,EACJ,kBAAkB,EAClB,gBAAgB,EAGjB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QAClB,KAAK,EAAE,MAAM,CAAA;QACb,UAAU,EAAE,sBAAsB,CAAA;QAClC,OAAO,EAAE,qBAAqB,CAAA;KAC/B,CAAC,CAED;YAEa,oBAAoB;IA0JlC,OAAO,CAAC,cAAc;CA4BvB"}
|
package/dist/client.js
CHANGED
|
@@ -114,6 +114,7 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
114
114
|
this.options = normalizedOptions;
|
|
115
115
|
this.captureMode = (0, config_js_namespaceObject.resolveCaptureMode)();
|
|
116
116
|
this.enableFullAiCapture = true === normalizedOptions.enableFullAiCapture;
|
|
117
|
+
this.privacyMode = true === normalizedOptions.privacyMode;
|
|
117
118
|
this.context = this.initializeContext();
|
|
118
119
|
this.options.featureFlagsPollingInterval = 'number' == typeof normalizedOptions.featureFlagsPollingInterval ? Math.max(normalizedOptions.featureFlagsPollingInterval, MINIMUM_POLLING_INTERVAL) : null === normalizedOptions.featureFlagsPollingInterval ? null : THIRTY_SECONDS;
|
|
119
120
|
if ('number' == typeof normalizedOptions.waitUntilDebounceMs) this.options.waitUntilDebounceMs = Math.max(normalizedOptions.waitUntilDebounceMs, 0);
|
|
@@ -902,12 +903,15 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
902
903
|
if (void 0 !== requestedFlagKeys) {
|
|
903
904
|
for (const key of Object.keys(records))if (!requestedFlagKeys.has(key)) delete records[key];
|
|
904
905
|
}
|
|
906
|
+
const unresolvedFlags = {};
|
|
907
|
+
for (const [key, reason] of Object.entries(localResult?.unresolved ?? {}))if (!Object.prototype.hasOwnProperty.call(records, key)) unresolvedFlags[key] = reason;
|
|
905
908
|
return new external_feature_flag_evaluations_js_namespaceObject.FeatureFlagEvaluations({
|
|
906
909
|
host: this._getFeatureFlagEvaluationsHost(),
|
|
907
910
|
distinctId: resolvedDistinctId,
|
|
908
911
|
groups,
|
|
909
912
|
disableGeoip,
|
|
910
913
|
flags: records,
|
|
914
|
+
unresolvedFlags,
|
|
911
915
|
requestId,
|
|
912
916
|
evaluatedAt,
|
|
913
917
|
flagDefinitionsLoadedAt: this.featureFlagsPoller?.getFlagDefinitionsLoadedAt(),
|
package/dist/client.mjs
CHANGED
|
@@ -71,6 +71,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
71
71
|
this.options = normalizedOptions;
|
|
72
72
|
this.captureMode = resolveCaptureMode();
|
|
73
73
|
this.enableFullAiCapture = true === normalizedOptions.enableFullAiCapture;
|
|
74
|
+
this.privacyMode = true === normalizedOptions.privacyMode;
|
|
74
75
|
this.context = this.initializeContext();
|
|
75
76
|
this.options.featureFlagsPollingInterval = 'number' == typeof normalizedOptions.featureFlagsPollingInterval ? Math.max(normalizedOptions.featureFlagsPollingInterval, MINIMUM_POLLING_INTERVAL) : null === normalizedOptions.featureFlagsPollingInterval ? null : THIRTY_SECONDS;
|
|
76
77
|
if ('number' == typeof normalizedOptions.waitUntilDebounceMs) this.options.waitUntilDebounceMs = Math.max(normalizedOptions.waitUntilDebounceMs, 0);
|
|
@@ -859,12 +860,15 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
859
860
|
if (void 0 !== requestedFlagKeys) {
|
|
860
861
|
for (const key of Object.keys(records))if (!requestedFlagKeys.has(key)) delete records[key];
|
|
861
862
|
}
|
|
863
|
+
const unresolvedFlags = {};
|
|
864
|
+
for (const [key, reason] of Object.entries(localResult?.unresolved ?? {}))if (!Object.prototype.hasOwnProperty.call(records, key)) unresolvedFlags[key] = reason;
|
|
862
865
|
return new FeatureFlagEvaluations({
|
|
863
866
|
host: this._getFeatureFlagEvaluationsHost(),
|
|
864
867
|
distinctId: resolvedDistinctId,
|
|
865
868
|
groups,
|
|
866
869
|
disableGeoip,
|
|
867
870
|
flags: records,
|
|
871
|
+
unresolvedFlags,
|
|
868
872
|
requestId,
|
|
869
873
|
evaluatedAt,
|
|
870
874
|
flagDefinitionsLoadedAt: this.featureFlagsPoller?.getFlagDefinitionsLoadedAt(),
|
package/dist/exports.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export * from './types';
|
|
|
4
4
|
export { FeatureFlagEvaluations } from './feature-flag-evaluations';
|
|
5
5
|
export type { FlagDefinitionCacheData, FlagDefinitionCacheInput, FlagDefinitionCacheProvider, } from './extensions/feature-flags/cache';
|
|
6
6
|
export { FeatureFlagError } from '@posthog/core';
|
|
7
|
-
export type { FeatureFlagErrorType } from '@posthog/core';
|
|
7
|
+
export type { FeatureFlagErrorType, UnresolvedFlagReason } from '@posthog/core';
|
|
8
8
|
export type { CaptureMetricOptions, Metrics, MetricsConfig } from '@posthog/core';
|
|
9
9
|
export type { Span, SpanAttributes, SpanAttributeValue, SpanKind, SpanStatusCode, SpanTimeInput, StartSpanOptions, SpanRecord, BeforeSpanSendFn, TracesConfig, } from '@posthog/core';
|
|
10
10
|
export { cookieStateToProperties, cookieStoreFromHeader, getPostHogCookieName, parsePostHogCookie, readPostHogCookie, serializePostHogCookie, uuidv7, } from '@posthog/core';
|
package/dist/exports.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAA;AAC/C,cAAc,sBAAsB,CAAA;AACpC,cAAc,SAAS,CAAA;AAEvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AACnE,YAAY,EACV,uBAAuB,EACvB,wBAAwB,EACxB,2BAA2B,GAC5B,MAAM,kCAAkC,CAAA;AAIzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAA;AAC/C,cAAc,sBAAsB,CAAA;AACpC,cAAc,SAAS,CAAA;AAEvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AACnE,YAAY,EACV,uBAAuB,EACvB,wBAAwB,EACxB,2BAA2B,GAC5B,MAAM,kCAAkC,CAAA;AAIzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAI/E,YAAY,EAAE,oBAAoB,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAIjF,YAAY,EACV,IAAI,EACJ,cAAc,EACd,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,YAAY,GACb,MAAM,eAAe,CAAA;AAKtB,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,MAAM,GACP,MAAM,eAAe,CAAA;AACtB,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FeatureFlagCondition, FeatureFlagEvaluationRuntime, PostHogFeatureFlag, PropertyGroup } from '../../types';
|
|
2
|
-
import type { FeatureFlagValue, JsonType, PostHogFetchOptions, PostHogFetchResponse } from '@posthog/core';
|
|
2
|
+
import type { FeatureFlagValue, JsonType, PostHogFetchOptions, PostHogFetchResponse, UnresolvedFlagReason } from '@posthog/core';
|
|
3
3
|
import { InconclusiveMatchError, relativeDateParseForFeatureFlagMatching } from '@posthog/core';
|
|
4
4
|
import { FlagDefinitionCacheProvider, FlagDefinitionCacheInput } from './cache';
|
|
5
5
|
type ConditionMatchResult = 'match' | 'no_match' | 'out_of_rollout_bound';
|
|
@@ -7,6 +7,7 @@ declare class ClientError extends Error {
|
|
|
7
7
|
constructor(message: string);
|
|
8
8
|
}
|
|
9
9
|
declare class RequiresServerEvaluation extends Error {
|
|
10
|
+
readonly reason: UnresolvedFlagReason;
|
|
10
11
|
constructor(message: string);
|
|
11
12
|
}
|
|
12
13
|
type FeatureFlagsPollerOptions = {
|
|
@@ -87,15 +88,18 @@ declare class FeatureFlagsPoller {
|
|
|
87
88
|
private onMinimalFlagCalledEvents?;
|
|
88
89
|
private evaluationContexts?;
|
|
89
90
|
private filteredOutFlagKeys;
|
|
91
|
+
private warnedUnresolvableFlags;
|
|
90
92
|
constructor({ pollingInterval, personalApiKey, projectApiKey, timeout, host, customHeaders, ...options }: FeatureFlagsPollerOptions);
|
|
91
93
|
debug(enabled?: boolean): void;
|
|
92
94
|
private logMsgIfDebug;
|
|
95
|
+
private currentDefinitions;
|
|
93
96
|
private withEvaluationSnapshot;
|
|
94
97
|
private createEvaluationContext;
|
|
95
98
|
getFeatureFlag(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, any>, groupProperties?: Record<string, Record<string, any>>): Promise<FeatureFlagValue | undefined>;
|
|
96
99
|
getAllFlagsAndPayloads(evaluationContext: FeatureFlagEvaluationContext, flagKeysToExplicitlyEvaluate?: string[]): Promise<{
|
|
97
100
|
response: Record<string, FeatureFlagValue>;
|
|
98
101
|
payloads: Record<string, JsonType>;
|
|
102
|
+
unresolved: Record<string, UnresolvedFlagReason>;
|
|
99
103
|
fallbackToFlags: boolean;
|
|
100
104
|
}>;
|
|
101
105
|
computeFlagAndPayloadLocally(flag: PostHogFeatureFlag, evaluationContext: FeatureFlagEvaluationContext, options?: ComputeFlagAndPayloadOptions): Promise<{
|
|
@@ -130,11 +134,11 @@ declare class FeatureFlagsPoller {
|
|
|
130
134
|
getFlagKeysByEvaluationRuntime(runtime: FeatureFlagEvaluationRuntime): string[];
|
|
131
135
|
private updateFlagState;
|
|
132
136
|
/**
|
|
133
|
-
* Warn about flags
|
|
134
|
-
* Called after loading flag definitions when local evaluation is enabled.
|
|
135
|
-
*
|
|
137
|
+
* Warn about flags whose definition local evaluation cannot resolve.
|
|
138
|
+
* Called after loading flag definitions when local evaluation is enabled. Each flag is
|
|
139
|
+
* warned about once until its definition changes.
|
|
136
140
|
*/
|
|
137
|
-
private
|
|
141
|
+
private warnAboutUnresolvableFlags;
|
|
138
142
|
/**
|
|
139
143
|
* Attempts to load flags from cache and update internal state.
|
|
140
144
|
* Returns true if flags were successfully loaded from cache, false otherwise.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-flags.d.ts","sourceRoot":"","sources":["../../../src/extensions/feature-flags/feature-flags.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAG5B,kBAAkB,EAClB,aAAa,EACd,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"feature-flags.d.ts","sourceRoot":"","sources":["../../../src/extensions/feature-flags/feature-flags.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAG5B,kBAAkB,EAClB,aAAa,EACd,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EACV,gBAAgB,EAChB,QAAQ,EACR,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,eAAe,CAAA;AACtB,OAAO,EAML,sBAAsB,EAItB,uCAAuC,EAGxC,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,2BAA2B,EAA2B,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAkBxG,KAAK,oBAAoB,GAAG,OAAO,GAAG,UAAU,GAAG,sBAAsB,CAAA;AAEzE,cAAM,WAAY,SAAQ,KAAK;IAC7B,YAAY,OAAO,EAAE,MAAM,EAM1B;CACF;AAWD,cAAM,wBAAyB,SAAQ,KAAK;IAE1C,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAA2B;IAEhE,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AA4BD,KAAK,yBAAyB,GAAG;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE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
class RequiresServerEvaluation extends Error {
|
|
62
62
|
constructor(message){
|
|
63
|
-
super(message);
|
|
63
|
+
super(message), this.reason = 'unsupported_definition';
|
|
64
64
|
setCustomErrorPrototype(this, RequiresServerEvaluation);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
const UNRESOLVED_REASON_PRECEDENCE = [
|
|
68
|
+
'experience_continuity',
|
|
69
|
+
'unsupported_definition',
|
|
70
|
+
'unresolved_dependency',
|
|
71
|
+
'missing_context'
|
|
72
|
+
];
|
|
73
|
+
function pickUnresolvedReason(current, next) {
|
|
74
|
+
if (void 0 === current) return next;
|
|
75
|
+
return UNRESOLVED_REASON_PRECEDENCE.indexOf(next) < UNRESOLVED_REASON_PRECEDENCE.indexOf(current) ? next : current;
|
|
76
|
+
}
|
|
77
|
+
function preserveRegexUncertainty(error, original) {
|
|
78
|
+
if (original instanceof core_namespaceObject.InconclusiveMatchError && Symbol.for('posthog.requiresServerRegexEvaluation') in original) Object.defineProperty(error, Symbol.for('posthog.requiresServerRegexEvaluation'), {
|
|
79
|
+
value: true
|
|
80
|
+
});
|
|
81
|
+
return error;
|
|
82
|
+
}
|
|
67
83
|
class FeatureFlagsPoller {
|
|
68
84
|
constructor({ pollingInterval, personalApiKey, projectApiKey, timeout, host, customHeaders, ...options }){
|
|
69
85
|
this.debugMode = false;
|
|
@@ -71,6 +87,7 @@ class FeatureFlagsPoller {
|
|
|
71
87
|
this.backOffCount = 0;
|
|
72
88
|
this.pollerStopped = false;
|
|
73
89
|
this.filteredOutFlagKeys = new Set();
|
|
90
|
+
this.warnedUnresolvableFlags = new Map();
|
|
74
91
|
this.pollingInterval = pollingInterval;
|
|
75
92
|
this.personalApiKey = personalApiKey;
|
|
76
93
|
this.featureFlags = [];
|
|
@@ -98,18 +115,21 @@ class FeatureFlagsPoller {
|
|
|
98
115
|
logMsgIfDebug(fn) {
|
|
99
116
|
if (this.debugMode) fn();
|
|
100
117
|
}
|
|
118
|
+
currentDefinitions() {
|
|
119
|
+
return {
|
|
120
|
+
featureFlagsByKey: this.featureFlagsByKey,
|
|
121
|
+
groupTypeMapping: this.groupTypeMapping,
|
|
122
|
+
cohorts: this.cohorts,
|
|
123
|
+
filteredOutFlagKeys: this.filteredOutFlagKeys,
|
|
124
|
+
propertyMatchingVersion: this.propertyMatchingVersion
|
|
125
|
+
};
|
|
126
|
+
}
|
|
101
127
|
withEvaluationSnapshot(context) {
|
|
102
128
|
if (context.definitions) return context;
|
|
103
129
|
return {
|
|
104
130
|
...context,
|
|
105
131
|
evaluationCache: {},
|
|
106
|
-
definitions:
|
|
107
|
-
featureFlagsByKey: this.featureFlagsByKey,
|
|
108
|
-
groupTypeMapping: this.groupTypeMapping,
|
|
109
|
-
cohorts: this.cohorts,
|
|
110
|
-
filteredOutFlagKeys: this.filteredOutFlagKeys,
|
|
111
|
-
propertyMatchingVersion: this.propertyMatchingVersion
|
|
112
|
-
}
|
|
132
|
+
definitions: this.currentDefinitions()
|
|
113
133
|
};
|
|
114
134
|
}
|
|
115
135
|
createEvaluationContext(distinctId, groups = {}, personProperties = {}, groupProperties = {}, evaluationCache = {}) {
|
|
@@ -144,6 +164,7 @@ class FeatureFlagsPoller {
|
|
|
144
164
|
await this.loadFeatureFlags();
|
|
145
165
|
const response = {};
|
|
146
166
|
const payloads = {};
|
|
167
|
+
const unresolved = {};
|
|
147
168
|
let fallbackToFlags = 0 == this.featureFlags.length;
|
|
148
169
|
const flagsToEvaluate = flagKeysToExplicitlyEvaluate ? flagKeysToExplicitlyEvaluate.map((key)=>this.featureFlagsByKey[key]).filter(Boolean) : this.featureFlags;
|
|
149
170
|
const sharedEvaluationContext = this.withEvaluationSnapshot({
|
|
@@ -158,14 +179,17 @@ class FeatureFlagsPoller {
|
|
|
158
179
|
response[flag.key] = matchValue;
|
|
159
180
|
if (matchPayload) payloads[flag.key] = matchPayload;
|
|
160
181
|
} catch (e) {
|
|
161
|
-
if (e instanceof RequiresServerEvaluation || e instanceof core_namespaceObject.InconclusiveMatchError)
|
|
162
|
-
|
|
182
|
+
if (e instanceof RequiresServerEvaluation || e instanceof core_namespaceObject.InconclusiveMatchError) {
|
|
183
|
+
this.logMsgIfDebug(()=>console.debug(`${e.name} when computing flag locally: ${flag.key}: ${e.message}`));
|
|
184
|
+
unresolved[flag.key] = e.reason;
|
|
185
|
+
} else if (e instanceof Error) this.onError?.(new Error(`Error computing flag locally: ${flag.key}: ${e}`));
|
|
163
186
|
fallbackToFlags = true;
|
|
164
187
|
}
|
|
165
188
|
}));
|
|
166
189
|
return {
|
|
167
190
|
response,
|
|
168
191
|
payloads,
|
|
192
|
+
unresolved,
|
|
169
193
|
fallbackToFlags
|
|
170
194
|
};
|
|
171
195
|
}
|
|
@@ -190,7 +214,7 @@ class FeatureFlagsPoller {
|
|
|
190
214
|
async computeFlagValueLocally(flag, evaluationContext) {
|
|
191
215
|
const { distinctId, groups, personProperties, groupProperties } = evaluationContext;
|
|
192
216
|
if (!flag.active) return false;
|
|
193
|
-
if (flag.ensure_experience_continuity) throw new core_namespaceObject.InconclusiveMatchError('Flag has experience continuity enabled');
|
|
217
|
+
if (flag.ensure_experience_continuity) throw new core_namespaceObject.InconclusiveMatchError('Flag has experience continuity enabled', 'experience_continuity');
|
|
194
218
|
const flagFilters = flag.filters || {};
|
|
195
219
|
const aggregation_group_type_index = flagFilters.aggregation_group_type_index;
|
|
196
220
|
if (void 0 != aggregation_group_type_index) {
|
|
@@ -211,7 +235,7 @@ class FeatureFlagsPoller {
|
|
|
211
235
|
const bucketingValue = this.getBucketingValueForFlag(flag, distinctId, personProperties);
|
|
212
236
|
if (void 0 === bucketingValue) {
|
|
213
237
|
this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute feature flag: ${flag.key} without $device_id, falling back to server evaluation`));
|
|
214
|
-
throw new core_namespaceObject.InconclusiveMatchError(`Can't compute feature flag: ${flag.key} without $device_id
|
|
238
|
+
throw new core_namespaceObject.InconclusiveMatchError(`Can't compute feature flag: ${flag.key} without $device_id`, getDefinitionUnresolvedReason(flag, evaluationContext.definitions) ?? 'missing_context');
|
|
215
239
|
}
|
|
216
240
|
return await this.matchFeatureFlagProperties(flag, bucketingValue, personProperties, evaluationContext);
|
|
217
241
|
}
|
|
@@ -233,6 +257,8 @@ class FeatureFlagsPoller {
|
|
|
233
257
|
const dependencyChain = property.dependency_chain;
|
|
234
258
|
if (!Array.isArray(dependencyChain)) throw new core_namespaceObject.InconclusiveMatchError(`Flag dependency property for '${targetFlagKey}' has an invalid 'dependency_chain' (expected array, got ${typeof dependencyChain})`);
|
|
235
259
|
if (0 === dependencyChain.length) throw new core_namespaceObject.InconclusiveMatchError(`Circular dependency detected for flag '${targetFlagKey}' (empty dependency chain)`);
|
|
260
|
+
const missingDependency = dependencyChain.find((depFlagKey)=>!(depFlagKey in evaluationCache) && !evaluationContext.definitions.featureFlagsByKey[depFlagKey] && !evaluationContext.definitions.filteredOutFlagKeys.has(depFlagKey));
|
|
261
|
+
if (void 0 !== missingDependency) throw new core_namespaceObject.InconclusiveMatchError(`Missing flag dependency '${missingDependency}' for flag '${targetFlagKey}'`);
|
|
236
262
|
for (const depFlagKey of dependencyChain){
|
|
237
263
|
if (!(depFlagKey in evaluationCache)) {
|
|
238
264
|
const depFlag = evaluationContext.definitions.featureFlagsByKey[depFlagKey];
|
|
@@ -240,14 +266,13 @@ class FeatureFlagsPoller {
|
|
|
240
266
|
const depResult = await this.computeFlagValueLocally(depFlag, evaluationContext);
|
|
241
267
|
evaluationCache[depFlagKey] = depResult;
|
|
242
268
|
} catch (error) {
|
|
243
|
-
throw new core_namespaceObject.InconclusiveMatchError(`Error evaluating flag dependency '${depFlagKey}' for flag '${targetFlagKey}': ${error}
|
|
269
|
+
throw preserveRegexUncertainty(new core_namespaceObject.InconclusiveMatchError(`Error evaluating flag dependency '${depFlagKey}' for flag '${targetFlagKey}': ${error}`, 'unresolved_dependency'), error);
|
|
244
270
|
}
|
|
245
271
|
else evaluationCache[depFlagKey] = false;
|
|
246
|
-
else
|
|
247
|
-
else throw new core_namespaceObject.InconclusiveMatchError(`Missing flag dependency '${depFlagKey}' for flag '${targetFlagKey}'`);
|
|
272
|
+
else evaluationCache[depFlagKey] = false;
|
|
248
273
|
}
|
|
249
274
|
const cachedResult = evaluationCache[depFlagKey];
|
|
250
|
-
if (null == cachedResult) throw new core_namespaceObject.InconclusiveMatchError(`Dependency '${depFlagKey}' could not be evaluated
|
|
275
|
+
if (null == cachedResult) throw new core_namespaceObject.InconclusiveMatchError(`Dependency '${depFlagKey}' could not be evaluated`, 'unresolved_dependency');
|
|
251
276
|
}
|
|
252
277
|
const targetFlagValue = evaluationCache[targetFlagKey];
|
|
253
278
|
return this.flagEvaluatesToExpectedValue(property.value, targetFlagValue);
|
|
@@ -266,45 +291,61 @@ class FeatureFlagsPoller {
|
|
|
266
291
|
const flagAggregation = flagFilters.aggregation_group_type_index;
|
|
267
292
|
const earlyExitEnabled = flagFilters.early_exit ?? false;
|
|
268
293
|
const { groups, groupProperties } = evaluationContext;
|
|
269
|
-
let
|
|
294
|
+
let inconclusiveReason;
|
|
295
|
+
let regexError;
|
|
296
|
+
const deferredRegexValues = new Set();
|
|
270
297
|
let result;
|
|
271
|
-
for (const condition of flagConditions)
|
|
272
|
-
const conditionAggregation = void 0 !== condition.aggregation_group_type_index ? condition.aggregation_group_type_index : flagAggregation;
|
|
273
|
-
let effectiveProperties = properties;
|
|
298
|
+
for (const condition of flagConditions){
|
|
274
299
|
let effectiveBucketingValue = bucketingValue;
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
300
|
+
try {
|
|
301
|
+
const conditionAggregation = void 0 !== condition.aggregation_group_type_index ? condition.aggregation_group_type_index : flagAggregation;
|
|
302
|
+
let effectiveProperties = properties;
|
|
303
|
+
if (conditionAggregation !== flagAggregation) {
|
|
304
|
+
if (null != conditionAggregation) {
|
|
305
|
+
const groupName = evaluationContext.definitions.groupTypeMapping[String(conditionAggregation)];
|
|
306
|
+
if (!groupName || !(groupName in groups)) {
|
|
307
|
+
this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Skipping group condition for flag '${flag.key}': group type index ${conditionAggregation} not available`));
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
if (!(groupName in groupProperties)) {
|
|
311
|
+
inconclusiveReason = pickUnresolvedReason(inconclusiveReason, 'missing_context');
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
effectiveProperties = groupProperties[groupName];
|
|
315
|
+
effectiveBucketingValue = groups[groupName];
|
|
285
316
|
}
|
|
286
|
-
effectiveProperties = groupProperties[groupName];
|
|
287
|
-
effectiveBucketingValue = groups[groupName];
|
|
288
317
|
}
|
|
318
|
+
const matchResult = await this.isConditionMatch(flag, effectiveBucketingValue, condition, effectiveProperties, evaluationContext);
|
|
319
|
+
if ('match' === matchResult) {
|
|
320
|
+
const variantOverride = condition.variant;
|
|
321
|
+
const flagVariants = flagFilters.multivariate?.variants || [];
|
|
322
|
+
result = variantOverride && flagVariants.some((variant)=>variant.key === variantOverride) ? variantOverride : await this.getMatchingVariant(flag, effectiveBucketingValue) || true;
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
if (earlyExitEnabled && 'out_of_rollout_bound' === matchResult) {
|
|
326
|
+
if (inconclusiveReason) break;
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
} catch (e) {
|
|
330
|
+
if (e instanceof RequiresServerEvaluation) throw e;
|
|
331
|
+
if (e instanceof core_namespaceObject.InconclusiveMatchError) {
|
|
332
|
+
inconclusiveReason = pickUnresolvedReason(inconclusiveReason, e.reason);
|
|
333
|
+
if (Symbol.for('posthog.requiresServerRegexEvaluation') in e) {
|
|
334
|
+
regexError = e;
|
|
335
|
+
if (earlyExitEnabled && void 0 != condition.rollout_percentage && await (0, core_namespaceObject.getFeatureFlagHash)(flag.key, effectiveBucketingValue) > condition.rollout_percentage / 100.0) deferredRegexValues.add(false);
|
|
336
|
+
else {
|
|
337
|
+
const variants = flagFilters.multivariate?.variants || [];
|
|
338
|
+
const override = condition.variant;
|
|
339
|
+
deferredRegexValues.add(override && variants.some((variant)=>variant.key === override) ? override : await this.getMatchingVariant(flag, effectiveBucketingValue) || true);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
} else throw e;
|
|
289
343
|
}
|
|
290
|
-
const matchResult = await this.isConditionMatch(flag, effectiveBucketingValue, condition, effectiveProperties, evaluationContext);
|
|
291
|
-
if ('match' === matchResult) {
|
|
292
|
-
const variantOverride = condition.variant;
|
|
293
|
-
const flagVariants = flagFilters.multivariate?.variants || [];
|
|
294
|
-
result = variantOverride && flagVariants.some((variant)=>variant.key === variantOverride) ? variantOverride : await this.getMatchingVariant(flag, effectiveBucketingValue) || true;
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
if (earlyExitEnabled && 'out_of_rollout_bound' === matchResult) {
|
|
298
|
-
if (isInconclusive) break;
|
|
299
|
-
return false;
|
|
300
|
-
}
|
|
301
|
-
} catch (e) {
|
|
302
|
-
if (e instanceof RequiresServerEvaluation) throw e;
|
|
303
|
-
if (e instanceof core_namespaceObject.InconclusiveMatchError) isInconclusive = true;
|
|
304
|
-
else throw e;
|
|
305
344
|
}
|
|
306
|
-
if (void 0 !== result
|
|
307
|
-
|
|
345
|
+
if (void 0 !== result && !(regexError && [
|
|
346
|
+
...deferredRegexValues
|
|
347
|
+
].some((value)=>value !== result))) return result;
|
|
348
|
+
if (inconclusiveReason) throw preserveRegexUncertainty(new core_namespaceObject.InconclusiveMatchError("Can't determine if feature flag is enabled or not with given properties", inconclusiveReason), regexError);
|
|
308
349
|
return false;
|
|
309
350
|
}
|
|
310
351
|
async isConditionMatch(flag, bucketingValue, condition, properties, evaluationContext) {
|
|
@@ -315,15 +356,40 @@ class FeatureFlagsPoller {
|
|
|
315
356
|
this.logMsgIfDebug(()=>console.warn(msg));
|
|
316
357
|
};
|
|
317
358
|
if ((condition.properties || []).length > 0) {
|
|
359
|
+
let inconclusiveReason;
|
|
360
|
+
let regexError;
|
|
361
|
+
let serverEvaluationError;
|
|
318
362
|
for (const prop of condition.properties){
|
|
319
363
|
const propertyType = prop.type;
|
|
320
364
|
let matches = false;
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
365
|
+
try {
|
|
366
|
+
if ('cohort' === propertyType) {
|
|
367
|
+
const inCohort = await matchCohort(prop, properties, definitions.cohorts, this.debugMode, (depProp)=>this.evaluateFlagDependency(depProp, properties, evaluationContext), definitions.propertyMatchingVersion);
|
|
368
|
+
matches = 'not_in' === prop.operator ? !inCohort : inCohort;
|
|
369
|
+
} else if ('flag' === propertyType) matches = await this.evaluateFlagDependency(prop, properties, evaluationContext);
|
|
370
|
+
else if (Object.prototype.hasOwnProperty.call(properties, prop.key)) matches = matchProperty(prop, properties, warnFunction, definitions.propertyMatchingVersion);
|
|
371
|
+
else {
|
|
372
|
+
(0, core_namespaceObject.assertFeatureFlagFilterSupported)(prop);
|
|
373
|
+
inconclusiveReason = pickUnresolvedReason(inconclusiveReason, 'missing_context');
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
} catch (e) {
|
|
377
|
+
if (e instanceof RequiresServerEvaluation) {
|
|
378
|
+
if (void 0 === inconclusiveReason) serverEvaluationError ??= e;
|
|
379
|
+
inconclusiveReason = pickUnresolvedReason(inconclusiveReason, e.reason);
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
if (e instanceof core_namespaceObject.InconclusiveMatchError) {
|
|
383
|
+
if (Symbol.for('posthog.requiresServerRegexEvaluation') in e) regexError = e;
|
|
384
|
+
inconclusiveReason = pickUnresolvedReason(inconclusiveReason, e.reason);
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
throw e;
|
|
388
|
+
}
|
|
325
389
|
if (!matches) return 'no_match';
|
|
326
390
|
}
|
|
391
|
+
if (serverEvaluationError) throw serverEvaluationError;
|
|
392
|
+
if (inconclusiveReason) throw preserveRegexUncertainty(new core_namespaceObject.InconclusiveMatchError(`Can't determine if a condition of flag ${flag.key} matches`, inconclusiveReason), regexError);
|
|
327
393
|
if (void 0 == rolloutPercentage) return 'match';
|
|
328
394
|
}
|
|
329
395
|
if (void 0 != rolloutPercentage && await (0, core_namespaceObject.getFeatureFlagHash)(flag.key, bucketingValue) > rolloutPercentage / 100.0) return 'out_of_rollout_bound';
|
|
@@ -365,10 +431,28 @@ class FeatureFlagsPoller {
|
|
|
365
431
|
this.loadedSuccessfullyOnce = true;
|
|
366
432
|
this.onMinimalFlagCalledEvents?.((flagData.minimal_flag_called_events ?? flagData.minimalFlagCalledEvents) === true);
|
|
367
433
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
const
|
|
371
|
-
|
|
434
|
+
warnAboutUnresolvableFlags(flags) {
|
|
435
|
+
const experienceContinuityFlags = [];
|
|
436
|
+
const unsupportedDefinitionFlags = [];
|
|
437
|
+
const warnedFlags = new Map();
|
|
438
|
+
const definitions = this.currentDefinitions();
|
|
439
|
+
for (const flag of flags){
|
|
440
|
+
const reason = getDefinitionUnresolvedReason(flag, definitions);
|
|
441
|
+
if (!reason) continue;
|
|
442
|
+
const fingerprint = JSON.stringify(flag);
|
|
443
|
+
warnedFlags.set(flag.key, fingerprint);
|
|
444
|
+
if (this.warnedUnresolvableFlags.get(flag.key) !== fingerprint) if ('experience_continuity' === reason) experienceContinuityFlags.push(flag.key);
|
|
445
|
+
else unsupportedDefinitionFlags.push(flag.key);
|
|
446
|
+
}
|
|
447
|
+
this.warnedUnresolvableFlags = warnedFlags;
|
|
448
|
+
if (experienceContinuityFlags.length > 0) {
|
|
449
|
+
const consequence = this.strictLocalEvaluation ? "With strictLocalEvaluation enabled these flags are left unresolved. To evaluate them locally, disable experience continuity on these flags in PostHog." : "Experience continuity is incompatible with local evaluation and will cause a server request on every flag evaluation, negating local evaluation cost savings. To avoid server requests and unexpected costs, either disable experience continuity on these flags in PostHog, use strictLocalEvaluation: true in client init, or pass onlyEvaluateLocally: true per flag call (flags that cannot be evaluated locally will return undefined).";
|
|
450
|
+
console.warn(`[PostHog] You are using local evaluation but ${experienceContinuityFlags.length} flag(s) have experience continuity enabled and cannot be resolved locally (reason: experience_continuity): ${experienceContinuityFlags.join(', ')}. ` + consequence);
|
|
451
|
+
}
|
|
452
|
+
if (unsupportedDefinitionFlags.length > 0) {
|
|
453
|
+
const consequence = this.strictLocalEvaluation ? "With strictLocalEvaluation enabled these flags are left unresolved when evaluation reaches that part." : "Evaluating these flags falls back to a server request when evaluation reaches that part.";
|
|
454
|
+
console.warn(`[PostHog] You are using local evaluation but ${unsupportedDefinitionFlags.length} flag(s) use something local evaluation does not support, such as a static cohort, an unknown operator, or a missing or circular flag dependency (reason: unsupported_definition): ${unsupportedDefinitionFlags.join(', ')}. ${consequence} To evaluate them locally, change these flags in PostHog or upgrade posthog-node.`);
|
|
455
|
+
}
|
|
372
456
|
}
|
|
373
457
|
async loadFromCache(debugMessage) {
|
|
374
458
|
if (!this.cacheProvider) return false;
|
|
@@ -378,7 +462,7 @@ class FeatureFlagsPoller {
|
|
|
378
462
|
this.updateFlagState(cached);
|
|
379
463
|
this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] ${debugMessage} (${cached.flags.length} flags)`));
|
|
380
464
|
this.onLoad?.(this.featureFlags.length);
|
|
381
|
-
this.
|
|
465
|
+
this.warnAboutUnresolvableFlags(this.featureFlags);
|
|
382
466
|
return true;
|
|
383
467
|
}
|
|
384
468
|
return false;
|
|
@@ -488,7 +572,7 @@ class FeatureFlagsPoller {
|
|
|
488
572
|
this.onError?.(new Error(`Failed to store in cache: ${err}`));
|
|
489
573
|
}
|
|
490
574
|
this.onLoad?.(this.featureFlags.length);
|
|
491
|
-
this.
|
|
575
|
+
this.warnAboutUnresolvableFlags(this.featureFlags);
|
|
492
576
|
break;
|
|
493
577
|
}
|
|
494
578
|
default:
|
|
@@ -570,6 +654,37 @@ class FeatureFlagsPoller {
|
|
|
570
654
|
}
|
|
571
655
|
}
|
|
572
656
|
}
|
|
657
|
+
function getDefinitionUnresolvedReason(flag, definitions) {
|
|
658
|
+
if (!flag.active) return;
|
|
659
|
+
if (flag.ensure_experience_continuity) return 'experience_continuity';
|
|
660
|
+
const flagFilters = flag.filters || {};
|
|
661
|
+
const aggregation = flagFilters.aggregation_group_type_index;
|
|
662
|
+
if (void 0 != aggregation && !definitions.groupTypeMapping[String(aggregation)]) return 'unsupported_definition';
|
|
663
|
+
const usesUnsupportedProperty = (flagFilters.groups || []).some((condition)=>(condition.properties || []).some((property)=>isUnsupportedProperty(property, definitions, new Set())));
|
|
664
|
+
return usesUnsupportedProperty ? 'unsupported_definition' : void 0;
|
|
665
|
+
}
|
|
666
|
+
function isUnsupportedProperty(property, definitions, visitedCohortIds) {
|
|
667
|
+
if ('flag' === property.type) {
|
|
668
|
+
const dependencyChain = property.dependency_chain;
|
|
669
|
+
if (!Array.isArray(dependencyChain) || 0 === dependencyChain.length) return true;
|
|
670
|
+
return dependencyChain.some((key)=>!definitions.featureFlagsByKey[key] && !definitions.filteredOutFlagKeys.has(key));
|
|
671
|
+
}
|
|
672
|
+
if ('cohort' !== property.type) try {
|
|
673
|
+
(0, core_namespaceObject.assertFeatureFlagFilterSupported)(property);
|
|
674
|
+
return false;
|
|
675
|
+
} catch (e) {
|
|
676
|
+
if (e instanceof core_namespaceObject.InconclusiveMatchError) return true;
|
|
677
|
+
throw e;
|
|
678
|
+
}
|
|
679
|
+
const cohortId = String(property.value);
|
|
680
|
+
if (!(cohortId in definitions.cohorts)) return true;
|
|
681
|
+
if (visitedCohortIds.has(cohortId)) return false;
|
|
682
|
+
visitedCohortIds.add(cohortId);
|
|
683
|
+
return isUnsupportedPropertyGroup(definitions.cohorts[cohortId], definitions, visitedCohortIds);
|
|
684
|
+
}
|
|
685
|
+
function isUnsupportedPropertyGroup(group, definitions, visitedCohortIds) {
|
|
686
|
+
return (group?.values ?? []).some((value)=>'values' in value ? isUnsupportedPropertyGroup(value, definitions, visitedCohortIds) : isUnsupportedProperty(value, definitions, visitedCohortIds));
|
|
687
|
+
}
|
|
573
688
|
function matchProperty(property, propertyValues, warnFunction, propertyMatchingVersion) {
|
|
574
689
|
return (0, core_namespaceObject.matchFeatureFlagProperty)(property, propertyValues, {
|
|
575
690
|
warnFunction,
|
|
@@ -593,7 +708,8 @@ async function matchPropertyGroup(propertyGroup, propertyValues, cohortPropertie
|
|
|
593
708
|
const propertyGroupType = propertyGroup.type;
|
|
594
709
|
const properties = propertyGroup.values;
|
|
595
710
|
if (!properties || 0 === properties.length) return true;
|
|
596
|
-
let
|
|
711
|
+
let inconclusiveReason;
|
|
712
|
+
let regexError;
|
|
597
713
|
if ('values' in properties[0]) {
|
|
598
714
|
for (const prop of properties)try {
|
|
599
715
|
const matches = await matchPropertyGroup(prop, propertyValues, cohortProperties, debugMode, flagDependencyEvaluator, propertyMatchingVersion);
|
|
@@ -604,10 +720,11 @@ async function matchPropertyGroup(propertyGroup, propertyValues, cohortPropertie
|
|
|
604
720
|
if (err instanceof RequiresServerEvaluation) throw err;
|
|
605
721
|
if (err instanceof core_namespaceObject.InconclusiveMatchError) {
|
|
606
722
|
if (debugMode) console.debug(`Failed to compute property ${prop} locally: ${err}`);
|
|
607
|
-
|
|
723
|
+
inconclusiveReason = pickUnresolvedReason(inconclusiveReason, err.reason);
|
|
724
|
+
if (Symbol.for('posthog.requiresServerRegexEvaluation') in err) regexError = err;
|
|
608
725
|
} else throw err;
|
|
609
726
|
}
|
|
610
|
-
if (
|
|
727
|
+
if (inconclusiveReason) throw preserveRegexUncertainty(new core_namespaceObject.InconclusiveMatchError("Can't match cohort without a given cohort property value", inconclusiveReason), regexError);
|
|
611
728
|
return 'AND' === propertyGroupType;
|
|
612
729
|
}
|
|
613
730
|
for (const prop of properties)try {
|
|
@@ -629,10 +746,11 @@ async function matchPropertyGroup(propertyGroup, propertyValues, cohortPropertie
|
|
|
629
746
|
if (err instanceof RequiresServerEvaluation) throw err;
|
|
630
747
|
if (err instanceof core_namespaceObject.InconclusiveMatchError) {
|
|
631
748
|
if (debugMode) console.debug(`Failed to compute property ${prop} locally: ${err}`);
|
|
632
|
-
|
|
749
|
+
inconclusiveReason = pickUnresolvedReason(inconclusiveReason, err.reason);
|
|
750
|
+
if (Symbol.for('posthog.requiresServerRegexEvaluation') in err) regexError = err;
|
|
633
751
|
} else throw err;
|
|
634
752
|
}
|
|
635
|
-
if (
|
|
753
|
+
if (inconclusiveReason) throw preserveRegexUncertainty(new core_namespaceObject.InconclusiveMatchError("can't match cohort without a given cohort property value", inconclusiveReason), regexError);
|
|
636
754
|
return 'AND' === propertyGroupType;
|
|
637
755
|
}
|
|
638
756
|
exports.ClientError = __webpack_exports__.ClientError;
|