posthog-node 4.1.1 → 4.2.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/lib/index.d.ts CHANGED
@@ -40,6 +40,8 @@ declare type PostHogCoreOptions = {
40
40
  /** Whether to post events to PostHog in JSON or compressed format. Defaults to 'form' */
41
41
  captureMode?: 'json' | 'form';
42
42
  disableGeoip?: boolean;
43
+ /** Special flag to indicate ingested data is for a historical migration. */
44
+ historicalMigration?: boolean;
43
45
  };
44
46
  declare enum PostHogPersistedProperty {
45
47
  AnonymousId = "anonymous_id",
@@ -137,6 +139,7 @@ declare abstract class PostHogCoreStateless {
137
139
  private captureMode;
138
140
  private removeDebugCallback?;
139
141
  private disableGeoip;
142
+ private historicalMigration;
140
143
  disabled: boolean;
141
144
  private defaultOptIn;
142
145
  private pendingPromises;
package/lib/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createHash } from 'rusha';
2
2
 
3
- var version = "4.1.1";
3
+ var version = "4.2.0";
4
4
 
5
5
  var PostHogPersistedProperty;
6
6
  (function (PostHogPersistedProperty) {
@@ -948,6 +948,7 @@ class PostHogCoreStateless {
948
948
  constructor(apiKey, options) {
949
949
  this.flushPromise = null;
950
950
  this.disableGeoip = true;
951
+ this.historicalMigration = false;
951
952
  this.disabled = false;
952
953
  this.defaultOptIn = true;
953
954
  this.pendingPromises = {};
@@ -973,6 +974,7 @@ class PostHogCoreStateless {
973
974
  this.featureFlagsRequestTimeoutMs = options?.featureFlagsRequestTimeoutMs ?? 3000; // 3 seconds
974
975
  this.disableGeoip = options?.disableGeoip ?? true;
975
976
  this.disabled = options?.disabled ?? false;
977
+ this.historicalMigration = options?.historicalMigration ?? false;
976
978
  // Init promise allows the derived class to block calls until it is ready
977
979
  this._initPromise = Promise.resolve();
978
980
  this._isInitialized = true;
@@ -1287,6 +1289,9 @@ class PostHogCoreStateless {
1287
1289
  batch: messages,
1288
1290
  sent_at: currentISOTime(),
1289
1291
  };
1292
+ if (this.historicalMigration) {
1293
+ data.historical_migration = true;
1294
+ }
1290
1295
  const payload = JSON.stringify(data);
1291
1296
  const url = this.captureMode === 'form'
1292
1297
  ? `${this.host}/e/?ip=1&_=${currentTimestamp()}&v=${this.getLibraryVersion()}`