posthog-node 2.5.4 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/lib/index.cjs.js +196 -44
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +20 -9
- package/lib/index.esm.js +196 -44
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/index.d.ts +7 -6
- package/lib/posthog-core/src/types.d.ts +2 -0
- package/lib/posthog-node/src/feature-flags.d.ts +2 -1
- package/lib/posthog-node/src/posthog-node.d.ts +9 -3
- package/lib/posthog-node/src/types.d.ts +14 -6
- package/package.json +1 -1
- package/src/feature-flags.ts +132 -9
- package/src/posthog-node.ts +42 -17
- package/src/types.ts +16 -6
- package/test/feature-flags.spec.ts +175 -2
- package/test/posthog-node.spec.ts +177 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
# 3.0.0 - 2023-04-14
|
|
2
|
+
|
|
3
|
+
Breaking change:
|
|
4
|
+
|
|
5
|
+
All events by default now send the `$geoip_disable` property to disable geoip lookup in app. This is because usually we don't
|
|
6
|
+
want to update person properties to take the server's location.
|
|
7
|
+
|
|
8
|
+
The same now happens for feature flag requests, where we discard the IP address of the server for matching on geoip properties like city, country, continent.
|
|
9
|
+
|
|
10
|
+
To restore previous behaviour, you can set the default to False like so:
|
|
11
|
+
|
|
12
|
+
```javascript
|
|
13
|
+
const posthog = new PostHog(PH_API_KEY, {
|
|
14
|
+
host: PH_HOST,
|
|
15
|
+
disableGeoip: false
|
|
16
|
+
})
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
# 2.6.0 - 2023-03-14
|
|
20
|
+
|
|
21
|
+
1. Add support for all cohorts local evaluation in feature flags.
|
|
22
|
+
|
|
1
23
|
# 2.5.4 - 2023-02-27
|
|
2
24
|
|
|
3
25
|
1. Fix error log for local evaluation of feature flags (InconclusiveMatchError(s)) to only show during debug mode.
|
package/lib/index.cjs.js
CHANGED
|
@@ -163,7 +163,7 @@ function __spreadArray(to, from, pack) {
|
|
|
163
163
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
var version = "
|
|
166
|
+
var version = "3.0.0";
|
|
167
167
|
|
|
168
168
|
var PostHogPersistedProperty;
|
|
169
169
|
(function (PostHogPersistedProperty) {
|
|
@@ -724,9 +724,10 @@ var SimpleEventEmitter = /** @class */ (function () {
|
|
|
724
724
|
|
|
725
725
|
var PostHogCoreStateless = /** @class */ (function () {
|
|
726
726
|
function PostHogCoreStateless(apiKey, options) {
|
|
727
|
-
var _a, _b, _c, _d;
|
|
727
|
+
var _a, _b, _c, _d, _e;
|
|
728
728
|
this.debugMode = false;
|
|
729
729
|
this.pendingPromises = {};
|
|
730
|
+
this.disableGeoip = true;
|
|
730
731
|
// internal
|
|
731
732
|
this._events = new SimpleEventEmitter();
|
|
732
733
|
assert(apiKey, "You must pass your PostHog project's api key.");
|
|
@@ -742,6 +743,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
742
743
|
retryDelay: (_c = options === null || options === void 0 ? void 0 : options.fetchRetryDelay) !== null && _c !== void 0 ? _c : 3000,
|
|
743
744
|
};
|
|
744
745
|
this.requestTimeout = (_d = options === null || options === void 0 ? void 0 : options.requestTimeout) !== null && _d !== void 0 ? _d : 10000; // 10 seconds
|
|
746
|
+
this.disableGeoip = (_e = options === null || options === void 0 ? void 0 : options.disableGeoip) !== null && _e !== void 0 ? _e : true;
|
|
745
747
|
}
|
|
746
748
|
PostHogCoreStateless.prototype.getCommonEventProperties = function () {
|
|
747
749
|
return {
|
|
@@ -801,13 +803,13 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
801
803
|
this.enqueue('capture', payload, options);
|
|
802
804
|
return this;
|
|
803
805
|
};
|
|
804
|
-
PostHogCoreStateless.prototype.aliasStateless = function (alias, distinctId, properties) {
|
|
806
|
+
PostHogCoreStateless.prototype.aliasStateless = function (alias, distinctId, properties, options) {
|
|
805
807
|
var payload = this.buildPayload({
|
|
806
808
|
event: '$create_alias',
|
|
807
809
|
distinct_id: distinctId,
|
|
808
810
|
properties: __assign(__assign({}, (properties || {})), { distinct_id: distinctId, alias: alias }),
|
|
809
811
|
});
|
|
810
|
-
this.enqueue('alias', payload);
|
|
812
|
+
this.enqueue('alias', payload, options);
|
|
811
813
|
return this;
|
|
812
814
|
};
|
|
813
815
|
/***
|
|
@@ -848,7 +850,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
848
850
|
});
|
|
849
851
|
});
|
|
850
852
|
};
|
|
851
|
-
PostHogCoreStateless.prototype.getFeatureFlagStateless = function (key, distinctId, groups, personProperties, groupProperties) {
|
|
853
|
+
PostHogCoreStateless.prototype.getFeatureFlagStateless = function (key, distinctId, groups, personProperties, groupProperties, disableGeoip) {
|
|
852
854
|
if (groups === void 0) { groups = {}; }
|
|
853
855
|
if (personProperties === void 0) { personProperties = {}; }
|
|
854
856
|
if (groupProperties === void 0) { groupProperties = {}; }
|
|
@@ -856,7 +858,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
856
858
|
var featureFlags, response;
|
|
857
859
|
return __generator(this, function (_a) {
|
|
858
860
|
switch (_a.label) {
|
|
859
|
-
case 0: return [4 /*yield*/, this.getFeatureFlagsStateless(distinctId, groups, personProperties, groupProperties)];
|
|
861
|
+
case 0: return [4 /*yield*/, this.getFeatureFlagsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip)];
|
|
860
862
|
case 1:
|
|
861
863
|
featureFlags = _a.sent();
|
|
862
864
|
if (!featureFlags) {
|
|
@@ -875,7 +877,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
875
877
|
});
|
|
876
878
|
});
|
|
877
879
|
};
|
|
878
|
-
PostHogCoreStateless.prototype.getFeatureFlagPayloadStateless = function (key, distinctId, groups, personProperties, groupProperties) {
|
|
880
|
+
PostHogCoreStateless.prototype.getFeatureFlagPayloadStateless = function (key, distinctId, groups, personProperties, groupProperties, disableGeoip) {
|
|
879
881
|
if (groups === void 0) { groups = {}; }
|
|
880
882
|
if (personProperties === void 0) { personProperties = {}; }
|
|
881
883
|
if (groupProperties === void 0) { groupProperties = {}; }
|
|
@@ -883,7 +885,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
883
885
|
var payloads, response;
|
|
884
886
|
return __generator(this, function (_a) {
|
|
885
887
|
switch (_a.label) {
|
|
886
|
-
case 0: return [4 /*yield*/, this.getFeatureFlagPayloadsStateless(distinctId, groups, personProperties, groupProperties)];
|
|
888
|
+
case 0: return [4 /*yield*/, this.getFeatureFlagPayloadsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip)];
|
|
887
889
|
case 1:
|
|
888
890
|
payloads = _a.sent();
|
|
889
891
|
if (!payloads) {
|
|
@@ -899,7 +901,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
899
901
|
});
|
|
900
902
|
});
|
|
901
903
|
};
|
|
902
|
-
PostHogCoreStateless.prototype.getFeatureFlagPayloadsStateless = function (distinctId, groups, personProperties, groupProperties) {
|
|
904
|
+
PostHogCoreStateless.prototype.getFeatureFlagPayloadsStateless = function (distinctId, groups, personProperties, groupProperties, disableGeoip) {
|
|
903
905
|
if (groups === void 0) { groups = {}; }
|
|
904
906
|
if (personProperties === void 0) { personProperties = {}; }
|
|
905
907
|
if (groupProperties === void 0) { groupProperties = {}; }
|
|
@@ -908,7 +910,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
908
910
|
var _this = this;
|
|
909
911
|
return __generator(this, function (_a) {
|
|
910
912
|
switch (_a.label) {
|
|
911
|
-
case 0: return [4 /*yield*/, this.getFeatureFlagsAndPayloadsStateless(distinctId, groups, personProperties, groupProperties)];
|
|
913
|
+
case 0: return [4 /*yield*/, this.getFeatureFlagsAndPayloadsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip)];
|
|
912
914
|
case 1:
|
|
913
915
|
payloads = (_a.sent()).payloads;
|
|
914
916
|
if (payloads) {
|
|
@@ -930,28 +932,33 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
930
932
|
return response;
|
|
931
933
|
}
|
|
932
934
|
};
|
|
933
|
-
PostHogCoreStateless.prototype.getFeatureFlagsStateless = function (distinctId, groups, personProperties, groupProperties) {
|
|
935
|
+
PostHogCoreStateless.prototype.getFeatureFlagsStateless = function (distinctId, groups, personProperties, groupProperties, disableGeoip) {
|
|
934
936
|
if (groups === void 0) { groups = {}; }
|
|
935
937
|
if (personProperties === void 0) { personProperties = {}; }
|
|
936
938
|
if (groupProperties === void 0) { groupProperties = {}; }
|
|
937
939
|
return __awaiter(this, void 0, void 0, function () {
|
|
938
940
|
return __generator(this, function (_a) {
|
|
939
941
|
switch (_a.label) {
|
|
940
|
-
case 0: return [4 /*yield*/, this.getFeatureFlagsAndPayloadsStateless(distinctId, groups, personProperties, groupProperties)];
|
|
942
|
+
case 0: return [4 /*yield*/, this.getFeatureFlagsAndPayloadsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip)];
|
|
941
943
|
case 1: return [2 /*return*/, (_a.sent()).flags];
|
|
942
944
|
}
|
|
943
945
|
});
|
|
944
946
|
});
|
|
945
947
|
};
|
|
946
|
-
PostHogCoreStateless.prototype.getFeatureFlagsAndPayloadsStateless = function (distinctId, groups, personProperties, groupProperties) {
|
|
948
|
+
PostHogCoreStateless.prototype.getFeatureFlagsAndPayloadsStateless = function (distinctId, groups, personProperties, groupProperties, disableGeoip) {
|
|
947
949
|
if (groups === void 0) { groups = {}; }
|
|
948
950
|
if (personProperties === void 0) { personProperties = {}; }
|
|
949
951
|
if (groupProperties === void 0) { groupProperties = {}; }
|
|
950
952
|
return __awaiter(this, void 0, void 0, function () {
|
|
951
|
-
var decideResponse, flags, payloads;
|
|
953
|
+
var extraPayload, decideResponse, flags, payloads;
|
|
952
954
|
return __generator(this, function (_a) {
|
|
953
955
|
switch (_a.label) {
|
|
954
|
-
case 0:
|
|
956
|
+
case 0:
|
|
957
|
+
extraPayload = {};
|
|
958
|
+
if (disableGeoip !== null && disableGeoip !== void 0 ? disableGeoip : this.disableGeoip) {
|
|
959
|
+
extraPayload['geoip_disable'] = true;
|
|
960
|
+
}
|
|
961
|
+
return [4 /*yield*/, this.getDecide(distinctId, groups, personProperties, groupProperties, extraPayload)];
|
|
955
962
|
case 1:
|
|
956
963
|
decideResponse = _a.sent();
|
|
957
964
|
flags = decideResponse === null || decideResponse === void 0 ? void 0 : decideResponse.featureFlags;
|
|
@@ -969,11 +976,19 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
969
976
|
***/
|
|
970
977
|
PostHogCoreStateless.prototype.enqueue = function (type, _message, options) {
|
|
971
978
|
var _this = this;
|
|
979
|
+
var _a;
|
|
972
980
|
if (this.optedOut) {
|
|
973
981
|
this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.enable()");
|
|
974
982
|
return;
|
|
975
983
|
}
|
|
976
984
|
var message = __assign(__assign({}, _message), { type: type, library: this.getLibraryId(), library_version: this.getLibraryVersion(), timestamp: (options === null || options === void 0 ? void 0 : options.timestamp) ? options === null || options === void 0 ? void 0 : options.timestamp : currentISOTime() });
|
|
985
|
+
var addGeoipDisableProperty = (_a = options === null || options === void 0 ? void 0 : options.disableGeoip) !== null && _a !== void 0 ? _a : this.disableGeoip;
|
|
986
|
+
if (addGeoipDisableProperty) {
|
|
987
|
+
if (!message.properties) {
|
|
988
|
+
message.properties = {};
|
|
989
|
+
}
|
|
990
|
+
message['properties']['$geoip_disable'] = true;
|
|
991
|
+
}
|
|
977
992
|
if (message.distinctId) {
|
|
978
993
|
message.distinct_id = message.distinctId;
|
|
979
994
|
delete message.distinctId;
|
|
@@ -1100,11 +1115,13 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
1100
1115
|
__extends(PostHogCore, _super);
|
|
1101
1116
|
function PostHogCore(apiKey, options) {
|
|
1102
1117
|
var _this = this;
|
|
1103
|
-
var _a, _b;
|
|
1104
|
-
|
|
1118
|
+
var _a, _b, _c;
|
|
1119
|
+
// Default for stateful mode is to not disable geoip. Only override if explicitly set
|
|
1120
|
+
var disableGeoipOption = (_a = options === null || options === void 0 ? void 0 : options.disableGeoip) !== null && _a !== void 0 ? _a : false;
|
|
1121
|
+
_this = _super.call(this, apiKey, __assign(__assign({}, options), { disableGeoip: disableGeoipOption })) || this;
|
|
1105
1122
|
_this.flagCallReported = {};
|
|
1106
|
-
_this.sendFeatureFlagEvent = (
|
|
1107
|
-
_this._sessionExpirationTimeSeconds = (
|
|
1123
|
+
_this.sendFeatureFlagEvent = (_b = options === null || options === void 0 ? void 0 : options.sendFeatureFlagEvent) !== null && _b !== void 0 ? _b : true;
|
|
1124
|
+
_this._sessionExpirationTimeSeconds = (_c = options === null || options === void 0 ? void 0 : options.sessionExpirationTimeSeconds) !== null && _c !== void 0 ? _c : 1800; // 30 minutes
|
|
1108
1125
|
// NOTE: It is important we don't initiate anything in the constructor as some async IO may still be underway on the parent
|
|
1109
1126
|
if ((options === null || options === void 0 ? void 0 : options.preloadFeatureFlags) !== false) {
|
|
1110
1127
|
safeSetTimeout(function () {
|
|
@@ -1606,6 +1623,7 @@ function () {
|
|
|
1606
1623
|
this.featureFlags = [];
|
|
1607
1624
|
this.featureFlagsByKey = {};
|
|
1608
1625
|
this.groupTypeMapping = {};
|
|
1626
|
+
this.cohorts = {};
|
|
1609
1627
|
this.loadedSuccessfullyOnce = false;
|
|
1610
1628
|
this.timeout = timeout;
|
|
1611
1629
|
this.projectApiKey = projectApiKey;
|
|
@@ -1943,14 +1961,23 @@ function () {
|
|
|
1943
1961
|
var rolloutPercentage = condition.rollout_percentage;
|
|
1944
1962
|
|
|
1945
1963
|
if ((condition.properties || []).length > 0) {
|
|
1946
|
-
var
|
|
1947
|
-
|
|
1948
|
-
|
|
1964
|
+
for (var _i = 0, _a = condition.properties; _i < _a.length; _i++) {
|
|
1965
|
+
var prop = _a[_i];
|
|
1966
|
+
var propertyType = prop.type;
|
|
1967
|
+
var matches = false;
|
|
1949
1968
|
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1969
|
+
if (propertyType === 'cohort') {
|
|
1970
|
+
matches = matchCohort(prop, properties, this.cohorts);
|
|
1971
|
+
} else {
|
|
1972
|
+
matches = matchProperty(prop, properties);
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
if (!matches) {
|
|
1976
|
+
return false;
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
if (rolloutPercentage == undefined) {
|
|
1954
1981
|
return true;
|
|
1955
1982
|
}
|
|
1956
1983
|
}
|
|
@@ -2083,6 +2110,7 @@ function () {
|
|
|
2083
2110
|
return acc[curr.key] = curr, acc;
|
|
2084
2111
|
}, {});
|
|
2085
2112
|
this.groupTypeMapping = responseJson.group_type_mapping || {};
|
|
2113
|
+
this.cohorts = responseJson.cohorts || [];
|
|
2086
2114
|
this.loadedSuccessfullyOnce = true;
|
|
2087
2115
|
return [3
|
|
2088
2116
|
/*break*/
|
|
@@ -2115,7 +2143,7 @@ function () {
|
|
|
2115
2143
|
return __generator(this, function (_a) {
|
|
2116
2144
|
switch (_a.label) {
|
|
2117
2145
|
case 0:
|
|
2118
|
-
url = "".concat(this.host, "/api/feature_flag/local_evaluation?token=").concat(this.projectApiKey);
|
|
2146
|
+
url = "".concat(this.host, "/api/feature_flag/local_evaluation?token=").concat(this.projectApiKey, "&send_cohorts");
|
|
2119
2147
|
options = {
|
|
2120
2148
|
method: 'GET',
|
|
2121
2149
|
headers: {
|
|
@@ -2252,6 +2280,119 @@ function matchProperty(property, propertyValues) {
|
|
|
2252
2280
|
}
|
|
2253
2281
|
}
|
|
2254
2282
|
|
|
2283
|
+
function matchCohort(property, propertyValues, cohortProperties) {
|
|
2284
|
+
var cohortId = String(property.value);
|
|
2285
|
+
|
|
2286
|
+
if (!(cohortId in cohortProperties)) {
|
|
2287
|
+
throw new InconclusiveMatchError("can't match cohort without a given cohort property value");
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2290
|
+
var propertyGroup = cohortProperties[cohortId];
|
|
2291
|
+
return matchPropertyGroup(propertyGroup, propertyValues, cohortProperties);
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
function matchPropertyGroup(propertyGroup, propertyValues, cohortProperties) {
|
|
2295
|
+
if (!propertyGroup) {
|
|
2296
|
+
return true;
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
var propertyGroupType = propertyGroup.type;
|
|
2300
|
+
var properties = propertyGroup.values;
|
|
2301
|
+
|
|
2302
|
+
if (!properties || properties.length === 0) {
|
|
2303
|
+
// empty groups are no-ops, always match
|
|
2304
|
+
return true;
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
var errorMatchingLocally = false;
|
|
2308
|
+
|
|
2309
|
+
if ('values' in properties[0]) {
|
|
2310
|
+
// a nested property group
|
|
2311
|
+
for (var _i = 0, _a = properties; _i < _a.length; _i++) {
|
|
2312
|
+
var prop = _a[_i];
|
|
2313
|
+
|
|
2314
|
+
try {
|
|
2315
|
+
var matches = matchPropertyGroup(prop, propertyValues, cohortProperties);
|
|
2316
|
+
|
|
2317
|
+
if (propertyGroupType === 'AND') {
|
|
2318
|
+
if (!matches) {
|
|
2319
|
+
return false;
|
|
2320
|
+
}
|
|
2321
|
+
} else {
|
|
2322
|
+
// OR group
|
|
2323
|
+
if (matches) {
|
|
2324
|
+
return true;
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
} catch (err) {
|
|
2328
|
+
if (err instanceof InconclusiveMatchError) {
|
|
2329
|
+
console.debug("Failed to compute property ".concat(prop, " locally: ").concat(err));
|
|
2330
|
+
errorMatchingLocally = true;
|
|
2331
|
+
} else {
|
|
2332
|
+
throw err;
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
if (errorMatchingLocally) {
|
|
2338
|
+
throw new InconclusiveMatchError("Can't match cohort without a given cohort property value");
|
|
2339
|
+
} // if we get here, all matched in AND case, or none matched in OR case
|
|
2340
|
+
|
|
2341
|
+
|
|
2342
|
+
return propertyGroupType === 'AND';
|
|
2343
|
+
} else {
|
|
2344
|
+
for (var _b = 0, _c = properties; _b < _c.length; _b++) {
|
|
2345
|
+
var prop = _c[_b];
|
|
2346
|
+
|
|
2347
|
+
try {
|
|
2348
|
+
var matches = void 0;
|
|
2349
|
+
|
|
2350
|
+
if (prop.type === 'cohort') {
|
|
2351
|
+
matches = matchCohort(prop, propertyValues, cohortProperties);
|
|
2352
|
+
} else {
|
|
2353
|
+
matches = matchProperty(prop, propertyValues);
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
var negation = prop.negation || false;
|
|
2357
|
+
|
|
2358
|
+
if (propertyGroupType === 'AND') {
|
|
2359
|
+
// if negated property, do the inverse
|
|
2360
|
+
if (!matches && !negation) {
|
|
2361
|
+
return false;
|
|
2362
|
+
}
|
|
2363
|
+
|
|
2364
|
+
if (matches && negation) {
|
|
2365
|
+
return false;
|
|
2366
|
+
}
|
|
2367
|
+
} else {
|
|
2368
|
+
// OR group
|
|
2369
|
+
if (matches && !negation) {
|
|
2370
|
+
return true;
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
if (!matches && negation) {
|
|
2374
|
+
return true;
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
} catch (err) {
|
|
2378
|
+
if (err instanceof InconclusiveMatchError) {
|
|
2379
|
+
console.debug("Failed to compute property ".concat(prop, " locally: ").concat(err));
|
|
2380
|
+
errorMatchingLocally = true;
|
|
2381
|
+
} else {
|
|
2382
|
+
throw err;
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
if (errorMatchingLocally) {
|
|
2388
|
+
throw new InconclusiveMatchError("can't match cohort without a given cohort property value");
|
|
2389
|
+
} // if we get here, all matched in AND case, or none matched in OR case
|
|
2390
|
+
|
|
2391
|
+
|
|
2392
|
+
return propertyGroupType === 'AND';
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2255
2396
|
function isValidRegex(regex) {
|
|
2256
2397
|
try {
|
|
2257
2398
|
new RegExp(regex);
|
|
@@ -2367,16 +2508,18 @@ function (_super) {
|
|
|
2367
2508
|
properties = _a.properties,
|
|
2368
2509
|
groups = _a.groups,
|
|
2369
2510
|
sendFeatureFlags = _a.sendFeatureFlags,
|
|
2370
|
-
timestamp = _a.timestamp
|
|
2511
|
+
timestamp = _a.timestamp,
|
|
2512
|
+
disableGeoip = _a.disableGeoip;
|
|
2371
2513
|
|
|
2372
2514
|
var _capture = function (props) {
|
|
2373
2515
|
_super.prototype.captureStateless.call(_this, distinctId, event, props, {
|
|
2374
|
-
timestamp: timestamp
|
|
2516
|
+
timestamp: timestamp,
|
|
2517
|
+
disableGeoip: disableGeoip
|
|
2375
2518
|
});
|
|
2376
2519
|
};
|
|
2377
2520
|
|
|
2378
2521
|
if (sendFeatureFlags) {
|
|
2379
|
-
_super.prototype.getFeatureFlagsStateless.call(this, distinctId, groups).then(function (flags) {
|
|
2522
|
+
_super.prototype.getFeatureFlagsStateless.call(this, distinctId, groups, undefined, undefined, disableGeoip).then(function (flags) {
|
|
2380
2523
|
var featureVariantProperties = {};
|
|
2381
2524
|
|
|
2382
2525
|
if (flags) {
|
|
@@ -2412,29 +2555,34 @@ function (_super) {
|
|
|
2412
2555
|
|
|
2413
2556
|
PostHog.prototype.identify = function (_a) {
|
|
2414
2557
|
var distinctId = _a.distinctId,
|
|
2415
|
-
properties = _a.properties
|
|
2558
|
+
properties = _a.properties,
|
|
2559
|
+
disableGeoip = _a.disableGeoip; // Catch properties passed as $set and move them to the top level
|
|
2416
2560
|
|
|
2417
2561
|
var personProperties = (properties === null || properties === void 0 ? void 0 : properties.$set) || properties;
|
|
2418
2562
|
|
|
2419
2563
|
_super.prototype.identifyStateless.call(this, distinctId, {
|
|
2420
2564
|
$set: personProperties
|
|
2565
|
+
}, {
|
|
2566
|
+
disableGeoip: disableGeoip
|
|
2421
2567
|
});
|
|
2422
2568
|
};
|
|
2423
2569
|
|
|
2424
2570
|
PostHog.prototype.alias = function (data) {
|
|
2425
|
-
_super.prototype.aliasStateless.call(this, data.alias, data.distinctId
|
|
2571
|
+
_super.prototype.aliasStateless.call(this, data.alias, data.distinctId, undefined, {
|
|
2572
|
+
disableGeoip: data.disableGeoip
|
|
2573
|
+
});
|
|
2426
2574
|
};
|
|
2427
2575
|
|
|
2428
2576
|
PostHog.prototype.getFeatureFlag = function (key, distinctId, options) {
|
|
2429
2577
|
var _a;
|
|
2430
2578
|
|
|
2431
2579
|
return __awaiter(this, void 0, void 0, function () {
|
|
2432
|
-
var _b, groups, personProperties, groupProperties, _c, onlyEvaluateLocally, sendFeatureFlagEvents, response, flagWasLocallyEvaluated, featureFlagReportedKey;
|
|
2580
|
+
var _b, groups, personProperties, groupProperties, disableGeoip, _c, onlyEvaluateLocally, sendFeatureFlagEvents, response, flagWasLocallyEvaluated, featureFlagReportedKey;
|
|
2433
2581
|
|
|
2434
2582
|
return __generator(this, function (_d) {
|
|
2435
2583
|
switch (_d.label) {
|
|
2436
2584
|
case 0:
|
|
2437
|
-
_b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties;
|
|
2585
|
+
_b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties, disableGeoip = _b.disableGeoip;
|
|
2438
2586
|
_c = options || {}, onlyEvaluateLocally = _c.onlyEvaluateLocally, sendFeatureFlagEvents = _c.sendFeatureFlagEvents; // set defaults
|
|
2439
2587
|
|
|
2440
2588
|
if (onlyEvaluateLocally == undefined) {
|
|
@@ -2457,7 +2605,7 @@ function (_super) {
|
|
|
2457
2605
|
, 3];
|
|
2458
2606
|
return [4
|
|
2459
2607
|
/*yield*/
|
|
2460
|
-
, _super.prototype.getFeatureFlagStateless.call(this, key, distinctId, groups, personProperties, groupProperties)];
|
|
2608
|
+
, _super.prototype.getFeatureFlagStateless.call(this, key, distinctId, groups, personProperties, groupProperties, disableGeoip)];
|
|
2461
2609
|
|
|
2462
2610
|
case 2:
|
|
2463
2611
|
response = _d.sent();
|
|
@@ -2485,7 +2633,8 @@ function (_super) {
|
|
|
2485
2633
|
$feature_flag_response: response,
|
|
2486
2634
|
locally_evaluated: flagWasLocallyEvaluated
|
|
2487
2635
|
},
|
|
2488
|
-
groups: groups
|
|
2636
|
+
groups: groups,
|
|
2637
|
+
disableGeoip: disableGeoip
|
|
2489
2638
|
});
|
|
2490
2639
|
}
|
|
2491
2640
|
|
|
@@ -2501,12 +2650,12 @@ function (_super) {
|
|
|
2501
2650
|
var _a;
|
|
2502
2651
|
|
|
2503
2652
|
return __awaiter(this, void 0, void 0, function () {
|
|
2504
|
-
var _b, groups, personProperties, groupProperties, _c, onlyEvaluateLocally, response, payloadWasLocallyEvaluated;
|
|
2653
|
+
var _b, groups, personProperties, groupProperties, disableGeoip, _c, onlyEvaluateLocally, response, payloadWasLocallyEvaluated;
|
|
2505
2654
|
|
|
2506
2655
|
return __generator(this, function (_d) {
|
|
2507
2656
|
switch (_d.label) {
|
|
2508
2657
|
case 0:
|
|
2509
|
-
_b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties;
|
|
2658
|
+
_b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties, disableGeoip = _b.disableGeoip;
|
|
2510
2659
|
_c = options || {}, onlyEvaluateLocally = _c.onlyEvaluateLocally, _c.sendFeatureFlagEvents;
|
|
2511
2660
|
response = undefined;
|
|
2512
2661
|
if (!!matchValue) return [3
|
|
@@ -2551,7 +2700,7 @@ function (_super) {
|
|
|
2551
2700
|
, 6];
|
|
2552
2701
|
return [4
|
|
2553
2702
|
/*yield*/
|
|
2554
|
-
, _super.prototype.getFeatureFlagPayloadStateless.call(this, key, distinctId, groups, personProperties, groupProperties)];
|
|
2703
|
+
, _super.prototype.getFeatureFlagPayloadStateless.call(this, key, distinctId, groups, personProperties, groupProperties, disableGeoip)];
|
|
2555
2704
|
|
|
2556
2705
|
case 5:
|
|
2557
2706
|
response = _d.sent();
|
|
@@ -2627,12 +2776,12 @@ function (_super) {
|
|
|
2627
2776
|
var _a;
|
|
2628
2777
|
|
|
2629
2778
|
return __awaiter(this, void 0, void 0, function () {
|
|
2630
|
-
var _b, groups, personProperties, groupProperties, onlyEvaluateLocally, localEvaluationResult, featureFlags, featureFlagPayloads, fallbackToDecide, remoteEvaluationResult;
|
|
2779
|
+
var _b, groups, personProperties, groupProperties, disableGeoip, onlyEvaluateLocally, localEvaluationResult, featureFlags, featureFlagPayloads, fallbackToDecide, remoteEvaluationResult;
|
|
2631
2780
|
|
|
2632
2781
|
return __generator(this, function (_c) {
|
|
2633
2782
|
switch (_c.label) {
|
|
2634
2783
|
case 0:
|
|
2635
|
-
_b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties;
|
|
2784
|
+
_b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties, disableGeoip = _b.disableGeoip;
|
|
2636
2785
|
onlyEvaluateLocally = (options || {}).onlyEvaluateLocally; // set defaults
|
|
2637
2786
|
|
|
2638
2787
|
if (onlyEvaluateLocally == undefined) {
|
|
@@ -2660,7 +2809,7 @@ function (_super) {
|
|
|
2660
2809
|
, 3];
|
|
2661
2810
|
return [4
|
|
2662
2811
|
/*yield*/
|
|
2663
|
-
, _super.prototype.getFeatureFlagsAndPayloadsStateless.call(this, distinctId, groups, personProperties, groupProperties)];
|
|
2812
|
+
, _super.prototype.getFeatureFlagsAndPayloadsStateless.call(this, distinctId, groups, personProperties, groupProperties, disableGeoip)];
|
|
2664
2813
|
|
|
2665
2814
|
case 2:
|
|
2666
2815
|
remoteEvaluationResult = _c.sent();
|
|
@@ -2684,9 +2833,12 @@ function (_super) {
|
|
|
2684
2833
|
var groupType = _a.groupType,
|
|
2685
2834
|
groupKey = _a.groupKey,
|
|
2686
2835
|
properties = _a.properties,
|
|
2687
|
-
distinctId = _a.distinctId
|
|
2836
|
+
distinctId = _a.distinctId,
|
|
2837
|
+
disableGeoip = _a.disableGeoip;
|
|
2688
2838
|
|
|
2689
|
-
_super.prototype.groupIdentifyStateless.call(this, groupType, groupKey, properties,
|
|
2839
|
+
_super.prototype.groupIdentifyStateless.call(this, groupType, groupKey, properties, {
|
|
2840
|
+
disableGeoip: disableGeoip
|
|
2841
|
+
}, distinctId);
|
|
2690
2842
|
};
|
|
2691
2843
|
|
|
2692
2844
|
PostHog.prototype.reloadFeatureFlags = function () {
|