posthog-js-lite 2.4.0 → 2.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.
@@ -1,4 +1,4 @@
1
- import { PostHogFetchOptions, PostHogFetchResponse, PostHogAutocaptureElement, PostHogDecideResponse, PosthogCoreOptions, PostHogEventProperties, PostHogPersistedProperty, PosthogCaptureOptions, JsonType } from './types';
1
+ import { PostHogFetchOptions, PostHogFetchResponse, PostHogAutocaptureElement, PostHogDecideResponse, PosthogCoreOptions, PostHogEventProperties, PostHogPersistedProperty, PostHogCaptureOptions, JsonType } from './types';
2
2
  import { RetriableOptions } from './utils';
3
3
  export * as utils from './utils';
4
4
  import { LZString } from './lz-string';
@@ -12,9 +12,9 @@ export declare abstract class PostHogCoreStateless {
12
12
  private captureMode;
13
13
  private removeDebugCallback?;
14
14
  private debugMode;
15
- private pendingPromises;
16
15
  private disableGeoip;
17
16
  private _optoutOverride;
17
+ private pendingPromises;
18
18
  protected _events: SimpleEventEmitter;
19
19
  protected _flushTimer?: any;
20
20
  protected _retryOptions: RetriableOptions;
@@ -32,20 +32,21 @@ export declare abstract class PostHogCoreStateless {
32
32
  on(event: string, cb: (...args: any[]) => void): () => void;
33
33
  debug(enabled?: boolean): void;
34
34
  private buildPayload;
35
+ protected addPendingPromise(promise: Promise<any>): void;
35
36
  /***
36
37
  *** TRACKING
37
38
  ***/
38
- protected identifyStateless(distinctId: string, properties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
39
+ protected identifyStateless(distinctId: string, properties?: PostHogEventProperties, options?: PostHogCaptureOptions): this;
39
40
  protected captureStateless(distinctId: string, event: string, properties?: {
40
41
  [key: string]: any;
41
- }, options?: PosthogCaptureOptions): this;
42
+ }, options?: PostHogCaptureOptions): this;
42
43
  protected aliasStateless(alias: string, distinctId: string, properties?: {
43
44
  [key: string]: any;
44
- }, options?: PosthogCaptureOptions): this;
45
+ }, options?: PostHogCaptureOptions): this;
45
46
  /***
46
47
  *** GROUPS
47
48
  ***/
48
- protected groupIdentifyStateless(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PosthogCaptureOptions, distinctId?: string, eventProperties?: PostHogEventProperties): this;
49
+ protected groupIdentifyStateless(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PostHogCaptureOptions, distinctId?: string, eventProperties?: PostHogEventProperties): this;
49
50
  /***
50
51
  *** FEATURE FLAGS
51
52
  ***/
