@amplitude/session-replay-react-native 0.0.1-beta.3 → 0.1.0-beta.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/AmplitudeSessionReplayReactNative.podspec +3 -3
- package/README.md +13 -0
- package/android/build.gradle +24 -18
- package/android/src/main/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativeModule.kt +16 -11
- package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativePackage.kt +40 -0
- package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativeSpec.kt +7 -0
- package/android/src/{main → oldarch}/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativePackage.kt +2 -1
- package/android/src/oldarch/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativeSpec.kt +20 -0
- package/ios/AMPNativeSessionReplay.mm +20 -0
- package/lib/commonjs/index.js +0 -7
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native-module.js +10 -1
- package/lib/commonjs/native-module.js.map +1 -1
- package/lib/commonjs/session-replay-config.js +27 -18
- package/lib/commonjs/session-replay-config.js.map +1 -1
- package/lib/commonjs/session-replay.js +52 -4
- package/lib/commonjs/session-replay.js.map +1 -1
- package/lib/commonjs/specs/NativeAmpSessionReplay.js +22 -0
- package/lib/commonjs/specs/NativeAmpSessionReplay.js.map +1 -0
- package/lib/commonjs/version.js +1 -2
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/native-module.js +10 -2
- package/lib/module/native-module.js.map +1 -1
- package/lib/module/session-replay-config.js +24 -17
- package/lib/module/session-replay-config.js.map +1 -1
- package/lib/module/session-replay.js +52 -4
- package/lib/module/session-replay.js.map +1 -1
- package/lib/module/specs/NativeAmpSessionReplay.js +18 -0
- package/lib/module/specs/NativeAmpSessionReplay.js.map +1 -0
- package/lib/module/version.js +1 -2
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/amp-mask-view.d.ts +1 -1
- package/lib/typescript/amp-mask-view.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/native-module.d.ts.map +1 -1
- package/lib/typescript/session-replay-config.d.ts +31 -16
- package/lib/typescript/session-replay-config.d.ts.map +1 -1
- package/lib/typescript/session-replay.d.ts.map +1 -1
- package/lib/typescript/specs/NativeAmpSessionReplay.d.ts +15 -0
- package/lib/typescript/specs/NativeAmpSessionReplay.d.ts.map +1 -0
- package/lib/typescript/version.d.ts +1 -1
- package/lib/typescript/version.d.ts.map +1 -1
- package/package.json +27 -20
- package/src/index.tsx +1 -1
- package/src/native-module.ts +16 -10
- package/src/session-replay-config.ts +39 -17
- package/src/session-replay.ts +42 -7
- package/src/specs/NativeAmpSessionReplay.ts +29 -0
- package/src/version.ts +1 -2
package/src/session-replay.ts
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
// @refresh reset
|
|
2
2
|
|
|
3
3
|
import { NativeSessionReplay, type NativeSessionReplayConfig } from './native-module';
|
|
4
|
-
import { getDefaultConfig, SessionReplayConfig } from './session-replay-config';
|
|
4
|
+
import { getDefaultConfig, SessionReplayConfig, SessionReplayConfigInternal } from './session-replay-config';
|
|
5
5
|
import { createSessionReplayLogger } from './logger';
|
|
6
6
|
import { VERSION } from './version';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
type ResolvedSessionReplayConfig = Required<SessionReplayConfigInternal>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Translates the public `SessionReplayConfig` into the internal shape by
|
|
12
|
+
* folding the deprecated top-level `maskLevel` into `privacyConfig`. After
|
|
13
|
+
* this step, the rest of the SDK only ever sees `privacyConfig`.
|
|
14
|
+
*
|
|
15
|
+
* `privacyConfig` wins when explicitly set; otherwise translate the
|
|
16
|
+
* deprecated `maskLevel`; otherwise leave the field out so the default
|
|
17
|
+
* supplied by `getDefaultConfig()` survives the shallow merge in `init()`.
|
|
18
|
+
*/
|
|
19
|
+
function normalizeConfig(config: SessionReplayConfig): SessionReplayConfigInternal {
|
|
20
|
+
const { maskLevel, privacyConfig, ...rest } = config;
|
|
21
|
+
if (privacyConfig !== undefined) {
|
|
22
|
+
return { ...rest, privacyConfig };
|
|
23
|
+
}
|
|
24
|
+
if (maskLevel !== undefined) {
|
|
25
|
+
return { ...rest, privacyConfig: { maskLevel } };
|
|
26
|
+
}
|
|
27
|
+
return rest;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let fullConfig: ResolvedSessionReplayConfig | null = null;
|
|
9
31
|
let isInitialized = false;
|
|
10
32
|
let logger = createSessionReplayLogger();
|
|
11
33
|
|
|
@@ -33,9 +55,13 @@ export async function init(config: SessionReplayConfig): Promise<void> {
|
|
|
33
55
|
return;
|
|
34
56
|
}
|
|
35
57
|
|
|
58
|
+
// TODO: this is a shallow merge — a user-supplied `privacyConfig` replaces
|
|
59
|
+
// the default object wholesale. That's fine while `PrivacyConfig` only
|
|
60
|
+
// carries `maskLevel`, but if it ever grows more fields a deeper merge will
|
|
61
|
+
// be needed so partial user configs don't drop defaults.
|
|
36
62
|
fullConfig = {
|
|
37
63
|
...getDefaultConfig(),
|
|
38
|
-
...config,
|
|
64
|
+
...normalizeConfig(config),
|
|
39
65
|
};
|
|
40
66
|
|
|
41
67
|
logger.setLogLevel(fullConfig.logLevel);
|
|
@@ -206,11 +232,20 @@ export async function stop(): Promise<void> {
|
|
|
206
232
|
await NativeSessionReplay.stop();
|
|
207
233
|
}
|
|
208
234
|
|
|
209
|
-
function nativeConfig(config:
|
|
235
|
+
function nativeConfig(config: ResolvedSessionReplayConfig): NativeSessionReplayConfig {
|
|
236
|
+
// Resolve the effective mask level here — the single source of truth for the
|
|
237
|
+
// default. `normalizeConfig()` already folded the deprecated top-level
|
|
238
|
+
// `maskLevel` into `privacyConfig`, but `privacyConfig.maskLevel` can still be
|
|
239
|
+
// `undefined` (no user value and no baked-in default), so fall back to
|
|
240
|
+
// `'medium'`. Strip `privacyConfig` from the spread because the native bridge
|
|
241
|
+
// only takes a flat `maskLevel` string.
|
|
242
|
+
const { privacyConfig, ...rest } = config;
|
|
243
|
+
const resolvedMaskLevel: NativeSessionReplayConfig['maskLevel'] = privacyConfig.maskLevel ?? 'medium';
|
|
210
244
|
return {
|
|
211
|
-
...
|
|
212
|
-
logLevel:
|
|
213
|
-
|
|
245
|
+
...rest,
|
|
246
|
+
logLevel: rest.logLevel as NativeSessionReplayConfig['logLevel'],
|
|
247
|
+
// TODO(SDKRN-15): Migrate native bridge to accept the full privacyConfig object instead of a flat maskLevel string.
|
|
248
|
+
maskLevel: resolvedMaskLevel,
|
|
214
249
|
};
|
|
215
250
|
}
|
|
216
251
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
// The codegen types live in a Flow-typed file that eslint-plugin-import cannot parse.
|
|
4
|
+
// eslint-disable-next-line import/namespace
|
|
5
|
+
import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
|
|
6
|
+
|
|
7
|
+
// Codegen TurboModule spec for the imperative Session Replay module.
|
|
8
|
+
//
|
|
9
|
+
// The config crosses the bridge as an untyped object: the native side already
|
|
10
|
+
// reads a ReadableMap / NSDictionary, and app-boundary type safety lives in the
|
|
11
|
+
// public `SessionReplayConfig`. See native-module.ts for the typed facade that
|
|
12
|
+
// JS callers actually use.
|
|
13
|
+
export interface Spec extends TurboModule {
|
|
14
|
+
setup(config: UnsafeObject): Promise<void>;
|
|
15
|
+
setSessionId(sessionId: number): Promise<void>;
|
|
16
|
+
setDeviceId(deviceId: string | null): Promise<void>;
|
|
17
|
+
getSessionId(): Promise<number>;
|
|
18
|
+
getSessionReplayProperties(): Promise<UnsafeObject>;
|
|
19
|
+
start(): Promise<void>;
|
|
20
|
+
stop(): Promise<void>;
|
|
21
|
+
flush(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Use non-enforcing `get` (returns null when the native module isn't linked)
|
|
25
|
+
// so importing the package never crashes app startup. The typed facade in
|
|
26
|
+
// native-module.ts throws a friendly linking error lazily on first use instead.
|
|
27
|
+
// Works on both architectures: JSI on the New Architecture, legacy NativeModules
|
|
28
|
+
// fallback on the old one.
|
|
29
|
+
export default TurboModuleRegistry.get<Spec>('AMPNativeSessionReplay');
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export const VERSION = '0.0.1-beta.3';
|
|
1
|
+
export const VERSION = '0.1.0-beta.1';
|