posthog-node 4.5.0 → 4.5.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 +12 -0
- package/lib/index.cjs.js +13 -11
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.esm.js +13 -11
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-node/src/error-tracking.d.ts +1 -1
- package/lib/posthog-node/src/posthog-node.d.ts +1 -1
- package/lib/posthog-node/src/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/error-tracking.ts +5 -4
- package/src/extensions/express.ts +1 -1
- package/src/posthog-node.ts +8 -3
- package/src/types.ts +1 -0
- package/test/feature-flags.spec.ts +81 -40
- package/test/posthog-node.spec.ts +3 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Next
|
|
2
2
|
|
|
3
|
+
# 4.5.2 - 2025-02-12
|
|
4
|
+
|
|
5
|
+
## Fixed
|
|
6
|
+
|
|
7
|
+
1. fix: Fixed edge case where `$feature_flag_called` events were enriched with additional feature flag data when they shouldn't be.
|
|
8
|
+
|
|
9
|
+
# 4.5.1 - 2025-02-12
|
|
10
|
+
|
|
11
|
+
## Fixed
|
|
12
|
+
|
|
13
|
+
1. Do not require a `distinctId` as an argument to `captureException`
|
|
14
|
+
|
|
3
15
|
# 4.5.0 - 2025-02-06
|
|
4
16
|
|
|
5
17
|
## Added
|
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.5.
|
|
10
|
+
var version = "4.5.2";
|
|
11
11
|
|
|
12
12
|
var PostHogPersistedProperty;
|
|
13
13
|
(function (PostHogPersistedProperty) {
|
|
@@ -2878,10 +2878,12 @@ function getLastStackFrame(arr) {
|
|
|
2878
2878
|
|
|
2879
2879
|
const SHUTDOWN_TIMEOUT = 2000;
|
|
2880
2880
|
class ErrorTracking {
|
|
2881
|
-
static async captureException(client, error,
|
|
2881
|
+
static async captureException(client, error, hint, distinctId, additionalProperties) {
|
|
2882
2882
|
const properties = {
|
|
2883
2883
|
...additionalProperties
|
|
2884
2884
|
};
|
|
2885
|
+
// Given stateless nature of Node SDK we capture exceptions using personless processing when no
|
|
2886
|
+
// user can be determined because a distinct_id is not provided e.g. exception autocapture
|
|
2885
2887
|
if (!distinctId) {
|
|
2886
2888
|
properties.$process_person_profile = false;
|
|
2887
2889
|
}
|
|
@@ -2907,11 +2909,7 @@ class ErrorTracking {
|
|
|
2907
2909
|
}
|
|
2908
2910
|
}
|
|
2909
2911
|
onException(exception, hint) {
|
|
2910
|
-
|
|
2911
|
-
// when no user can be determined e.g. in the case of exception autocapture
|
|
2912
|
-
ErrorTracking.captureException(this.client, exception, uuidv7(), hint, {
|
|
2913
|
-
$process_person_profile: false
|
|
2914
|
-
});
|
|
2912
|
+
ErrorTracking.captureException(this.client, exception, hint);
|
|
2915
2913
|
}
|
|
2916
2914
|
async onFatalError() {
|
|
2917
2915
|
await this.client.shutdown(SHUTDOWN_TIMEOUT);
|
|
@@ -3002,8 +3000,12 @@ class PostHog extends PostHogCoreStateless {
|
|
|
3002
3000
|
// return await super.getFeatureFlagsStateless(distinctId, groups, undefined, undefined, disableGeoip)
|
|
3003
3001
|
return await _getFlags(distinctId, groups, disableGeoip);
|
|
3004
3002
|
}
|
|
3003
|
+
if (event === '$feature_flag_called') {
|
|
3004
|
+
// If we're capturing a $feature_flag_called event, we don't want to enrich the event with cached flags that may be out of date.
|
|
3005
|
+
return {};
|
|
3006
|
+
}
|
|
3005
3007
|
if ((this.featureFlagsPoller?.featureFlags?.length || 0) > 0) {
|
|
3006
|
-
// Otherwise we may as well check for the flags locally and include them if
|
|
3008
|
+
// Otherwise we may as well check for the flags locally and include them if they are already loaded
|
|
3007
3009
|
const groupsWithStringValues = {};
|
|
3008
3010
|
for (const [key, value] of Object.entries(groups || {})) {
|
|
3009
3011
|
groupsWithStringValues[key] = String(value);
|
|
@@ -3249,9 +3251,9 @@ class PostHog extends PostHogCoreStateless {
|
|
|
3249
3251
|
}
|
|
3250
3252
|
captureException(error, distinctId, additionalProperties) {
|
|
3251
3253
|
const syntheticException = new Error('PostHog syntheticException');
|
|
3252
|
-
ErrorTracking.captureException(this, error,
|
|
3254
|
+
ErrorTracking.captureException(this, error, {
|
|
3253
3255
|
syntheticException
|
|
3254
|
-
}, additionalProperties);
|
|
3256
|
+
}, distinctId, additionalProperties);
|
|
3255
3257
|
}
|
|
3256
3258
|
}
|
|
3257
3259
|
|
|
@@ -3372,7 +3374,7 @@ function setupExpressErrorHandler(_posthog, app) {
|
|
|
3372
3374
|
};
|
|
3373
3375
|
// Given stateless nature of Node SDK we capture exceptions using personless processing
|
|
3374
3376
|
// when no user can be determined e.g. in the case of exception autocapture
|
|
3375
|
-
ErrorTracking.captureException(_posthog, error, uuidv7(),
|
|
3377
|
+
ErrorTracking.captureException(_posthog, error, hint, uuidv7(), {
|
|
3376
3378
|
$process_person_profile: false
|
|
3377
3379
|
});
|
|
3378
3380
|
next(error);
|