posthog-js-lite 3.0.2 → 3.1.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.
@@ -4,9 +4,9 @@ export * as utils from './utils';
4
4
  import { LZString } from './lz-string';
5
5
  import { SimpleEventEmitter } from './eventemitter';
6
6
  export declare abstract class PostHogCoreStateless {
7
- private apiKey;
8
- host: string;
9
- private flushAt;
7
+ readonly apiKey: string;
8
+ readonly host: string;
9
+ readonly flushAt: number;
10
10
  private maxBatchSize;
11
11
  private maxQueueSize;
12
12
  private flushInterval;
@@ -16,7 +16,8 @@ export declare abstract class PostHogCoreStateless {
16
16
  private captureMode;
17
17
  private removeDebugCallback?;
18
18
  private disableGeoip;
19
- disabled: boolean;
19
+ private historicalMigration;
20
+ protected disabled: boolean;
20
21
  private defaultOptIn;
21
22
  private pendingPromises;
22
23
  protected _events: SimpleEventEmitter;
@@ -31,6 +32,7 @@ export declare abstract class PostHogCoreStateless {
31
32
  abstract getPersistedProperty<T>(key: PostHogPersistedProperty): T | undefined;
32
33
  abstract setPersistedProperty<T>(key: PostHogPersistedProperty, value: T | null): void;
33
34
  constructor(apiKey: string, options?: PostHogCoreOptions);
35
+ protected logMsgIfDebug(fn: () => void): void;
34
36
  protected wrap(fn: () => void): void;
35
37
  protected getCommonEventProperties(): any;
36
38
  get optedOut(): boolean;
@@ -39,6 +41,7 @@ export declare abstract class PostHogCoreStateless {
39
41
  on(event: string, cb: (...args: any[]) => void): () => void;
40
42
  debug(enabled?: boolean): void;
41
43
  get isDebug(): boolean;
44
+ get isDisabled(): boolean;
42
45
  private buildPayload;
43
46
  protected addPendingPromise<T>(promise: Promise<T>): Promise<T>;
44
47
  /***
@@ -1,4 +1,4 @@
1
- export declare type PostHogCoreOptions = {
1
+ export type PostHogCoreOptions = {
2
2
  /** PostHog API host, usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com' */
3
3
  host?: string;
4
4
  /** The number of events to queue before sending to PostHog (flushing) */
@@ -36,9 +36,11 @@ export declare type PostHogCoreOptions = {
36
36
  featureFlagsRequestTimeoutMs?: number;
37
37
  /** For Session Analysis how long before we expire a session (defaults to 30 mins) */
38
38
  sessionExpirationTimeSeconds?: number;
39
- /** Whether to post events to PostHog in JSON or compressed format. Defaults to 'form' */
39
+ /** Whether to post events to PostHog in JSON or compressed format. Defaults to 'json' */
40
40
  captureMode?: 'json' | 'form';
41
41
  disableGeoip?: boolean;
42
+ /** Special flag to indicate ingested data is for a historical migration. */
43
+ historicalMigration?: boolean;
42
44
  };
43
45
  export declare enum PostHogPersistedProperty {
44
46
  AnonymousId = "anonymous_id",
@@ -54,9 +56,10 @@ export declare enum PostHogPersistedProperty {
54
56
  PersonProperties = "person_properties",
55
57
  GroupProperties = "group_properties",
56
58
  InstalledAppBuild = "installed_app_build",
57
- InstalledAppVersion = "installed_app_version"
59
+ InstalledAppVersion = "installed_app_version",
60
+ SessionReplay = "session_replay"
58
61
  }
59
- export declare type PostHogFetchOptions = {
62
+ export type PostHogFetchOptions = {
60
63
  method: 'GET' | 'POST' | 'PUT' | 'PATCH';
61
64
  mode?: 'no-cors';
62
65
  credentials?: 'omit';
@@ -66,26 +69,26 @@ export declare type PostHogFetchOptions = {
66
69
  body?: string;
67
70
  signal?: AbortSignal;
68
71
  };
69
- export declare type PostHogCaptureOptions = {
72
+ export type PostHogCaptureOptions = {
70
73
  /** If provided overrides the auto-generated event ID */
71
74
  uuid?: string;
72
75
  /** If provided overrides the auto-generated timestamp */
73
76
  timestamp?: Date;
74
77
  disableGeoip?: boolean;
75
78
  };
76
- export declare type PostHogFetchResponse = {
79
+ export type PostHogFetchResponse = {
77
80
  status: number;
78
81
  text: () => Promise<string>;
79
82
  json: () => Promise<any>;
80
83
  };
81
- export declare type PostHogQueueItem = {
84
+ export type PostHogQueueItem = {
82
85
  message: any;
83
86
  callback?: (err: any) => void;
84
87
  };
85
- export declare type PostHogEventProperties = {
88
+ export type PostHogEventProperties = {
86
89
  [key: string]: any;
87
90
  };
88
- export declare type PostHogAutocaptureElement = {
91
+ export type PostHogAutocaptureElement = {
89
92
  $el_text?: string;
90
93
  tag_name: string;
91
94
  href?: string;
@@ -95,7 +98,7 @@ export declare type PostHogAutocaptureElement = {
95
98
  } & {
96
99
  [key: string]: any;
97
100
  };
98
- export declare type PostHogDecideResponse = {
101
+ export type PostHogDecideResponse = {
99
102
  config: {
100
103
  enable_collect_everything: boolean;
101
104
  };
@@ -112,12 +115,14 @@ export declare type PostHogDecideResponse = {
112
115
  [key: string]: JsonType;
113
116
  };
114
117
  errorsWhileComputingFlags: boolean;
115
- sessionRecording: boolean;
118
+ sessionRecording?: boolean | {
119
+ [key: string]: JsonType;
120
+ };
116
121
  };
117
- export declare type PostHogFlagsAndPayloadsResponse = {
122
+ export type PostHogFlagsAndPayloadsResponse = {
118
123
  featureFlags: PostHogDecideResponse['featureFlags'];
119
124
  featureFlagPayloads: PostHogDecideResponse['featureFlagPayloads'];
120
125
  };
121
- export declare type JsonType = string | number | boolean | null | {
126
+ export type JsonType = string | number | boolean | null | {
122
127
  [key: string]: JsonType;
123
128
  } | Array<JsonType>;
@@ -1,5 +1,5 @@
1
1
  import { PostHogOptions } from './types';
2
- export declare type PostHogStorage = {
2
+ export type PostHogStorage = {
3
3
  getItem: (key: string) => string | null | undefined;
4
4
  setItem: (key: string, value: string) => void;
5
5
  removeItem: (key: string) => void;
@@ -1,5 +1,5 @@
1
1
  import { PostHogCoreOptions } from '../../posthog-core/src';
2
- export declare type PostHogOptions = {
2
+ export type PostHogOptions = {
3
3
  autocapture?: boolean;
4
4
  persistence?: 'localStorage' | 'sessionStorage' | 'cookie' | 'memory';
5
5
  persistence_name?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-js-lite",
3
- "version": "3.0.2",
3
+ "version": "3.1.0",
4
4
  "main": "lib/index.cjs.js",
5
5
  "module": "lib/index.esm.js",
6
6
  "types": "lib/index.d.ts",