posthog-node 5.6.0 → 5.8.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 DELETED
@@ -1,485 +0,0 @@
1
- # Next
2
-
3
- # 5.6.0 – 2025-07-15
4
-
5
- 1. Added support for filtering feature flags with flagKeys parameter in sendFeatureFlags options
6
-
7
- # 5.5.1 – 2025-07-15
8
-
9
- 1. wrap `InconclusiveMatchError`s in `logMsgIfDebug` for local flag evaluations on `sendFeatureFlags`
10
-
11
- # 5.5.0 – 2025-07-10
12
-
13
- 1. feat: make the `sendFeatureFlags` parameter more declarative and ergonomic. Implementation notes below:
14
-
15
- Modified `sendFeatureFlags` to be type `boolean | SendFeatureFlagsOptions`, (which is defined thusly)
16
-
17
- ```ts
18
- export interface SendFeatureFlagsOptions {
19
- onlyEvaluateLocally?: boolean
20
- personProperties?: Record<string, any>
21
- groupProperties?: Record<string, Record<string, any>>
22
- }
23
- ```
24
-
25
- This lets users declare (1) whether to use local evaluation, and (2) which properties to supply explicitly for that evaluation, every time they want to send feature flags. It also supports the old boolean behavior if folks don't care and would rather the SDK infer it.
26
-
27
- Now, you can make calls like this
28
-
29
- ```ts
30
- posthog.captureImmediate({
31
- distinctId: "user123",
32
- event: "test event",
33
- sendFeatureFlags: {
34
- onlyEvaluateLocally: true,
35
- personProperties: {
36
- plan: "premium",
37
- },
38
- },
39
- properties: {
40
- foo: "bar",
41
- },
42
- });
43
- ```
44
-
45
- or simply
46
-
47
- ```
48
- posthog.captureImmediate({
49
- distinctId: "user123",
50
- event: "test event",
51
- sendFeatureFlags: true // this will still infer local evaluation if it appears to be configured, but it won't try to pull properties from the event message
52
- properties: {
53
- foo: "bar",
54
- },
55
- });
56
- ```
57
-
58
- # 5.4.0 – 2025-07-09
59
-
60
- feat: respect local evaluation preferences with `sendFeatureFlags`; add property overrides from the event to those local computations so that the locally evaluated flags can be more accuratee. NB: this change chagnes the default behavior of `capture` and `captureImmediately` – we will now only send feature flag data along with those events if `sendFeatureFlags` is explicitly specified, instead of optimistically sending along locally evaluated flags by default.
61
-
62
- # 5.3.1 - 2025-07-07
63
-
64
- 1. feat: decouple feature flag local evaluation from personal API keys; support decrypting remote config payloads without relying on the feature flags poller
65
-
66
- # 5.2.1 - 2025-07-07
67
-
68
- 1. feat: add captureExceptionImmediate method on posthog client
69
-
70
- # 5.1.1 - 2025-06-16
71
-
72
- 1. fix: Handle double-encoded JSON payloads from the remote config endpoint
73
-
74
- # 5.1.0 - 2025-06-12
75
-
76
- 1. chore: use `/flags?v=2&config=true` instead of `/decide?v=4` for the flag evaluation backend
77
-
78
- # 5.0.0 - 2025-06-10
79
-
80
- ## Removed
81
-
82
- 1. Remove `is_simple_flag` from `PostHogFeatureFlag` type
83
- 2. Remove `captureMode` in favor of `json` capture mode only
84
- 3. Remove deprecated `personProperties` and `groupProperties` in favor of `setPersonPropertiesForFlags` and `setGroupPropertiesForFlags`
85
-
86
- ## Breaking changes
87
-
88
- 1. feat: migrate to native fetch, Node 20+ required
89
- 2. PostHog Node now compresses messages with GZip before sending them to our servers when the runtime supports compression. This reduces network bandwidth and improves performance. Network traffic interceptors and test assertions on payloads must handle GZip decompression to inspect the data. Alternatively, you can disable compression by setting `disableCompression: true` in the client configuration during tests.
90
-
91
- # 5.0.0-alpha.1 - 2025-04-29
92
-
93
- ## Breaking changes
94
-
95
- 1. feat: migrate to native fetch, Node 18+ required
96
-
97
- ## Added
98
-
99
- 1. rotate session id if expired after 24 hours
100
-
101
- # 4.17.2 - 2025-05-22
102
-
103
- 1. chore: improve event prop types
104
- 2. fix: no throw in sendImmediate
105
-
106
- # 4.17.1 - 2025-05-02
107
-
108
- 1. fix: fix imports for old node.js version
109
-
110
- # 4.17.0 - 2025-05-02
111
-
112
- 1. fix: specific exports for edge environments
113
-
114
- # 4.16.0 - 2025-05-01
115
-
116
- 1. chore: improve flush event
117
-
118
- # 4.15.0 - 2025-04-30
119
-
120
- 1. chore: add immediate-mode
121
- 2. chore: better error logging when flushing events
122
-
123
- # 4.14.0 - 2025-04-24
124
-
125
- 1. feat: Add super properties as a concept to the Node SDK
126
-
127
- # 4.13.0 - 2025-04-21
128
-
129
- 1. feat: Add method to wait for local evaluation feature flag definitions to be loaded
130
-
131
- # 4.12.0 – 2025-04-17
132
-
133
- 1. chore: roll out new feature flag evaluation backend to majority of customers
134
-
135
- # 4.11.7 - 2025-04-16
136
-
137
- 1. fix: do not reference `node:` prefix as it is not supported by Next.js edge runtime
138
-
139
- # 4.11.6 - 2025-04-15
140
-
141
- ## Fixed
142
-
143
- 1. move survey export top-level declarations
144
-
145
- # 4.11.5 - 2025-04-14
146
-
147
- ## Fixed
148
-
149
- 1. export and declare top-level declarations for surveys
150
-
151
- # 4.11.4 - 2025-04-14
152
-
153
- ## Fixed
154
-
155
- 1. export top-level declarations for surveys
156
-
157
- # 4.11.3 - 2025-04-08
158
-
159
- ## Fixed
160
-
161
- 1. do not access `fs` or `readline` in when not available e.g. edge environments
162
-
163
- # 4.11.2 - 2025-04-07
164
-
165
- ## Fixed
166
-
167
- 1. chore: bump axios to 1.8.2 (fixes [CVE-2025-27152](https://github.com/advisories/GHSA-jr5f-v2jv-69x6))
168
-
169
- # 4.11.1 - 2025-03-28
170
-
171
- ## Fixed
172
-
173
- 1. `getFeatureFlag`, `isFeatureEnabled`, and `getAllFlagsAndPayloads` now return `undefined` if the flag is not found.
174
-
175
- # 4.11.0 - 2025-03-28
176
-
177
- ## Added
178
-
179
- 1. `$feature_flag_called` event now includes additional properties such as `feature_flag_id`, `feature_flag_version`, `feature_flag_reason`, and `feature_flag_request_id`.
180
-
181
- ## Fixed
182
-
183
- 1. apiKey cannot be empty.
184
-
185
- # 4.10.2 - 2025-03-06
186
-
187
- 1. Add: log error message when feature flags have computation errors.
188
-
189
- # 4.10.1 – 2025-03-06
190
-
191
- 1. Fix: only set `platform` on PostHog exception frame properties
192
- 1. Fix: prevent fetch floods when rate-limited.
193
-
194
- # 4.10.0 – 2025-03-06
195
-
196
- 1. Attach requestId to $feature_flag_called if present in /decide response
197
-
198
- # 4.9.0 – 2025-03-04
199
-
200
- 1. Allow feature flags to be evaluated individually when local evaluation is not being used
201
-
202
- # 4.8.1 – 2025-02-26
203
-
204
- 1. Supports gracefully handling quotaLimited responses from the PostHog API for feature flag evaluation
205
-
206
- # 4.8.0 - 2025-02-26
207
-
208
- 1. Add guardrails and exponential error backoff in the feature flag local evaluation poller to prevent high rates of 401/403 traffic towards `/local_evaluation`
209
-
210
- # 4.7.0 - 2025-02-20
211
-
212
- ## Added
213
-
214
- 1. Adds the ability to capture user feedback in LLM Observability using the `captureTraceFeedback` and `captureTraceMetric` methods.
215
-
216
- # 4.6.0 - 2025-02-12
217
-
218
- ## Added
219
-
220
- 1. Adds ability to fetch decrypted remote config flag payloads via `getRemoteConfigPayload`
221
-
222
- # 4.5.2 - 2025-02-12
223
-
224
- ## Fixed
225
-
226
- 1. fix: Fixed edge case where `$feature_flag_called` events were enriched with additional feature flag data when they shouldn't be.
227
-
228
- # 4.5.1 - 2025-02-12
229
-
230
- ## Fixed
231
-
232
- 1. Do not require a `distinctId` as an argument to `captureException`
233
-
234
- # 4.5.0 - 2025-02-06
235
-
236
- ## Added
237
-
238
- 1. Adds manual exception capture with full stack trace processing via `captureException` function
239
- 2. Adds ability to enable exception autocapture via the `enableExceptionAutocapture` init option
240
-
241
- # 4.4.1 - 2025-01-21
242
-
243
- - Add option privacyMode to remove input and output from LLM Observability
244
-
245
- # 4.4.0 - 2025-01-15
246
-
247
- Switch from rusha to native (node:crypto) sha1 implementation
248
-
249
- # 4.3.2 - 2024-12-11
250
-
251
- 1. REVERT: Fix bug where this SDK incorrectly sent `$feature_flag_called` events with null values when using `getFeatureFlagPayload`.
252
-
253
- # 4.3.1 - 2024-11-26
254
-
255
- 1. Fix bug where this SDK incorrectly sent `$feature_flag_called` events with null values when using `getFeatureFlagPayload`.
256
-
257
- # 4.3.0 - 2024-11-25
258
-
259
- 1. Add Sentry v8 support to the Sentry integration
260
-
261
- # 4.2.3 - 2024-11-21
262
-
263
- 1. fix: identify method allows passing a $set_once object
264
-
265
- # 4.2.2 - 2024-11-18
266
-
267
- 1. fix: Shutdown will now respect the timeout and forcefully return rather than returning after the next fetch.
268
-
269
- # 4.2.1 - 2024-10-14
270
-
271
- 1. fix: only log messages if debug is enabled
272
-
273
- # 4.2.0 - 2024-08-26
274
-
275
- 1. Added `historicalMigration` option for use in tools that are migrating large data to PostHog
276
-
277
- # 4.1.1 - 2024-08-20
278
-
279
- 1. Local evaluation returns correct results on `undefined/null` values
280
-
281
- # 4.1.0 - 2024-08-14
282
-
283
- 1. chore: change host to new address.
284
- 2. chore: bump axios to 1.7.4 (fixes [CVE-2024-39338](https://github.com/advisories/GHSA-8hc4-vh64-cxmj))
285
-
286
- # 4.0.1 - 2024-04-25
287
-
288
- 1. Prevent double JSON parsing of feature flag payloads, which would convert the payload [1] into 1.
289
-
290
- # 4.0.0 - 2024-03-18
291
-
292
- ## Added
293
-
294
- 1. Adds a `disabled` option and the ability to change it later via `posthog.disabled = true`. Useful for disabling PostHog tracking for example in a testing environment without having complex conditional checking
295
- 2. Adds a new `featureFlagsRequestTimeoutMs` timeout parameter for feature flags which defaults to 3 seconds, updated from the default 10s for all other API calls.
296
- 3. `shutdown` takes a `shutdownTimeoutMs` param with a default of 30000 (30s). This is the time to wait for flushing events before shutting down the client. If the timeout is reached, the client will be shut down regardless of pending events.
297
- 4. Flushes will now try to flush up to `maxBatchSize` (default 100) in one go
298
- 5. Queued events are limited up to `maxQueueSize` (default 1000) and the oldest events are dropped when the limit is reached
299
- 6. Sets `User-Agent` headers with SDK name and version for RN
300
-
301
- ## Removed
302
-
303
- 1. `flushAsync` and `shutdownAsync` are removed with `flush` and `shutdown` now being the async methods.
304
-
305
- ## Changed
306
-
307
- 1. `flush` and `shutdown` now being async methods.
308
-
309
- ## Fixed
310
-
311
- 1. Fixed an issue where `shutdown` would potentially exit early if a flush was already in progress
312
- 2. Fixes some typos in types
313
-
314
- # 4.0.0-beta.3 - 2024-03-13
315
-
316
- 1. Sets `User-Agent` headers with SDK name and version for RN
317
-
318
- # 4.0.0-beta.2 - 2024-03-12
319
-
320
- 1. `flushAsync` and `shutdownAsync` are removed with `flush` and `shutdown` now being the async methods.
321
- 2. Fixed an issue where `shutdown` would potentially exit early if a flush was already in progress
322
- 3. Flushes will now try to flush up to `maxBatchSize` (default 100) in one go
323
-
324
- # 4.0.0-beta.1 - 2024-03-04
325
-
326
- 1. Adds a `disabled` option and the ability to change it later via `posthog.disabled = true`. Useful for disabling PostHog tracking for example in a testing environment without having complex conditional checking
327
- 2. Fixes some typos in types
328
- 3. `shutdown` and `shutdownAsync` takes a `shutdownTimeoutMs` param with a default of 30000 (30s). This is the time to wait for flushing events before shutting down the client. If the timeout is reached, the client will be shut down regardless of pending events.
329
- 4. Adds a new `featureFlagsRequestTimeoutMs` timeout parameter for feature flags which defaults to 3 seconds, updated from the default 10s for all other API calls.
330
-
331
- # 3.6.3 - 2024-02-15
332
-
333
- 1. fix: using `captureMode=form` won't throw an error and retry unnecessarily
334
-
335
- # 3.6.2 - 2024-02-06
336
-
337
- 1. Swapped to `uuidv7` for unique ID generation
338
-
339
- # 3.6.1 - 2024-01-26
340
-
341
- 1. Remove new relative date operators, combine into regular date operators
342
-
343
- # 3.6.0 - 2024-01-18
344
-
345
- 1. Adds support for overriding the event `uuid`
346
-
347
- # 3.5.0 - 2024-01-09
348
-
349
- 1. When local evaluation is enabled, we automatically add flag information to all events sent to PostHog, whenever possible. This makes it easier to use these events in experiments.
350
- 2. Fixes a bug where in some rare cases we may drop events when send_feature_flags is enabled on capture.
351
-
352
- # 3.4.0 - 2024-01-09
353
-
354
- 1. Numeric property handling for feature flags now does the expected: When passed in a number, we do a numeric comparison. When passed in a string, we do a string comparison. Previously, we always did a string comparison.
355
- 2. Add support for relative date operators for local evaluation.
356
-
357
- # 3.3.0 - 2024-01-02
358
-
359
- 1. Adds PostHogSentryIntegration to allow automatic capturing of exceptions reported via the @sentry/node package
360
-
361
- # 3.2.1 - 2023-12-15
362
-
363
- 1. Fixes issue where a background refresh of feature flags could throw an unhandled error. It now emits to be detected by `.on('error', ...)`
364
-
365
- # 3.2.0 - 2023-12-05
366
-
367
- 1. Fixes issues with Axios imports for non-node environments like Cloudflare workers
368
- 2. Uses the globally defined `fetch` if available, otherwise imports and uses axios as a polyfill
369
-
370
- # 3.1.3 - 2023-10-27
371
-
372
- 1. Updates axios dependency
373
-
374
- # 3.1.2 - 2023-08-17
375
-
376
- 1. Returns the current flag property with $feature_flag_called events, to make it easier to use in experiments
377
-
378
- # 3.1.1 - 2023-04-26
379
-
380
- 1. Replace crypto library with pure-js rusha library which makes posthog-node work with Cloudflare Workers in Next.js edge runtime.
381
-
382
- # 3.1.0 - 2023-04-19
383
-
384
- 1. Some small fixes to incorrect types
385
- 2. Fixed fetch compatibility by aligning error handling
386
- 3. Added two errors: PostHogFetchHttpError (non-2xx status) and PostHogFetchNetworkError (fetch network error)
387
- 4. Added .on('error', (err) => void)
388
- 5. shutdownAsync now ignores fetch errors. They should be handled with .on('error', ...) from now on.
389
-
390
- # 3.0.0 - 2023-04-14
391
-
392
- Breaking change:
393
-
394
- All events by default now send the `$geoip_disable` property to disable geoip lookup in app. This is because usually we don't
395
- want to update person properties to take the server's location.
396
-
397
- 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.
398
-
399
- To restore previous behaviour, you can set the default to False like so:
400
-
401
- ```javascript
402
- const posthog = new PostHog(PH_API_KEY, {
403
- host: PH_HOST,
404
- disableGeoip: false,
405
- })
406
- ```
407
-
408
- # 2.6.0 - 2023-03-14
409
-
410
- 1. Add support for all cohorts local evaluation in feature flags.
411
-
412
- # 2.5.4 - 2023-02-27
413
-
414
- 1. Fix error log for local evaluation of feature flags (InconclusiveMatchError(s)) to only show during debug mode.
415
-
416
- # 2.5.3 - 2023-02-21
417
-
418
- 1. Allow passing in a distinctId to `groupIdentify()`.
419
- 2. Fix a bug with active feature flags on capture events, where non-active flags would be added to the list as well.
420
-
421
- # 2.5.2 - 2023-02-17
422
-
423
- 1. Fix issue where properties passed to `.identify` were not set correctly
424
-
425
- # 2.5.1 - 2023-02-16
426
-
427
- 1. Make sure shutdown waits for pending promises to resolve. Fixes a problem with using PostHog Node in serverless environments.
428
-
429
- # 2.5.0 - 2023-02-15
430
-
431
- 1. Removes shared client from `posthog-node`, getting rid of some race condition bugs when capturing events.
432
- 2. Sets minimum version of node.js to 15
433
-
434
- # 2.4.0 - 2023-02-02
435
-
436
- 1. Adds support for overriding timestamp of capture events
437
-
438
- # 2.3.0 - 2023-1-26
439
-
440
- 1. uses v3 decide endpoint
441
- 2. JSON payloads will be returned with feature flags
442
- 3. Feature flags will gracefully fail and optimistically save evaluated flags if server is down
443
-
444
- # 2.2.3 - 2022-12-01
445
-
446
- 1. Fix issues with timeouts for local evaluation requests
447
-
448
- # 2.2.2 - 2022-11-28
449
-
450
- 1. Fix issues with timeout
451
-
452
- # 2.2.1 - 2022-11-24
453
-
454
- 1. Add standard 10 second timeout
455
-
456
- # 2.2.0 - 2022-11-18
457
-
458
- 1. Add support for variant overrides for feature flag local evaluation.
459
- 2. Add support for date operators in feature flag local evaluation.
460
-
461
- # 2.1.0 - 2022-09-08
462
-
463
- 1. Swaps `unidici` for `axios` in order to support older versions of Node
464
- 2. The `fetch` implementation can be overridden as an option for those who wish to use an alternative implementation
465
- 3. Fixes the minimum Node version to >=14.17.0
466
-
467
- # 2.0.2 - 2022-08-23
468
-
469
- 1. Removes references to `cli.js`
470
- 2. Removes default `PostHogGlobal` export, and unifies import signature for `typescript`, `commonjs` and `esm` builds.
471
-
472
- # 2.0.1 - 2022-08-15
473
-
474
- Breaking changes:
475
-
476
- 1. Feature flag defaults are no more. When we fail to compute any flag, we return `undefined`. All computed flags return either `true`, `false` or `String`.
477
- 2. Minimum PostHog version requirement is 1.38
478
- 3. Default polling interval for feature flags is now set at 30 seconds. If you don't want local evaluation, don't set a personal API key in the library.
479
- 4. The `callback` parameter passed as an optional last argument to most of the methods is no longer supported
480
- 5. The CLI is no longer supported
481
-
482
- What's new:
483
-
484
- 1. You can now evaluate feature flags locally (i.e. without sending a request to your PostHog servers) by setting a personal API key, and passing in groups and person properties to `isFeatureEnabled` and `getFeatureFlag` calls.
485
- 2. Introduces a `getAllFlags` method that returns all feature flags. This is useful for when you want to seed your frontend with some initial flags, given a user ID.
package/CONTRIBUTING.md DELETED
@@ -1,14 +0,0 @@
1
- # Contributing
2
-
3
- First install yalc:
4
-
5
- ```sh
6
- yarn global add yalc
7
- ```
8
-
9
- Then run:
10
-
11
- ```sh
12
- cd ../examples/example-node
13
- yarn && yarn start
14
- ```