@amplitude/session-replay-react-native 0.0.1-beta.2

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.
Files changed (78) hide show
  1. package/AmplitudeSessionReplayReactNative.podspec +45 -0
  2. package/LICENSE +20 -0
  3. package/README.md +101 -0
  4. package/android/build.gradle +101 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +3 -0
  7. package/android/src/main/AndroidManifestNew.xml +2 -0
  8. package/android/src/main/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativeModule.kt +182 -0
  9. package/android/src/main/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativePackage.kt +17 -0
  10. package/android/src/main/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativeViewManager.kt +22 -0
  11. package/ios/AMPNativeSessionReplay.mm +21 -0
  12. package/ios/NativeSessionReplay-Bridging-Header.h +2 -0
  13. package/ios/NativeSessionReplay.swift +150 -0
  14. package/ios/RCTAmpMaskViewManager.m +29 -0
  15. package/lib/commonjs/amp-mask-view.js +9 -0
  16. package/lib/commonjs/amp-mask-view.js.map +1 -0
  17. package/lib/commonjs/index.js +76 -0
  18. package/lib/commonjs/index.js.map +1 -0
  19. package/lib/commonjs/logger.js +42 -0
  20. package/lib/commonjs/logger.js.map +1 -0
  21. package/lib/commonjs/native-module.js +31 -0
  22. package/lib/commonjs/native-module.js.map +1 -0
  23. package/lib/commonjs/plugin-session-replay-config.js +21 -0
  24. package/lib/commonjs/plugin-session-replay-config.js.map +1 -0
  25. package/lib/commonjs/plugin-session-replay.js +150 -0
  26. package/lib/commonjs/plugin-session-replay.js.map +1 -0
  27. package/lib/commonjs/session-replay-config.js +49 -0
  28. package/lib/commonjs/session-replay-config.js.map +1 -0
  29. package/lib/commonjs/session-replay.js +226 -0
  30. package/lib/commonjs/session-replay.js.map +1 -0
  31. package/lib/commonjs/version.js +9 -0
  32. package/lib/commonjs/version.js.map +1 -0
  33. package/lib/module/amp-mask-view.js +3 -0
  34. package/lib/module/amp-mask-view.js.map +1 -0
  35. package/lib/module/index.js +5 -0
  36. package/lib/module/index.js.map +1 -0
  37. package/lib/module/logger.js +35 -0
  38. package/lib/module/logger.js.map +1 -0
  39. package/lib/module/native-module.js +25 -0
  40. package/lib/module/native-module.js.map +1 -0
  41. package/lib/module/plugin-session-replay-config.js +15 -0
  42. package/lib/module/plugin-session-replay-config.js.map +1 -0
  43. package/lib/module/plugin-session-replay.js +144 -0
  44. package/lib/module/plugin-session-replay.js.map +1 -0
  45. package/lib/module/session-replay-config.js +40 -0
  46. package/lib/module/session-replay-config.js.map +1 -0
  47. package/lib/module/session-replay.js +212 -0
  48. package/lib/module/session-replay.js.map +1 -0
  49. package/lib/module/version.js +3 -0
  50. package/lib/module/version.js.map +1 -0
  51. package/lib/typescript/amp-mask-view.d.ts +7 -0
  52. package/lib/typescript/amp-mask-view.d.ts.map +1 -0
  53. package/lib/typescript/index.d.ts +6 -0
  54. package/lib/typescript/index.d.ts.map +1 -0
  55. package/lib/typescript/logger.d.ts +9 -0
  56. package/lib/typescript/logger.d.ts.map +1 -0
  57. package/lib/typescript/native-module.d.ts +87 -0
  58. package/lib/typescript/native-module.d.ts.map +1 -0
  59. package/lib/typescript/plugin-session-replay-config.d.ts +29 -0
  60. package/lib/typescript/plugin-session-replay-config.d.ts.map +1 -0
  61. package/lib/typescript/plugin-session-replay.d.ts +77 -0
  62. package/lib/typescript/plugin-session-replay.d.ts.map +1 -0
  63. package/lib/typescript/session-replay-config.d.ts +80 -0
  64. package/lib/typescript/session-replay-config.d.ts.map +1 -0
  65. package/lib/typescript/session-replay.d.ts +128 -0
  66. package/lib/typescript/session-replay.d.ts.map +1 -0
  67. package/lib/typescript/version.d.ts +2 -0
  68. package/lib/typescript/version.d.ts.map +1 -0
  69. package/package.json +96 -0
  70. package/src/amp-mask-view.tsx +7 -0
  71. package/src/index.tsx +16 -0
  72. package/src/logger.ts +41 -0
  73. package/src/native-module.ts +113 -0
  74. package/src/plugin-session-replay-config.ts +40 -0
  75. package/src/plugin-session-replay.ts +159 -0
  76. package/src/session-replay-config.ts +103 -0
  77. package/src/session-replay.ts +223 -0
  78. package/src/version.ts +2 -0
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VERSION = void 0;
7
+ // Autogenerated by `yarn version-file`. DO NOT EDIT
8
+ const VERSION = exports.VERSION = '0.0.1-beta.2';
9
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["VERSION","exports"],"sourceRoot":"../../src","sources":["version.ts"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG,cAAc","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import { requireNativeComponent } from 'react-native';
2
+ export const AmpMaskView = requireNativeComponent('AMPMaskComponentView');
3
+ //# sourceMappingURL=amp-mask-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["requireNativeComponent","AmpMaskView"],"sourceRoot":"../../src","sources":["amp-mask-view.tsx"],"mappings":"AAAA,SAASA,sBAAsB,QAAwB,cAAc;AAMrE,OAAO,MAAMC,WAAW,GAAGD,sBAAsB,CAAmB,sBAAsB,CAAC","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ export { init, setSessionId, getSessionId, getSessionReplayProperties, flush, start, stop, setDeviceId } from './session-replay';
2
+ export { MaskLevel } from './session-replay-config';
3
+ export { SessionReplayPlugin } from './plugin-session-replay';
4
+ export { AmpMaskView } from './amp-mask-view';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["init","setSessionId","getSessionId","getSessionReplayProperties","flush","start","stop","setDeviceId","MaskLevel","SessionReplayPlugin","AmpMaskView"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SACEA,IAAI,EACJC,YAAY,EACZC,YAAY,EACZC,0BAA0B,EAC1BC,KAAK,EACLC,KAAK,EACLC,IAAI,EACJC,WAAW,QACN,kBAAkB;AACzB,SAAmCC,SAAS,QAAQ,yBAAyB;AAE7E,SAASC,mBAAmB,QAAQ,yBAAyB;AAG7D,SAASC,WAAW,QAAQ,iBAAiB","ignoreList":[]}
@@ -0,0 +1,35 @@
1
+ import { LogLevel } from '@amplitude/analytics-types';
2
+ const PREFIX = 'Amplitude Session Replay ';
3
+ export const createSessionReplayLogger = () => {
4
+ let logLevel = LogLevel.Warn;
5
+ return {
6
+ setLogLevel: function setLogLevel(level) {
7
+ logLevel = level;
8
+ },
9
+ log: function log(...args) {
10
+ if (logLevel < LogLevel.Verbose) {
11
+ return;
12
+ }
13
+ console.log(`${PREFIX}[Log]:`, ...args);
14
+ },
15
+ warn: function warn(...args) {
16
+ if (logLevel < LogLevel.Warn) {
17
+ return;
18
+ }
19
+ console.warn(`${PREFIX}[Warn]:`, ...args);
20
+ },
21
+ error: function error(...args) {
22
+ if (logLevel < LogLevel.Error) {
23
+ return;
24
+ }
25
+ console.error(`${PREFIX}[Error]:`, ...args);
26
+ },
27
+ debug: function debug(...args) {
28
+ if (logLevel < LogLevel.Debug) {
29
+ return;
30
+ }
31
+ console.log(`${PREFIX}[Debug]:`, ...args);
32
+ }
33
+ };
34
+ };
35
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LogLevel","PREFIX","createSessionReplayLogger","logLevel","Warn","setLogLevel","level","log","args","Verbose","console","warn","error","Error","debug","Debug"],"sourceRoot":"../../src","sources":["logger.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,4BAA4B;AAErD,MAAMC,MAAM,GAAG,2BAA2B;AAE1C,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC7C,IAAIC,QAAkB,GAAGH,QAAQ,CAACI,IAAI;EAEtC,OAAO;IACLC,WAAW,EAAE,SAASA,WAAWA,CAACC,KAAe,EAAQ;MACvDH,QAAQ,GAAGG,KAAK;IAClB,CAAC;IAEDC,GAAG,EAAE,SAASA,GAAGA,CAAC,GAAGC,IAAe,EAAQ;MAC1C,IAAIL,QAAQ,GAAGH,QAAQ,CAACS,OAAO,EAAE;QAC/B;MACF;MACAC,OAAO,CAACH,GAAG,CAAC,GAAGN,MAAM,QAAQ,EAAE,GAAGO,IAAI,CAAC;IACzC,CAAC;IAEDG,IAAI,EAAE,SAASA,IAAIA,CAAC,GAAGH,IAAe,EAAQ;MAC5C,IAAIL,QAAQ,GAAGH,QAAQ,CAACI,IAAI,EAAE;QAC5B;MACF;MACAM,OAAO,CAACC,IAAI,CAAC,GAAGV,MAAM,SAAS,EAAE,GAAGO,IAAI,CAAC;IAC3C,CAAC;IAEDI,KAAK,EAAE,SAASA,KAAKA,CAAC,GAAGJ,IAAe,EAAQ;MAC9C,IAAIL,QAAQ,GAAGH,QAAQ,CAACa,KAAK,EAAE;QAC7B;MACF;MACAH,OAAO,CAACE,KAAK,CAAC,GAAGX,MAAM,UAAU,EAAE,GAAGO,IAAI,CAAC;IAC7C,CAAC;IAEDM,KAAK,EAAE,SAASA,KAAKA,CAAC,GAAGN,IAAe,EAAQ;MAC9C,IAAIL,QAAQ,GAAGH,QAAQ,CAACe,KAAK,EAAE;QAC7B;MACF;MACAL,OAAO,CAACH,GAAG,CAAC,GAAGN,MAAM,UAAU,EAAE,GAAGO,IAAI,CAAC;IAC3C;EACF,CAAC;AACH,CAAC","ignoreList":[]}
@@ -0,0 +1,25 @@
1
+ import { NativeModules, Platform } from 'react-native';
2
+ const LINKING_ERROR = `The package '@amplitude/session-replay-react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
3
+ ios: "- You have run 'pod install'\n",
4
+ default: ''
5
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
6
+ export const NativeSessionReplay = NativeModules.AMPNativeSessionReplay ? NativeModules.AMPNativeSessionReplay : new Proxy({}, {
7
+ get() {
8
+ throw new Error(LINKING_ERROR);
9
+ }
10
+ });
11
+
12
+ /**
13
+ * Configuration interface for setting up the native iOS and Android session replay modules.
14
+ * This interface defines all the parameters required to initialize the native session replay functionality.
15
+ */
16
+
17
+ /**
18
+ * Interface defining the native session replay module specification.
19
+ * This interface provides the contract for communication between JavaScript and
20
+ * the native iOS/Android session replay modules through React Native's bridge.
21
+ *
22
+ * All methods are asynchronous and return Promises to handle the bridge communication
23
+ * between JavaScript and native code.
24
+ */
25
+ //# sourceMappingURL=native-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","NativeSessionReplay","AMPNativeSessionReplay","Proxy","get","Error"],"sourceRoot":"../../src","sources":["native-module.ts"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GACjB,iGAAiG,GACjGD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,OAAO,MAAMC,mBAAmB,GAAGN,aAAa,CAACO,sBAAsB,GAClEP,aAAa,CAACO,sBAAsB,GACpC,IAAIC,KAAK,CACR,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CACF,CAA6B;;AAEjC;AACA;AACA;AACA;;AA4BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ import { LogLevel } from '@amplitude/analytics-types';
2
+
3
+ /**
4
+ * Configuration for Session Replay React Native Plugin
5
+ */
6
+
7
+ export const getDefaultSessionReplayPluginConfig = () => {
8
+ return {
9
+ sampleRate: 0,
10
+ enableRemoteConfig: true,
11
+ logLevel: LogLevel.Warn,
12
+ autoStart: true
13
+ };
14
+ };
15
+ //# sourceMappingURL=plugin-session-replay-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LogLevel","getDefaultSessionReplayPluginConfig","sampleRate","enableRemoteConfig","logLevel","Warn","autoStart"],"sourceRoot":"../../src","sources":["plugin-session-replay-config.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,4BAA4B;;AAErD;AACA;AACA;;AA4BA,OAAO,MAAMC,mCAA8E,GAAGA,CAAA,KAAM;EAClG,OAAO;IACLC,UAAU,EAAE,CAAC;IACbC,kBAAkB,EAAE,IAAI;IACxBC,QAAQ,EAAEJ,QAAQ,CAACK,IAAI;IACvBC,SAAS,EAAE;EACb,CAAC;AACH,CAAC","ignoreList":[]}
@@ -0,0 +1,144 @@
1
+ import { getDefaultSessionReplayPluginConfig } from './plugin-session-replay-config';
2
+ import { getSessionId, getSessionReplayProperties, privateInit, setSessionId, start, stop } from './session-replay';
3
+ import { createSessionReplayLogger } from './logger';
4
+
5
+ /**
6
+ * Session Replay Plugin for React Native Amplitude SDK.
7
+ * This plugin automatically handles session replay recording and event correlation.
8
+ *
9
+ * The plugin automatically handles:
10
+ * - Device ID and Session ID management
11
+ * - Session ID changes
12
+ * - Event property collection and tracking
13
+ */
14
+ export class SessionReplayPlugin {
15
+ name = '@amplitude/plugin-session-replay-react-native';
16
+ type = 'enrichment';
17
+ config = null;
18
+ isInitialized = false;
19
+ logger = createSessionReplayLogger();
20
+
21
+ /**
22
+ * Create a new Session Replay Plugin instance.
23
+ *
24
+ * @param config - Configuration options for the session replay plugin
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const sessionReplayPlugin = new SessionReplayPlugin({
29
+ * sampleRate: 0.1,
30
+ * enableRemoteConfig: true,
31
+ * logLevel: LogLevel.Warn,
32
+ * autoStart: true
33
+ * });
34
+ * ```
35
+ */
36
+ constructor(config = {}) {
37
+ this.sessionReplayConfig = {
38
+ ...getDefaultSessionReplayPluginConfig(),
39
+ ...config
40
+ };
41
+ this.logger.setLogLevel(this.sessionReplayConfig.logLevel);
42
+ this.logger.log('Creating SessionReplayPlugin with config: ', this.sessionReplayConfig);
43
+ }
44
+
45
+ /**
46
+ * Set up the Session Replay Plugin with the Amplitude configuration.
47
+ * This method is called automatically by the Amplitude SDK during initialization.
48
+ *
49
+ * @param config - The React Native configuration from the Amplitude SDK
50
+ * @param _ - The React Native client instance (unused)
51
+ * @returns Promise that resolves when setup is complete
52
+ */
53
+ async setup(config, _) {
54
+ this.config = config;
55
+ await privateInit({
56
+ apiKey: config.apiKey,
57
+ deviceId: config.deviceId,
58
+ sessionId: config.sessionId,
59
+ serverZone: config.serverZone,
60
+ sampleRate: this.sessionReplayConfig.sampleRate,
61
+ enableRemoteConfig: this.sessionReplayConfig.enableRemoteConfig,
62
+ logLevel: this.sessionReplayConfig.logLevel,
63
+ autoStart: this.sessionReplayConfig.autoStart
64
+ }, this.logger);
65
+ this.isInitialized = true;
66
+ }
67
+ async execute(event) {
68
+ var _this$config, _this$config2;
69
+ if (!this.isInitialized) {
70
+ return Promise.resolve(event);
71
+ }
72
+
73
+ // On event, synchronize the session id to the what's on the browserConfig (source of truth)
74
+ // Choosing not to read from event object here, concerned about offline/delayed events messing up the state stored
75
+ // in SR.
76
+ if ((_this$config = this.config) !== null && _this$config !== void 0 && _this$config.sessionId && this.config.sessionId !== (await getSessionId())) {
77
+ await setSessionId(this.config.sessionId);
78
+ }
79
+ // Treating config.sessionId as source of truth, if the event's session id doesn't match, the
80
+ // event is not of the current session (offline/late events). In that case, don't tag the events
81
+ if ((_this$config2 = this.config) !== null && _this$config2 !== void 0 && _this$config2.sessionId && this.config.sessionId === event.session_id) {
82
+ const sessionRecordingProperties = await getSessionReplayProperties();
83
+ event.event_properties = {
84
+ ...event.event_properties,
85
+ ...sessionRecordingProperties
86
+ };
87
+ }
88
+ return Promise.resolve(event);
89
+ }
90
+
91
+ /**
92
+ * Start session replay recording.
93
+ * Begins capturing user interactions and screen content for replay.
94
+ *
95
+ * @returns Promise that resolves when recording starts
96
+ */
97
+ async start() {
98
+ if (this.isInitialized) {
99
+ await start();
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Stop session replay recording.
105
+ * Ends the current recording session and processes any captured data.
106
+ *
107
+ * @returns Promise that resolves when recording stops
108
+ */
109
+ async stop() {
110
+ if (this.isInitialized) {
111
+ await stop();
112
+ }
113
+ }
114
+ async teardown() {
115
+ if (this.isInitialized) {
116
+ await stop();
117
+ }
118
+ this.config = null;
119
+ this.isInitialized = false;
120
+ }
121
+
122
+ /**
123
+ * Get session replay properties for manual event correlation.
124
+ * When you send events to Amplitude, call this method to get the most up-to-date session replay properties for the event.
125
+ *
126
+ * @returns Promise that resolves to an object containing session replay metadata
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * const sessionReplayProperties = await plugin.getSessionReplayProperties();
131
+ * analytics.track('Button Clicked', {
132
+ * buttonName: 'submit',
133
+ * ...sessionReplayProperties
134
+ * });
135
+ * ```
136
+ */
137
+ async getSessionReplayProperties() {
138
+ if (!this.isInitialized) {
139
+ return {};
140
+ }
141
+ return getSessionReplayProperties();
142
+ }
143
+ }
144
+ //# sourceMappingURL=plugin-session-replay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getDefaultSessionReplayPluginConfig","getSessionId","getSessionReplayProperties","privateInit","setSessionId","start","stop","createSessionReplayLogger","SessionReplayPlugin","name","type","config","isInitialized","logger","constructor","sessionReplayConfig","setLogLevel","logLevel","log","setup","_","apiKey","deviceId","sessionId","serverZone","sampleRate","enableRemoteConfig","autoStart","execute","event","_this$config","_this$config2","Promise","resolve","session_id","sessionRecordingProperties","event_properties","teardown"],"sourceRoot":"../../src","sources":["plugin-session-replay.ts"],"mappings":"AAOA,SAAoCA,mCAAmC,QAAQ,gCAAgC;AAC/G,SAASC,YAAY,EAAEC,0BAA0B,EAAEC,WAAW,EAAEC,YAAY,EAAEC,KAAK,EAAEC,IAAI,QAAQ,kBAAkB;AACnH,SAASC,yBAAyB,QAAQ,UAAU;;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,MAAMV,0BAA0BA,CAAA,EAAG;IACjC,IAAI,CAAC,IAAI,CAACU,aAAa,EAAE;MACvB,OAAO,CAAC,CAAC;IACX;IACA,OAAOV,0BAA0B,CAAC,CAAC;EACrC;AACF","ignoreList":[]}
@@ -0,0 +1,40 @@
1
+ import { LogLevel } from '@amplitude/analytics-types';
2
+
3
+ /**
4
+ * Masking levels for sensitive content in session replay
5
+ */
6
+ export let MaskLevel = /*#__PURE__*/function (MaskLevel) {
7
+ /**
8
+ * Light masking - minimal content is masked
9
+ */
10
+ MaskLevel["Light"] = "light";
11
+ /**
12
+ * Medium masking - balanced approach to content masking
13
+ */
14
+ MaskLevel["Medium"] = "medium";
15
+ /**
16
+ * Conservative masking - maximum content masking for privacy
17
+ */
18
+ MaskLevel["Conservative"] = "conservative";
19
+ return MaskLevel;
20
+ }({});
21
+
22
+ /**
23
+ * Configuration for Session Replay React Native SDK
24
+ */
25
+
26
+ export const getDefaultConfig = () => {
27
+ return {
28
+ autoStart: true,
29
+ deviceId: null,
30
+ enableRemoteConfig: true,
31
+ logLevel: LogLevel.Warn,
32
+ maskLevel: MaskLevel.Medium,
33
+ optOut: false,
34
+ sampleRate: 0,
35
+ serverZone: 'US',
36
+ sessionId: -1
37
+ };
38
+ };
39
+ export { LogLevel };
40
+ //# sourceMappingURL=session-replay-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LogLevel","MaskLevel","getDefaultConfig","autoStart","deviceId","enableRemoteConfig","logLevel","Warn","maskLevel","Medium","optOut","sampleRate","serverZone","sessionId"],"sourceRoot":"../../src","sources":["session-replay-config.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,4BAA4B;;AAErD;AACA;AACA;AACA,WAAYC,SAAS,0BAATA,SAAS;EACnB;AACF;AACA;EAHYA,SAAS;EAKnB;AACF;AACA;EAPYA,SAAS;EASnB;AACF;AACA;EAXYA,SAAS;EAAA,OAATA,SAAS;AAAA;;AAerB;AACA;AACA;;AAmEA,OAAO,MAAMC,gBAAqE,GAAGA,CAAA,KAAM;EACzF,OAAO;IACLC,SAAS,EAAE,IAAI;IACfC,QAAQ,EAAE,IAAI;IACdC,kBAAkB,EAAE,IAAI;IACxBC,QAAQ,EAAEN,QAAQ,CAACO,IAAI;IACvBC,SAAS,EAAEP,SAAS,CAACQ,MAAM;IAC3BC,MAAM,EAAE,KAAK;IACbC,UAAU,EAAE,CAAC;IACbC,UAAU,EAAE,IAAI;IAChBC,SAAS,EAAE,CAAC;EACd,CAAC;AACH,CAAC;AACD,SAASb,QAAQ","ignoreList":[]}
@@ -0,0 +1,212 @@
1
+ // @refresh reset
2
+
3
+ import { NativeSessionReplay } from './native-module';
4
+ import { getDefaultConfig } from './session-replay-config';
5
+ import { createSessionReplayLogger } from './logger';
6
+ import { VERSION } from './version';
7
+ let fullConfig = null;
8
+ let isInitialized = false;
9
+ let logger = createSessionReplayLogger();
10
+
11
+ /**
12
+ * Configure the SDK and begin collecting replays.
13
+ * This function must be called before any other session replay operations.
14
+ *
15
+ * @param config - Configuration object containing API key, device ID, session ID, and other options
16
+ * @returns Promise that resolves when initialization is complete
17
+ * @throws Error if initialization fails
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * await init({
22
+ * apiKey: 'YOUR_API_KEY',
23
+ * deviceId: 'user-device-id',
24
+ * sessionId: Date.now(),
25
+ * sampleRate: 0.1
26
+ * });
27
+ * ```
28
+ */
29
+ export async function init(config) {
30
+ if (isInitialized) {
31
+ logger.warn('SessionReplay is already initialized');
32
+ return;
33
+ }
34
+ fullConfig = {
35
+ ...getDefaultConfig(),
36
+ ...config
37
+ };
38
+ logger.setLogLevel(fullConfig.logLevel);
39
+ logger.log(`initializing @amplitude/session-replay-react-native version: ${VERSION} with config: `, fullConfig);
40
+ try {
41
+ await NativeSessionReplay.setup(nativeConfig(fullConfig));
42
+ logger.log('SessionReplay initialized');
43
+ isInitialized = true;
44
+ } catch (error) {
45
+ logger.error('Error initializing SessionReplay', error);
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Call whenever the session ID changes.
51
+ * The Session ID you pass to the SDK must match the Session ID sent as event properties to Amplitude.
52
+ *
53
+ * @param sessionId - The new session identifier number
54
+ * @returns Promise that resolves when the session ID is updated
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * await setSessionId(Date.now());
59
+ * ```
60
+ */
61
+ export async function setSessionId(sessionId) {
62
+ if (!isInitialized) {
63
+ logger.warn('SessionReplay is not initialized');
64
+ return;
65
+ }
66
+ await NativeSessionReplay.setSessionId(sessionId);
67
+ }
68
+
69
+ /**
70
+ * Update the device ID used for session replay tracking.
71
+ * The Device ID you pass to the SDK must match the Device ID sent as event properties to Amplitude.
72
+ *
73
+ * @param deviceId - The device identifier string, or null to clear the device ID
74
+ * @returns Promise that resolves when the device ID is updated
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * await setDeviceId('user-device-id');
79
+ * // or clear device ID
80
+ * await setDeviceId(null);
81
+ * ```
82
+ */
83
+ export async function setDeviceId(deviceId) {
84
+ if (!isInitialized) {
85
+ logger.warn('SessionReplay is not initialized');
86
+ return;
87
+ }
88
+ await NativeSessionReplay.setDeviceId(deviceId);
89
+ }
90
+
91
+ /**
92
+ * Get the current session identifier from the session replay SDK.
93
+ *
94
+ * @returns Promise that resolves to the current session ID number, or null if not initialized
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const sessionId = await getSessionId();
99
+ * if (sessionId !== null) {
100
+ * console.log('Current session ID:', sessionId);
101
+ * }
102
+ * ```
103
+ */
104
+ export async function getSessionId() {
105
+ if (!isInitialized) {
106
+ logger.warn('SessionReplay is not initialized');
107
+ return null;
108
+ }
109
+ return await NativeSessionReplay.getSessionId();
110
+ }
111
+
112
+ /**
113
+ * Interface for session replay properties that should be attached to Amplitude events.
114
+ * These properties help correlate events with session recordings.
115
+ */
116
+
117
+ /**
118
+ * When you send events to Amplitude, call this function to get the most up-to-date session replay properties for the event.
119
+ * Collect Session Replay properties to send with other event properties.
120
+ *
121
+ * @returns Promise that resolves to an object containing session replay metadata
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * const sessionReplayProperties = await getSessionReplayProperties();
126
+ * analytics.track('Button Clicked', {
127
+ * buttonName: 'submit',
128
+ * ...sessionReplayProperties // Merge session replay properties
129
+ * });
130
+ * ```
131
+ */
132
+ export async function getSessionReplayProperties() {
133
+ if (!isInitialized) {
134
+ logger.warn('SessionReplay is not initialized');
135
+ return {};
136
+ }
137
+ const properties = await NativeSessionReplay.getSessionReplayProperties();
138
+ return properties;
139
+ }
140
+
141
+ /**
142
+ * Flush any pending session replay data to the server.
143
+ * Forces immediate upload of recorded session data that may be buffered locally.
144
+ *
145
+ * @returns Promise that resolves when the flush operation is complete
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * // Flush data before app termination
150
+ * await flush();
151
+ * ```
152
+ */
153
+ export async function flush() {
154
+ if (!isInitialized) {
155
+ logger.warn('SessionReplay is not initialized');
156
+ return;
157
+ }
158
+ await NativeSessionReplay.flush();
159
+ }
160
+
161
+ /**
162
+ * Start session replay recording.
163
+ * Begins capturing user interactions and screen content for replay.
164
+ * If autoStart is enabled in the configuration, this is called automatically during initialization.
165
+ *
166
+ * @returns Promise that resolves when recording starts
167
+ *
168
+ * @example
169
+ * ```typescript
170
+ * // Start recording manually if autoStart is false
171
+ * await start();
172
+ * ```
173
+ */
174
+ export async function start() {
175
+ if (!isInitialized) {
176
+ logger.warn('SessionReplay is not initialized');
177
+ return;
178
+ }
179
+ await NativeSessionReplay.start();
180
+ }
181
+
182
+ /**
183
+ * Stop session replay recording.
184
+ * Ends the current recording session and processes any captured data.
185
+ *
186
+ * @returns Promise that resolves when recording stops
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * // Stop recording when user logs out or app goes to background
191
+ * await stop();
192
+ * ```
193
+ */
194
+ export async function stop() {
195
+ if (!isInitialized) {
196
+ logger.warn('SessionReplay is not initialized');
197
+ return;
198
+ }
199
+ await NativeSessionReplay.stop();
200
+ }
201
+ function nativeConfig(config) {
202
+ return {
203
+ ...config,
204
+ logLevel: config.logLevel,
205
+ maskLevel: config.maskLevel.toString()
206
+ };
207
+ }
208
+ export async function privateInit(config, newLogger) {
209
+ logger = newLogger;
210
+ return init(config);
211
+ }
212
+ //# sourceMappingURL=session-replay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeSessionReplay","getDefaultConfig","createSessionReplayLogger","VERSION","fullConfig","isInitialized","logger","init","config","warn","setLogLevel","logLevel","log","setup","nativeConfig","error","setSessionId","sessionId","setDeviceId","deviceId","getSessionId","getSessionReplayProperties","properties","flush","start","stop","maskLevel","toString","privateInit","newLogger"],"sourceRoot":"../../src","sources":["session-replay.ts"],"mappings":"AAAA;;AAEA,SAASA,mBAAmB,QAAwC,iBAAiB;AACrF,SAASC,gBAAgB,QAA6B,yBAAyB;AAC/E,SAASC,yBAAyB,QAAQ,UAAU;AACpD,SAASC,OAAO,QAAQ,WAAW;AAEnC,IAAIC,UAAgD,GAAG,IAAI;AAC3D,IAAIC,aAAa,GAAG,KAAK;AACzB,IAAIC,MAAM,GAAGJ,yBAAyB,CAAC,CAAC;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeK,IAAIA,CAACC,MAA2B,EAAiB;EACrE,IAAIH,aAAa,EAAE;IACjBC,MAAM,CAACG,IAAI,CAAC,sCAAsC,CAAC;IACnD;EACF;EAEAL,UAAU,GAAG;IACX,GAAGH,gBAAgB,CAAC,CAAC;IACrB,GAAGO;EACL,CAAC;EAEDF,MAAM,CAACI,WAAW,CAACN,UAAU,CAACO,QAAQ,CAAC;EACvCL,MAAM,CAACM,GAAG,CAAC,gEAAgET,OAAO,gBAAgB,EAAEC,UAAU,CAAC;EAE/G,IAAI;IACF,MAAMJ,mBAAmB,CAACa,KAAK,CAACC,YAAY,CAACV,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U,GAAG,MAAMtB,mBAAmB,CAACqB,0BAA0B,CAAC,CAAC;EACzE,OAAOC,UAAU;AACnB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,KAAKA,CAAA,EAAkB;EAC3C,IAAI,CAAClB,aAAa,EAAE;IAClBC,MAAM,CAACG,IAAI,CAAC,kCAAkC,CAAC;IAC/C;EACF;EACA,MAAMT,mBAAmB,CAACuB,KAAK,CAAC,CAAC;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,KAAKA,CAAA,EAAkB;EAC3C,IAAI,CAACnB,aAAa,EAAE;IAClBC,MAAM,CAACG,IAAI,CAAC,kCAAkC,CAAC;IAC/C;EACF;EACA,MAAMT,mBAAmB,CAACwB,KAAK,CAAC,CAAC;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,IAAIA,CAAA,EAAkB;EAC1C,IAAI,CAACpB,aAAa,EAAE;IAClBC,MAAM,CAACG,IAAI,CAAC,kCAAkC,CAAC;IAC/C;EACF;EACA,MAAMT,mBAAmB,CAACyB,IAAI,CAAC,CAAC;AAClC;AAEA,SAASX,YAAYA,CAACN,MAAqC,EAA6B;EACtF,OAAO;IACL,GAAGA,MAAM;IACTG,QAAQ,EAAEH,MAAM,CAACG,QAAiD;IAClEe,SAAS,EAAElB,MAAM,CAACkB,SAAS,CAACC,QAAQ,CAAC;EACvC,CAAC;AACH;AAEA,OAAO,eAAeC,WAAWA,CAC/BpB,MAA2B,EAC3BqB,SAAuD,EACxC;EACfvB,MAAM,GAAGuB,SAAS;EAClB,OAAOtB,IAAI,CAACC,MAAM,CAAC;AACrB","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ // Autogenerated by `yarn version-file`. DO NOT EDIT
2
+ export const VERSION = '0.0.1-beta.2';
3
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["VERSION"],"sourceRoot":"../../src","sources":["version.ts"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,cAAc","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ import { type ViewProps } from 'react-native';
2
+ interface AmpMaskViewProps extends ViewProps {
3
+ mask: 'amp-mask' | 'amp-unmask' | 'amp-block';
4
+ }
5
+ export declare const AmpMaskView: import("react-native").HostComponent<AmpMaskViewProps>;
6
+ export {};
7
+ //# sourceMappingURL=amp-mask-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amp-mask-view.d.ts","sourceRoot":"","sources":["../../src/amp-mask-view.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAEtE,UAAU,gBAAiB,SAAQ,SAAS;IAC1C,IAAI,EAAE,UAAU,GAAG,YAAY,GAAG,WAAW,CAAC;CAC/C;AAED,eAAO,MAAM,WAAW,wDAAmE,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { init, setSessionId, getSessionId, getSessionReplayProperties, flush, start, stop, setDeviceId, } from './session-replay';
2
+ export { type SessionReplayConfig, MaskLevel } from './session-replay-config';
3
+ export { SessionReplayPlugin } from './plugin-session-replay';
4
+ export type { SessionReplayPluginConfig } from './plugin-session-replay-config';
5
+ export { AmpMaskView } from './amp-mask-view';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,0BAA0B,EAC1B,KAAK,EACL,KAAK,EACL,IAAI,EACJ,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,mBAAmB,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAE9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,YAAY,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAEhF,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { LogLevel } from '@amplitude/analytics-types';
2
+ export declare const createSessionReplayLogger: () => {
3
+ setLogLevel: (level: LogLevel) => void;
4
+ log: (...args: unknown[]) => void;
5
+ warn: (...args: unknown[]) => void;
6
+ error: (...args: unknown[]) => void;
7
+ debug: (...args: unknown[]) => void;
8
+ };
9
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAItD,eAAO,MAAM,yBAAyB;yBAIO,QAAQ,KAAG,IAAI;mBAI7B,OAAO,EAAE,KAAG,IAAI;oBAOd,OAAO,EAAE,KAAG,IAAI;qBAOd,OAAO,EAAE,KAAG,IAAI;qBAOhB,OAAO,EAAE,KAAG,IAAI;CAOlD,CAAC"}