posthog-node 3.5.0 → 3.6.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
@@ -45,7 +45,10 @@ declare type PostHogFetchOptions = {
45
45
  body?: string;
46
46
  signal?: AbortSignal;
47
47
  };
48
- declare type PosthogCaptureOptions = {
48
+ declare type PostHogCaptureOptions = {
49
+ /** If provided overrides the auto-generated event ID */
50
+ uuid?: string;
51
+ /** If provided overrides the auto-generated timestamp */
49
52
  timestamp?: Date;
50
53
  disableGeoip?: boolean;
51
54
  };
@@ -132,17 +135,17 @@ declare abstract class PostHogCoreStateless {
132
135
  /***
133
136
  *** TRACKING
134
137
  ***/
135
- protected identifyStateless(distinctId: string, properties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
138
+ protected identifyStateless(distinctId: string, properties?: PostHogEventProperties, options?: PostHogCaptureOptions): this;
136
139
  protected captureStateless(distinctId: string, event: string, properties?: {
137
140
  [key: string]: any;
138
- }, options?: PosthogCaptureOptions): this;
141
+ }, options?: PostHogCaptureOptions): this;
139
142
  protected aliasStateless(alias: string, distinctId: string, properties?: {
140
143
  [key: string]: any;
141
- }, options?: PosthogCaptureOptions): this;
144
+ }, options?: PostHogCaptureOptions): this;
142
145
  /***
143
146
  *** GROUPS
144
147
  ***/
145
- protected groupIdentifyStateless(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PosthogCaptureOptions, distinctId?: string, eventProperties?: PostHogEventProperties): this;
148
+ protected groupIdentifyStateless(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PostHogCaptureOptions, distinctId?: string, eventProperties?: PostHogEventProperties): this;
146
149
  /***
147
150
  *** FEATURE FLAGS
148
151
  ***/
