posthog-node 3.1.1 → 3.1.2
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 +4 -0
- package/lib/index.cjs.js +22 -12
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +22 -12
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/index.d.ts +7 -2
- package/package.json +1 -1
- package/src/posthog-node.ts +1 -0
- package/test/posthog-node.spec.ts +4 -0
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 = "3.1.
|
|
158
|
+
var version = "3.1.2";
|
|
159
159
|
|
|
160
160
|
var PostHogPersistedProperty;
|
|
161
161
|
(function (PostHogPersistedProperty) {
|
|
@@ -1179,6 +1179,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
1179
1179
|
var disableGeoipOption = (_a = options === null || options === void 0 ? void 0 : options.disableGeoip) !== null && _a !== void 0 ? _a : false;
|
|
1180
1180
|
_this = _super.call(this, apiKey, __assign(__assign({}, options), { disableGeoip: disableGeoipOption })) || this;
|
|
1181
1181
|
_this.flagCallReported = {};
|
|
1182
|
+
_this.sessionProps = {};
|
|
1182
1183
|
_this.sendFeatureFlagEvent = (_b = options === null || options === void 0 ? void 0 : options.sendFeatureFlagEvent) !== null && _b !== void 0 ? _b : true;
|
|
1183
1184
|
_this._sessionExpirationTimeSeconds = (_c = options === null || options === void 0 ? void 0 : options.sessionExpirationTimeSeconds) !== null && _c !== void 0 ? _c : 1800; // 30 minutes
|
|
1184
1185
|
return _this;
|
|
@@ -1220,6 +1221,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
1220
1221
|
});
|
|
1221
1222
|
PostHogCore.prototype.clearProps = function () {
|
|
1222
1223
|
this.props = undefined;
|
|
1224
|
+
this.sessionProps = {};
|
|
1223
1225
|
};
|
|
1224
1226
|
PostHogCore.prototype.on = function (event, cb) {
|
|
1225
1227
|
return this._events.on(event, cb);
|
|
@@ -1247,7 +1249,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
1247
1249
|
return __assign(__assign({ $active_feature_flags: featureFlags ? Object.keys(featureFlags) : undefined }, featureVariantProperties), _super.prototype.getCommonEventProperties.call(this));
|
|
1248
1250
|
};
|
|
1249
1251
|
PostHogCore.prototype.enrichProperties = function (properties) {
|
|
1250
|
-
return __assign(__assign(__assign(__assign({}, this.props), (properties || {})), this.getCommonEventProperties()), { $session_id: this.getSessionId() });
|
|
1252
|
+
return __assign(__assign(__assign(__assign(__assign({}, this.props), this.sessionProps), (properties || {})), this.getCommonEventProperties()), { $session_id: this.getSessionId() });
|
|
1251
1253
|
};
|
|
1252
1254
|
PostHogCore.prototype.getSessionId = function () {
|
|
1253
1255
|
var sessionId = this.getPersistedProperty(PostHogPersistedProperty.SessionId);
|
|
@@ -1273,13 +1275,19 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
1273
1275
|
PostHogCore.prototype.getDistinctId = function () {
|
|
1274
1276
|
return this.getPersistedProperty(PostHogPersistedProperty.DistinctId) || this.getAnonymousId();
|
|
1275
1277
|
};
|
|
1278
|
+
PostHogCore.prototype.unregister = function (property) {
|
|
1279
|
+
delete this.props[property];
|
|
1280
|
+
this.setPersistedProperty(PostHogPersistedProperty.Props, this.props);
|
|
1281
|
+
};
|
|
1276
1282
|
PostHogCore.prototype.register = function (properties) {
|
|
1277
1283
|
this.props = __assign(__assign({}, this.props), properties);
|
|
1278
1284
|
this.setPersistedProperty(PostHogPersistedProperty.Props, this.props);
|
|
1279
1285
|
};
|
|
1280
|
-
PostHogCore.prototype.
|
|
1281
|
-
|
|
1282
|
-
|
|
1286
|
+
PostHogCore.prototype.registerForSession = function (properties) {
|
|
1287
|
+
this.sessionProps = __assign(__assign({}, this.sessionProps), properties);
|
|
1288
|
+
};
|
|
1289
|
+
PostHogCore.prototype.unregisterForSession = function (property) {
|
|
1290
|
+
delete this.sessionProps[property];
|
|
1283
1291
|
};
|
|
1284
1292
|
/***
|
|
1285
1293
|
*** TRACKING
|
|
@@ -2647,8 +2655,10 @@ function (_super) {
|
|
|
2647
2655
|
return __awaiter(this, void 0, void 0, function () {
|
|
2648
2656
|
var _b, groups, personProperties, groupProperties, disableGeoip, _c, onlyEvaluateLocally, sendFeatureFlagEvents, response, flagWasLocallyEvaluated, featureFlagReportedKey;
|
|
2649
2657
|
|
|
2650
|
-
|
|
2651
|
-
|
|
2658
|
+
var _d;
|
|
2659
|
+
|
|
2660
|
+
return __generator(this, function (_e) {
|
|
2661
|
+
switch (_e.label) {
|
|
2652
2662
|
case 0:
|
|
2653
2663
|
_b = options || {}, groups = _b.groups, personProperties = _b.personProperties, groupProperties = _b.groupProperties, disableGeoip = _b.disableGeoip;
|
|
2654
2664
|
_c = options || {}, onlyEvaluateLocally = _c.onlyEvaluateLocally, sendFeatureFlagEvents = _c.sendFeatureFlagEvents; // set defaults
|
|
@@ -2666,7 +2676,7 @@ function (_super) {
|
|
|
2666
2676
|
, (_a = this.featureFlagsPoller) === null || _a === void 0 ? void 0 : _a.getFeatureFlag(key, distinctId, groups, personProperties, groupProperties)];
|
|
2667
2677
|
|
|
2668
2678
|
case 1:
|
|
2669
|
-
response =
|
|
2679
|
+
response = _e.sent();
|
|
2670
2680
|
flagWasLocallyEvaluated = response !== undefined;
|
|
2671
2681
|
if (!(!flagWasLocallyEvaluated && !onlyEvaluateLocally)) return [3
|
|
2672
2682
|
/*break*/
|
|
@@ -2676,8 +2686,8 @@ function (_super) {
|
|
|
2676
2686
|
, _super.prototype.getFeatureFlagStateless.call(this, key, distinctId, groups, personProperties, groupProperties, disableGeoip)];
|
|
2677
2687
|
|
|
2678
2688
|
case 2:
|
|
2679
|
-
response =
|
|
2680
|
-
|
|
2689
|
+
response = _e.sent();
|
|
2690
|
+
_e.label = 3;
|
|
2681
2691
|
|
|
2682
2692
|
case 3:
|
|
2683
2693
|
featureFlagReportedKey = "".concat(key, "_").concat(response);
|
|
@@ -2696,11 +2706,11 @@ function (_super) {
|
|
|
2696
2706
|
this.capture({
|
|
2697
2707
|
distinctId: distinctId,
|
|
2698
2708
|
event: '$feature_flag_called',
|
|
2699
|
-
properties: {
|
|
2709
|
+
properties: (_d = {
|
|
2700
2710
|
$feature_flag: key,
|
|
2701
2711
|
$feature_flag_response: response,
|
|
2702
2712
|
locally_evaluated: flagWasLocallyEvaluated
|
|
2703
|
-
},
|
|
2713
|
+
}, _d["$feature/".concat(key)] = response, _d),
|
|
2704
2714
|
groups: groups,
|
|
2705
2715
|
disableGeoip: disableGeoip
|
|
2706
2716
|
});
|