posthog-node 4.0.0-beta.3 → 4.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 +25 -0
- package/lib/index.cjs.js +6 -1
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +5 -0
- package/lib/index.esm.js +6 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/index.d.ts +1 -0
- package/lib/posthog-core/src/types.d.ts +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
# 4.0.0 - 2024-03-18
|
|
2
|
+
|
|
3
|
+
## Added
|
|
4
|
+
|
|
5
|
+
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
|
|
6
|
+
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.
|
|
7
|
+
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.
|
|
8
|
+
4. Flushes will now try to flush up to `maxBatchSize` (default 100) in one go
|
|
9
|
+
5. Queued events are limited up to `maxQueueSize` (default 1000) and the oldest events are dropped when the limit is reached
|
|
10
|
+
6. Sets `User-Agent` headers with SDK name and version for RN
|
|
11
|
+
|
|
12
|
+
## Removed
|
|
13
|
+
|
|
14
|
+
1. `flushAsync` and `shutdownAsync` are removed with `flush` and `shutdown` now being the async methods.
|
|
15
|
+
|
|
16
|
+
## Changed
|
|
17
|
+
|
|
18
|
+
1. `flush` and `shutdown` now being async methods.
|
|
19
|
+
|
|
20
|
+
## Fixed
|
|
21
|
+
|
|
22
|
+
1. Fixed an issue where `shutdown` would potentially exit early if a flush was already in progress
|
|
23
|
+
2. Fixes some typos in types
|
|
24
|
+
|
|
25
|
+
|
|
1
26
|
# 4.0.0-beta.3 - 2024-03-13
|
|
2
27
|
|
|
3
28
|
1. Sets `User-Agent` headers with SDK name and version for RN
|
package/lib/index.cjs.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var rusha = require('rusha');
|
|
6
6
|
|
|
7
|
-
var version = "4.0.0
|
|
7
|
+
var version = "4.0.0";
|
|
8
8
|
|
|
9
9
|
var PostHogPersistedProperty;
|
|
10
10
|
(function (PostHogPersistedProperty) {
|
|
@@ -963,6 +963,7 @@ class PostHogCoreStateless {
|
|
|
963
963
|
this.host = removeTrailingSlash(options?.host || 'https://app.posthog.com');
|
|
964
964
|
this.flushAt = options?.flushAt ? Math.max(options?.flushAt, 1) : 20;
|
|
965
965
|
this.maxBatchSize = Math.max(this.flushAt, options?.maxBatchSize ?? 100);
|
|
966
|
+
this.maxQueueSize = Math.max(this.flushAt, options?.maxQueueSize ?? 1000);
|
|
966
967
|
this.flushInterval = options?.flushInterval ?? 10000;
|
|
967
968
|
this.captureMode = options?.captureMode || 'form';
|
|
968
969
|
// If enable is explicitly set to false we override the optout
|
|
@@ -1221,6 +1222,10 @@ class PostHogCoreStateless {
|
|
|
1221
1222
|
delete message.distinctId;
|
|
1222
1223
|
}
|
|
1223
1224
|
const queue = this.getPersistedProperty(PostHogPersistedProperty.Queue) || [];
|
|
1225
|
+
if (queue.length >= this.maxQueueSize) {
|
|
1226
|
+
queue.shift();
|
|
1227
|
+
console.info('Queue is full, the oldest event is dropped.');
|
|
1228
|
+
}
|
|
1224
1229
|
queue.push({ message });
|
|
1225
1230
|
this.setPersistedProperty(PostHogPersistedProperty.Queue, queue);
|
|
1226
1231
|
this._events.emit(type, message);
|