@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.
- package/AmplitudeSessionReplayReactNative.podspec +45 -0
- package/LICENSE +20 -0
- package/README.md +101 -0
- package/android/build.gradle +101 -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/amplitude/sessionreplayreactnative/SessionReplayReactNativeModule.kt +182 -0
- package/android/src/main/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativePackage.kt +17 -0
- package/android/src/main/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativeViewManager.kt +22 -0
- package/ios/AMPNativeSessionReplay.mm +21 -0
- package/ios/NativeSessionReplay-Bridging-Header.h +2 -0
- package/ios/NativeSessionReplay.swift +150 -0
- package/ios/RCTAmpMaskViewManager.m +29 -0
- package/lib/commonjs/amp-mask-view.js +9 -0
- package/lib/commonjs/amp-mask-view.js.map +1 -0
- package/lib/commonjs/index.js +76 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/logger.js +42 -0
- package/lib/commonjs/logger.js.map +1 -0
- package/lib/commonjs/native-module.js +31 -0
- package/lib/commonjs/native-module.js.map +1 -0
- package/lib/commonjs/plugin-session-replay-config.js +21 -0
- package/lib/commonjs/plugin-session-replay-config.js.map +1 -0
- package/lib/commonjs/plugin-session-replay.js +150 -0
- package/lib/commonjs/plugin-session-replay.js.map +1 -0
- package/lib/commonjs/session-replay-config.js +49 -0
- package/lib/commonjs/session-replay-config.js.map +1 -0
- package/lib/commonjs/session-replay.js +226 -0
- package/lib/commonjs/session-replay.js.map +1 -0
- package/lib/commonjs/version.js +9 -0
- package/lib/commonjs/version.js.map +1 -0
- package/lib/module/amp-mask-view.js +3 -0
- package/lib/module/amp-mask-view.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/logger.js +35 -0
- package/lib/module/logger.js.map +1 -0
- package/lib/module/native-module.js +25 -0
- package/lib/module/native-module.js.map +1 -0
- package/lib/module/plugin-session-replay-config.js +15 -0
- package/lib/module/plugin-session-replay-config.js.map +1 -0
- package/lib/module/plugin-session-replay.js +144 -0
- package/lib/module/plugin-session-replay.js.map +1 -0
- package/lib/module/session-replay-config.js +40 -0
- package/lib/module/session-replay-config.js.map +1 -0
- package/lib/module/session-replay.js +212 -0
- package/lib/module/session-replay.js.map +1 -0
- package/lib/module/version.js +3 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/amp-mask-view.d.ts +7 -0
- package/lib/typescript/amp-mask-view.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +6 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/logger.d.ts +9 -0
- package/lib/typescript/logger.d.ts.map +1 -0
- package/lib/typescript/native-module.d.ts +87 -0
- package/lib/typescript/native-module.d.ts.map +1 -0
- package/lib/typescript/plugin-session-replay-config.d.ts +29 -0
- package/lib/typescript/plugin-session-replay-config.d.ts.map +1 -0
- package/lib/typescript/plugin-session-replay.d.ts +77 -0
- package/lib/typescript/plugin-session-replay.d.ts.map +1 -0
- package/lib/typescript/session-replay-config.d.ts +80 -0
- package/lib/typescript/session-replay-config.d.ts.map +1 -0
- package/lib/typescript/session-replay.d.ts +128 -0
- package/lib/typescript/session-replay.d.ts.map +1 -0
- package/lib/typescript/version.d.ts +2 -0
- package/lib/typescript/version.d.ts.map +1 -0
- package/package.json +96 -0
- package/src/amp-mask-view.tsx +7 -0
- package/src/index.tsx +16 -0
- package/src/logger.ts +41 -0
- package/src/native-module.ts +113 -0
- package/src/plugin-session-replay-config.ts +40 -0
- package/src/plugin-session-replay.ts +159 -0
- package/src/session-replay-config.ts +103 -0
- package/src/session-replay.ts +223 -0
- package/src/version.ts +2 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#import <React/RCTViewManager.h>
|
|
2
|
+
#import <React/RCTView.h>
|
|
3
|
+
@import AmplitudeSessionReplay;
|
|
4
|
+
|
|
5
|
+
@interface AMPMaskComponentViewManager : RCTViewManager
|
|
6
|
+
@end
|
|
7
|
+
|
|
8
|
+
@implementation AMPMaskComponentViewManager
|
|
9
|
+
|
|
10
|
+
RCT_EXPORT_MODULE(AMPMaskComponentView)
|
|
11
|
+
|
|
12
|
+
- (UIView *)view
|
|
13
|
+
{
|
|
14
|
+
return [[RCTView alloc] init];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
RCT_CUSTOM_VIEW_PROPERTY(mask, NSString, RCTView)
|
|
18
|
+
{
|
|
19
|
+
NSString* mask = [RCTConvert NSString:json];
|
|
20
|
+
if ([mask isEqualToString:@"amp-mask"]) {
|
|
21
|
+
view.amp_isBlocked = true;
|
|
22
|
+
} else if ([mask isEqualToString:@"amp-block"]) {
|
|
23
|
+
view.amp_isBlocked = true;
|
|
24
|
+
} else if ([mask isEqualToString:@"amp-unmask"]) {
|
|
25
|
+
view.amp_isBlocked = false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AmpMaskView = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
const AmpMaskView = exports.AmpMaskView = (0, _reactNative.requireNativeComponent)('AMPMaskComponentView');
|
|
9
|
+
//# sourceMappingURL=amp-mask-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","AmpMaskView","exports","requireNativeComponent"],"sourceRoot":"../../src","sources":["amp-mask-view.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMO,MAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,IAAAE,mCAAsB,EAAmB,sBAAsB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "AmpMaskView", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ampMaskView.AmpMaskView;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "MaskLevel", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _sessionReplayConfig.MaskLevel;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "SessionReplayPlugin", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _pluginSessionReplay.SessionReplayPlugin;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "flush", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _sessionReplay.flush;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "getSessionId", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _sessionReplay.getSessionId;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "getSessionReplayProperties", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _sessionReplay.getSessionReplayProperties;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "init", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _sessionReplay.init;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "setDeviceId", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _sessionReplay.setDeviceId;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "setSessionId", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _sessionReplay.setSessionId;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "start", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _sessionReplay.start;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "stop", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _sessionReplay.stop;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
var _sessionReplay = require("./session-replay");
|
|
73
|
+
var _sessionReplayConfig = require("./session-replay-config");
|
|
74
|
+
var _pluginSessionReplay = require("./plugin-session-replay");
|
|
75
|
+
var _ampMaskView = require("./amp-mask-view");
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_sessionReplay","require","_sessionReplayConfig","_pluginSessionReplay","_ampMaskView"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAUA,IAAAC,oBAAA,GAAAD,OAAA;AAEA,IAAAE,oBAAA,GAAAF,OAAA;AAGA,IAAAG,YAAA,GAAAH,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createSessionReplayLogger = void 0;
|
|
7
|
+
var _analyticsTypes = require("@amplitude/analytics-types");
|
|
8
|
+
const PREFIX = 'Amplitude Session Replay ';
|
|
9
|
+
const createSessionReplayLogger = () => {
|
|
10
|
+
let logLevel = _analyticsTypes.LogLevel.Warn;
|
|
11
|
+
return {
|
|
12
|
+
setLogLevel: function setLogLevel(level) {
|
|
13
|
+
logLevel = level;
|
|
14
|
+
},
|
|
15
|
+
log: function log(...args) {
|
|
16
|
+
if (logLevel < _analyticsTypes.LogLevel.Verbose) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
console.log(`${PREFIX}[Log]:`, ...args);
|
|
20
|
+
},
|
|
21
|
+
warn: function warn(...args) {
|
|
22
|
+
if (logLevel < _analyticsTypes.LogLevel.Warn) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
console.warn(`${PREFIX}[Warn]:`, ...args);
|
|
26
|
+
},
|
|
27
|
+
error: function error(...args) {
|
|
28
|
+
if (logLevel < _analyticsTypes.LogLevel.Error) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
console.error(`${PREFIX}[Error]:`, ...args);
|
|
32
|
+
},
|
|
33
|
+
debug: function debug(...args) {
|
|
34
|
+
if (logLevel < _analyticsTypes.LogLevel.Debug) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
console.log(`${PREFIX}[Debug]:`, ...args);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.createSessionReplayLogger = createSessionReplayLogger;
|
|
42
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_analyticsTypes","require","PREFIX","createSessionReplayLogger","logLevel","LogLevel","Warn","setLogLevel","level","log","args","Verbose","console","warn","error","Error","debug","Debug","exports"],"sourceRoot":"../../src","sources":["logger.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA,MAAMC,MAAM,GAAG,2BAA2B;AAEnC,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC7C,IAAIC,QAAkB,G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
+
var _reactNative = require("react-native");
|
|
8
|
+
const LINKING_ERROR = `The package '@amplitude/session-replay-react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
9
|
+
ios: "- You have run 'pod install'\n",
|
|
10
|
+
default: ''
|
|
11
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
12
|
+
const NativeSessionReplay = exports.NativeSessionReplay = _reactNative.NativeModules.AMPNativeSessionReplay ? _reactNative.NativeModules.AMPNativeSessionReplay : new Proxy({}, {
|
|
13
|
+
get() {
|
|
14
|
+
throw new Error(LINKING_ERROR);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Configuration interface for setting up the native iOS and Android session replay modules.
|
|
20
|
+
* This interface defines all the parameters required to initialize the native session replay functionality.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Interface defining the native session replay module specification.
|
|
25
|
+
* This interface provides the contract for communication between JavaScript and
|
|
26
|
+
* the native iOS/Android session replay modules through React Native's bridge.
|
|
27
|
+
*
|
|
28
|
+
* All methods are asynchronous and return Promises to handle the bridge communication
|
|
29
|
+
* between JavaScript and native code.
|
|
30
|
+
*/
|
|
31
|
+
//# sourceMappingURL=native-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","NativeSessionReplay","exports","NativeModules","AMPNativeSessionReplay","Proxy","get","Error"],"sourceRoot":"../../src","sources":["native-module.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GACjB,iGAAiG,GACjGC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAE1B,MAAMC,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAGE,0BAAa,CAACC,sBAAsB,GAClED,0BAAa,CAACC,sBAAsB,GACpC,IAAIC,KAAK,CACR,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACX,aAAa,CAAC;EAChC;AACF,CACF,CAA6B;;AAEjC;AACA;AACA;AACA;;AA4BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getDefaultSessionReplayPluginConfig = void 0;
|
|
7
|
+
var _analyticsTypes = require("@amplitude/analytics-types");
|
|
8
|
+
/**
|
|
9
|
+
* Configuration for Session Replay React Native Plugin
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const getDefaultSessionReplayPluginConfig = () => {
|
|
13
|
+
return {
|
|
14
|
+
sampleRate: 0,
|
|
15
|
+
enableRemoteConfig: true,
|
|
16
|
+
logLevel: _analyticsTypes.LogLevel.Warn,
|
|
17
|
+
autoStart: true
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.getDefaultSessionReplayPluginConfig = getDefaultSessionReplayPluginConfig;
|
|
21
|
+
//# sourceMappingURL=plugin-session-replay-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_analyticsTypes","require","getDefaultSessionReplayPluginConfig","sampleRate","enableRemoteConfig","logLevel","LogLevel","Warn","autoStart","exports"],"sourceRoot":"../../src","sources":["plugin-session-replay-config.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA;AACA;AACA;;AA4BO,MAAMC,mCAA8E,GAAGA,CAAA,KAAM;EAClG,OAAO;IACLC,UAAU,EAAE,CAAC;IACbC,kBAAkB,EAAE,IAAI;IACxBC,QAAQ,EAAEC,wBAAQ,CAACC,IAAI;IACvBC,SAAS,EAAE;EACb,CAAC;AACH,CAAC;AAACC,OAAA,CAAAP,mCAAA,GAAAA,mCAAA","ignoreList":[]}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SessionReplayPlugin = void 0;
|
|
7
|
+
var _pluginSessionReplayConfig = require("./plugin-session-replay-config");
|
|
8
|
+
var _sessionReplay = require("./session-replay");
|
|
9
|
+
var _logger = require("./logger");
|
|
10
|
+
/**
|
|
11
|
+
* Session Replay Plugin for React Native Amplitude SDK.
|
|
12
|
+
* This plugin automatically handles session replay recording and event correlation.
|
|
13
|
+
*
|
|
14
|
+
* The plugin automatically handles:
|
|
15
|
+
* - Device ID and Session ID management
|
|
16
|
+
* - Session ID changes
|
|
17
|
+
* - Event property collection and tracking
|
|
18
|
+
*/
|
|
19
|
+
class SessionReplayPlugin {
|
|
20
|
+
name = '@amplitude/plugin-session-replay-react-native';
|
|
21
|
+
type = 'enrichment';
|
|
22
|
+
config = null;
|
|
23
|
+
isInitialized = false;
|
|
24
|
+
logger = (0, _logger.createSessionReplayLogger)();
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Create a new Session Replay Plugin instance.
|
|
28
|
+
*
|
|
29
|
+
* @param config - Configuration options for the session replay plugin
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const sessionReplayPlugin = new SessionReplayPlugin({
|
|
34
|
+
* sampleRate: 0.1,
|
|
35
|
+
* enableRemoteConfig: true,
|
|
36
|
+
* logLevel: LogLevel.Warn,
|
|
37
|
+
* autoStart: true
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
constructor(config = {}) {
|
|
42
|
+
this.sessionReplayConfig = {
|
|
43
|
+
...(0, _pluginSessionReplayConfig.getDefaultSessionReplayPluginConfig)(),
|
|
44
|
+
...config
|
|
45
|
+
};
|
|
46
|
+
this.logger.setLogLevel(this.sessionReplayConfig.logLevel);
|
|
47
|
+
this.logger.log('Creating SessionReplayPlugin with config: ', this.sessionReplayConfig);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Set up the Session Replay Plugin with the Amplitude configuration.
|
|
52
|
+
* This method is called automatically by the Amplitude SDK during initialization.
|
|
53
|
+
*
|
|
54
|
+
* @param config - The React Native configuration from the Amplitude SDK
|
|
55
|
+
* @param _ - The React Native client instance (unused)
|
|
56
|
+
* @returns Promise that resolves when setup is complete
|
|
57
|
+
*/
|
|
58
|
+
async setup(config, _) {
|
|
59
|
+
this.config = config;
|
|
60
|
+
await (0, _sessionReplay.privateInit)({
|
|
61
|
+
apiKey: config.apiKey,
|
|
62
|
+
deviceId: config.deviceId,
|
|
63
|
+
sessionId: config.sessionId,
|
|
64
|
+
serverZone: config.serverZone,
|
|
65
|
+
sampleRate: this.sessionReplayConfig.sampleRate,
|
|
66
|
+
enableRemoteConfig: this.sessionReplayConfig.enableRemoteConfig,
|
|
67
|
+
logLevel: this.sessionReplayConfig.logLevel,
|
|
68
|
+
autoStart: this.sessionReplayConfig.autoStart
|
|
69
|
+
}, this.logger);
|
|
70
|
+
this.isInitialized = true;
|
|
71
|
+
}
|
|
72
|
+
async execute(event) {
|
|
73
|
+
var _this$config, _this$config2;
|
|
74
|
+
if (!this.isInitialized) {
|
|
75
|
+
return Promise.resolve(event);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// On event, synchronize the session id to the what's on the browserConfig (source of truth)
|
|
79
|
+
// Choosing not to read from event object here, concerned about offline/delayed events messing up the state stored
|
|
80
|
+
// in SR.
|
|
81
|
+
if ((_this$config = this.config) !== null && _this$config !== void 0 && _this$config.sessionId && this.config.sessionId !== (await (0, _sessionReplay.getSessionId)())) {
|
|
82
|
+
await (0, _sessionReplay.setSessionId)(this.config.sessionId);
|
|
83
|
+
}
|
|
84
|
+
// Treating config.sessionId as source of truth, if the event's session id doesn't match, the
|
|
85
|
+
// event is not of the current session (offline/late events). In that case, don't tag the events
|
|
86
|
+
if ((_this$config2 = this.config) !== null && _this$config2 !== void 0 && _this$config2.sessionId && this.config.sessionId === event.session_id) {
|
|
87
|
+
const sessionRecordingProperties = await (0, _sessionReplay.getSessionReplayProperties)();
|
|
88
|
+
event.event_properties = {
|
|
89
|
+
...event.event_properties,
|
|
90
|
+
...sessionRecordingProperties
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return Promise.resolve(event);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Start session replay recording.
|
|
98
|
+
* Begins capturing user interactions and screen content for replay.
|
|
99
|
+
*
|
|
100
|
+
* @returns Promise that resolves when recording starts
|
|
101
|
+
*/
|
|
102
|
+
async start() {
|
|
103
|
+
if (this.isInitialized) {
|
|
104
|
+
await (0, _sessionReplay.start)();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Stop session replay recording.
|
|
110
|
+
* Ends the current recording session and processes any captured data.
|
|
111
|
+
*
|
|
112
|
+
* @returns Promise that resolves when recording stops
|
|
113
|
+
*/
|
|
114
|
+
async stop() {
|
|
115
|
+
if (this.isInitialized) {
|
|
116
|
+
await (0, _sessionReplay.stop)();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async teardown() {
|
|
120
|
+
if (this.isInitialized) {
|
|
121
|
+
await (0, _sessionReplay.stop)();
|
|
122
|
+
}
|
|
123
|
+
this.config = null;
|
|
124
|
+
this.isInitialized = false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Get session replay properties for manual event correlation.
|
|
129
|
+
* When you send events to Amplitude, call this method to get the most up-to-date session replay properties for the event.
|
|
130
|
+
*
|
|
131
|
+
* @returns Promise that resolves to an object containing session replay metadata
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* const sessionReplayProperties = await plugin.getSessionReplayProperties();
|
|
136
|
+
* analytics.track('Button Clicked', {
|
|
137
|
+
* buttonName: 'submit',
|
|
138
|
+
* ...sessionReplayProperties
|
|
139
|
+
* });
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
async getSessionReplayProperties() {
|
|
143
|
+
if (!this.isInitialized) {
|
|
144
|
+
return {};
|
|
145
|
+
}
|
|
146
|
+
return (0, _sessionReplay.getSessionReplayProperties)();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.SessionReplayPlugin = SessionReplayPlugin;
|
|
150
|
+
//# sourceMappingURL=plugin-session-replay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_pluginSessionReplayConfig","require","_sessionReplay","_logger","SessionReplayPlugin","name","type","config","isInitialized","logger","createSessionReplayLogger","constructor","sessionReplayConfig","getDefaultSessionReplayPluginConfig","setLogLevel","logLevel","log","setup","_","privateInit","apiKey","deviceId","sessionId","serverZone","sampleRate","enableRemoteConfig","autoStart","execute","event","_this$config","_this$config2","Promise","resolve","getSessionId","setSessionId","session_id","sessionRecordingProperties","getSessionReplayProperties","event_properties","start","stop","teardown","exports"],"sourceRoot":"../../src","sources":["plugin-session-replay.ts"],"mappings":";;;;;;AAOA,IAAAA,0BAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,mBAAmB,CAAmE;EACjGC,IAAI,GAAG,+CAA+C;EACtDC,IAAI,GAAG,YAAY;EAEXC,MAAM,GAA6B,IAAI;EACvCC,aAAa,GAAG,KAAK;EAGrBC,MAAM,GAAG,IAAAC,iCAAyB,EAAC,CAAC;;EAE5C;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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O,IAAA6B,yCAA0B,EAAC,CAAC;EACrC;AACF;AAACK,OAAA,CAAAtC,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "LogLevel", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _analyticsTypes.LogLevel;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.getDefaultConfig = exports.MaskLevel = void 0;
|
|
13
|
+
var _analyticsTypes = require("@amplitude/analytics-types");
|
|
14
|
+
/**
|
|
15
|
+
* Masking levels for sensitive content in session replay
|
|
16
|
+
*/
|
|
17
|
+
let MaskLevel = exports.MaskLevel = /*#__PURE__*/function (MaskLevel) {
|
|
18
|
+
/**
|
|
19
|
+
* Light masking - minimal content is masked
|
|
20
|
+
*/
|
|
21
|
+
MaskLevel["Light"] = "light";
|
|
22
|
+
/**
|
|
23
|
+
* Medium masking - balanced approach to content masking
|
|
24
|
+
*/
|
|
25
|
+
MaskLevel["Medium"] = "medium";
|
|
26
|
+
/**
|
|
27
|
+
* Conservative masking - maximum content masking for privacy
|
|
28
|
+
*/
|
|
29
|
+
MaskLevel["Conservative"] = "conservative";
|
|
30
|
+
return MaskLevel;
|
|
31
|
+
}({});
|
|
32
|
+
/**
|
|
33
|
+
* Configuration for Session Replay React Native SDK
|
|
34
|
+
*/
|
|
35
|
+
const getDefaultConfig = () => {
|
|
36
|
+
return {
|
|
37
|
+
autoStart: true,
|
|
38
|
+
deviceId: null,
|
|
39
|
+
enableRemoteConfig: true,
|
|
40
|
+
logLevel: _analyticsTypes.LogLevel.Warn,
|
|
41
|
+
maskLevel: MaskLevel.Medium,
|
|
42
|
+
optOut: false,
|
|
43
|
+
sampleRate: 0,
|
|
44
|
+
serverZone: 'US',
|
|
45
|
+
sessionId: -1
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
exports.getDefaultConfig = getDefaultConfig;
|
|
49
|
+
//# sourceMappingURL=session-replay-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_analyticsTypes","require","MaskLevel","exports","getDefaultConfig","autoStart","deviceId","enableRemoteConfig","logLevel","LogLevel","Warn","maskLevel","Medium","optOut","sampleRate","serverZone","sessionId"],"sourceRoot":"../../src","sources":["session-replay-config.ts"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA;AACA;AACA;AAFA,IAGYC,SAAS,GAAAC,OAAA,CAAAD,SAAA,0BAATA,SAAS;EACnB;AACF;AACA;EAHYA,SAAS;EAKnB;AACF;AACA;EAPYA,SAAS;EASnB;AACF;AACA;EAXYA,SAAS;EAAA,OAATA,SAAS;AAAA;AAerB;AACA;AACA;AAmEO,MAAME,gBAAqE,GAAGA,CAAA,KAAM;EACzF,OAAO;IACLC,SAAS,EAAE,IAAI;IACfC,QAAQ,EAAE,IAAI;IACdC,kBAAkB,EAAE,IAAI;IACxBC,QAAQ,EAAEC,wBAAQ,CAACC,IAAI;IACvBC,SAAS,EAAET,SAAS,CAACU,MAAM;IAC3BC,MAAM,EAAE,KAAK;IACbC,UAAU,EAAE,CAAC;IACbC,UAAU,EAAE,IAAI;IAChBC,SAAS,EAAE,CAAC;EACd,CAAC;AACH,CAAC;AAACb,OAAA,CAAAC,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.flush = flush;
|
|
7
|
+
exports.getSessionId = getSessionId;
|
|
8
|
+
exports.getSessionReplayProperties = getSessionReplayProperties;
|
|
9
|
+
exports.init = init;
|
|
10
|
+
exports.privateInit = privateInit;
|
|
11
|
+
exports.setDeviceId = setDeviceId;
|
|
12
|
+
exports.setSessionId = setSessionId;
|
|
13
|
+
exports.start = start;
|
|
14
|
+
exports.stop = stop;
|
|
15
|
+
var _nativeModule = require("./native-module");
|
|
16
|
+
var _sessionReplayConfig = require("./session-replay-config");
|
|
17
|
+
var _logger = require("./logger");
|
|
18
|
+
var _version = require("./version");
|
|
19
|
+
// @refresh reset
|
|
20
|
+
|
|
21
|
+
let fullConfig = null;
|
|
22
|
+
let isInitialized = false;
|
|
23
|
+
let logger = (0, _logger.createSessionReplayLogger)();
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Configure the SDK and begin collecting replays.
|
|
27
|
+
* This function must be called before any other session replay operations.
|
|
28
|
+
*
|
|
29
|
+
* @param config - Configuration object containing API key, device ID, session ID, and other options
|
|
30
|
+
* @returns Promise that resolves when initialization is complete
|
|
31
|
+
* @throws Error if initialization fails
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* await init({
|
|
36
|
+
* apiKey: 'YOUR_API_KEY',
|
|
37
|
+
* deviceId: 'user-device-id',
|
|
38
|
+
* sessionId: Date.now(),
|
|
39
|
+
* sampleRate: 0.1
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
async function init(config) {
|
|
44
|
+
if (isInitialized) {
|
|
45
|
+
logger.warn('SessionReplay is already initialized');
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
fullConfig = {
|
|
49
|
+
...(0, _sessionReplayConfig.getDefaultConfig)(),
|
|
50
|
+
...config
|
|
51
|
+
};
|
|
52
|
+
logger.setLogLevel(fullConfig.logLevel);
|
|
53
|
+
logger.log(`initializing @amplitude/session-replay-react-native version: ${_version.VERSION} with config: `, fullConfig);
|
|
54
|
+
try {
|
|
55
|
+
await _nativeModule.NativeSessionReplay.setup(nativeConfig(fullConfig));
|
|
56
|
+
logger.log('SessionReplay initialized');
|
|
57
|
+
isInitialized = true;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
logger.error('Error initializing SessionReplay', error);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Call whenever the session ID changes.
|
|
65
|
+
* The Session ID you pass to the SDK must match the Session ID sent as event properties to Amplitude.
|
|
66
|
+
*
|
|
67
|
+
* @param sessionId - The new session identifier number
|
|
68
|
+
* @returns Promise that resolves when the session ID is updated
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* await setSessionId(Date.now());
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
async function setSessionId(sessionId) {
|
|
76
|
+
if (!isInitialized) {
|
|
77
|
+
logger.warn('SessionReplay is not initialized');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
await _nativeModule.NativeSessionReplay.setSessionId(sessionId);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Update the device ID used for session replay tracking.
|
|
85
|
+
* The Device ID you pass to the SDK must match the Device ID sent as event properties to Amplitude.
|
|
86
|
+
*
|
|
87
|
+
* @param deviceId - The device identifier string, or null to clear the device ID
|
|
88
|
+
* @returns Promise that resolves when the device ID is updated
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* await setDeviceId('user-device-id');
|
|
93
|
+
* // or clear device ID
|
|
94
|
+
* await setDeviceId(null);
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
async function setDeviceId(deviceId) {
|
|
98
|
+
if (!isInitialized) {
|
|
99
|
+
logger.warn('SessionReplay is not initialized');
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
await _nativeModule.NativeSessionReplay.setDeviceId(deviceId);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get the current session identifier from the session replay SDK.
|
|
107
|
+
*
|
|
108
|
+
* @returns Promise that resolves to the current session ID number, or null if not initialized
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const sessionId = await getSessionId();
|
|
113
|
+
* if (sessionId !== null) {
|
|
114
|
+
* console.log('Current session ID:', sessionId);
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
async function getSessionId() {
|
|
119
|
+
if (!isInitialized) {
|
|
120
|
+
logger.warn('SessionReplay is not initialized');
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
return await _nativeModule.NativeSessionReplay.getSessionId();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Interface for session replay properties that should be attached to Amplitude events.
|
|
128
|
+
* These properties help correlate events with session recordings.
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* When you send events to Amplitude, call this function to get the most up-to-date session replay properties for the event.
|
|
133
|
+
* Collect Session Replay properties to send with other event properties.
|
|
134
|
+
*
|
|
135
|
+
* @returns Promise that resolves to an object containing session replay metadata
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const sessionReplayProperties = await getSessionReplayProperties();
|
|
140
|
+
* analytics.track('Button Clicked', {
|
|
141
|
+
* buttonName: 'submit',
|
|
142
|
+
* ...sessionReplayProperties // Merge session replay properties
|
|
143
|
+
* });
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
async function getSessionReplayProperties() {
|
|
147
|
+
if (!isInitialized) {
|
|
148
|
+
logger.warn('SessionReplay is not initialized');
|
|
149
|
+
return {};
|
|
150
|
+
}
|
|
151
|
+
const properties = await _nativeModule.NativeSessionReplay.getSessionReplayProperties();
|
|
152
|
+
return properties;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Flush any pending session replay data to the server.
|
|
157
|
+
* Forces immediate upload of recorded session data that may be buffered locally.
|
|
158
|
+
*
|
|
159
|
+
* @returns Promise that resolves when the flush operation is complete
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* // Flush data before app termination
|
|
164
|
+
* await flush();
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
async function flush() {
|
|
168
|
+
if (!isInitialized) {
|
|
169
|
+
logger.warn('SessionReplay is not initialized');
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
await _nativeModule.NativeSessionReplay.flush();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Start session replay recording.
|
|
177
|
+
* Begins capturing user interactions and screen content for replay.
|
|
178
|
+
* If autoStart is enabled in the configuration, this is called automatically during initialization.
|
|
179
|
+
*
|
|
180
|
+
* @returns Promise that resolves when recording starts
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```typescript
|
|
184
|
+
* // Start recording manually if autoStart is false
|
|
185
|
+
* await start();
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
async function start() {
|
|
189
|
+
if (!isInitialized) {
|
|
190
|
+
logger.warn('SessionReplay is not initialized');
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
await _nativeModule.NativeSessionReplay.start();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Stop session replay recording.
|
|
198
|
+
* Ends the current recording session and processes any captured data.
|
|
199
|
+
*
|
|
200
|
+
* @returns Promise that resolves when recording stops
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```typescript
|
|
204
|
+
* // Stop recording when user logs out or app goes to background
|
|
205
|
+
* await stop();
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
async function stop() {
|
|
209
|
+
if (!isInitialized) {
|
|
210
|
+
logger.warn('SessionReplay is not initialized');
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
await _nativeModule.NativeSessionReplay.stop();
|
|
214
|
+
}
|
|
215
|
+
function nativeConfig(config) {
|
|
216
|
+
return {
|
|
217
|
+
...config,
|
|
218
|
+
logLevel: config.logLevel,
|
|
219
|
+
maskLevel: config.maskLevel.toString()
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
async function privateInit(config, newLogger) {
|
|
223
|
+
logger = newLogger;
|
|
224
|
+
return init(config);
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=session-replay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_nativeModule","require","_sessionReplayConfig","_logger","_version","fullConfig","isInitialized","logger","createSessionReplayLogger","init","config","warn","getDefaultConfig","setLogLevel","logLevel","log","VERSION","NativeSessionReplay","setup","nativeConfig","error","setSessionId","sessionId","setDeviceId","deviceId","getSessionId","getSessionReplayProperties","properties","flush","start","stop","maskLevel","toString","privateInit","newLogger"],"sourceRoot":"../../src","sources":["session-replay.ts"],"mappings":";;;;;;;;;;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AALA;;AAOA,IAAII,UAAgD,GAAG,IAAI;AAC3D,IAAIC,aAAa,GAAG,KAAK;AACzB,IAAIC,MAAM,GAAG,IAAAC,iCAAyB,EAAC,CAAC;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeC,IAAIA,CAACC,MAA2B,EAAiB;EACrE,IAAIJ,aAAa,EAAE;IACjBC,MAAM,CAACI,IAAI,CAAC,sCAAsC,CAAC;IACnD;EACF;EAEAN,UAAU,GAAG;IACX,GAAG,IAAAO,qCAAgB,EAAC,CAAC;IACrB,GAAGF;EACL,CAAC;EAEDH,MAAM,CAACM,WAAW,CAACR,UAAU,CAACS,QAAQ,CAAC;EACvCP,MAAM,CAAC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