@@ -62,7 +63,7 @@ export declare abstract class PostHogCoreStateless {
62
63
  /***
63
64
  *** QUEUEING AND FLUSHING
64
65
  ***/
65
- protected enqueue(type: string, _message: any, options?: PosthogCaptureOptions): void;
66
+ protected enqueue(type: string, _message: any, options?: PostHogCaptureOptions): void;
66
67
  flushAsync(): Promise<any>;
67
68
  flush(callback?: (err?: any, data?: any) => void): void;
68
69
  private fetchWithRetry;
@@ -74,6 +75,7 @@ export declare abstract class PostHogCore extends PostHogCoreStateless {
74
75
  private flagCallReported;
75
76
  protected _decideResponsePromise?: Promise<PostHogDecideResponse | undefined>;
76
77
  protected _sessionExpirationTimeSeconds: number;
78
+ protected sessionProps: PostHogEventProperties;
77
79
  constructor(apiKey: string, options?: PosthogCoreOptions);
78
80
  protected setupBootstrap(options?: Partial<PosthogCoreOptions>): void;
79
81
  private get props();
@@ -83,38 +85,52 @@ export declare abstract class PostHogCore extends PostHogCoreStateless {
83
85
  on(event: string, cb: (...args: any[]) => void): () => void;
84
86
  reset(propertiesToKeep?: PostHogPersistedProperty[]): void;
85
87
  protected getCommonEventProperties(): any;
86
- private enrichProperties;
88
+ enrichProperties(properties?: PostHogEventProperties): any;
87
89
  getSessionId(): string | undefined;
88
90
  resetSessionId(): void;
89
91
  getAnonymousId(): string;
90
92
  getDistinctId(): string;
93
+ unregister(property: string): void;
91
94
  register(properties: {
92
95
  [key: string]: any;
93
96
  }): void;
94
- unregister(property: string): void;
97
+ registerForSession(properties: {
98
+ [key: string]: any;
99
+ }): void;
100
+ unregisterForSession(property: string): void;
95
101
  /***
96
102
  *** TRACKING
97
103
  ***/
98
- identify(distinctId?: string, properties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
104
+ identify(distinctId?: string, properties?: PostHogEventProperties, options?: PostHogCaptureOptions): this;
99
105
  capture(event: string, properties?: {
100
106
  [key: string]: any;
101
- }, options?: PosthogCaptureOptions): this;
107
+ }, options?: PostHogCaptureOptions): this;
102
108
  alias(alias: string): this;
103
- autocapture(eventType: string, elements: PostHogAutocaptureElement[], properties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
109
+ autocapture(eventType: string, elements: PostHogAutocaptureElement[], properties?: PostHogEventProperties, options?: PostHogCaptureOptions): this;
104
110
  /***
105
111
  *** GROUPS
106
112
  ***/
107
113
  groups(groups: {
108
114
  [type: string]: string | number;
109
115
  }): this;
110
- group(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
111
- groupIdentify(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
116
+ group(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PostHogCaptureOptions): this;
117
+ groupIdentify(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PostHogCaptureOptions): this;
112
118
  /***
113
119
  * PROPERTIES
114
120
  ***/
121
+ setPersonPropertiesForFlags(properties: {
122
+ [type: string]: string;
123
+ }): this;
124
+ resetPersonPropertiesForFlags(): void;
125
+ /** @deprecated - Renamed to setPersonPropertiesForFlags */
115
126
  personProperties(properties: {
116
127
  [type: string]: string;
117
128
  }): this;
129
+ setGroupPropertiesForFlags(properties: {
130
+ [type: string]: Record<string, string>;
131
+ }): this;
132
+ resetGroupPropertiesForFlags(): void;
133
+ /** @deprecated - Renamed to setGroupPropertiesForFlags */
118
134
  groupProperties(properties: {
119
135
  [type: string]: Record<string, string>;
120
136
  }): this;
@@ -30,7 +30,9 @@ export declare enum PostHogPersistedProperty {
30
30
  SessionId = "session_id",
31
31
  SessionLastTimestamp = "session_timestamp",
32
32
  PersonProperties = "person_properties",
33
- GroupProperties = "group_properties"
33
+ GroupProperties = "group_properties",
34
+ InstalledAppBuild = "installed_app_build",
35
+ InstalledAppVersion = "installed_app_version"
34
36
  }
35
37
  export declare type PostHogFetchOptions = {
36
38
  method: 'GET' | 'POST' | 'PUT' | 'PATCH';
@@ -42,7 +44,10 @@ export declare type PostHogFetchOptions = {
42
44
  body?: string;
43
45
  signal?: AbortSignal;
44
46
  };
45
- export declare type PosthogCaptureOptions = {
47
+ export declare type PostHogCaptureOptions = {
48
+ /** If provided overrides the auto-generated event ID */
49
+ uuid?: string;
50
+ /** If provided overrides the auto-generated timestamp */
46
51
  timestamp?: Date;
47
52
  disableGeoip?: boolean;
48
53
  };
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "posthog-js-lite",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "main": "lib/index.cjs.js",
5
5
  "module": "lib/index.esm.js",
6
6
  "types": "lib/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/PostHog/posthog-js-lite.git",
10
+ "directory": "posthog-web"
11
+ },
7
12
  "scripts": {
8
13
  "test": "jest -c jest.config.js",
9
14
  "prepublishOnly": "cd .. && yarn build"