posthog-js-lite 3.0.0-beta.1 → 3.0.0-beta.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.
@@ -7,7 +7,9 @@ export declare abstract class PostHogCoreStateless {
7
7
  private apiKey;
8
8
  host: string;
9
9
  private flushAt;
10
+ private maxBatchSize;
10
11
  private flushInterval;
12
+ private flushPromise;
11
13
  private requestTimeout;
12
14
  private featureFlagsRequestTimeoutMs;
13
15
  private captureMode;
@@ -37,7 +39,7 @@ export declare abstract class PostHogCoreStateless {
37
39
  debug(enabled?: boolean): void;
38
40
  get isDebug(): boolean;
39
41
  private buildPayload;
40
- protected addPendingPromise(promise: Promise<any>): void;
42
+ protected addPendingPromise<T>(promise: Promise<T>): Promise<T>;
41
43
  /***
42
44
  *** TRACKING
43
45
  ***/
@@ -69,11 +71,16 @@ export declare abstract class PostHogCoreStateless {
69
71
  *** QUEUEING AND FLUSHING
70
72
  ***/
71
73
  protected enqueue(type: string, _message: any, options?: PostHogCaptureOptions): void;
72
- flushAsync(): Promise<any>;
73
- flush(callback?: (err?: any, data?: any) => void): void;
74
+ private clearFlushTimer;
75
+ /**
76
+ * Helper for flushing the queue in the background
77
+ * Avoids unnecessary promise errors
78
+ */
79
+ private flushBackground;
80
+ flush(): Promise<any[]>;
81
+ private _flush;
74
82
  private fetchWithRetry;
75
- shutdownAsync(shutdownTimeoutMs?: number): Promise<void>;
76
- shutdown(shutdownTimeoutMs?: number): void;
83
+ shutdown(shutdownTimeoutMs?: number): Promise<void>;
77
84
  }
78
85
  export declare abstract class PostHogCore extends PostHogCoreStateless {
79
86
  private sendFeatureFlagEvent;
@@ -5,6 +5,8 @@ export declare type PostHogCoreOptions = {
5
5
  flushAt?: number;
6
6
  /** The interval in milliseconds between periodic flushes */
7
7
  flushInterval?: number;
8
+ /** The maximum number of queued messages to be flushed as part of a single batch (must be higher than `flushAt`) */
9
+ maxBatchSize?: number;
8
10
  /** If set to true the SDK is essentially disabled (useful for local environments where you don't want to track anything) */
9
11
  disabled?: boolean;
10
12
  /** If set to false the SDK will not track until the `optIn` function is called. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-js-lite",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-beta.2",
4
4
  "main": "lib/index.cjs.js",
5
5
  "module": "lib/index.esm.js",
6
6
  "types": "lib/index.d.ts",