@txlemetry/react-native-plugin 2.5.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/LICENSE +353 -0
- package/README.md +9 -0
- package/android/build.gradle +91 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/posthogreactnativeplugin/PosthogReactNativePluginModule.kt +638 -0
- package/android/src/main/java/com/posthogreactnativeplugin/PosthogReactNativePluginPackage.kt +13 -0
- package/ios/Package.swift +70 -0
- package/ios/PosthogReactNativePlugin-Bridging-Header.h +3 -0
- package/ios/PosthogReactNativePlugin.mm +77 -0
- package/ios/PosthogReactNativePlugin.swift +474 -0
- package/lib/commonjs/index.js +143 -0
- package/lib/module/index.js +124 -0
- package/lib/typescript/commonjs/package.json +3 -0
- package/lib/typescript/commonjs/src/index.d.ts +92 -0
- package/lib/typescript/module/package.json +3 -0
- package/lib/typescript/module/src/index.d.ts +92 -0
- package/package.json +121 -0
- package/src/index.tsx +238 -0
- package/txlemetry-react-native-plugin.podspec +69 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.addExceptionStep = addExceptionStep;
|
|
7
|
+
exports.capturePushNotificationOpened = capturePushNotificationOpened;
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
exports.endSession = endSession;
|
|
10
|
+
exports.identify = identify;
|
|
11
|
+
exports.isEnabled = isEnabled;
|
|
12
|
+
exports.registerPushNotificationToken = registerPushNotificationToken;
|
|
13
|
+
exports.reset = reset;
|
|
14
|
+
exports.setOptOut = setOptOut;
|
|
15
|
+
exports.setPushIdentityProvider = setPushIdentityProvider;
|
|
16
|
+
exports.setup = setup;
|
|
17
|
+
exports.start = start;
|
|
18
|
+
exports.startRecording = startRecording;
|
|
19
|
+
exports.startSession = startSession;
|
|
20
|
+
exports.stopRecording = stopRecording;
|
|
21
|
+
exports.unregisterPushNotificationToken = unregisterPushNotificationToken;
|
|
22
|
+
var _reactNative = require("react-native");
|
|
23
|
+
const LINKING_ERROR = `The package '@txlemetry/react-native-plugin' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
24
|
+
ios: "- You have run 'pod install'\n",
|
|
25
|
+
default: ''
|
|
26
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
27
|
+
const nativeModule = _reactNative.NativeModules.TxlemetryReactNativePlugin || _reactNative.NativeModules.PosthogReactNativePlugin ? _reactNative.NativeModules.TxlemetryReactNativePlugin || _reactNative.NativeModules.PosthogReactNativePlugin : new Proxy({}, {
|
|
28
|
+
get() {
|
|
29
|
+
throw new Error(LINKING_ERROR);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
function setup(sessionId, sdkOptions, pluginConfig = {}) {
|
|
33
|
+
return nativeModule.setup(sessionId, sdkOptions, pluginConfig);
|
|
34
|
+
}
|
|
35
|
+
function start(sessionId, sdkOptions, sdkReplayConfig, decideReplayConfig) {
|
|
36
|
+
return nativeModule.start(sessionId, sdkOptions, sdkReplayConfig, decideReplayConfig);
|
|
37
|
+
}
|
|
38
|
+
function startSession(sessionId) {
|
|
39
|
+
return nativeModule.startSession(sessionId);
|
|
40
|
+
}
|
|
41
|
+
function endSession() {
|
|
42
|
+
return nativeModule.endSession();
|
|
43
|
+
}
|
|
44
|
+
function isEnabled() {
|
|
45
|
+
return nativeModule.isEnabled();
|
|
46
|
+
}
|
|
47
|
+
function identify(distinctId, anonymousId) {
|
|
48
|
+
return nativeModule.identify(distinctId, anonymousId);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Resets the native SDK's identity on logout. Unlike {@link identify}, this calls the native
|
|
53
|
+
* SDK's own `reset()`, which unregisters the logged-out user's push subscription and
|
|
54
|
+
* re-registers it under the new anonymous id.
|
|
55
|
+
*/
|
|
56
|
+
function reset(distinctId, anonymousId) {
|
|
57
|
+
return nativeModule.reset(distinctId, anonymousId);
|
|
58
|
+
}
|
|
59
|
+
function startRecording(resumeCurrent) {
|
|
60
|
+
return nativeModule.startRecording(resumeCurrent);
|
|
61
|
+
}
|
|
62
|
+
function stopRecording() {
|
|
63
|
+
return nativeModule.stopRecording();
|
|
64
|
+
}
|
|
65
|
+
function addExceptionStep(message, properties) {
|
|
66
|
+
return nativeModule.addExceptionStep(message, properties ?? {});
|
|
67
|
+
}
|
|
68
|
+
function registerPushNotificationToken(deviceToken, appId) {
|
|
69
|
+
return nativeModule.registerPushNotificationToken(deviceToken, appId);
|
|
70
|
+
}
|
|
71
|
+
function unregisterPushNotificationToken() {
|
|
72
|
+
return nativeModule.unregisterPushNotificationToken();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Propagates a runtime consent change to the native SDK, which otherwise only reads the JS
|
|
77
|
+
* opt-out flag at setup() and could auto-register a refreshed push token after optOut().
|
|
78
|
+
*/
|
|
79
|
+
function setOptOut(optOut) {
|
|
80
|
+
return nativeModule.setOptOut(optOut);
|
|
81
|
+
}
|
|
82
|
+
function capturePushNotificationOpened(properties) {
|
|
83
|
+
return nativeModule.capturePushNotificationOpened(properties);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Mints a signed identity-verification token for a push subscription request.
|
|
88
|
+
* Return null to send the request without an identity token.
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
const PUSH_IDENTITY_EVENT = 'PostHogPushIdentityRequest';
|
|
92
|
+
let pushIdentitySubscription;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Installs the JS side of the push identity-provider bridge. The native SDK asks for a
|
|
96
|
+
* token via the native bridge event; the reply is routed back with
|
|
97
|
+
* `providePushIdentityToken`, keyed by the request id so late replies are ignored.
|
|
98
|
+
*
|
|
99
|
+
* Install before setup() with `push.pushIdentityProviderEnabled` set, so the native
|
|
100
|
+
* config gets its bridging provider at SDK initialization. Any provider failure
|
|
101
|
+
* degrades to a null token — an unauthenticated request — never a stalled mint.
|
|
102
|
+
*/
|
|
103
|
+
function setPushIdentityProvider(provider) {
|
|
104
|
+
pushIdentitySubscription?.remove();
|
|
105
|
+
// Via the proxy, not raw NativeModules: an unlinked module would build an emitter over
|
|
106
|
+
// undefined and throw a generic RN error inside the SDK's init try, taking replay down with it.
|
|
107
|
+
const emitter = new _reactNative.NativeEventEmitter(nativeModule);
|
|
108
|
+
pushIdentitySubscription = emitter.addListener(PUSH_IDENTITY_EVENT, async request => {
|
|
109
|
+
let token = null;
|
|
110
|
+
try {
|
|
111
|
+
const minted = await provider(request.distinctId, request.appId);
|
|
112
|
+
token = typeof minted === 'string' ? minted : null;
|
|
113
|
+
} catch (e) {
|
|
114
|
+
// eslint-disable-next-line no-console
|
|
115
|
+
console.warn(`[Txlemetry] pushIdentityProvider threw: ${e}. Push subscription will be sent unauthenticated.`);
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
await nativeModule.providePushIdentityToken(request.requestId, token);
|
|
119
|
+
} catch (e) {
|
|
120
|
+
// eslint-disable-next-line no-console
|
|
121
|
+
console.warn(`[Txlemetry] Failed to deliver push identity token to native: ${e}`);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
const TxlemetryReactNativePlugin = {
|
|
126
|
+
setup,
|
|
127
|
+
start,
|
|
128
|
+
startSession,
|
|
129
|
+
endSession,
|
|
130
|
+
isEnabled,
|
|
131
|
+
identify,
|
|
132
|
+
reset,
|
|
133
|
+
startRecording,
|
|
134
|
+
stopRecording,
|
|
135
|
+
addExceptionStep,
|
|
136
|
+
registerPushNotificationToken,
|
|
137
|
+
unregisterPushNotificationToken,
|
|
138
|
+
setOptOut,
|
|
139
|
+
capturePushNotificationOpened,
|
|
140
|
+
setPushIdentityProvider
|
|
141
|
+
};
|
|
142
|
+
var _default = exports.default = TxlemetryReactNativePlugin;
|
|
143
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
|
4
|
+
const LINKING_ERROR = `The package '@txlemetry/react-native-plugin' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
5
|
+
ios: "- You have run 'pod install'\n",
|
|
6
|
+
default: ''
|
|
7
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
8
|
+
const nativeModule = NativeModules.TxlemetryReactNativePlugin || NativeModules.PosthogReactNativePlugin ? NativeModules.TxlemetryReactNativePlugin || NativeModules.PosthogReactNativePlugin : new Proxy({}, {
|
|
9
|
+
get() {
|
|
10
|
+
throw new Error(LINKING_ERROR);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export function setup(sessionId, sdkOptions, pluginConfig = {}) {
|
|
14
|
+
return nativeModule.setup(sessionId, sdkOptions, pluginConfig);
|
|
15
|
+
}
|
|
16
|
+
export function start(sessionId, sdkOptions, sdkReplayConfig, decideReplayConfig) {
|
|
17
|
+
return nativeModule.start(sessionId, sdkOptions, sdkReplayConfig, decideReplayConfig);
|
|
18
|
+
}
|
|
19
|
+
export function startSession(sessionId) {
|
|
20
|
+
return nativeModule.startSession(sessionId);
|
|
21
|
+
}
|
|
22
|
+
export function endSession() {
|
|
23
|
+
return nativeModule.endSession();
|
|
24
|
+
}
|
|
25
|
+
export function isEnabled() {
|
|
26
|
+
return nativeModule.isEnabled();
|
|
27
|
+
}
|
|
28
|
+
export function identify(distinctId, anonymousId) {
|
|
29
|
+
return nativeModule.identify(distinctId, anonymousId);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Resets the native SDK's identity on logout. Unlike {@link identify}, this calls the native
|
|
34
|
+
* SDK's own `reset()`, which unregisters the logged-out user's push subscription and
|
|
35
|
+
* re-registers it under the new anonymous id.
|
|
36
|
+
*/
|
|
37
|
+
export function reset(distinctId, anonymousId) {
|
|
38
|
+
return nativeModule.reset(distinctId, anonymousId);
|
|
39
|
+
}
|
|
40
|
+
export function startRecording(resumeCurrent) {
|
|
41
|
+
return nativeModule.startRecording(resumeCurrent);
|
|
42
|
+
}
|
|
43
|
+
export function stopRecording() {
|
|
44
|
+
return nativeModule.stopRecording();
|
|
45
|
+
}
|
|
46
|
+
export function addExceptionStep(message, properties) {
|
|
47
|
+
return nativeModule.addExceptionStep(message, properties ?? {});
|
|
48
|
+
}
|
|
49
|
+
export function registerPushNotificationToken(deviceToken, appId) {
|
|
50
|
+
return nativeModule.registerPushNotificationToken(deviceToken, appId);
|
|
51
|
+
}
|
|
52
|
+
export function unregisterPushNotificationToken() {
|
|
53
|
+
return nativeModule.unregisterPushNotificationToken();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Propagates a runtime consent change to the native SDK, which otherwise only reads the JS
|
|
58
|
+
* opt-out flag at setup() and could auto-register a refreshed push token after optOut().
|
|
59
|
+
*/
|
|
60
|
+
export function setOptOut(optOut) {
|
|
61
|
+
return nativeModule.setOptOut(optOut);
|
|
62
|
+
}
|
|
63
|
+
export function capturePushNotificationOpened(properties) {
|
|
64
|
+
return nativeModule.capturePushNotificationOpened(properties);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Mints a signed identity-verification token for a push subscription request.
|
|
69
|
+
* Return null to send the request without an identity token.
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
const PUSH_IDENTITY_EVENT = 'PostHogPushIdentityRequest';
|
|
73
|
+
let pushIdentitySubscription;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Installs the JS side of the push identity-provider bridge. The native SDK asks for a
|
|
77
|
+
* token via the native bridge event; the reply is routed back with
|
|
78
|
+
* `providePushIdentityToken`, keyed by the request id so late replies are ignored.
|
|
79
|
+
*
|
|
80
|
+
* Install before setup() with `push.pushIdentityProviderEnabled` set, so the native
|
|
81
|
+
* config gets its bridging provider at SDK initialization. Any provider failure
|
|
82
|
+
* degrades to a null token — an unauthenticated request — never a stalled mint.
|
|
83
|
+
*/
|
|
84
|
+
export function setPushIdentityProvider(provider) {
|
|
85
|
+
pushIdentitySubscription?.remove();
|
|
86
|
+
// Via the proxy, not raw NativeModules: an unlinked module would build an emitter over
|
|
87
|
+
// undefined and throw a generic RN error inside the SDK's init try, taking replay down with it.
|
|
88
|
+
const emitter = new NativeEventEmitter(nativeModule);
|
|
89
|
+
pushIdentitySubscription = emitter.addListener(PUSH_IDENTITY_EVENT, async request => {
|
|
90
|
+
let token = null;
|
|
91
|
+
try {
|
|
92
|
+
const minted = await provider(request.distinctId, request.appId);
|
|
93
|
+
token = typeof minted === 'string' ? minted : null;
|
|
94
|
+
} catch (e) {
|
|
95
|
+
// eslint-disable-next-line no-console
|
|
96
|
+
console.warn(`[Txlemetry] pushIdentityProvider threw: ${e}. Push subscription will be sent unauthenticated.`);
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
await nativeModule.providePushIdentityToken(request.requestId, token);
|
|
100
|
+
} catch (e) {
|
|
101
|
+
// eslint-disable-next-line no-console
|
|
102
|
+
console.warn(`[Txlemetry] Failed to deliver push identity token to native: ${e}`);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const TxlemetryReactNativePlugin = {
|
|
107
|
+
setup,
|
|
108
|
+
start,
|
|
109
|
+
startSession,
|
|
110
|
+
endSession,
|
|
111
|
+
isEnabled,
|
|
112
|
+
identify,
|
|
113
|
+
reset,
|
|
114
|
+
startRecording,
|
|
115
|
+
stopRecording,
|
|
116
|
+
addExceptionStep,
|
|
117
|
+
registerPushNotificationToken,
|
|
118
|
+
unregisterPushNotificationToken,
|
|
119
|
+
setOptOut,
|
|
120
|
+
capturePushNotificationOpened,
|
|
121
|
+
setPushIdentityProvider
|
|
122
|
+
};
|
|
123
|
+
export default TxlemetryReactNativePlugin;
|
|
124
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export type TxlemetryReactNativePluginMap = {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
};
|
|
4
|
+
export interface TxlemetryReactNativePluginSessionReplayConfig {
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
sdkReplayConfig?: TxlemetryReactNativePluginMap;
|
|
7
|
+
decideReplayConfig?: TxlemetryReactNativePluginMap;
|
|
8
|
+
}
|
|
9
|
+
export interface TxlemetryReactNativePluginExceptionStepsConfig {
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
maxBytes?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface TxlemetryReactNativePluginErrorTrackingConfig {
|
|
14
|
+
nativeAutocapture?: boolean;
|
|
15
|
+
exceptionSteps?: TxlemetryReactNativePluginExceptionStepsConfig;
|
|
16
|
+
}
|
|
17
|
+
export interface TxlemetryReactNativePluginPushConfig {
|
|
18
|
+
capturePushNotificationSubscriptions?: boolean;
|
|
19
|
+
capturePushNotificationOpened?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* A provider callback can't cross the bridge, so this only tells native whether to
|
|
22
|
+
* install the bridging provider at all — installing one the host didn't ask for
|
|
23
|
+
* would change how the native SDK handles a 401 on the subscription call.
|
|
24
|
+
* Pair with {@link setPushIdentityProvider} before calling setup().
|
|
25
|
+
*/
|
|
26
|
+
pushIdentityProviderEnabled?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface TxlemetryReactNativePluginConfig {
|
|
29
|
+
sessionReplay?: TxlemetryReactNativePluginSessionReplayConfig;
|
|
30
|
+
errorTracking?: TxlemetryReactNativePluginErrorTrackingConfig;
|
|
31
|
+
push?: TxlemetryReactNativePluginPushConfig;
|
|
32
|
+
}
|
|
33
|
+
export declare function setup(sessionId: string, sdkOptions: TxlemetryReactNativePluginMap, pluginConfig?: TxlemetryReactNativePluginConfig): Promise<void>;
|
|
34
|
+
export declare function start(sessionId: string, sdkOptions: TxlemetryReactNativePluginMap, sdkReplayConfig: TxlemetryReactNativePluginMap, decideReplayConfig: TxlemetryReactNativePluginMap): Promise<void>;
|
|
35
|
+
export declare function startSession(sessionId: string): Promise<void>;
|
|
36
|
+
export declare function endSession(): Promise<void>;
|
|
37
|
+
export declare function isEnabled(): Promise<boolean>;
|
|
38
|
+
export declare function identify(distinctId: string, anonymousId: string): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Resets the native SDK's identity on logout. Unlike {@link identify}, this calls the native
|
|
41
|
+
* SDK's own `reset()`, which unregisters the logged-out user's push subscription and
|
|
42
|
+
* re-registers it under the new anonymous id.
|
|
43
|
+
*/
|
|
44
|
+
export declare function reset(distinctId: string, anonymousId: string): Promise<void>;
|
|
45
|
+
export declare function startRecording(resumeCurrent: boolean): Promise<void>;
|
|
46
|
+
export declare function stopRecording(): Promise<void>;
|
|
47
|
+
export declare function addExceptionStep(message: string, properties?: TxlemetryReactNativePluginMap): Promise<void>;
|
|
48
|
+
export declare function registerPushNotificationToken(deviceToken: string, appId: string | null): Promise<void>;
|
|
49
|
+
export declare function unregisterPushNotificationToken(): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Propagates a runtime consent change to the native SDK, which otherwise only reads the JS
|
|
52
|
+
* opt-out flag at setup() and could auto-register a refreshed push token after optOut().
|
|
53
|
+
*/
|
|
54
|
+
export declare function setOptOut(optOut: boolean): Promise<void>;
|
|
55
|
+
export declare function capturePushNotificationOpened(properties: TxlemetryReactNativePluginMap): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Mints a signed identity-verification token for a push subscription request.
|
|
58
|
+
* Return null to send the request without an identity token.
|
|
59
|
+
*/
|
|
60
|
+
export type TxlemetryPushIdentityProvider = (distinctId: string, appId: string) => Promise<string | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Installs the JS side of the push identity-provider bridge. The native SDK asks for a
|
|
63
|
+
* token via the native bridge event; the reply is routed back with
|
|
64
|
+
* `providePushIdentityToken`, keyed by the request id so late replies are ignored.
|
|
65
|
+
*
|
|
66
|
+
* Install before setup() with `push.pushIdentityProviderEnabled` set, so the native
|
|
67
|
+
* config gets its bridging provider at SDK initialization. Any provider failure
|
|
68
|
+
* degrades to a null token — an unauthenticated request — never a stalled mint.
|
|
69
|
+
*/
|
|
70
|
+
export declare function setPushIdentityProvider(provider: TxlemetryPushIdentityProvider): void;
|
|
71
|
+
export interface TxlemetryReactNativePluginModule {
|
|
72
|
+
setup: (sessionId: string, sdkOptions: TxlemetryReactNativePluginMap, pluginConfig?: TxlemetryReactNativePluginConfig) => Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Legacy session replay setup entrypoint. Prefer setup() for new native features.
|
|
75
|
+
*/
|
|
76
|
+
start: (sessionId: string, sdkOptions: TxlemetryReactNativePluginMap, sdkReplayConfig: TxlemetryReactNativePluginMap, decideReplayConfig: TxlemetryReactNativePluginMap) => Promise<void>;
|
|
77
|
+
startSession: (sessionId: string) => Promise<void>;
|
|
78
|
+
endSession: () => Promise<void>;
|
|
79
|
+
isEnabled: () => Promise<boolean>;
|
|
80
|
+
identify: (distinctId: string, anonymousId: string) => Promise<void>;
|
|
81
|
+
reset: (distinctId: string, anonymousId: string) => Promise<void>;
|
|
82
|
+
startRecording: (resumeCurrent: boolean) => Promise<void>;
|
|
83
|
+
stopRecording: () => Promise<void>;
|
|
84
|
+
addExceptionStep: (message: string, properties?: TxlemetryReactNativePluginMap) => Promise<void>;
|
|
85
|
+
registerPushNotificationToken: (deviceToken: string, appId: string | null) => Promise<void>;
|
|
86
|
+
unregisterPushNotificationToken: () => Promise<void>;
|
|
87
|
+
setOptOut: (optOut: boolean) => Promise<void>;
|
|
88
|
+
capturePushNotificationOpened: (properties: TxlemetryReactNativePluginMap) => Promise<void>;
|
|
89
|
+
setPushIdentityProvider: (provider: TxlemetryPushIdentityProvider) => void;
|
|
90
|
+
}
|
|
91
|
+
declare const TxlemetryReactNativePlugin: TxlemetryReactNativePluginModule;
|
|
92
|
+
export default TxlemetryReactNativePlugin;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export type TxlemetryReactNativePluginMap = {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
};
|
|
4
|
+
export interface TxlemetryReactNativePluginSessionReplayConfig {
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
sdkReplayConfig?: TxlemetryReactNativePluginMap;
|
|
7
|
+
decideReplayConfig?: TxlemetryReactNativePluginMap;
|
|
8
|
+
}
|
|
9
|
+
export interface TxlemetryReactNativePluginExceptionStepsConfig {
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
maxBytes?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface TxlemetryReactNativePluginErrorTrackingConfig {
|
|
14
|
+
nativeAutocapture?: boolean;
|
|
15
|
+
exceptionSteps?: TxlemetryReactNativePluginExceptionStepsConfig;
|
|
16
|
+
}
|
|
17
|
+
export interface TxlemetryReactNativePluginPushConfig {
|
|
18
|
+
capturePushNotificationSubscriptions?: boolean;
|
|
19
|
+
capturePushNotificationOpened?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* A provider callback can't cross the bridge, so this only tells native whether to
|
|
22
|
+
* install the bridging provider at all — installing one the host didn't ask for
|
|
23
|
+
* would change how the native SDK handles a 401 on the subscription call.
|
|
24
|
+
* Pair with {@link setPushIdentityProvider} before calling setup().
|
|
25
|
+
*/
|
|
26
|
+
pushIdentityProviderEnabled?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface TxlemetryReactNativePluginConfig {
|
|
29
|
+
sessionReplay?: TxlemetryReactNativePluginSessionReplayConfig;
|
|
30
|
+
errorTracking?: TxlemetryReactNativePluginErrorTrackingConfig;
|
|
31
|
+
push?: TxlemetryReactNativePluginPushConfig;
|
|
32
|
+
}
|
|
33
|
+
export declare function setup(sessionId: string, sdkOptions: TxlemetryReactNativePluginMap, pluginConfig?: TxlemetryReactNativePluginConfig): Promise<void>;
|
|
34
|
+
export declare function start(sessionId: string, sdkOptions: TxlemetryReactNativePluginMap, sdkReplayConfig: TxlemetryReactNativePluginMap, decideReplayConfig: TxlemetryReactNativePluginMap): Promise<void>;
|
|
35
|
+
export declare function startSession(sessionId: string): Promise<void>;
|
|
36
|
+
export declare function endSession(): Promise<void>;
|
|
37
|
+
export declare function isEnabled(): Promise<boolean>;
|
|
38
|
+
export declare function identify(distinctId: string, anonymousId: string): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Resets the native SDK's identity on logout. Unlike {@link identify}, this calls the native
|
|
41
|
+
* SDK's own `reset()`, which unregisters the logged-out user's push subscription and
|
|
42
|
+
* re-registers it under the new anonymous id.
|
|
43
|
+
*/
|
|
44
|
+
export declare function reset(distinctId: string, anonymousId: string): Promise<void>;
|
|
45
|
+
export declare function startRecording(resumeCurrent: boolean): Promise<void>;
|
|
46
|
+
export declare function stopRecording(): Promise<void>;
|
|
47
|
+
export declare function addExceptionStep(message: string, properties?: TxlemetryReactNativePluginMap): Promise<void>;
|
|
48
|
+
export declare function registerPushNotificationToken(deviceToken: string, appId: string | null): Promise<void>;
|
|
49
|
+
export declare function unregisterPushNotificationToken(): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Propagates a runtime consent change to the native SDK, which otherwise only reads the JS
|
|
52
|
+
* opt-out flag at setup() and could auto-register a refreshed push token after optOut().
|
|
53
|
+
*/
|
|
54
|
+
export declare function setOptOut(optOut: boolean): Promise<void>;
|
|
55
|
+
export declare function capturePushNotificationOpened(properties: TxlemetryReactNativePluginMap): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Mints a signed identity-verification token for a push subscription request.
|
|
58
|
+
* Return null to send the request without an identity token.
|
|
59
|
+
*/
|
|
60
|
+
export type TxlemetryPushIdentityProvider = (distinctId: string, appId: string) => Promise<string | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Installs the JS side of the push identity-provider bridge. The native SDK asks for a
|
|
63
|
+
* token via the native bridge event; the reply is routed back with
|
|
64
|
+
* `providePushIdentityToken`, keyed by the request id so late replies are ignored.
|
|
65
|
+
*
|
|
66
|
+
* Install before setup() with `push.pushIdentityProviderEnabled` set, so the native
|
|
67
|
+
* config gets its bridging provider at SDK initialization. Any provider failure
|
|
68
|
+
* degrades to a null token — an unauthenticated request — never a stalled mint.
|
|
69
|
+
*/
|
|
70
|
+
export declare function setPushIdentityProvider(provider: TxlemetryPushIdentityProvider): void;
|
|
71
|
+
export interface TxlemetryReactNativePluginModule {
|
|
72
|
+
setup: (sessionId: string, sdkOptions: TxlemetryReactNativePluginMap, pluginConfig?: TxlemetryReactNativePluginConfig) => Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Legacy session replay setup entrypoint. Prefer setup() for new native features.
|
|
75
|
+
*/
|
|
76
|
+
start: (sessionId: string, sdkOptions: TxlemetryReactNativePluginMap, sdkReplayConfig: TxlemetryReactNativePluginMap, decideReplayConfig: TxlemetryReactNativePluginMap) => Promise<void>;
|
|
77
|
+
startSession: (sessionId: string) => Promise<void>;
|
|
78
|
+
endSession: () => Promise<void>;
|
|
79
|
+
isEnabled: () => Promise<boolean>;
|
|
80
|
+
identify: (distinctId: string, anonymousId: string) => Promise<void>;
|
|
81
|
+
reset: (distinctId: string, anonymousId: string) => Promise<void>;
|
|
82
|
+
startRecording: (resumeCurrent: boolean) => Promise<void>;
|
|
83
|
+
stopRecording: () => Promise<void>;
|
|
84
|
+
addExceptionStep: (message: string, properties?: TxlemetryReactNativePluginMap) => Promise<void>;
|
|
85
|
+
registerPushNotificationToken: (deviceToken: string, appId: string | null) => Promise<void>;
|
|
86
|
+
unregisterPushNotificationToken: () => Promise<void>;
|
|
87
|
+
setOptOut: (optOut: boolean) => Promise<void>;
|
|
88
|
+
capturePushNotificationOpened: (properties: TxlemetryReactNativePluginMap) => Promise<void>;
|
|
89
|
+
setPushIdentityProvider: (provider: TxlemetryPushIdentityProvider) => void;
|
|
90
|
+
}
|
|
91
|
+
declare const TxlemetryReactNativePlugin: TxlemetryReactNativePluginModule;
|
|
92
|
+
export default TxlemetryReactNativePlugin;
|
package/package.json
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@txlemetry/react-native-plugin",
|
|
3
|
+
"version": "2.5.1",
|
|
4
|
+
"description": "Txlemetry React Native plugin for iOS and Android integrations",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"android",
|
|
7
|
+
"ios",
|
|
8
|
+
"macos",
|
|
9
|
+
"react-native"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://txlemetry.com",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/hectorvss/Txlemetry/issues"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "Txlemetry",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/hectorvss/Txlemetry.git",
|
|
20
|
+
"directory": "txlemetry-sdk/react-native-plugin"
|
|
21
|
+
},
|
|
22
|
+
"source": "./src/index.tsx",
|
|
23
|
+
"files": [
|
|
24
|
+
"src",
|
|
25
|
+
"lib",
|
|
26
|
+
"android",
|
|
27
|
+
"ios",
|
|
28
|
+
"cpp",
|
|
29
|
+
"txlemetry-react-native-plugin.podspec",
|
|
30
|
+
"!ios/build",
|
|
31
|
+
"!android/build",
|
|
32
|
+
"!android/gradle",
|
|
33
|
+
"!android/gradlew",
|
|
34
|
+
"!android/gradlew.bat",
|
|
35
|
+
"!android/local.properties",
|
|
36
|
+
"!android/src/test",
|
|
37
|
+
"!**/__tests__",
|
|
38
|
+
"!**/__fixtures__",
|
|
39
|
+
"!**/__mocks__",
|
|
40
|
+
"!**/*.map",
|
|
41
|
+
"!**/.*"
|
|
42
|
+
],
|
|
43
|
+
"main": "./lib/commonjs/index.js",
|
|
44
|
+
"module": "./lib/module/index.js",
|
|
45
|
+
"types": "./lib/typescript/module/src/index.d.ts",
|
|
46
|
+
"exports": {
|
|
47
|
+
".": {
|
|
48
|
+
"import": {
|
|
49
|
+
"types": "./lib/typescript/module/src/index.d.ts",
|
|
50
|
+
"default": "./lib/module/index.js"
|
|
51
|
+
},
|
|
52
|
+
"require": {
|
|
53
|
+
"types": "./lib/typescript/commonjs/src/index.d.ts",
|
|
54
|
+
"default": "./lib/commonjs/index.js"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"./package.json": "./package.json"
|
|
58
|
+
},
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"clean": "del-cli android/build lib",
|
|
64
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
65
|
+
"lint:fix": "eslint \"**/*.{js,ts,tsx}\" --fix",
|
|
66
|
+
"typecheck": "tsc",
|
|
67
|
+
"test:unit": "jest --passWithNoTests && node scripts/check-spm-manifest.mjs",
|
|
68
|
+
"test": "pnpm test:unit",
|
|
69
|
+
"build": "bob build",
|
|
70
|
+
"package": "pnpm pack --out $PACKAGE_DEST/%s.tgz"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@react-native-community/cli": "20.0.0",
|
|
74
|
+
"@types/jest": "^29.5.14",
|
|
75
|
+
"@types/react": "^18.2.44",
|
|
76
|
+
"del-cli": "^5.1.0",
|
|
77
|
+
"jest": "29.7.0",
|
|
78
|
+
"react": "18.3.1",
|
|
79
|
+
"react-native": "0.75.3",
|
|
80
|
+
"react-native-builder-bob": "^0.30.2",
|
|
81
|
+
"typescript": "5.8.2"
|
|
82
|
+
},
|
|
83
|
+
"peerDependencies": {
|
|
84
|
+
"react": "*",
|
|
85
|
+
"react-native": "*"
|
|
86
|
+
},
|
|
87
|
+
"jest": {
|
|
88
|
+
"modulePathIgnorePatterns": [
|
|
89
|
+
"<rootDir>/lib/"
|
|
90
|
+
],
|
|
91
|
+
"testPathIgnorePatterns": [
|
|
92
|
+
"/node_modules/",
|
|
93
|
+
"<rootDir>/lib/"
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
"react-native-builder-bob": {
|
|
97
|
+
"source": "src",
|
|
98
|
+
"output": "lib",
|
|
99
|
+
"targets": [
|
|
100
|
+
[
|
|
101
|
+
"commonjs",
|
|
102
|
+
{
|
|
103
|
+
"esm": true
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
[
|
|
107
|
+
"module",
|
|
108
|
+
{
|
|
109
|
+
"esm": true
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
[
|
|
113
|
+
"typescript",
|
|
114
|
+
{
|
|
115
|
+
"project": "tsconfig.build.json",
|
|
116
|
+
"esm": true
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
}
|