posthog-node 2.6.0 → 3.1.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 CHANGED
@@ -1,3 +1,29 @@
1
+ # 3.1.0 - 2023-04-19
2
+
3
+ 1. Some small fixes to incorrect types
4
+ 2. Fixed fetch compatibility by aligning error handling
5
+ 3. Added two errors: PostHogFetchHttpError (non-2xx status) and PostHogFetchNetworkError (fetch network error)
6
+ 4. Added .on('error', (err) => void)
7
+ 5. shutdownAsync now ignores fetch errors. They should be handled with .on('error', ...) from now on.
8
+
9
+ # 3.0.0 - 2023-04-14
10
+
11
+ Breaking change:
12
+
13
+ All events by default now send the `$geoip_disable` property to disable geoip lookup in app. This is because usually we don't
14
+ want to update person properties to take the server's location.
15
+
16
+ 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.
17
+
18
+ To restore previous behaviour, you can set the default to False like so:
19
+
20
+ ```javascript
21
+ const posthog = new PostHog(PH_API_KEY, {
22
+ host: PH_HOST,
23
+ disableGeoip: false,
24
+ })
25
+ ```
26
+
1
27
  # 2.6.0 - 2023-03-14
2
28
 
3
29
  1. Add support for all cohorts local evaluation in feature flags.
@@ -5,10 +31,12 @@
5
31
  # 2.5.4 - 2023-02-27
6
32
 
7
33
  1. Fix error log for local evaluation of feature flags (InconclusiveMatchError(s)) to only show during debug mode.
34
+
8
35
  # 2.5.3 - 2023-02-21
9
36
 
10
37
  1. Allow passing in a distinctId to `groupIdentify()`.
11
38
  2. Fix a bug with active feature flags on capture events, where non-active flags would be added to the list as well.
39
+
12
40
  # 2.5.2 - 2023-02-17
13
41
 
14
42
  1. Fix issue where properties passed to `.identify` were not set correctly
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 = "2.6.0";
166
+ var version = "3.1.0";
167
167
 
168
168
  var PostHogPersistedProperty;
169
169
  (function (PostHogPersistedProperty) {
@@ -201,29 +201,31 @@ function retriable(fn, props) {
201
201
  i = 0;
202
202
  _d.label = 1;
203
203
  case 1:
204
- if (!(i < retryCount + 1)) return [3 /*break*/, 8];
205
- _d.label = 2;
204
+ if (!(i < retryCount + 1)) return [3 /*break*/, 7];
205
+ if (!(i > 0)) return [3 /*break*/, 3];
206
+ // don't wait when it's the last try
207
+ return [4 /*yield*/, new Promise(function (r) { return setTimeout(r, retryDelay); })];
206
208
  case 2:
207
- _d.trys.push([2, 4, , 5]);
208
- return [4 /*yield*/, fn()];
209
+ // don't wait when it's the last try
210
+ _d.sent();
211
+ _d.label = 3;
209
212
  case 3:
213
+ _d.trys.push([3, 5, , 6]);
214
+ return [4 /*yield*/, fn()];
215
+ case 4:
210
216
  res = _d.sent();
211
217
  return [2 /*return*/, res];
212
- case 4:
218
+ case 5:
213
219
  e_1 = _d.sent();
214
220
  lastError = e_1;
215
221
  if (!retryCheck(e_1)) {
216
222
  throw e_1;
217
223
  }
218
- return [3 /*break*/, 5];
219
- case 5: return [4 /*yield*/, new Promise(function (r) { return setTimeout(r, retryDelay); })];
224
+ return [3 /*break*/, 6];
220
225
  case 6:
221
- _d.sent();
222
- _d.label = 7;
223
- case 7:
224
226
  i++;
225
227
  return [3 /*break*/, 1];
226
- case 8: throw lastError;
228
+ case 7: throw lastError;
227
229
  }
228
230
  });
229
231
  });
