posthog-react-native 2.0.0-alpha9 → 2.1.1
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/CHANGELOG.md +8 -0
- package/lib/index.cjs.js +282 -141
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +50 -16
- package/lib/index.esm.js +281 -141
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/eventemitter.d.ts +2 -2
- package/lib/posthog-core/src/index.d.ts +27 -9
- package/lib/posthog-core/src/storage-memory.d.ts +6 -0
- package/lib/posthog-core/src/types.d.ts +12 -3
- package/lib/posthog-core/src/utils.d.ts +0 -1
- package/lib/posthog-react-native/src/hooks/useFeatureFlag.d.ts +1 -1
- package/lib/posthog-react-native/src/optional-imports.d.ts +0 -4
- package/lib/posthog-react-native/src/posthog-rn.d.ts +5 -1
- package/lib/posthog-react-native/src/types.d.ts +3 -0
- package/package.json +7 -14
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare class SimpleEventEmitter {
|
|
2
2
|
events: {
|
|
3
|
-
[key: string]: ((
|
|
3
|
+
[key: string]: ((...args: any[]) => void)[];
|
|
4
4
|
};
|
|
5
5
|
constructor();
|
|
6
|
-
on(event: string, listener: (
|
|
6
|
+
on(event: string, listener: (...args: any[]) => void): () => void;
|
|
7
7
|
emit(event: string, payload: any): void;
|
|
8
8
|
}
|
|
@@ -5,17 +5,16 @@ import { LZString } from './lz-string';
|
|
|
5
5
|
import { SimpleEventEmitter } from './eventemitter';
|
|
6
6
|
export declare abstract class PostHogCore {
|
|
7
7
|
private apiKey;
|
|
8
|
-
|
|
8
|
+
host: string;
|
|
9
9
|
private flushAt;
|
|
10
10
|
private flushInterval;
|
|
11
11
|
private captureMode;
|
|
12
12
|
private sendFeatureFlagEvent;
|
|
13
13
|
private flagCallReported;
|
|
14
|
+
private removeDebugCallback?;
|
|
14
15
|
protected _events: SimpleEventEmitter;
|
|
15
16
|
protected _flushTimer?: any;
|
|
16
17
|
protected _decideResponsePromise?: Promise<PostHogDecideResponse>;
|
|
17
|
-
protected _decideTimer?: any;
|
|
18
|
-
protected _decidePollInterval: number;
|
|
19
18
|
protected _retryOptions: RetriableOptions;
|
|
20
19
|
protected _sessionExpirationTimeSeconds: number;
|
|
21
20
|
abstract fetch(url: string, options: PostHogFetchOptions): Promise<PostHogFetchResponse>;
|
|
@@ -27,16 +26,21 @@ export declare abstract class PostHogCore {
|
|
|
27
26
|
private _optoutOverride;
|
|
28
27
|
constructor(apiKey: string, options?: PosthogCoreOptions);
|
|
29
28
|
protected getCommonEventProperties(): any;
|
|
29
|
+
protected setupBootstrap(options?: Partial<PosthogCoreOptions>): void;
|
|
30
30
|
private get props();
|
|
31
31
|
private set props(value);
|
|
32
|
+
private clearProps;
|
|
32
33
|
private _props;
|
|
33
34
|
get optedOut(): boolean;
|
|
34
35
|
optIn(): void;
|
|
35
36
|
optOut(): void;
|
|
36
|
-
on(event: string, cb: (
|
|
37
|
-
reset(): void;
|
|
37
|
+
on(event: string, cb: (...args: any[]) => void): () => void;
|
|
38
|
+
reset(propertiesToKeep?: PostHogPersistedProperty[]): void;
|
|
39
|
+
debug(enabled?: boolean): void;
|
|
38
40
|
private buildPayload;
|
|
39
41
|
getSessionId(): string | undefined;
|
|
42
|
+
resetSessionId(): void;
|
|
43
|
+
getAnonymousId(): string;
|
|
40
44
|
getDistinctId(): string;
|
|
41
45
|
register(properties: {
|
|
42
46
|
[key: string]: any;
|
|
@@ -48,7 +52,7 @@ export declare abstract class PostHogCore {
|
|
|
48
52
|
identify(distinctId?: string, properties?: PostHogEventProperties): this;
|
|
49
53
|
capture(event: string, properties?: {
|
|
50
54
|
[key: string]: any;
|
|
51
|
-
}): this;
|
|
55
|
+
}, forceSendFeatureFlags?: boolean): this;
|
|
52
56
|
alias(alias: string): this;
|
|
53
57
|
autocapture(eventType: string, elements: PostHogAutocaptureElement[], properties?: PostHogEventProperties): this;
|
|
54
58
|
/***
|
|
@@ -59,17 +63,31 @@ export declare abstract class PostHogCore {
|
|
|
59
63
|
}): this;
|
|
60
64
|
group(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties): this;
|
|
61
65
|
groupIdentify(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties): this;
|
|
66
|
+
/***
|
|
67
|
+
* PROPERTIES
|
|
68
|
+
***/
|
|
69
|
+
personProperties(properties: {
|
|
70
|
+
[type: string]: string;
|
|
71
|
+
}): this;
|
|
72
|
+
groupProperties(properties: {
|
|
73
|
+
[type: string]: Record<string, string>;
|
|
74
|
+
}): this;
|
|
62
75
|
/***
|
|
63
76
|
*** FEATURE FLAGS
|
|
64
77
|
***/
|
|
65
78
|
private decideAsync;
|
|
66
79
|
private _decideAsync;
|
|
67
|
-
|
|
80
|
+
private setKnownFeatureFlags;
|
|
81
|
+
getFeatureFlag(key: string): boolean | string | undefined;
|
|
68
82
|
getFeatureFlags(): PostHogDecideResponse['featureFlags'] | undefined;
|
|
69
|
-
isFeatureEnabled(key: string
|
|
70
|
-
reloadFeatureFlagsAsync(): Promise<PostHogDecideResponse['featureFlags']>;
|
|
83
|
+
isFeatureEnabled(key: string): boolean | undefined;
|
|
84
|
+
reloadFeatureFlagsAsync(sendAnonDistinctId?: boolean): Promise<PostHogDecideResponse['featureFlags']>;
|
|
71
85
|
onFeatureFlags(cb: (flags: PostHogDecideResponse['featureFlags']) => void): () => void;
|
|
86
|
+
onFeatureFlag(key: string, cb: (value: string | boolean) => void): () => void;
|
|
72
87
|
overrideFeatureFlag(flags: PostHogDecideResponse['featureFlags'] | null): void;
|
|
88
|
+
_sendFeatureFlags(event: string, properties?: {
|
|
89
|
+
[key: string]: any;
|
|
90
|
+
}): void;
|
|
73
91
|
/***
|
|
74
92
|
*** QUEUEING AND FLUSHING
|
|
75
93
|
***/
|
|
@@ -5,13 +5,18 @@ export declare type PosthogCoreOptions = {
|
|
|
5
5
|
enable?: boolean;
|
|
6
6
|
sendFeatureFlagEvent?: boolean;
|
|
7
7
|
preloadFeatureFlags?: boolean;
|
|
8
|
-
|
|
8
|
+
bootstrap?: {
|
|
9
|
+
distinctId?: string;
|
|
10
|
+
isIdentifiedId?: boolean;
|
|
11
|
+
featureFlags?: Record<string, boolean | string>;
|
|
12
|
+
};
|
|
9
13
|
fetchRetryCount?: number;
|
|
10
14
|
fetchRetryDelay?: number;
|
|
11
15
|
sessionExpirationTimeSeconds?: number;
|
|
12
16
|
captureMode?: 'json' | 'form';
|
|
13
17
|
};
|
|
14
18
|
export declare enum PostHogPersistedProperty {
|
|
19
|
+
AnonymousId = "anonymous_id",
|
|
15
20
|
DistinctId = "distinct_id",
|
|
16
21
|
Props = "props",
|
|
17
22
|
FeatureFlags = "feature_flags",
|
|
@@ -19,7 +24,9 @@ export declare enum PostHogPersistedProperty {
|
|
|
19
24
|
Queue = "queue",
|
|
20
25
|
OptedOut = "opted_out",
|
|
21
26
|
SessionId = "session_id",
|
|
22
|
-
SessionLastTimestamp = "session_timestamp"
|
|
27
|
+
SessionLastTimestamp = "session_timestamp",
|
|
28
|
+
PersonProperties = "person_properties",
|
|
29
|
+
GroupProperties = "group_properties"
|
|
23
30
|
}
|
|
24
31
|
export declare type PostHogFetchOptions = {
|
|
25
32
|
method: 'GET' | 'POST' | 'PUT' | 'PATCH';
|
|
@@ -28,11 +35,13 @@ export declare type PostHogFetchOptions = {
|
|
|
28
35
|
headers: {
|
|
29
36
|
[key: string]: string;
|
|
30
37
|
};
|
|
31
|
-
body
|
|
38
|
+
body?: string;
|
|
39
|
+
signal?: AbortSignal;
|
|
32
40
|
};
|
|
33
41
|
export declare type PostHogFetchResponse = {
|
|
34
42
|
status: number;
|
|
35
43
|
text: () => Promise<string>;
|
|
44
|
+
json: () => Promise<any>;
|
|
36
45
|
};
|
|
37
46
|
export declare type PostHogQueueItem = {
|
|
38
47
|
message: any;
|
|
@@ -9,5 +9,4 @@ export declare function retriable<T>(fn: () => Promise<T>, props?: RetriableOpti
|
|
|
9
9
|
export declare function generateUUID(globalThis?: any): string;
|
|
10
10
|
export declare function currentTimestamp(): number;
|
|
11
11
|
export declare function currentISOTime(): string;
|
|
12
|
-
export declare function isUndefined(obj: any): boolean;
|
|
13
12
|
export declare function safeSetTimeout(fn: () => void, timeout: number): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useFeatureFlag(flag: string
|
|
1
|
+
export declare function useFeatureFlag(flag: string): string | boolean | undefined;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
import type ReactNativeNavigation from '@react-navigation/native';
|
|
2
|
-
import type * as ExpoLocalization from 'expo-localization';
|
|
3
|
-
import type * as ExpoNetwork from 'expo-network';
|
|
4
2
|
export declare const OptionalReactNativeNavigation: typeof ReactNativeNavigation | undefined;
|
|
5
|
-
export declare const OptionalExpoLocalization: typeof ExpoLocalization | undefined;
|
|
6
|
-
export declare const OptionalExpoNetwork: typeof ExpoNetwork | undefined;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { PostHogCore, PosthogCoreOptions, PostHogFetchOptions, PostHogFetchResponse, PostHogPersistedProperty } from '../../posthog-core/src';
|
|
2
|
-
export declare type PostHogOptions = PosthogCoreOptions
|
|
2
|
+
export declare type PostHogOptions = PosthogCoreOptions & {
|
|
3
|
+
persistence?: 'memory' | 'file';
|
|
4
|
+
};
|
|
3
5
|
export declare class PostHog extends PostHogCore {
|
|
6
|
+
private _persistence;
|
|
7
|
+
private _memoryStorage;
|
|
4
8
|
static initAsync(): Promise<void>;
|
|
5
9
|
constructor(apiKey: string, options?: PostHogOptions);
|
|
6
10
|
getPersistedProperty<T>(key: PostHogPersistedProperty): T | undefined;
|
|
@@ -8,5 +8,8 @@ export declare type PostHogAutocaptureOptions = {
|
|
|
8
8
|
noCaptureProp?: string;
|
|
9
9
|
maxElementsCaptured?: number;
|
|
10
10
|
ignoreLabels?: string[];
|
|
11
|
+
propsToCapture?: string[];
|
|
12
|
+
captureScreens?: boolean;
|
|
11
13
|
navigation?: PostHogAutocaptureNavigationTrackerOptions;
|
|
14
|
+
captureLifecycleEvents?: boolean;
|
|
12
15
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "posthog-react-native",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"main": "lib/index.cjs.js",
|
|
5
5
|
"module": "lib/index.esm.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -20,27 +20,20 @@
|
|
|
20
20
|
"expo-device": "^4.0.0",
|
|
21
21
|
"expo-file-system": "^13.0.0",
|
|
22
22
|
"expo-localization": "~11.0.0",
|
|
23
|
-
"expo
|
|
23
|
+
"jest-expo": "^46.0.1",
|
|
24
24
|
"react": "^18.2.0",
|
|
25
25
|
"react-native": "^0.69.1"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@react-navigation/native": "
|
|
29
|
-
"expo-
|
|
30
|
-
"expo-
|
|
31
|
-
"expo-file-system": "
|
|
32
|
-
"expo-
|
|
33
|
-
"expo-device": "^4.0.0"
|
|
28
|
+
"@react-navigation/native": ">= 5.0.10",
|
|
29
|
+
"expo-application": ">= 4.0.0",
|
|
30
|
+
"expo-device": ">= 4.0.0",
|
|
31
|
+
"expo-file-system": ">= 13.0.0",
|
|
32
|
+
"expo-localization": ">= 11.0.0"
|
|
34
33
|
},
|
|
35
34
|
"peerDependenciesMeta": {
|
|
36
35
|
"@react-navigation/native": {
|
|
37
36
|
"optional": true
|
|
38
|
-
},
|
|
39
|
-
"expo-localization": {
|
|
40
|
-
"optional": true
|
|
41
|
-
},
|
|
42
|
-
"expo-network": {
|
|
43
|
-
"optional": true
|
|
44
37
|
}
|
|
45
38
|
}
|
|
46
39
|
}
|