@@ -159,7 +162,7 @@ declare abstract class PostHogCoreStateless {
159
162
  /***
160
163
  *** QUEUEING AND FLUSHING
161
164
  ***/
162
- protected enqueue(type: string, _message: any, options?: PosthogCaptureOptions): void;
165
+ protected enqueue(type: string, _message: any, options?: PostHogCaptureOptions): void;
163
166
  flushAsync(): Promise<any>;
164
167
  flush(callback?: (err?: any, data?: any) => void): void;
165
168
  private fetchWithRetry;
@@ -167,16 +170,17 @@ declare abstract class PostHogCoreStateless {
167
170
  shutdown(): void;
168
171
  }
169
172
 
170
- interface IdentifyMessageV1 {
173
+ interface IdentifyMessage {
171
174
  distinctId: string;
172
175
  properties?: Record<string | number, any>;
173
176
  disableGeoip?: boolean;
174
177
  }
175
- interface EventMessageV1 extends IdentifyMessageV1 {
178
+ interface EventMessage extends IdentifyMessage {
176
179
  event: string;
177
180
  groups?: Record<string, string | number>;
178
181
  sendFeatureFlags?: boolean;
179
182
  timestamp?: Date;
183
+ uuid?: string;
180
184
  }
181
185
  interface GroupIdentifyMessage {
182
186
  groupType: string;
@@ -197,7 +201,7 @@ declare type PostHogNodeV1 = {
197
201
  * @param groups OPTIONAL | object of what groups are related to this event, example: { company: 'id:5' }. Can be used to analyze companies instead of users.
198
202
  * @param sendFeatureFlags OPTIONAL | Used with experiments. Determines whether to send feature flag values with the event.
199
203
  */
200
- capture({ distinctId, event, properties, groups, sendFeatureFlags }: EventMessageV1): void;
204
+ capture({ distinctId, event, properties, groups, sendFeatureFlags }: EventMessage): void;
201
205
  /**
202
206
  * @description Identify lets you add metadata on your users so you can more easily identify who they are in PostHog,
203
207
  * and even do things like segment users by these properties.
@@ -205,7 +209,7 @@ declare type PostHogNodeV1 = {
205
209
  * @param distinctId which uniquely identifies your user
206
210
  * @param properties with a dict with any key: value pairs
207
211
  */
208
- identify({ distinctId, properties }: IdentifyMessageV1): void;
212
+ identify({ distinctId, properties }: IdentifyMessage): void;
209
213
  /**
210
214
  * @description To marry up whatever a user does before they sign up or log in with what they do after you need to make an alias call.
211
215
  * This will allow you to answer questions like "Which marketing channels leads to users churning after a month?"
@@ -329,8 +333,8 @@ declare class PostHog extends PostHogCoreStateless implements PostHogNodeV1 {
329
333
  enable(): void;
330
334
  disable(): void;
331
335
  debug(enabled?: boolean): void;
332
- capture({ distinctId, event, properties, groups, sendFeatureFlags, timestamp, disableGeoip }: EventMessageV1): void;
333
- identify({ distinctId, properties, disableGeoip }: IdentifyMessageV1): void;
336
+ capture({ distinctId, event, properties, groups, sendFeatureFlags, timestamp, disableGeoip, uuid, }: EventMessage): void;
337
+ identify({ distinctId, properties, disableGeoip }: IdentifyMessage): void;
334
338
  alias(data: {
335
339
  distinctId: string;
336
340
  alias: string;
package/lib/index.esm.js CHANGED
@@ -154,7 +154,7 @@ function __spreadArray(to, from, pack) {
154
154
  return to.concat(ar || Array.prototype.slice.call(from));
155
155
  }
156
156
 
157
- var version = "3.5.0";
157
+ var version = "3.6.0";
158
158
 
159
159
  var PostHogPersistedProperty;
160
160
  (function (PostHogPersistedProperty) {
@@ -1012,7 +1012,7 @@ var PostHogCoreStateless = /** @class */ (function () {
1012
1012
  this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
1013
1013
  return;
1014
1014
  }
1015
- var message = __assign(__assign({}, _message), { type: type, library: this.getLibraryId(), library_version: this.getLibraryVersion(), timestamp: (options === null || options === void 0 ? void 0 : options.timestamp) ? options === null || options === void 0 ? void 0 : options.timestamp : currentISOTime() });
1015
+ var message = __assign(__assign({}, _message), { type: type, library: this.getLibraryId(), library_version: this.getLibraryVersion(), timestamp: (options === null || options === void 0 ? void 0 : options.timestamp) ? options === null || options === void 0 ? void 0 : options.timestamp : currentISOTime(), uuid: (options === null || options === void 0 ? void 0 : options.uuid) ? options.uuid : generateUUID(globalThis) });
1016
1016
  var addGeoipDisableProperty = (_a = options === null || options === void 0 ? void 0 : options.disableGeoip) !== null && _a !== void 0 ? _a : this.disableGeoip;
1017
1017
  if (addGeoipDisableProperty) {
1018
1018
  if (!message.properties) {
@@ -2746,12 +2746,14 @@ function (_super) {
2746
2746
  groups = _a.groups,
2747
2747
  sendFeatureFlags = _a.sendFeatureFlags,
2748
2748
  timestamp = _a.timestamp,
2749
- disableGeoip = _a.disableGeoip;
2749
+ disableGeoip = _a.disableGeoip,
2750
+ uuid = _a.uuid;
2750
2751
 
2751
2752
  var _capture = function (props) {
2752
2753
  _super.prototype.captureStateless.call(_this, distinctId, event, props, {
2753
2754
  timestamp: timestamp,
2754
- disableGeoip: disableGeoip
2755
+ disableGeoip: disableGeoip,
2756
+ uuid: uuid
2755
2757
  });
2756
2758
  }; // :TRICKY: If we flush, or need to shut down, to not lose events we want this promise to resolve before we flush
2757
2759