posthog-node 4.9.0 → 4.10.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/CHANGELOG.md +8 -0
- package/lib/index.cjs.js +36 -15
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +11 -2
- package/lib/index.esm.js +36 -15
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/index.d.ts +10 -2
- package/lib/posthog-core/src/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/extensions/sentry-integration.ts +13 -6
- package/src/posthog-node.ts +7 -4
- package/test/extensions/sentry-integration.spec.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Next
|
|
2
2
|
|
|
3
|
+
# 4.10.1 – 2025-03-06
|
|
4
|
+
|
|
5
|
+
1. Fix: only set `platform` on PostHog exception frame properties
|
|
6
|
+
|
|
7
|
+
# 4.10.0 – 2025-03-06
|
|
8
|
+
|
|
9
|
+
1. Attach requestId to $feature_flag_called if present in /decide response
|
|
10
|
+
|
|
3
11
|
# 4.9.0 – 2025-03-04
|
|
4
12
|
|
|
5
13
|
1. Allow feature flags to be evaluated individually when local evaluation is not being used
|
package/lib/index.cjs.js
CHANGED
|
@@ -7,7 +7,7 @@ var node_fs = require('node:fs');
|
|
|
7
7
|
var node_readline = require('node:readline');
|
|
8
8
|
var node_path = require('node:path');
|
|
9
9
|
|
|
10
|
-
var version = "4.
|
|
10
|
+
var version = "4.10.1";
|
|
11
11
|
|
|
12
12
|
var PostHogPersistedProperty;
|
|
13
13
|
(function (PostHogPersistedProperty) {
|
|
@@ -1155,10 +1155,14 @@ class PostHogCoreStateless {
|
|
|
1155
1155
|
}
|
|
1156
1156
|
async getFeatureFlagStateless(key, distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip) {
|
|
1157
1157
|
await this._initPromise;
|
|
1158
|
-
const
|
|
1158
|
+
const decideResponse = await this.getFeatureFlagsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip, [key]);
|
|
1159
|
+
const featureFlags = decideResponse.flags;
|
|
1159
1160
|
if (!featureFlags) {
|
|
1160
1161
|
// If we haven't loaded flags yet, or errored out, we respond with undefined
|
|
1161
|
-
return
|
|
1162
|
+
return {
|
|
1163
|
+
response: undefined,
|
|
1164
|
+
requestId: undefined,
|
|
1165
|
+
};
|
|
1162
1166
|
}
|
|
1163
1167
|
let response = featureFlags[key];
|
|
1164
1168
|
// `/decide` v3 returns all flags
|
|
@@ -1167,7 +1171,10 @@ class PostHogCoreStateless {
|
|
|
1167
1171
|
response = false;
|
|
1168
1172
|
}
|
|
1169
1173
|
// If we have flags we either return the value (true or string) or false
|
|
1170
|
-
return
|
|
1174
|
+
return {
|
|
1175
|
+
response,
|
|
1176
|
+
requestId: decideResponse.requestId,
|
|
1177
|
+
};
|
|
1171
1178
|
}
|
|
1172
1179
|
async getFeatureFlagPayloadStateless(key, distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip) {
|
|
1173
1180
|
await this._initPromise;
|
|
@@ -1197,7 +1204,7 @@ class PostHogCoreStateless {
|
|
|
1197
1204
|
}
|
|
1198
1205
|
async getFeatureFlagsStateless(distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip, flagKeysToEvaluate) {
|
|
1199
1206
|
await this._initPromise;
|
|
1200
|
-
return
|
|
1207
|
+
return await this.getFeatureFlagsAndPayloadsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip, flagKeysToEvaluate);
|
|
1201
1208
|
}
|
|
1202
1209
|
async getFeatureFlagsAndPayloadsStateless(distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip, flagKeysToEvaluate) {
|
|
1203
1210
|
await this._initPromise;
|
|
@@ -1215,6 +1222,7 @@ class PostHogCoreStateless {
|
|
|
1215
1222
|
return {
|
|
1216
1223
|
flags: undefined,
|
|
1217
1224
|
payloads: undefined,
|
|
1225
|
+
requestId: decideResponse?.requestId,
|
|
1218
1226
|
};
|
|
1219
1227
|
}
|
|
1220
1228
|
const flags = decideResponse?.featureFlags;
|
|
@@ -1226,6 +1234,7 @@ class PostHogCoreStateless {
|
|
|
1226
1234
|
return {
|
|
1227
1235
|
flags,
|
|
1228
1236
|
payloads: parsedPayloads,
|
|
1237
|
+
requestId: decideResponse?.requestId,
|
|
1229
1238
|
};
|
|
1230
1239
|
}
|
|
1231
1240
|
/***
|
|
@@ -3066,8 +3075,8 @@ class PostHog extends PostHogCoreStateless {
|
|
|
3066
3075
|
uuid
|
|
3067
3076
|
});
|
|
3068
3077
|
};
|
|
3069
|
-
const _getFlags = (distinctId, groups, disableGeoip) => {
|
|
3070
|
-
return super.getFeatureFlagsStateless(distinctId, groups, undefined, undefined, disableGeoip);
|
|
3078
|
+
const _getFlags = async (distinctId, groups, disableGeoip) => {
|
|
3079
|
+
return (await super.getFeatureFlagsStateless(distinctId, groups, undefined, undefined, disableGeoip)).flags;
|
|
3071
3080
|
};
|
|
3072
3081
|
// :TRICKY: If we flush, or need to shut down, to not lose events we want this promise to resolve before we flush
|
|
3073
3082
|
const capturePromise = Promise.resolve().then(async () => {
|
|
@@ -3165,8 +3174,11 @@ class PostHog extends PostHogCoreStateless {
|
|
|
3165
3174
|
}
|
|
3166
3175
|
let response = await this.featureFlagsPoller?.getFeatureFlag(key, distinctId, groups, personProperties, groupProperties);
|
|
3167
3176
|
const flagWasLocallyEvaluated = response !== undefined;
|
|
3177
|
+
let requestId = undefined;
|
|
3168
3178
|
if (!flagWasLocallyEvaluated && !onlyEvaluateLocally) {
|
|
3169
|
-
|
|
3179
|
+
const remoteResponse = await super.getFeatureFlagStateless(key, distinctId, groups, personProperties, groupProperties, disableGeoip);
|
|
3180
|
+
response = remoteResponse.response;
|
|
3181
|
+
requestId = remoteResponse.requestId;
|
|
3170
3182
|
}
|
|
3171
3183
|
const featureFlagReportedKey = `${key}_${response}`;
|
|
3172
3184
|
if (sendFeatureFlagEvents && (!(distinctId in this.distinctIdHasSentFlagCalls) || !this.distinctIdHasSentFlagCalls[distinctId].includes(featureFlagReportedKey))) {
|
|
@@ -3185,7 +3197,8 @@ class PostHog extends PostHogCoreStateless {
|
|
|
3185
3197
|
$feature_flag: key,
|
|
3186
3198
|
$feature_flag_response: response,
|
|
3187
3199
|
locally_evaluated: flagWasLocallyEvaluated,
|
|
3188
|
-
[`$feature/${key}`]: response
|
|
3200
|
+
[`$feature/${key}`]: response,
|
|
3201
|
+
$feature_flag_request_id: requestId
|
|
3189
3202
|
},
|
|
3190
3203
|
groups,
|
|
3191
3204
|
disableGeoip
|
|
@@ -3384,18 +3397,26 @@ function createEventProcessor(_posthog, {
|
|
|
3384
3397
|
const personUrl = new URL(`/project/${_posthog.apiKey}/person/${userId}`, uiHost).toString();
|
|
3385
3398
|
event.tags['PostHog Person URL'] = personUrl;
|
|
3386
3399
|
const exceptions = event.exception?.values || [];
|
|
3387
|
-
exceptions.map(exception => {
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3400
|
+
const exceptionList = exceptions.map(exception => ({
|
|
3401
|
+
...exception,
|
|
3402
|
+
stacktrace: exception.stacktrace ? {
|
|
3403
|
+
...exception.stacktrace,
|
|
3404
|
+
type: 'raw',
|
|
3405
|
+
frames: (exception.stacktrace.frames || []).map(frame => {
|
|
3406
|
+
return {
|
|
3407
|
+
...frame,
|
|
3408
|
+
platform: 'node:javascript'
|
|
3409
|
+
};
|
|
3410
|
+
})
|
|
3411
|
+
} : undefined
|
|
3412
|
+
}));
|
|
3392
3413
|
const properties = {
|
|
3393
3414
|
// PostHog Exception Properties,
|
|
3394
3415
|
$exception_message: exceptions[0]?.value || event.message,
|
|
3395
3416
|
$exception_type: exceptions[0]?.type,
|
|
3396
3417
|
$exception_personURL: personUrl,
|
|
3397
3418
|
$exception_level: event.level,
|
|
3398
|
-
$exception_list:
|
|
3419
|
+
$exception_list: exceptionList,
|
|
3399
3420
|
// Sentry Exception Properties
|
|
3400
3421
|
$sentry_event_id: event.event_id,
|
|
3401
3422
|
$sentry_exception: event.exception,
|