posthog-react-native 2.1.3 → 2.2.0-alpha1

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
@@ -9,6 +9,11 @@ declare type PosthogCoreOptions = {
9
9
  enable?: boolean;
10
10
  sendFeatureFlagEvent?: boolean;
11
11
  preloadFeatureFlags?: boolean;
12
+ bootstrap?: {
13
+ distinctId?: string;
14
+ isIdentifiedId?: boolean;
15
+ featureFlags?: Record<string, boolean | string>;
16
+ };
12
17
  fetchRetryCount?: number;
13
18
  fetchRetryDelay?: number;
14
19
  sessionExpirationTimeSeconds?: number;
@@ -34,7 +39,8 @@ declare type PostHogFetchOptions = {
34
39
  headers: {
35
40
  [key: string]: string;
36
41
  };
37
- body: string;
42
+ body?: string;
43
+ signal?: AbortSignal;
38
44
  };
39
45
  declare type PostHogFetchResponse = {
40
46
  status: number;
@@ -108,6 +114,7 @@ declare abstract class PostHogCore {
108
114
  private _optoutOverride;
109
115
  constructor(apiKey: string, options?: PosthogCoreOptions);
110
116
  protected getCommonEventProperties(): any;
117
+ protected setupBootstrap(options?: Partial<PosthogCoreOptions>): void;
111
118
  private get props();
112
119
  private set props(value);
113
120
  private clearProps;
@@ -158,6 +165,7 @@ declare abstract class PostHogCore {
158
165
  ***/
159
166
  private decideAsync;
160
167
  private _decideAsync;
168
+ private setKnownFeatureFlags;
161
169
  getFeatureFlag(key: string): boolean | string | undefined;
162
170
  getFeatureFlags(): PostHogDecideResponse['featureFlags'] | undefined;
163
171
  isFeatureEnabled(key: string): boolean | undefined;
@@ -179,14 +187,61 @@ declare abstract class PostHogCore {
179
187
  shutdown(): void;
180
188
  }
181
189
 
190
+ declare type PostHogAutocaptureNavigationTrackerOptions = {
191
+ routeToName?: (name: string, params: any) => string;
192
+ routeToProperties?: (name: string, params: any) => string;
193
+ };
194
+ declare type PostHogAutocaptureOptions = {
195
+ captureTouches?: boolean;
196
+ customLabelProp?: string;
197
+ noCaptureProp?: string;
198
+ maxElementsCaptured?: number;
199
+ ignoreLabels?: string[];
200
+ propsToCapture?: string[];
201
+ captureScreens?: boolean;
202
+ navigation?: PostHogAutocaptureNavigationTrackerOptions;
203
+ captureLifecycleEvents?: boolean;
204
+ };
205
+ interface PostHogCustomAppProperties {
206
+ /** Build number like "1.2.2" or "122" */
207
+ $app_build?: string | null;
208
+ /** Name of the app as displayed below the icon like "PostHog" */
209
+ $app_name?: string | null;
210
+ /** Namespace of the app usually like "com.posthog.app" */
211
+ $app_namespace?: string | null;
212
+ /** Human friendly app version like what a user would see in the app store like "1.2.2" */
213
+ $app_version?: string | null;
214
+ /** Manufacturer like "Apple", "Samsung" or "Android" */
215
+ $device_manufacturer?: string | null;
216
+ /** Readable model name like "iPhone 12" */
217
+ $device_name?: string | null;
218
+ /** Operating system name like iOS or Android */
219
+ $os_name?: string | null;
220
+ /** Operating system version "14.0" */
221
+ $os_version?: string | null;
222
+ /** Locale (language) of the device like "en-US" */
223
+ $locale?: string | null;
224
+ /** Timezone of the device like "Europe/Berlin" */
225
+ $timezone?: string | null;
226
+ }
227
+ interface PostHogCustomAsyncStorage {
228
+ getItem: (key: string) => Promise<string | null>;
229
+ setItem: (key: string, value: string) => Promise<void>;
230
+ }
231
+
182
232
  declare type PostHogOptions = PosthogCoreOptions & {
183
233
  persistence?: 'memory' | 'file';
234
+ customAppProperties?: PostHogCustomAppProperties;
235
+ customAsyncStorage?: PostHogCustomAsyncStorage;
184
236
  };
185
237
  declare class PostHog extends PostHogCore {
186
238
  private _persistence;
187
239
  private _memoryStorage;
188
- static initAsync(): Promise<void>;
240
+ private _semiAsyncStorage;
241
+ private _appProperties;
189
242
  constructor(apiKey: string, options?: PostHogOptions);
243
+ /** Await this method to ensure that all state has been loaded from the async provider */
244
+ initAsync(): Promise<void>;
190
245
  getPersistedProperty<T>(key: PostHogPersistedProperty): T | undefined;
191
246
  setPersistedProperty<T>(key: PostHogPersistedProperty, value: T | null): void;
192
247
  fetch(url: string, options: PostHogFetchOptions): Promise<PostHogFetchResponse>;
@@ -199,20 +254,6 @@ declare class PostHog extends PostHogCore {
199
254
 
200
255
  declare function useLifecycleTracker(client?: PostHog): void;
201
256
 
202
- declare type PostHogAutocaptureNavigationTrackerOptions = {
203
- routeToName?: (name: string, params: any) => string;
204
- routeToProperties?: (name: string, params: any) => string;
205
- };
206
- declare type PostHogAutocaptureOptions = {
207
- captureTouches?: boolean;
208
- customLabelProp?: string;
209
- noCaptureProp?: string;
210
- maxElementsCaptured?: number;
211
- ignoreLabels?: string[];
212
- propsToCapture?: string[];
213
- navigation?: PostHogAutocaptureNavigationTrackerOptions;
214
- };
215
-
216
257
  declare function _useNavigationTracker(options?: PostHogAutocaptureNavigationTrackerOptions, client?: PostHog): void;
217
258
  declare const useNavigationTracker: typeof _useNavigationTracker;
218
259
 
@@ -232,4 +273,4 @@ interface PostHogProviderProps {
232
273
  }
233
274
  declare const PostHogProvider: ({ children, client, options, apiKey, autocapture, style, }: PostHogProviderProps) => JSX.Element;
234
275
 
235
- export { PostHog, PostHogAutocaptureNavigationTrackerOptions, PostHogAutocaptureOptions, PostHogOptions, PostHogProvider, PostHogProviderProps, PostHog as default, useFeatureFlag, useFeatureFlags, useLifecycleTracker, useNavigationTracker, usePostHog };
276
+ export { PostHog, PostHogAutocaptureNavigationTrackerOptions, PostHogAutocaptureOptions, PostHogCustomAppProperties, PostHogCustomAsyncStorage, PostHogOptions, PostHogProvider, PostHogProviderProps, PostHog as default, useFeatureFlag, useFeatureFlags, useLifecycleTracker, useNavigationTracker, usePostHog };