posthog-node 2.6.0 → 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 +18 -0
- package/lib/index.cjs.js +64 -36
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +20 -9
- package/lib/index.esm.js +64 -36
- 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/posthog-node.d.ts +9 -3
- package/lib/posthog-node/src/types.d.ts +2 -0
- package/package.json +1 -1
- package/src/posthog-node.ts +42 -17
- package/src/types.ts +2 -0
- package/test/feature-flags.spec.ts +2 -0
- package/test/posthog-node.spec.ts +177 -11
package/lib/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ declare type PosthogCoreOptions = {
|
|
|
17
17
|
requestTimeout?: number;
|
|
18
18
|
sessionExpirationTimeSeconds?: number;
|
|
19
19
|
captureMode?: 'json' | 'form';
|
|
20
|
+
disableGeoip?: boolean;
|
|
20
21
|
};
|
|
21
22
|
declare enum PostHogPersistedProperty {
|
|
22
23
|
AnonymousId = "anonymous_id",
|
|
@@ -44,6 +45,7 @@ declare type PostHogFetchOptions = {
|
|
|
44
45
|
};
|
|
45
46
|
declare type PosthogCaptureOptions = {
|
|
46
47
|
timestamp?: Date;
|
|
48
|
+
disableGeoip?: boolean;
|
|
47
49
|
};
|
|
48
50
|
declare type PostHogFetchResponse = {
|
|
49
51
|
status: number;
|
|
@@ -105,6 +107,7 @@ declare abstract class PostHogCoreStateless {
|
|
|
105
107
|
private removeDebugCallback?;
|
|
106
108
|
private debugMode;
|
|
107
109
|
private pendingPromises;
|
|
110
|
+
private disableGeoip;
|
|
108
111
|
private _optoutOverride;
|
|
109
112
|
protected _events: SimpleEventEmitter;
|
|
110
113
|
protected _flushTimer?: any;
|
|
@@ -132,7 +135,7 @@ declare abstract class PostHogCoreStateless {
|
|
|
132
135
|
}, options?: PosthogCaptureOptions): this;
|
|
133
136
|
protected aliasStateless(alias: string, distinctId: string, properties?: {
|
|
134
137
|
[key: string]: any;
|
|
135
|
-
}): this;
|
|
138
|
+
}, options?: PosthogCaptureOptions): this;
|
|
136
139
|
/***
|
|
137
140
|
*** GROUPS
|
|
138
141
|
***/
|
|
@@ -141,12 +144,12 @@ declare abstract class PostHogCoreStateless {
|
|
|
141
144
|
*** FEATURE FLAGS
|
|
142
145
|
***/
|
|
143
146
|
protected getDecide(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, extraPayload?: Record<string, any>): Promise<PostHogDecideResponse | undefined>;
|
|
144
|
-
protected getFeatureFlagStateless(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string
|
|
145
|
-
protected getFeatureFlagPayloadStateless(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string
|
|
146
|
-
protected getFeatureFlagPayloadsStateless(distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string
|
|
147
|
+
protected getFeatureFlagStateless(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<boolean | string | undefined>;
|
|
148
|
+
protected getFeatureFlagPayloadStateless(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<JsonType | undefined>;
|
|
149
|
+
protected getFeatureFlagPayloadsStateless(distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<PostHogDecideResponse['featureFlagPayloads'] | undefined>;
|
|
147
150
|
protected _parsePayload(response: any): any;
|
|
148
|
-
protected getFeatureFlagsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string
|
|
149
|
-
protected getFeatureFlagsAndPayloadsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string
|
|
151
|
+
protected getFeatureFlagsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<PostHogDecideResponse['featureFlags'] | undefined>;
|
|
152
|
+
protected getFeatureFlagsAndPayloadsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<{
|
|
150
153
|
flags: PostHogDecideResponse['featureFlags'] | undefined;
|
|
151
154
|
payloads: PostHogDecideResponse['featureFlagPayloads'] | undefined;
|
|
152
155
|
}>;
|
|
@@ -164,6 +167,7 @@ declare abstract class PostHogCoreStateless {
|
|
|
164
167
|
interface IdentifyMessageV1 {
|
|
165
168
|
distinctId: string;
|
|
166
169
|
properties?: Record<string | number, any>;
|
|
170
|
+
disableGeoip?: boolean;
|
|
167
171
|
}
|
|
168
172
|
interface EventMessageV1 extends IdentifyMessageV1 {
|
|
169
173
|
event: string;
|
|
@@ -176,6 +180,7 @@ interface GroupIdentifyMessage {
|
|
|
176
180
|
groupKey: string;
|
|
177
181
|
properties?: Record<string | number, any>;
|
|
178
182
|
distinctId?: string;
|
|
183
|
+
disableGeoip?: boolean;
|
|
179
184
|
}
|
|
180
185
|
declare type PostHogNodeV1 = {
|
|
181
186
|
/**
|
|
@@ -321,11 +326,12 @@ declare class PostHog extends PostHogCoreStateless implements PostHogNodeV1 {
|
|
|
321
326
|
enable(): void;
|
|
322
327
|
disable(): void;
|
|
323
328
|
debug(enabled?: boolean): void;
|
|
324
|
-
capture({ distinctId, event, properties, groups, sendFeatureFlags, timestamp }: EventMessageV1): void;
|
|
325
|
-
identify({ distinctId, properties }: IdentifyMessageV1): void;
|
|
329
|
+
capture({ distinctId, event, properties, groups, sendFeatureFlags, timestamp, disableGeoip }: EventMessageV1): void;
|
|
330
|
+
identify({ distinctId, properties, disableGeoip }: IdentifyMessageV1): void;
|
|
326
331
|
alias(data: {
|
|
327
332
|
distinctId: string;
|
|
328
333
|
alias: string;
|
|
334
|
+
disableGeoip?: boolean;
|
|
329
335
|
}): void;
|
|
330
336
|
getFeatureFlag(key: string, distinctId: string, options?: {
|
|
331
337
|
groups?: Record<string, string>;
|
|
@@ -333,6 +339,7 @@ declare class PostHog extends PostHogCoreStateless implements PostHogNodeV1 {
|
|
|
333
339
|
groupProperties?: Record<string, Record<string, string>>;
|
|
334
340
|
onlyEvaluateLocally?: boolean;
|
|
335
341
|
sendFeatureFlagEvents?: boolean;
|
|
342
|
+
disableGeoip?: boolean;
|
|
336
343
|
}): Promise<string | boolean | undefined>;
|
|
337
344
|
getFeatureFlagPayload(key: string, distinctId: string, matchValue?: string | boolean, options?: {
|
|
338
345
|
groups?: Record<string, string>;
|
|
@@ -340,6 +347,7 @@ declare class PostHog extends PostHogCoreStateless implements PostHogNodeV1 {
|
|
|
340
347
|
groupProperties?: Record<string, Record<string, string>>;
|
|
341
348
|
onlyEvaluateLocally?: boolean;
|
|
342
349
|
sendFeatureFlagEvents?: boolean;
|
|
350
|
+
disableGeoip?: boolean;
|
|
343
351
|
}): Promise<JsonType | undefined>;
|
|
344
352
|
isFeatureEnabled(key: string, distinctId: string, options?: {
|
|
345
353
|
groups?: Record<string, string>;
|
|
@@ -347,20 +355,23 @@ declare class PostHog extends PostHogCoreStateless implements PostHogNodeV1 {
|
|
|
347
355
|
groupProperties?: Record<string, Record<string, string>>;
|
|
348
356
|
onlyEvaluateLocally?: boolean;
|
|
349
357
|
sendFeatureFlagEvents?: boolean;
|
|
358
|
+
disableGeoip?: boolean;
|
|
350
359
|
}): Promise<boolean | undefined>;
|
|
351
360
|
getAllFlags(distinctId: string, options?: {
|
|
352
361
|
groups?: Record<string, string>;
|
|
353
362
|
personProperties?: Record<string, string>;
|
|
354
363
|
groupProperties?: Record<string, Record<string, string>>;
|
|
355
364
|
onlyEvaluateLocally?: boolean;
|
|
365
|
+
disableGeoip?: boolean;
|
|
356
366
|
}): Promise<Record<string, string | boolean>>;
|
|
357
367
|
getAllFlagsAndPayloads(distinctId: string, options?: {
|
|
358
368
|
groups?: Record<string, string>;
|
|
359
369
|
personProperties?: Record<string, string>;
|
|
360
370
|
groupProperties?: Record<string, Record<string, string>>;
|
|
361
371
|
onlyEvaluateLocally?: boolean;
|
|
372
|
+
disableGeoip?: boolean;
|
|
362
373
|
}): Promise<PosthogFlagsAndPayloadsResponse>;
|
|
363
|
-
groupIdentify({ groupType, groupKey, properties, distinctId }: GroupIdentifyMessage): void;
|
|
374
|
+
groupIdentify({ groupType, groupKey, properties, distinctId, disableGeoip }: GroupIdentifyMessage): void;
|
|
364
375
|
reloadFeatureFlags(): Promise<void>;
|
|
365
376
|
shutdown(): void;
|
|
366
377
|
shutdownAsync(): Promise<void>;
|
package/lib/index.esm.js
CHANGED
|
@@ -155,7 +155,7 @@ function __spreadArray(to, from, pack) {
|
|
|
155
155
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
var version = "
|
|
158
|
+
var version = "3.0.0";
|
|
159
159
|
|
|
160
160
|
var PostHogPersistedProperty;
|
|
161
161
|
(function (PostHogPersistedProperty) {
|
|
@@ -716,9 +716,10 @@ var SimpleEventEmitter = /** @class */ (function () {
|
|
|
716
716
|
|
|
717
717
|
var PostHogCoreStateless = /** @class */ (function () {
|
|
718
718
|
function PostHogCoreStateless(apiKey, options) {
|
|
719
|
-
var _a, _b, _c, _d;
|
|
719
|
+
var _a, _b, _c, _d, _e;
|
|
720
720
|
this.debugMode = false;
|
|
721
721
|
this.pendingPromises = {};
|
|
722
|
+
this.disableGeoip = true;
|
|
722
723
|
// internal
|
|
723
724
|
this._events = new SimpleEventEmitter();
|
|
724
725
|
assert(apiKey, "You must pass your PostHog project's api key.");
|
|
@@ -734,6 +735,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
734
735
|
retryDelay: (_c = options === null || options === void 0 ? void 0 : options.fetchRetryDelay) !== null && _c !== void 0 ? _c : 3000,
|
|
735
736
|
};
|
|
736
737
|
this.requestTimeout = (_d = options === null || options === void 0 ? void 0 : options.requestTimeout) !== null && _d !== void 0 ? _d : 10000; // 10 seconds
|
|
738
|
+
this.disableGeoip = (_e = options === null || options === void 0 ? void 0 : options.disableGeoip) !== null && _e !== void 0 ? _e : true;
|
|
737
739
|
}
|
|
738
740
|
PostHogCoreStateless.prototype.getCommonEventProperties = function () {
|
|
739
741
|
return {
|
|
@@ -793,13 +795,13 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
793
795
|
this.enqueue('capture', payload, options);
|
|
794
796
|
return this;
|
|
795
797
|
};
|
|
796
|
-
PostHogCoreStateless.prototype.aliasStateless = function (alias, distinctId, properties) {
|
|
798
|
+
PostHogCoreStateless.prototype.aliasStateless = function (alias, distinctId, properties, options) {
|
|
797
799
|
var payload = this.buildPayload({
|
|
798
800
|
event: '$create_alias',
|
|
799
801
|
distinct_id: distinctId,
|
|
800
802
|
properties: __assign(__assign({}, (properties || {})), { distinct_id: distinctId, alias: alias }),
|
|
801
803
|
});
|
|
802
|
-
this.enqueue('alias', payload);
|
|
804
|
+
this.enqueue('alias', payload, options);
|
|
803
805
|
return this;
|
|
804
806
|
};
|
|
805
807
|
/***
|
|
@@ -840,7 +842,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
840
842
|
});
|
|
841
843
|
});
|
|
842
844
|
};
|
|
843
|
-
PostHogCoreStateless.prototype.getFeatureFlagStateless = function (key, distinctId, groups, personProperties, groupProperties) {
|
|
845
|
+
PostHogCoreStateless.prototype.getFeatureFlagStateless = function (key, distinctId, groups, personProperties, groupProperties, disableGeoip) {
|
|
844
846
|
if (groups === void 0) { groups = {}; }
|
|
845
847
|
if (personProperties === void 0) { personProperties = {}; }
|
|
846
848
|
if (groupProperties === void 0) { groupProperties = {}; }
|
|
@@ -848,7 +850,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
848
850
|
var featureFlags, response;
|
|
849
851
|
return __generator(this, function (_a) {
|
|
850
852
|
switch (_a.label) {
|
|
851
|
-
case 0: return [4 /*yield*/, this.getFeatureFlagsStateless(distinctId, groups, personProperties, groupProperties)];
|
|
853
|
+
case 0: return [4 /*yield*/, this.getFeatureFlagsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip)];
|
|
852
854
|
case 1:
|
|
853
855
|
featureFlags = _a.sent();
|
|
854
856
|
if (!featureFlags) {
|
|
@@ -867,7 +869,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
867
869
|
});
|
|
868
870
|
});
|
|
869
871
|
};
|
|
870
|
-
PostHogCoreStateless.prototype.getFeatureFlagPayloadStateless = function (key, distinctId, groups, personProperties, groupProperties) {
|
|
872
|
+
PostHogCoreStateless.prototype.getFeatureFlagPayloadStateless = function (key, distinctId, groups, personProperties, groupProperties, disableGeoip) {
|
|
871
873
|
if (groups === void 0) { groups = {}; }
|
|
872
874
|
if (personProperties === void 0) { personProperties = {}; }
|
|
873
875
|
if (groupProperties === void 0) { groupProperties = {}; }
|
|
@@ -875,7 +877,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
875
877
|
var payloads, response;
|
|
876
878
|
return __generator(this, function (_a) {
|
|
877
879
|
switch (_a.label) {
|
|
878
|
-
case 0: return [4 /*yield*/, this.getFeatureFlagPayloadsStateless(distinctId, groups, personProperties, groupProperties)];
|
|
880
|
+
case 0: return [4 /*yield*/, this.getFeatureFlagPayloadsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip)];
|
|
879
881
|
case 1:
|
|
880
882
|
payloads = _a.sent();
|
|
881
883
|
if (!payloads) {
|
|
@@ -891,7 +893,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
891
893
|
});
|
|
892
894
|
});
|
|
893
895
|
};
|
|
894
|
-
PostHogCoreStateless.prototype.getFeatureFlagPayloadsStateless = function (distinctId, groups, personProperties, groupProperties) {
|
|
896
|
+
PostHogCoreStateless.prototype.getFeatureFlagPayloadsStateless = function (distinctId, groups, personProperties, groupProperties, disableGeoip) {
|
|
895
897
|
if (groups === void 0) { groups = {}; }
|
|
896
898
|
if (personProperties === void 0) { personProperties = {}; }
|
|
897
899
|
if (groupProperties === void 0) { groupProperties = {}; }
|
|
@@ -900,7 +902,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
900
902
|
var _this = this;
|
|
901
903
|
return __generator(this, function (_a) {
|
|
902
904
|
switch (_a.label) {
|
|
903
|
-
case 0: return [4 /*yield*/, this.getFeatureFlagsAndPayloadsStateless(distinctId, groups, personProperties, groupProperties)];
|
|
905
|
+
case 0: return [4 /*yield*/, this.getFeatureFlagsAndPayloadsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip)];
|
|
904
906
|
case 1:
|
|
905
907
|
payloads = (_a.sent()).payloads;
|
|
906
908
|
if (payloads) {
|
|
@@ -922,28 +924,33 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
922
924
|
return response;
|
|
923
925
|
}
|
|
924
926
|
};
|
|
925
|
-
PostHogCoreStateless.prototype.getFeatureFlagsStateless = function (distinctId, groups, personProperties, groupProperties) {
|
|
927
|
+
PostHogCoreStateless.prototype.getFeatureFlagsStateless = function (distinctId, groups, personProperties, groupProperties, disableGeoip) {
|
|
926
928
|
if (groups === void 0) { groups = {}; }
|
|
927
929
|
if (personProperties === void 0) { personProperties = {}; }
|
|
928
930
|
if (groupProperties === void 0) { groupProperties = {}; }
|
|
929
931
|
return __awaiter(this, void 0, void 0, function () {
|
|
930
932
|
return __generator(this, function (_a) {
|
|
931
933
|
switch (_a.label) {
|
|
932
|
-
case 0: return [4 /*yield*/, this.getFeatureFlagsAndPayloadsStateless(distinctId, groups, personProperties, groupProperties)];
|
|
934
|
+
case 0: return [4 /*yield*/, this.getFeatureFlagsAndPayloadsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip)];
|
|
933
935
|
case 1: return [2 /*return*/, (_a.sent()).flags];
|
|
934
936
|
}
|
|
935
937
|
});
|
|
936
938
|
});
|
|
937
939
|
};
|
|
938
|
-
PostHogCoreStateless.prototype.getFeatureFlagsAndPayloadsStateless = function (distinctId, groups, personProperties, groupProperties) {
|
|
940
|
+
PostHogCoreStateless.prototype.getFeatureFlagsAndPayloadsStateless = function (distinctId, groups, personProperties, groupProperties, disableGeoip) {
|
|
939
941
|
if (groups === void 0) { groups = {}; }
|
|
940
942
|
if (personProperties === void 0) { personProperties = {}; }
|
|
941
943
|
if (groupProperties === void 0) { groupProperties = {}; }
|
|
942
944
|
return __awaiter(this, void 0, void 0, function () {
|
|
943
|
-
var decideResponse, flags, payloads;
|
|
945
|
+
var extraPayload, decideResponse, flags, payloads;
|
|
944
946
|
return __generator(this, function (_a) {
|
|
945
947
|
switch (_a.label) {
|
|
946
|
-
case 0:
|
|
948
|
+
case 0:
|
|
949
|
+
extraPayload = {};
|
|
950
|
+
if (disableGeoip !== null && disableGeoip !== void 0 ? disableGeoip : this.disableGeoip) {
|
|
951
|
+
extraPayload['geoip_disable'] = true;
|
|
952
|
+
}
|
|
953
|
+
return [4 /*yield*/, this.getDecide(distinctId, groups, personProperties, groupProperties, extraPayload)];
|
|
947
954
|
case 1:
|
|
948
955
|
decideResponse = _a.sent();
|
|
949
956
|
flags = decideResponse === null || decideResponse === void 0 ? void 0 : decideResponse.featureFlags;
|
|
@@ -961,11 +968,19 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
961
968
|
***/
|
|
962
969
|
PostHogCoreStateless.prototype.enqueue = function (type, _message, options) {
|
|
963
970
|
var _this = this;
|
|
971
|
+
var _a;
|
|
964
972
|
if (this.optedOut) {
|
|
965
973
|
this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.enable()");
|
|
966
974
|
return;
|
|
967
975
|
}
|
|
968
976
|
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() });
|
|
977
|
+
var addGeoipDisableProperty = (_a = options === null || options === void 0 ? void 0 : options.disableGeoip) !== null && _a !== void 0 ? _a : this.disableGeoip;
|
|
978
|
+
if (addGeoipDisableProperty) {
|
|
979
|
+
if (!message.properties) {
|
|
980
|
+
message.properties = {};
|
|
981
|
+
}
|
|
982
|
+
message['properties']['$geoip_disable'] = true;
|
|
983
|
+
}
|
|
969
984
|
if (message.distinctId) {
|
|
970
985
|
message.distinct_id = message.distinctId;
|
|
971
986
|
delete message.distinctId;
|
|
@@ -1092,11 +1107,13 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
1092
1107
|
__extends(PostHogCore, _super);
|
|
1093
1108
|
function PostHogCore(apiKey, options) {
|
|
1094
1109
|
var _this = this;
|
|
1095
|
-
var _a, _b;
|
|
1096
|
-
|
|
1110
|
+
var _a, _b, _c;
|
|
1111
|
+
// Default for stateful mode is to not disable geoip. Only override if explicitly set
|
|
1112
|
+
var disableGeoipOption = (_a = options === null || options === void 0 ? void 0 : options.disableGeoip) !== null && _a !== void 0 ? _a : false;
|
|
1113
|
+
_this = _super.call(this, apiKey, __assign(__assign({}, options), { disableGeoip: disableGeoipOption })) || this;
|
|
1097
1114
|
_this.flagCallReported = {};
|
|
1098
|
-
_this.sendFeatureFlagEvent = (
|
|
1099
|
-
_this._sessionExpirationTimeSeconds = (
|
|
1115
|
+
_this.sendFeatureFlagEvent = (_b = options === null || options === void 0 ? void 0 : options.sendFeatureFlagEvent) !== null && _b !== void 0 ? _b : true;
|
|
1116
|
+
_this._sessionExpirationTimeSeconds = (_c = options === null || options === void 0 ? void 0 : options.sessionExpirationTimeSeconds) !== null && _c !== void 0 ? _c : 1800; // 30 minutes
|
|
1100
1117
|
// NOTE: It is important we don't initiate anything in the constructor as some async IO may still be underway on the parent
|
|
1101
1118
|
if ((options === null || options === void 0 ? void 0 : options.preloadFeatureFlags) !== false) {
|
|
1102
1119
|
safeSetTimeout(function () {
|
|
@@ -2483,16 +2500,18 @@ function (_super) {
|
|
|
2483
2500
|
properties = _a.properties,
|
|
2484
2501
|
groups = _a.groups,
|
|
2485
2502
|
sendFeatureFlags = _a.sendFeatureFlags,
|
|
2486
|
-
timestamp = _a.timestamp
|
|
2503
|
+
timestamp = _a.timestamp,
|
|
2504
|
+
disableGeoip = _a.disableGeoip;
|
|
2487
2505
|
|
|
2488
2506
|
var _capture = function (props) {
|
|
2489
2507
|
_super.prototype.captureStateless.call(_this, distinctId, event, props, {
|
|
2490
|
-
timestamp: timestamp
|
|
2508
|
+
timestamp: timestamp,
|
|
2509
|
+
disableGeoip: disableGeoip
|
|
2491
2510
|
});
|
|
2492
2511
|
};
|
|
2493
2512
|
|
|
2494
2513
|
if (sendFeatureFlags) {
|
|
2495
|
-
_super.prototype.getFeatureFlagsStateless.call(this, distinctId, groups).then(function (flags) {
|
|
2514
|
+
_super.prototype.getFeatureFlagsStateless.call(this, distinctId, groups, undefined, undefined, disableGeoip).then(function (flags) {
|
|
2496
2515
|
var featureVariantProperties = {};
|
|
2497
2516
|
|
|
2498
2517
|
if (flags) {
|
|
@@ -2528,29 +2547,34 @@ function (_super) {
|
|
|
2528
2547
|
|
|
2529
2548
|
PostHog.prototype.identify = function (_a) {
|
|
2530
2549
|
var distinctId = _a.distinctId,
|
|
2531
|
-
properties = _a.properties
|
|
2550
|
+
properties = _a.properties,
|
|
2551
|
+
disableGeoip = _a.disableGeoip; // Catch properties passed as $set and move them to the top level
|
|
2532
2552
|
|
|
2533
2553
|
var personProperties = (properties === null || properties === void 0 ? void 0 : properties.$set) || properties;
|
|
2534
2554
|
|
|
2535
2555
|
_super.prototype.identifyStateless.call(this, distinctId, {
|
|
2536
2556
|
$set: personProperties
|
|
2557
|
+
}, {
|
|
2558
|
+
disableGeoip: disableGeoip
|
|
2537
2559
|
});
|
|
2538
2560
|
};
|
|
2539
2561
|
|
|
2540
2562
|
PostHog.prototype.alias = function (data) {
|
|
2541
|
-
_super.prototype.aliasStateless.call(this, data.alias, data.distinctId
|
|
2563
|
+
_super.prototype.aliasStateless.call(this, data.alias, data.distinctId, undefined, {
|
|
2564
|
+
disableGeoip: data.disableGeoip
|
|
2565
|
+
});
|
|
2542
2566
|
};
|
|
2543
2567
|
|
|
2544
2568
|
PostHog.prototype.getFeatureFlag = function (key, distinctId, options) {
|
|
2545
2569
|
var _a;
|
|
2546
2570
|
|
|
2547
2571
|
return __awaiter(this, void 0, void 0, function () {
|
|
2548
|
-
var _b, groups, personProperties, groupProperties, _c, onlyEvaluateLocally, sendFeatureFlagEvents, response, flagWasLocallyEvaluated, featureFlagReportedKey;
|
|
2572
|
+
var _b, groups, personProperties, groupProperties, disableGeoip, _c, onlyEvaluateLocally, sendFeatureFlagEvents, response, flagWasLocallyEvaluated, featureFlagReportedKey;
|
|
2549
2573
|
|
|
2550
2574
|
return __generator(this, function (_d) {
|
|
2551
2575
|
switch (_d.label) {
|
|
2552
2576
|
case 0:
|
|
2553
|
-
_b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties;
|
|
2577
|
+
_b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties, disableGeoip = _b.disableGeoip;
|
|
2554
2578
|
_c = options || {}, onlyEvaluateLocally = _c.onlyEvaluateLocally, sendFeatureFlagEvents = _c.sendFeatureFlagEvents; // set defaults
|
|
2555
2579
|
|
|
2556
2580
|
if (onlyEvaluateLocally == undefined) {
|
|
@@ -2573,7 +2597,7 @@ function (_super) {
|
|
|
2573
2597
|
, 3];
|
|
2574
2598
|
return [4
|
|
2575
2599
|
/*yield*/
|
|
2576
|
-
, _super.prototype.getFeatureFlagStateless.call(this, key, distinctId, groups, personProperties, groupProperties)];
|
|
2600
|
+
, _super.prototype.getFeatureFlagStateless.call(this, key, distinctId, groups, personProperties, groupProperties, disableGeoip)];
|
|
2577
2601
|
|
|
2578
2602
|
case 2:
|
|
2579
2603
|
response = _d.sent();
|
|
@@ -2601,7 +2625,8 @@ function (_super) {
|
|
|
2601
2625
|
$feature_flag_response: response,
|
|
2602
2626
|
locally_evaluated: flagWasLocallyEvaluated
|
|
2603
2627
|
},
|
|
2604
|
-
groups: groups
|
|
2628
|
+
groups: groups,
|
|
2629
|
+
disableGeoip: disableGeoip
|
|
2605
2630
|
});
|
|
2606
2631
|
}
|
|
2607
2632
|
|
|
@@ -2617,12 +2642,12 @@ function (_super) {
|
|
|
2617
2642
|
var _a;
|
|
2618
2643
|
|
|
2619
2644
|
return __awaiter(this, void 0, void 0, function () {
|
|
2620
|
-
var _b, groups, personProperties, groupProperties, _c, onlyEvaluateLocally, response, payloadWasLocallyEvaluated;
|
|
2645
|
+
var _b, groups, personProperties, groupProperties, disableGeoip, _c, onlyEvaluateLocally, response, payloadWasLocallyEvaluated;
|
|
2621
2646
|
|
|
2622
2647
|
return __generator(this, function (_d) {
|
|
2623
2648
|
switch (_d.label) {
|
|
2624
2649
|
case 0:
|
|
2625
|
-
_b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties;
|
|
2650
|
+
_b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties, disableGeoip = _b.disableGeoip;
|
|
2626
2651
|
_c = options || {}, onlyEvaluateLocally = _c.onlyEvaluateLocally, _c.sendFeatureFlagEvents;
|
|
2627
2652
|
response = undefined;
|
|
2628
2653
|
if (!!matchValue) return [3
|
|
@@ -2667,7 +2692,7 @@ function (_super) {
|
|
|
2667
2692
|
, 6];
|
|
2668
2693
|
return [4
|
|
2669
2694
|
/*yield*/
|
|
2670
|
-
, _super.prototype.getFeatureFlagPayloadStateless.call(this, key, distinctId, groups, personProperties, groupProperties)];
|
|
2695
|
+
, _super.prototype.getFeatureFlagPayloadStateless.call(this, key, distinctId, groups, personProperties, groupProperties, disableGeoip)];
|
|
2671
2696
|
|
|
2672
2697
|
case 5:
|
|
2673
2698
|
response = _d.sent();
|
|
@@ -2743,12 +2768,12 @@ function (_super) {
|
|
|
2743
2768
|
var _a;
|
|
2744
2769
|
|
|
2745
2770
|
return __awaiter(this, void 0, void 0, function () {
|
|
2746
|
-
var _b, groups, personProperties, groupProperties, onlyEvaluateLocally, localEvaluationResult, featureFlags, featureFlagPayloads, fallbackToDecide, remoteEvaluationResult;
|
|
2771
|
+
var _b, groups, personProperties, groupProperties, disableGeoip, onlyEvaluateLocally, localEvaluationResult, featureFlags, featureFlagPayloads, fallbackToDecide, remoteEvaluationResult;
|
|
2747
2772
|
|
|
2748
2773
|
return __generator(this, function (_c) {
|
|
2749
2774
|
switch (_c.label) {
|
|
2750
2775
|
case 0:
|
|
2751
|
-
_b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties;
|
|
2776
|
+
_b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties, disableGeoip = _b.disableGeoip;
|
|
2752
2777
|
onlyEvaluateLocally = (options || {}).onlyEvaluateLocally; // set defaults
|
|
2753
2778
|
|
|
2754
2779
|
if (onlyEvaluateLocally == undefined) {
|
|
@@ -2776,7 +2801,7 @@ function (_super) {
|
|
|
2776
2801
|
, 3];
|
|
2777
2802
|
return [4
|
|
2778
2803
|
/*yield*/
|
|
2779
|
-
, _super.prototype.getFeatureFlagsAndPayloadsStateless.call(this, distinctId, groups, personProperties, groupProperties)];
|
|
2804
|
+
, _super.prototype.getFeatureFlagsAndPayloadsStateless.call(this, distinctId, groups, personProperties, groupProperties, disableGeoip)];
|
|
2780
2805
|
|
|
2781
2806
|
case 2:
|
|
2782
2807
|
remoteEvaluationResult = _c.sent();
|
|
@@ -2800,9 +2825,12 @@ function (_super) {
|
|
|
2800
2825
|
var groupType = _a.groupType,
|
|
2801
2826
|
groupKey = _a.groupKey,
|
|
2802
2827
|
properties = _a.properties,
|
|
2803
|
-
distinctId = _a.distinctId
|
|
2828
|
+
distinctId = _a.distinctId,
|
|
2829
|
+
disableGeoip = _a.disableGeoip;
|
|
2804
2830
|
|
|
2805
|
-
_super.prototype.groupIdentifyStateless.call(this, groupType, groupKey, properties,
|
|
2831
|
+
_super.prototype.groupIdentifyStateless.call(this, groupType, groupKey, properties, {
|
|
2832
|
+
disableGeoip: disableGeoip
|
|
2833
|
+
}, distinctId);
|
|
2806
2834
|
};
|
|
2807
2835
|
|
|
2808
2836
|
PostHog.prototype.reloadFeatureFlags = function () {
|