@@ -722,11 +724,35 @@ var SimpleEventEmitter = /** @class */ (function () {
722
724
  return SimpleEventEmitter;
723
725
  }());
724
726
 
727
+ var PostHogFetchHttpError = /** @class */ (function (_super) {
728
+ __extends(PostHogFetchHttpError, _super);
729
+ function PostHogFetchHttpError(response) {
730
+ var _this = _super.call(this, 'HTTP error while fetching PostHog: ' + response.status) || this;
731
+ _this.response = response;
732
+ _this.name = 'PostHogFetchHttpError';
733
+ return _this;
734
+ }
735
+ return PostHogFetchHttpError;
736
+ }(Error));
737
+ var PostHogFetchNetworkError = /** @class */ (function (_super) {
738
+ __extends(PostHogFetchNetworkError, _super);
739
+ function PostHogFetchNetworkError(error) {
740
+ var _this = _super.call(this, 'Network error while fetching PostHog', error instanceof Error ? { cause: error } : {}) || this;
741
+ _this.error = error;
742
+ _this.name = 'PostHogFetchNetworkError';
743
+ return _this;
744
+ }
745
+ return PostHogFetchNetworkError;
746
+ }(Error));
747
+ function isPostHogFetchError(err) {
748
+ return typeof err === 'object' && (err.name === 'PostHogFetchHttpError' || err.name === 'PostHogFetchNetworkError');
749
+ }
725
750
  var PostHogCoreStateless = /** @class */ (function () {
726
751
  function PostHogCoreStateless(apiKey, options) {
727
- var _a, _b, _c, _d;
752
+ var _a, _b, _c, _d, _e;
728
753
  this.debugMode = false;
729
754
  this.pendingPromises = {};
755
+ this.disableGeoip = true;
730
756
  // internal
731
757
  this._events = new SimpleEventEmitter();
732
758
  assert(apiKey, "You must pass your PostHog project's api key.");
@@ -740,8 +766,10 @@ var PostHogCoreStateless = /** @class */ (function () {
740
766
  this._retryOptions = {
741
767
  retryCount: (_b = options === null || options === void 0 ? void 0 : options.fetchRetryCount) !== null && _b !== void 0 ? _b : 3,
742
768
  retryDelay: (_c = options === null || options === void 0 ? void 0 : options.fetchRetryDelay) !== null && _c !== void 0 ? _c : 3000,
769
+ retryCheck: isPostHogFetchError,
743
770
  };
744
771
  this.requestTimeout = (_d = options === null || options === void 0 ? void 0 : options.requestTimeout) !== null && _d !== void 0 ? _d : 10000; // 10 seconds
772
+ this.disableGeoip = (_e = options === null || options === void 0 ? void 0 : options.disableGeoip) !== null && _e !== void 0 ? _e : true;
745
773
  }
746
774
  PostHogCoreStateless.prototype.getCommonEventProperties = function () {
747
775
  return {
@@ -801,13 +829,13 @@ var PostHogCoreStateless = /** @class */ (function () {
801
829
  this.enqueue('capture', payload, options);
802
830
  return this;
803
831
  };
804
- PostHogCoreStateless.prototype.aliasStateless = function (alias, distinctId, properties) {
832
+ PostHogCoreStateless.prototype.aliasStateless = function (alias, distinctId, properties, options) {
805
833
  var payload = this.buildPayload({
806
834
  event: '$create_alias',
807
835
  distinct_id: distinctId,
808
836
  properties: __assign(__assign({}, (properties || {})), { distinct_id: distinctId, alias: alias }),
809
837
  });
810
- this.enqueue('alias', payload);
838
+ this.enqueue('alias', payload, options);
811
839
  return this;
812
840
  };
813
841
  /***
@@ -848,7 +876,7 @@ var PostHogCoreStateless = /** @class */ (function () {
848
876
  });
849
877
  });
850
878
  };
851
- PostHogCoreStateless.prototype.getFeatureFlagStateless = function (key, distinctId, groups, personProperties, groupProperties) {
879
+ PostHogCoreStateless.prototype.getFeatureFlagStateless = function (key, distinctId, groups, personProperties, groupProperties, disableGeoip) {
852
880
  if (groups === void 0) { groups = {}; }
853
881
  if (personProperties === void 0) { personProperties = {}; }
854
882
  if (groupProperties === void 0) { groupProperties = {}; }
@@ -856,7 +884,7 @@ var PostHogCoreStateless = /** @class */ (function () {
856
884
  var featureFlags, response;
857
885
  return __generator(this, function (_a) {
858
886
  switch (_a.label) {
859
- case 0: return [4 /*yield*/, this.getFeatureFlagsStateless(distinctId, groups, personProperties, groupProperties)];
887
+ case 0: return [4 /*yield*/, this.getFeatureFlagsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip)];
860
888
  case 1:
861
889
  featureFlags = _a.sent();
862
890
  if (!featureFlags) {
@@ -875,7 +903,7 @@ var PostHogCoreStateless = /** @class */ (function () {
875
903
  });
876
904
  });
877
905
  };
878
- PostHogCoreStateless.prototype.getFeatureFlagPayloadStateless = function (key, distinctId, groups, personProperties, groupProperties) {
906
+ PostHogCoreStateless.prototype.getFeatureFlagPayloadStateless = function (key, distinctId, groups, personProperties, groupProperties, disableGeoip) {
879
907
  if (groups === void 0) { groups = {}; }
880
908
  if (personProperties === void 0) { personProperties = {}; }
881
909
  if (groupProperties === void 0) { groupProperties = {}; }
@@ -883,7 +911,7 @@ var PostHogCoreStateless = /** @class */ (function () {
883
911
  var payloads, response;
884
912
  return __generator(this, function (_a) {
885
913
  switch (_a.label) {
886
- case 0: return [4 /*yield*/, this.getFeatureFlagPayloadsStateless(distinctId, groups, personProperties, groupProperties)];
914
+ case 0: return [4 /*yield*/, this.getFeatureFlagPayloadsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip)];
887
915
  case 1:
888
916
  payloads = _a.sent();
889
917
  if (!payloads) {
@@ -899,7 +927,7 @@ var PostHogCoreStateless = /** @class */ (function () {
899
927
  });
900
928
  });
901
929
  };
902
- PostHogCoreStateless.prototype.getFeatureFlagPayloadsStateless = function (distinctId, groups, personProperties, groupProperties) {
930
+ PostHogCoreStateless.prototype.getFeatureFlagPayloadsStateless = function (distinctId, groups, personProperties, groupProperties, disableGeoip) {
903
931
  if (groups === void 0) { groups = {}; }
904
932
  if (personProperties === void 0) { personProperties = {}; }
905
933
  if (groupProperties === void 0) { groupProperties = {}; }
@@ -908,7 +936,7 @@ var PostHogCoreStateless = /** @class */ (function () {
908
936
  var _this = this;
909
937
  return __generator(this, function (_a) {
910
938
  switch (_a.label) {
911
- case 0: return [4 /*yield*/, this.getFeatureFlagsAndPayloadsStateless(distinctId, groups, personProperties, groupProperties)];
939
+ case 0: return [4 /*yield*/, this.getFeatureFlagsAndPayloadsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip)];
912
940
  case 1:
913
941
  payloads = (_a.sent()).payloads;
914
942
  if (payloads) {
@@ -930,28 +958,33 @@ var PostHogCoreStateless = /** @class */ (function () {
930
958
  return response;
931
959
  }
932
960
  };
933
- PostHogCoreStateless.prototype.getFeatureFlagsStateless = function (distinctId, groups, personProperties, groupProperties) {
961
+ PostHogCoreStateless.prototype.getFeatureFlagsStateless = function (distinctId, groups, personProperties, groupProperties, disableGeoip) {
934
962
  if (groups === void 0) { groups = {}; }
935
963
  if (personProperties === void 0) { personProperties = {}; }
936
964
  if (groupProperties === void 0) { groupProperties = {}; }
937
965
  return __awaiter(this, void 0, void 0, function () {
938
966
  return __generator(this, function (_a) {
939
967
  switch (_a.label) {
940
- case 0: return [4 /*yield*/, this.getFeatureFlagsAndPayloadsStateless(distinctId, groups, personProperties, groupProperties)];
968
+ case 0: return [4 /*yield*/, this.getFeatureFlagsAndPayloadsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip)];
941
969
  case 1: return [2 /*return*/, (_a.sent()).flags];
942
970
  }
943
971
  });
944
972
  });
945
973
  };
946
- PostHogCoreStateless.prototype.getFeatureFlagsAndPayloadsStateless = function (distinctId, groups, personProperties, groupProperties) {
974
+ PostHogCoreStateless.prototype.getFeatureFlagsAndPayloadsStateless = function (distinctId, groups, personProperties, groupProperties, disableGeoip) {
947
975
  if (groups === void 0) { groups = {}; }
948
976
  if (personProperties === void 0) { personProperties = {}; }
949
977
  if (groupProperties === void 0) { groupProperties = {}; }
950
978
  return __awaiter(this, void 0, void 0, function () {
951
- var decideResponse, flags, payloads;
979
+ var extraPayload, decideResponse, flags, payloads;
952
980
  return __generator(this, function (_a) {
953
981
  switch (_a.label) {
954
- case 0: return [4 /*yield*/, this.getDecide(distinctId, groups, personProperties, groupProperties)];
982
+ case 0:
983
+ extraPayload = {};
984
+ if (disableGeoip !== null && disableGeoip !== void 0 ? disableGeoip : this.disableGeoip) {
985
+ extraPayload['geoip_disable'] = true;
986
+ }
987
+ return [4 /*yield*/, this.getDecide(distinctId, groups, personProperties, groupProperties, extraPayload)];
955
988
  case 1:
956
989
  decideResponse = _a.sent();
957
990
  flags = decideResponse === null || decideResponse === void 0 ? void 0 : decideResponse.featureFlags;
@@ -969,11 +1002,19 @@ var PostHogCoreStateless = /** @class */ (function () {
969
1002
  ***/
970
1003
  PostHogCoreStateless.prototype.enqueue = function (type, _message, options) {
971
1004
  var _this = this;
1005
+ var _a;
972
1006
  if (this.optedOut) {
973
1007
  this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.enable()");
974
1008
  return;
975
1009
  }
976
1010
  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() });
1011
+ var addGeoipDisableProperty = (_a = options === null || options === void 0 ? void 0 : options.disableGeoip) !== null && _a !== void 0 ? _a : this.disableGeoip;
1012
+ if (addGeoipDisableProperty) {
1013
+ if (!message.properties) {
1014
+ message.properties = {};
1015
+ }
1016
+ message['properties']['$geoip_disable'] = true;
1017
+ }
977
1018
  if (message.distinctId) {
978
1019
  message.distinct_id = message.distinctId;
979
1020
  delete message.distinctId;
@@ -1018,6 +1059,9 @@ var PostHogCoreStateless = /** @class */ (function () {
1018
1059
  };
1019
1060
  var promiseUUID = generateUUID();
1020
1061
  var done = function (err) {
1062
+ if (err) {
1063
+ _this._events.emit('error', err);
1064
+ }
1021
1065
  callback === null || callback === void 0 ? void 0 : callback(err, messages);
1022
1066
  // remove promise from pendingPromises
1023
1067
  delete _this.pendingPromises[promiseUUID];
@@ -1050,10 +1094,6 @@ var PostHogCoreStateless = /** @class */ (function () {
1050
1094
  requestPromise
1051
1095
  .then(function () { return done(); })
1052
1096
  .catch(function (err) {
1053
- if (err.response) {
1054
- var error = new Error(err.response.statusText);
1055
- return done(error);
1056
- }
1057
1097
  done(err);
1058
1098
  });
1059
1099
  };
@@ -1063,30 +1103,68 @@ var PostHogCoreStateless = /** @class */ (function () {
1063
1103
  return __awaiter(this, void 0, void 0, function () {
1064
1104
  var _this = this;
1065
1105
  return __generator(this, function (_c) {
1066
- (_a = (_b = AbortSignal).timeout) !== null && _a !== void 0 ? _a : (_b.timeout = function timeout(ms) {
1067
- var ctrl = new AbortController();
1068
- setTimeout(function () { return ctrl.abort(); }, ms);
1069
- return ctrl.signal;
1070
- });
1071
- return [2 /*return*/, retriable(function () {
1072
- return _this.fetch(url, __assign({ signal: AbortSignal.timeout(_this.requestTimeout) }, options));
1073
- }, retryOptions || this._retryOptions)];
1106
+ switch (_c.label) {
1107
+ case 0:
1108
+ (_a = (_b = AbortSignal).timeout) !== null && _a !== void 0 ? _a : (_b.timeout = function timeout(ms) {
1109
+ var ctrl = new AbortController();
1110
+ setTimeout(function () { return ctrl.abort(); }, ms);
1111
+ return ctrl.signal;
1112
+ });
1113
+ return [4 /*yield*/, retriable(function () { return __awaiter(_this, void 0, void 0, function () {
1114
+ var res, e_1;
1115
+ return __generator(this, function (_a) {
1116
+ switch (_a.label) {
1117
+ case 0:
1118
+ res = null;
1119
+ _a.label = 1;
1120
+ case 1:
1121
+ _a.trys.push([1, 3, , 4]);
1122
+ return [4 /*yield*/, this.fetch(url, __assign({ signal: AbortSignal.timeout(this.requestTimeout) }, options))];
1123
+ case 2:
1124
+ res = _a.sent();
1125
+ return [3 /*break*/, 4];
1126
+ case 3:
1127
+ e_1 = _a.sent();
1128
+ // fetch will only throw on network errors or on timeouts
1129
+ throw new PostHogFetchNetworkError(e_1);
1130
+ case 4:
1131
+ if (res.status < 200 || res.status >= 400) {
1132
+ throw new PostHogFetchHttpError(res);
1133
+ }
1134
+ return [2 /*return*/, res];
1135
+ }
1136
+ });
1137
+ }); }, __assign(__assign({}, this._retryOptions), retryOptions))];
1138
+ case 1: return [2 /*return*/, _c.sent()];
1139
+ }
1074
1140
  });
1075
1141
  });
1076
1142
  };
1077
1143
  PostHogCoreStateless.prototype.shutdownAsync = function () {
1078
1144
  return __awaiter(this, void 0, void 0, function () {
1145
+ var e_2;
1079
1146
  return __generator(this, function (_a) {
1080
1147
  switch (_a.label) {
1081
1148
  case 0:
1082
1149
  clearTimeout(this._flushTimer);
1083
- return [4 /*yield*/, this.flushAsync()];
1150
+ _a.label = 1;
1084
1151
  case 1:
1152
+ _a.trys.push([1, 4, , 5]);
1153
+ return [4 /*yield*/, this.flushAsync()];
1154
+ case 2:
1085
1155
  _a.sent();
1086
1156
  return [4 /*yield*/, Promise.allSettled(Object.values(this.pendingPromises))];
1087
- case 2:
1157
+ case 3:
1088
1158
  _a.sent();
1089
- return [2 /*return*/];
1159
+ return [3 /*break*/, 5];
1160
+ case 4:
1161
+ e_2 = _a.sent();
1162
+ if (!isPostHogFetchError(e_2)) {
1163
+ throw e_2;
1164
+ }
1165
+ console.error('Error while shutting down PostHog', e_2);
1166
+ return [3 /*break*/, 5];
1167
+ case 5: return [2 /*return*/];
1090
1168
  }
1091
1169
  });
1092
1170
  });
@@ -1100,11 +1178,13 @@ var PostHogCoreStateless = /** @class */ (function () {
1100
1178
  __extends(PostHogCore, _super);
1101
1179
  function PostHogCore(apiKey, options) {
1102
1180
  var _this = this;
1103
- var _a, _b;
1104
- _this = _super.call(this, apiKey, options) || this;
1181
+ var _a, _b, _c;
1182
+ // Default for stateful mode is to not disable geoip. Only override if explicitly set
1183
+ var disableGeoipOption = (_a = options === null || options === void 0 ? void 0 : options.disableGeoip) !== null && _a !== void 0 ? _a : false;
1184
+ _this = _super.call(this, apiKey, __assign(__assign({}, options), { disableGeoip: disableGeoipOption })) || this;
1105
1185
  _this.flagCallReported = {};
1106
- _this.sendFeatureFlagEvent = (_a = options === null || options === void 0 ? void 0 : options.sendFeatureFlagEvent) !== null && _a !== void 0 ? _a : true;
1107
- _this._sessionExpirationTimeSeconds = (_b = options === null || options === void 0 ? void 0 : options.sessionExpirationTimeSeconds) !== null && _b !== void 0 ? _b : 1800; // 30 minutes
1186
+ _this.sendFeatureFlagEvent = (_b = options === null || options === void 0 ? void 0 : options.sendFeatureFlagEvent) !== null && _b !== void 0 ? _b : true;
1187
+ _this._sessionExpirationTimeSeconds = (_c = options === null || options === void 0 ? void 0 : options.sessionExpirationTimeSeconds) !== null && _c !== void 0 ? _c : 1800; // 30 minutes
1108
1188
  // NOTE: It is important we don't initiate anything in the constructor as some async IO may still be underway on the parent
1109
1189
  if ((options === null || options === void 0 ? void 0 : options.preloadFeatureFlags) !== false) {
1110
1190
  safeSetTimeout(function () {
@@ -1528,7 +1608,11 @@ var fetch = function (url, options) {
1528
1608
  headers: options.headers,
1529
1609
  method: options.method.toLowerCase(),
1530
1610
  data: options.body,
1531
- signal: options.signal
1611
+ signal: options.signal,
1612
+ // fetch only throws on network errors, not on HTTP errors
1613
+ validateStatus: function () {
1614
+ return true;
1615
+ }
1532
1616
  })];
1533
1617
 
1534
1618
  case 1:
@@ -1538,10 +1622,22 @@ var fetch = function (url, options) {
1538
1622
  , {
1539
1623
  status: res.status,
1540
1624
  text: function () {
1541
- return res.data;
1625
+ return __awaiter(void 0, void 0, void 0, function () {
1626
+ return __generator(this, function (_a) {
1627
+ return [2
1628
+ /*return*/
1629
+ , res.data];
1630
+ });
1631
+ });
1542
1632
  },
1543
1633
  json: function () {
1544
- return res.data;
1634
+ return __awaiter(void 0, void 0, void 0, function () {
1635
+ return __generator(this, function (_a) {
1636
+ return [2
1637
+ /*return*/
1638
+ , res.data];
1639
+ });
1640
+ });
1545
1641
  }
1546
1642
  }];
1547
1643
  }
@@ -2161,7 +2257,7 @@ function () {
2161
2257
 
2162
2258
  case 3:
2163
2259
  err_2 = _a.sent();
2164
- throw new Error("Request failed with error: ".concat(err_2));
2260
+ throw err_2;
2165
2261
 
2166
2262
  case 4:
2167
2263
  clearTimeout(abortTimeout);
@@ -2491,16 +2587,18 @@ function (_super) {
2491
2587
  properties = _a.properties,
2492
2588
  groups = _a.groups,
2493
2589
  sendFeatureFlags = _a.sendFeatureFlags,
2494
- timestamp = _a.timestamp;
2590
+ timestamp = _a.timestamp,
2591
+ disableGeoip = _a.disableGeoip;
2495
2592
 
2496
2593
  var _capture = function (props) {
2497
2594
  _super.prototype.captureStateless.call(_this, distinctId, event, props, {
2498
- timestamp: timestamp
2595
+ timestamp: timestamp,
2596
+ disableGeoip: disableGeoip
2499
2597
  });
2500
2598
  };
2501
2599
 
2502
2600
  if (sendFeatureFlags) {
2503
- _super.prototype.getFeatureFlagsStateless.call(this, distinctId, groups).then(function (flags) {
2601
+ _super.prototype.getFeatureFlagsStateless.call(this, distinctId, groups, undefined, undefined, disableGeoip).then(function (flags) {
2504
2602
  var featureVariantProperties = {};
2505
2603
 
2506
2604
  if (flags) {
@@ -2536,29 +2634,34 @@ function (_super) {
2536
2634
 
2537
2635
  PostHog.prototype.identify = function (_a) {
2538
2636
  var distinctId = _a.distinctId,
2539
- properties = _a.properties; // Catch properties passed as $set and move them to the top level
2637
+ properties = _a.properties,
2638
+ disableGeoip = _a.disableGeoip; // Catch properties passed as $set and move them to the top level
2540
2639
 
2541
2640
  var personProperties = (properties === null || properties === void 0 ? void 0 : properties.$set) || properties;
2542
2641
 
2543
2642
  _super.prototype.identifyStateless.call(this, distinctId, {
2544
2643
  $set: personProperties
2644
+ }, {
2645
+ disableGeoip: disableGeoip
2545
2646
  });
2546
2647
  };
2547
2648
 
2548
2649
  PostHog.prototype.alias = function (data) {
2549
- _super.prototype.aliasStateless.call(this, data.alias, data.distinctId);
2650
+ _super.prototype.aliasStateless.call(this, data.alias, data.distinctId, undefined, {
2651
+ disableGeoip: data.disableGeoip
2652
+ });
2550
2653
  };
2551
2654
 
2552
2655
  PostHog.prototype.getFeatureFlag = function (key, distinctId, options) {
2553
2656
  var _a;
2554
2657
 
2555
2658
  return __awaiter(this, void 0, void 0, function () {
2556
- var _b, groups, personProperties, groupProperties, _c, onlyEvaluateLocally, sendFeatureFlagEvents, response, flagWasLocallyEvaluated, featureFlagReportedKey;
2659
+ var _b, groups, personProperties, groupProperties, disableGeoip, _c, onlyEvaluateLocally, sendFeatureFlagEvents, response, flagWasLocallyEvaluated, featureFlagReportedKey;
2557
2660
 
2558
2661
  return __generator(this, function (_d) {
2559
2662
  switch (_d.label) {
2560
2663
  case 0:
2561
- _b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties;
2664
+ _b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties, disableGeoip = _b.disableGeoip;
2562
2665
  _c = options || {}, onlyEvaluateLocally = _c.onlyEvaluateLocally, sendFeatureFlagEvents = _c.sendFeatureFlagEvents; // set defaults
2563
2666
 
2564
2667
  if (onlyEvaluateLocally == undefined) {
@@ -2581,7 +2684,7 @@ function (_super) {
2581
2684
  , 3];
2582
2685
  return [4
2583
2686
  /*yield*/
2584
- , _super.prototype.getFeatureFlagStateless.call(this, key, distinctId, groups, personProperties, groupProperties)];
2687
+ , _super.prototype.getFeatureFlagStateless.call(this, key, distinctId, groups, personProperties, groupProperties, disableGeoip)];
2585
2688
 
2586
2689
  case 2:
2587
2690
  response = _d.sent();
@@ -2609,7 +2712,8 @@ function (_super) {
2609
2712
  $feature_flag_response: response,
2610
2713
  locally_evaluated: flagWasLocallyEvaluated
2611
2714
  },
2612
- groups: groups
2715
+ groups: groups,
2716
+ disableGeoip: disableGeoip
2613
2717
  });
2614
2718
  }
2615
2719
 
@@ -2625,12 +2729,12 @@ function (_super) {
2625
2729
  var _a;
2626
2730
 
2627
2731
  return __awaiter(this, void 0, void 0, function () {
2628
- var _b, groups, personProperties, groupProperties, _c, onlyEvaluateLocally, response, payloadWasLocallyEvaluated;
2732
+ var _b, groups, personProperties, groupProperties, disableGeoip, _c, onlyEvaluateLocally, response, payloadWasLocallyEvaluated;
2629
2733
 
2630
2734
  return __generator(this, function (_d) {
2631
2735
  switch (_d.label) {
2632
2736
  case 0:
2633
- _b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties;
2737
+ _b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties, disableGeoip = _b.disableGeoip;
2634
2738
  _c = options || {}, onlyEvaluateLocally = _c.onlyEvaluateLocally, _c.sendFeatureFlagEvents;
2635
2739
  response = undefined;
2636
2740
  if (!!matchValue) return [3
@@ -2675,7 +2779,7 @@ function (_super) {
2675
2779
  , 6];
2676
2780
  return [4
2677
2781
  /*yield*/
2678
- , _super.prototype.getFeatureFlagPayloadStateless.call(this, key, distinctId, groups, personProperties, groupProperties)];
2782
+ , _super.prototype.getFeatureFlagPayloadStateless.call(this, key, distinctId, groups, personProperties, groupProperties, disableGeoip)];
2679
2783
 
2680
2784
  case 5:
2681
2785
  response = _d.sent();
@@ -2751,12 +2855,12 @@ function (_super) {
2751
2855
  var _a;
2752
2856
 
2753
2857
  return __awaiter(this, void 0, void 0, function () {
2754
- var _b, groups, personProperties, groupProperties, onlyEvaluateLocally, localEvaluationResult, featureFlags, featureFlagPayloads, fallbackToDecide, remoteEvaluationResult;
2858
+ var _b, groups, personProperties, groupProperties, disableGeoip, onlyEvaluateLocally, localEvaluationResult, featureFlags, featureFlagPayloads, fallbackToDecide, remoteEvaluationResult;
2755
2859
 
2756
2860
  return __generator(this, function (_c) {
2757
2861
  switch (_c.label) {
2758
2862
  case 0:
2759
- _b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties;
2863
+ _b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties, disableGeoip = _b.disableGeoip;
2760
2864
  onlyEvaluateLocally = (options || {}).onlyEvaluateLocally; // set defaults
2761
2865
 
2762
2866
  if (onlyEvaluateLocally == undefined) {
@@ -2784,7 +2888,7 @@ function (_super) {
2784
2888
  , 3];
2785
2889
  return [4
2786
2890
  /*yield*/
2787
- , _super.prototype.getFeatureFlagsAndPayloadsStateless.call(this, distinctId, groups, personProperties, groupProperties)];
2891
+ , _super.prototype.getFeatureFlagsAndPayloadsStateless.call(this, distinctId, groups, personProperties, groupProperties, disableGeoip)];
2788
2892
 
2789
2893
  case 2:
2790
2894
  remoteEvaluationResult = _c.sent();
@@ -2808,9 +2912,12 @@ function (_super) {
2808
2912
  var groupType = _a.groupType,
2809
2913
  groupKey = _a.groupKey,
2810
2914
  properties = _a.properties,
2811
- distinctId = _a.distinctId;
2915
+ distinctId = _a.distinctId,
2916
+ disableGeoip = _a.disableGeoip;
2812
2917
 
2813
- _super.prototype.groupIdentifyStateless.call(this, groupType, groupKey, properties, undefined, distinctId);
2918
+ _super.prototype.groupIdentifyStateless.call(this, groupType, groupKey, properties, {
2919
+ disableGeoip: disableGeoip
2920
+ }, distinctId);
2814
2921
  };
2815
2922
 
2816
2923
  PostHog.prototype.reloadFeatureFlags = function () {