@datadog/mobile-react-native-session-replay 2.0.2-alpha.0
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/DatadogSDKReactNativeSessionReplay.podspec +41 -0
- package/README.md +3 -0
- package/android/build.gradle +239 -0
- package/android/detekt.yml +572 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +11 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/DatadogSDKReactNativeSessionReplayPackage.kt +46 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementation.kt +57 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/NoopTextPropertiesResolver.kt +22 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/ReactNativeSessionReplayExtensionSupport.kt +77 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/ReactTextPropertiesResolver.kt +196 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplaySDKWrapper.kt +24 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/SessionReplayWrapper.kt +22 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/ShadowNodeWrapper.kt +70 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/TextPropertiesResolver.kt +20 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/extensions/LongExt.kt +15 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactMaskInputTextMapper.kt +54 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactMaskTextMapper.kt +55 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactTextMapper.kt +54 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactViewGroupMapper.kt +58 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/ColorUtils.kt +22 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/DrawableUtils.kt +35 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.kt +66 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/ReflectionUtils.kt +30 -0
- package/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/utils/TextViewUtils.kt +40 -0
- package/android/src/newarch/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplay.kt +33 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplay.kt +34 -0
- package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementationTest.kt +105 -0
- package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/ReactNativeSessionReplayExtensionSupportTest.kt +127 -0
- package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/ReactTextPropertiesResolverTest.kt +271 -0
- package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/mappers/ReactViewGroupMapperTest.kt +131 -0
- package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/utils/ColorUtilsTest.kt +42 -0
- package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/utils/DrawableUtilsTest.kt +101 -0
- package/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/utils/TextViewUtilsTest.kt +109 -0
- package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/GenericAssert.kt +69 -0
- package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/MapExt.kt +29 -0
- package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/ReflectUtils.kt +266 -0
- package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/BaseConfigurator.kt +24 -0
- package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/ForgeConfigurator.kt +24 -0
- package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/TextWireframeForgeryFactory.kt +64 -0
- package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/Throwable.kt +31 -0
- package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/ThrowableForgeryFactory.kt +21 -0
- package/android/src/test/kotlin/com/datadog/reactnative/tools/unit/forge/WireframeClipForgeryFactory.kt +25 -0
- package/android/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +1 -0
- package/ios/DatadogSDKReactNativeSessionReplay.xcodeproj/project.pbxproj +272 -0
- package/ios/DatadogSDKReactNativeSessionReplay.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/Sources/DatadogSDKReactNativeSessionReplay.h +8 -0
- package/ios/Sources/DdSessionReplay.h +24 -0
- package/ios/Sources/DdSessionReplay.mm +53 -0
- package/ios/Sources/DdSessionReplayImplementation.swift +70 -0
- package/ios/Sources/RCTTextViewRecorder.swift +157 -0
- package/lib/commonjs/SessionReplay.js +66 -0
- package/lib/commonjs/SessionReplay.js.map +1 -0
- package/lib/commonjs/index.js +26 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/nativeModulesTypes.js +2 -0
- package/lib/commonjs/nativeModulesTypes.js.map +1 -0
- package/lib/commonjs/specs/NativeDdSessionReplay.js +20 -0
- package/lib/commonjs/specs/NativeDdSessionReplay.js.map +1 -0
- package/lib/module/SessionReplay.js +53 -0
- package/lib/module/SessionReplay.js.map +1 -0
- package/lib/module/index.js +8 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/nativeModulesTypes.js +2 -0
- package/lib/module/nativeModulesTypes.js.map +1 -0
- package/lib/module/specs/NativeDdSessionReplay.js +14 -0
- package/lib/module/specs/NativeDdSessionReplay.js.map +1 -0
- package/lib/typescript/SessionReplay.d.ts +34 -0
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/nativeModulesTypes.d.ts +18 -0
- package/lib/typescript/specs/NativeDdSessionReplay.d.ts +15 -0
- package/package.json +90 -0
- package/src/SessionReplay.ts +84 -0
- package/src/__tests__/SessionReplay.test.ts +49 -0
- package/src/index.ts +13 -0
- package/src/nativeModulesTypes.ts +29 -0
- package/src/specs/NativeDdSessionReplay.ts +28 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "SessionReplay", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _SessionReplay.SessionReplay;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "SessionReplayConfiguration", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _SessionReplay.SessionReplayConfiguration;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "SessionReplayPrivacy", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _SessionReplay.SessionReplayPrivacy;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
var _SessionReplay = require("./SessionReplay");
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAMA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport {\n SessionReplay,\n SessionReplayConfiguration,\n SessionReplayPrivacy\n} from './SessionReplay';\n\nexport { SessionReplay, SessionReplayConfiguration, SessionReplayPrivacy };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
12
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
13
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
17
|
+
var _default = _reactNative.TurboModuleRegistry.get('DdSessionReplay');
|
|
18
|
+
|
|
19
|
+
exports.default = _default;
|
|
20
|
+
//# sourceMappingURL=NativeDdSessionReplay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["NativeDdSessionReplay.ts"],"names":["TurboModuleRegistry","get"],"mappings":";;;;;;;AAQA;;AARA;AACA;AACA;AACA;AACA;;AAEA;eAqBeA,iCAAoBC,GAApB,CAA8B,iBAA9B,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n/**\n * Do not import this Spec directly, use NativeSessionReplayType instead.\n */\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n /**\n * Enable session replay and start recording session.\n * @param replaySampleRate: The sample rate applied for session replay.\n * @param defaultPrivacyLevel: The privacy level used for replay.\n */\n enable(\n replaySampleRate: number,\n defaultPrivacyLevel: string\n ): Promise<void>;\n}\n\nexport default TurboModuleRegistry.get<Spec>('DdSessionReplay');\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
5
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
6
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
7
|
+
*/
|
|
8
|
+
export let SessionReplayPrivacy;
|
|
9
|
+
/**
|
|
10
|
+
* The Session Replay configuration object.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
(function (SessionReplayPrivacy) {
|
|
14
|
+
SessionReplayPrivacy["MASK"] = "MASK";
|
|
15
|
+
SessionReplayPrivacy["ALLOW"] = "ALLOW";
|
|
16
|
+
SessionReplayPrivacy["MASK_USER_INPUT"] = "MASK_USER_INPUT";
|
|
17
|
+
})(SessionReplayPrivacy || (SessionReplayPrivacy = {}));
|
|
18
|
+
|
|
19
|
+
const DEFAULTS = {
|
|
20
|
+
replaySampleRate: 0,
|
|
21
|
+
defaultPrivacyLevel: SessionReplayPrivacy.MASK
|
|
22
|
+
};
|
|
23
|
+
export class SessionReplayWrapper {
|
|
24
|
+
constructor() {
|
|
25
|
+
_defineProperty(this, "nativeSessionReplay", require('./specs/NativeDdSessionReplay').default);
|
|
26
|
+
|
|
27
|
+
_defineProperty(this, "buildConfiguration", configuration => {
|
|
28
|
+
if (!configuration) {
|
|
29
|
+
return DEFAULTS;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
replaySampleRate,
|
|
34
|
+
defaultPrivacyLevel
|
|
35
|
+
} = configuration;
|
|
36
|
+
return {
|
|
37
|
+
replaySampleRate: replaySampleRate !== undefined ? replaySampleRate : DEFAULTS.replaySampleRate,
|
|
38
|
+
defaultPrivacyLevel: defaultPrivacyLevel !== undefined ? defaultPrivacyLevel : DEFAULTS.defaultPrivacyLevel
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
_defineProperty(this, "enable", configuration => {
|
|
43
|
+
const {
|
|
44
|
+
replaySampleRate,
|
|
45
|
+
defaultPrivacyLevel
|
|
46
|
+
} = this.buildConfiguration(configuration);
|
|
47
|
+
return this.nativeSessionReplay.enable(replaySampleRate, defaultPrivacyLevel);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
export const SessionReplay = new SessionReplayWrapper();
|
|
53
|
+
//# sourceMappingURL=SessionReplay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["SessionReplay.ts"],"names":["SessionReplayPrivacy","DEFAULTS","replaySampleRate","defaultPrivacyLevel","MASK","SessionReplayWrapper","require","default","configuration","undefined","buildConfiguration","nativeSessionReplay","enable","SessionReplay"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,WAAYA,oBAAZ;AAMA;AACA;AACA;;WARYA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;GAAAA,oB,KAAAA,oB;;AA0BZ,MAAMC,QAAQ,GAAG;AACbC,EAAAA,gBAAgB,EAAE,CADL;AAEbC,EAAAA,mBAAmB,EAAEH,oBAAoB,CAACI;AAF7B,CAAjB;AAKA,OAAO,MAAMC,oBAAN,CAA2B;AAAA;AAAA,iDAEyBC,OAAO,CAAC,+BAAD,CAAP,CAClDC,OAHyB;;AAAA,gDAM1BC,aADyB,IAKxB;AACD,UAAI,CAACA,aAAL,EAAoB;AAChB,eAAOP,QAAP;AACH;;AACD,YAAM;AAAEC,QAAAA,gBAAF;AAAoBC,QAAAA;AAApB,UAA4CK,aAAlD;AACA,aAAO;AACHN,QAAAA,gBAAgB,EACZA,gBAAgB,KAAKO,SAArB,GACMP,gBADN,GAEMD,QAAQ,CAACC,gBAJhB;AAKHC,QAAAA,mBAAmB,EACfA,mBAAmB,KAAKM,SAAxB,GACMN,mBADN,GAEMF,QAAQ,CAACE;AARhB,OAAP;AAUH,KAzB6B;;AAAA,oCA+BpBK,aAAD,IAA+D;AACpE,YAAM;AACFN,QAAAA,gBADE;AAEFC,QAAAA;AAFE,UAGF,KAAKO,kBAAL,CAAwBF,aAAxB,CAHJ;AAKA,aAAO,KAAKG,mBAAL,CAAyBC,MAAzB,CACHV,gBADG,EAEHC,mBAFG,CAAP;AAIH,KAzC6B;AAAA;;AAAA;AA4ClC,OAAO,MAAMU,aAAa,GAAG,IAAIR,oBAAJ,EAAtB","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { NativeSessionReplayType } from './nativeModulesTypes';\n\nexport enum SessionReplayPrivacy {\n MASK = 'MASK',\n ALLOW = 'ALLOW',\n MASK_USER_INPUT = 'MASK_USER_INPUT'\n}\n\n/**\n * The Session Replay configuration object.\n */\nexport interface SessionReplayConfiguration {\n /**\n * The sampling rate for Session Replay.\n * It is applied in addition to the RUM session sample rate.\n * Range `0`-`100`.\n *\n * Default value is `20`.\n */\n replaySampleRate?: number;\n /**\n * Defines the way sensitive content (e.g. text) should be masked.\n *\n * Default `SessionReplayPrivacy.MASK`.\n */\n defaultPrivacyLevel?: SessionReplayPrivacy;\n}\n\nconst DEFAULTS = {\n replaySampleRate: 0,\n defaultPrivacyLevel: SessionReplayPrivacy.MASK\n};\n\nexport class SessionReplayWrapper {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n private nativeSessionReplay: NativeSessionReplayType = require('./specs/NativeDdSessionReplay')\n .default;\n\n private buildConfiguration = (\n configuration?: SessionReplayConfiguration\n ): {\n replaySampleRate: number;\n defaultPrivacyLevel: SessionReplayPrivacy;\n } => {\n if (!configuration) {\n return DEFAULTS;\n }\n const { replaySampleRate, defaultPrivacyLevel } = configuration;\n return {\n replaySampleRate:\n replaySampleRate !== undefined\n ? replaySampleRate\n : DEFAULTS.replaySampleRate,\n defaultPrivacyLevel:\n defaultPrivacyLevel !== undefined\n ? defaultPrivacyLevel\n : DEFAULTS.defaultPrivacyLevel\n };\n };\n\n /**\n * Enable session replay and start recording session.\n * @param configuration: The session replay configuration.\n */\n enable = (configuration?: SessionReplayConfiguration): Promise<void> => {\n const {\n replaySampleRate,\n defaultPrivacyLevel\n } = this.buildConfiguration(configuration);\n\n return this.nativeSessionReplay.enable(\n replaySampleRate,\n defaultPrivacyLevel\n );\n };\n}\n\nexport const SessionReplay = new SessionReplayWrapper();\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
import { SessionReplay, SessionReplayConfiguration, SessionReplayPrivacy } from './SessionReplay';
|
|
7
|
+
export { SessionReplay, SessionReplayConfiguration, SessionReplayPrivacy };
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["SessionReplay","SessionReplayConfiguration","SessionReplayPrivacy"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SACIA,aADJ,EAEIC,0BAFJ,EAGIC,oBAHJ,QAIO,iBAJP;AAMA,SAASF,aAAT,EAAwBC,0BAAxB,EAAoDC,oBAApD","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport {\n SessionReplay,\n SessionReplayConfiguration,\n SessionReplayPrivacy\n} from './SessionReplay';\n\nexport { SessionReplay, SessionReplayConfiguration, SessionReplayPrivacy };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
8
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
9
|
+
/**
|
|
10
|
+
* Do not import this Spec directly, use NativeSessionReplayType instead.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export default TurboModuleRegistry.get('DdSessionReplay');
|
|
14
|
+
//# sourceMappingURL=NativeDdSessionReplay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["NativeDdSessionReplay.ts"],"names":["TurboModuleRegistry","get"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AAEA,SAASA,mBAAT,QAAoC,cAApC;AAEA;AACA;AACA;;AAeA,eAAeA,mBAAmB,CAACC,GAApB,CAA8B,iBAA9B,CAAf","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n/**\n * Do not import this Spec directly, use NativeSessionReplayType instead.\n */\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n /**\n * Enable session replay and start recording session.\n * @param replaySampleRate: The sample rate applied for session replay.\n * @param defaultPrivacyLevel: The privacy level used for replay.\n */\n enable(\n replaySampleRate: number,\n defaultPrivacyLevel: string\n ): Promise<void>;\n}\n\nexport default TurboModuleRegistry.get<Spec>('DdSessionReplay');\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare enum SessionReplayPrivacy {
|
|
2
|
+
MASK = "MASK",
|
|
3
|
+
ALLOW = "ALLOW",
|
|
4
|
+
MASK_USER_INPUT = "MASK_USER_INPUT"
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The Session Replay configuration object.
|
|
8
|
+
*/
|
|
9
|
+
export interface SessionReplayConfiguration {
|
|
10
|
+
/**
|
|
11
|
+
* The sampling rate for Session Replay.
|
|
12
|
+
* It is applied in addition to the RUM session sample rate.
|
|
13
|
+
* Range `0`-`100`.
|
|
14
|
+
*
|
|
15
|
+
* Default value is `20`.
|
|
16
|
+
*/
|
|
17
|
+
replaySampleRate?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Defines the way sensitive content (e.g. text) should be masked.
|
|
20
|
+
*
|
|
21
|
+
* Default `SessionReplayPrivacy.MASK`.
|
|
22
|
+
*/
|
|
23
|
+
defaultPrivacyLevel?: SessionReplayPrivacy;
|
|
24
|
+
}
|
|
25
|
+
export declare class SessionReplayWrapper {
|
|
26
|
+
private nativeSessionReplay;
|
|
27
|
+
private buildConfiguration;
|
|
28
|
+
/**
|
|
29
|
+
* Enable session replay and start recording session.
|
|
30
|
+
* @param configuration: The session replay configuration.
|
|
31
|
+
*/
|
|
32
|
+
enable: (configuration?: SessionReplayConfiguration) => Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
export declare const SessionReplay: SessionReplayWrapper;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Spec as NativeDdSessionReplay } from './specs/NativeDdSessionReplay';
|
|
2
|
+
/**
|
|
3
|
+
* In this file, native modules types extend the specs for TurboModules.
|
|
4
|
+
* As we cannot use enums or classes in the specs, we override methods using them here.
|
|
5
|
+
*/
|
|
6
|
+
declare type PrivacyLevel = 'MASK' | 'MASK_USER_INPUT' | 'ALLOW';
|
|
7
|
+
/**
|
|
8
|
+
* The entry point to use Datadog's Session Replay feature.
|
|
9
|
+
*/
|
|
10
|
+
export interface NativeSessionReplayType extends NativeDdSessionReplay {
|
|
11
|
+
/**
|
|
12
|
+
* Enable session replay and start recording session.
|
|
13
|
+
* @param replaySampleRate: The sample rate applied for session replay.
|
|
14
|
+
* @param defaultPrivacyLevel: The privacy level used for replay.
|
|
15
|
+
*/
|
|
16
|
+
enable(replaySampleRate: number, defaultPrivacyLevel: PrivacyLevel): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* Do not import this Spec directly, use NativeSessionReplayType instead.
|
|
4
|
+
*/
|
|
5
|
+
export interface Spec extends TurboModule {
|
|
6
|
+
readonly getConstants: () => {};
|
|
7
|
+
/**
|
|
8
|
+
* Enable session replay and start recording session.
|
|
9
|
+
* @param replaySampleRate: The sample rate applied for session replay.
|
|
10
|
+
* @param defaultPrivacyLevel: The privacy level used for replay.
|
|
11
|
+
*/
|
|
12
|
+
enable(replaySampleRate: number, defaultPrivacyLevel: string): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
declare const _default: Spec | null;
|
|
15
|
+
export default _default;
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@datadog/mobile-react-native-session-replay",
|
|
3
|
+
"version": "2.0.2-alpha.0",
|
|
4
|
+
"description": "A client-side React Native module to enable session replay with Datadog",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"datadog",
|
|
7
|
+
"react-native",
|
|
8
|
+
"ios",
|
|
9
|
+
"android"
|
|
10
|
+
],
|
|
11
|
+
"author": "Datadog (https://github.com/DataDog)",
|
|
12
|
+
"homepage": "https://github.com/DataDog/dd-sdk-reactnative#readme",
|
|
13
|
+
"repository": "https://github.com/DataDog/dd-sdk-reactnative",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/DataDog/dd-sdk-reactnative/issues"
|
|
16
|
+
},
|
|
17
|
+
"license": "Apache-2.0",
|
|
18
|
+
"main": "lib/commonjs/index",
|
|
19
|
+
"files": [
|
|
20
|
+
"src/**",
|
|
21
|
+
"lib/**",
|
|
22
|
+
"android/build.gradle",
|
|
23
|
+
"android/detekt.yml",
|
|
24
|
+
"android/gradle.properties",
|
|
25
|
+
"android/src/**",
|
|
26
|
+
"ios/Sources/**",
|
|
27
|
+
"ios/DatadogSDKReactNativeSessionReplay.xcodeproj/project.xcworkspace/xcsharedata",
|
|
28
|
+
"ios/DatadogSDKReactNativeSessionReplay.xcodeproj/project.xcworkspace/*.xcworkspacedata",
|
|
29
|
+
"ios/DatadogSDKReactNativeSessionReplay.xcodeproj/*.pbxproj",
|
|
30
|
+
"DatadogSDKReactNativeSessionReplay.podspec"
|
|
31
|
+
],
|
|
32
|
+
"types": "lib/typescript/index.d.ts",
|
|
33
|
+
"react-native": "src/index",
|
|
34
|
+
"source": "src",
|
|
35
|
+
"module": "lib/module/index",
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "restricted"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"test": "jest",
|
|
41
|
+
"lint": "eslint .",
|
|
42
|
+
"prepare": "rm -rf lib && yarn bob build"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"react": ">=16.13.1",
|
|
46
|
+
"react-native": ">=0.63.4 <1.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@testing-library/react-native": "7.0.2",
|
|
50
|
+
"react-native-builder-bob": "0.17.1"
|
|
51
|
+
},
|
|
52
|
+
"jest": {
|
|
53
|
+
"preset": "react-native",
|
|
54
|
+
"moduleNameMapper": {
|
|
55
|
+
"@datadog/mobile-react-native": "<rootDir>../core/src"
|
|
56
|
+
},
|
|
57
|
+
"modulePathIgnorePatterns": [
|
|
58
|
+
"<rootDir>/lib/"
|
|
59
|
+
],
|
|
60
|
+
"setupFiles": [
|
|
61
|
+
"./../../node_modules/react-native-gesture-handler/jestSetup.js",
|
|
62
|
+
"./../../jest.setup.js"
|
|
63
|
+
],
|
|
64
|
+
"transformIgnorePatterns": [
|
|
65
|
+
"jest-runner"
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
"react-native-builder-bob": {
|
|
69
|
+
"source": "src",
|
|
70
|
+
"output": "lib",
|
|
71
|
+
"targets": [
|
|
72
|
+
"commonjs",
|
|
73
|
+
"module",
|
|
74
|
+
[
|
|
75
|
+
"typescript",
|
|
76
|
+
{
|
|
77
|
+
"tsc": "./../../node_modules/.bin/tsc"
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
"codegenConfig": {
|
|
83
|
+
"name": "DatadogSDKReactNativeSessionReplay",
|
|
84
|
+
"type": "modules",
|
|
85
|
+
"jsSrcsDir": "./src/specs",
|
|
86
|
+
"android": {
|
|
87
|
+
"javaPackageName": "com.datadog.reactnative.sessionreplay"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { NativeSessionReplayType } from './nativeModulesTypes';
|
|
8
|
+
|
|
9
|
+
export enum SessionReplayPrivacy {
|
|
10
|
+
MASK = 'MASK',
|
|
11
|
+
ALLOW = 'ALLOW',
|
|
12
|
+
MASK_USER_INPUT = 'MASK_USER_INPUT'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The Session Replay configuration object.
|
|
17
|
+
*/
|
|
18
|
+
export interface SessionReplayConfiguration {
|
|
19
|
+
/**
|
|
20
|
+
* The sampling rate for Session Replay.
|
|
21
|
+
* It is applied in addition to the RUM session sample rate.
|
|
22
|
+
* Range `0`-`100`.
|
|
23
|
+
*
|
|
24
|
+
* Default value is `20`.
|
|
25
|
+
*/
|
|
26
|
+
replaySampleRate?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Defines the way sensitive content (e.g. text) should be masked.
|
|
29
|
+
*
|
|
30
|
+
* Default `SessionReplayPrivacy.MASK`.
|
|
31
|
+
*/
|
|
32
|
+
defaultPrivacyLevel?: SessionReplayPrivacy;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const DEFAULTS = {
|
|
36
|
+
replaySampleRate: 0,
|
|
37
|
+
defaultPrivacyLevel: SessionReplayPrivacy.MASK
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export class SessionReplayWrapper {
|
|
41
|
+
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
42
|
+
private nativeSessionReplay: NativeSessionReplayType = require('./specs/NativeDdSessionReplay')
|
|
43
|
+
.default;
|
|
44
|
+
|
|
45
|
+
private buildConfiguration = (
|
|
46
|
+
configuration?: SessionReplayConfiguration
|
|
47
|
+
): {
|
|
48
|
+
replaySampleRate: number;
|
|
49
|
+
defaultPrivacyLevel: SessionReplayPrivacy;
|
|
50
|
+
} => {
|
|
51
|
+
if (!configuration) {
|
|
52
|
+
return DEFAULTS;
|
|
53
|
+
}
|
|
54
|
+
const { replaySampleRate, defaultPrivacyLevel } = configuration;
|
|
55
|
+
return {
|
|
56
|
+
replaySampleRate:
|
|
57
|
+
replaySampleRate !== undefined
|
|
58
|
+
? replaySampleRate
|
|
59
|
+
: DEFAULTS.replaySampleRate,
|
|
60
|
+
defaultPrivacyLevel:
|
|
61
|
+
defaultPrivacyLevel !== undefined
|
|
62
|
+
? defaultPrivacyLevel
|
|
63
|
+
: DEFAULTS.defaultPrivacyLevel
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Enable session replay and start recording session.
|
|
69
|
+
* @param configuration: The session replay configuration.
|
|
70
|
+
*/
|
|
71
|
+
enable = (configuration?: SessionReplayConfiguration): Promise<void> => {
|
|
72
|
+
const {
|
|
73
|
+
replaySampleRate,
|
|
74
|
+
defaultPrivacyLevel
|
|
75
|
+
} = this.buildConfiguration(configuration);
|
|
76
|
+
|
|
77
|
+
return this.nativeSessionReplay.enable(
|
|
78
|
+
replaySampleRate,
|
|
79
|
+
defaultPrivacyLevel
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const SessionReplay = new SessionReplayWrapper();
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { NativeModules } from 'react-native';
|
|
8
|
+
|
|
9
|
+
import { SessionReplay, SessionReplayPrivacy } from '../SessionReplay';
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
NativeModules.DdSessionReplay.enable.mockClear();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe('SessionReplay', () => {
|
|
16
|
+
describe('enable', () => {
|
|
17
|
+
it('calls native session replay with default configuration', () => {
|
|
18
|
+
SessionReplay.enable();
|
|
19
|
+
|
|
20
|
+
expect(NativeModules.DdSessionReplay.enable).toHaveBeenCalledWith(
|
|
21
|
+
0,
|
|
22
|
+
'MASK'
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('calls native session replay with provided configuration', () => {
|
|
27
|
+
SessionReplay.enable({
|
|
28
|
+
replaySampleRate: 100,
|
|
29
|
+
defaultPrivacyLevel: SessionReplayPrivacy.ALLOW
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
expect(NativeModules.DdSessionReplay.enable).toHaveBeenCalledWith(
|
|
33
|
+
100,
|
|
34
|
+
'ALLOW'
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('calls native session replay with edge cases in configuration', () => {
|
|
39
|
+
SessionReplay.enable({
|
|
40
|
+
replaySampleRate: 0
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
expect(NativeModules.DdSessionReplay.enable).toHaveBeenCalledWith(
|
|
44
|
+
0,
|
|
45
|
+
'MASK'
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
SessionReplay,
|
|
9
|
+
SessionReplayConfiguration,
|
|
10
|
+
SessionReplayPrivacy
|
|
11
|
+
} from './SessionReplay';
|
|
12
|
+
|
|
13
|
+
export { SessionReplay, SessionReplayConfiguration, SessionReplayPrivacy };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { Spec as NativeDdSessionReplay } from './specs/NativeDdSessionReplay';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* In this file, native modules types extend the specs for TurboModules.
|
|
11
|
+
* As we cannot use enums or classes in the specs, we override methods using them here.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
type PrivacyLevel = 'MASK' | 'MASK_USER_INPUT' | 'ALLOW';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The entry point to use Datadog's Session Replay feature.
|
|
18
|
+
*/
|
|
19
|
+
export interface NativeSessionReplayType extends NativeDdSessionReplay {
|
|
20
|
+
/**
|
|
21
|
+
* Enable session replay and start recording session.
|
|
22
|
+
* @param replaySampleRate: The sample rate applied for session replay.
|
|
23
|
+
* @param defaultPrivacyLevel: The privacy level used for replay.
|
|
24
|
+
*/
|
|
25
|
+
enable(
|
|
26
|
+
replaySampleRate: number,
|
|
27
|
+
defaultPrivacyLevel: PrivacyLevel
|
|
28
|
+
): Promise<void>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
8
|
+
import type { TurboModule } from 'react-native';
|
|
9
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Do not import this Spec directly, use NativeSessionReplayType instead.
|
|
13
|
+
*/
|
|
14
|
+
export interface Spec extends TurboModule {
|
|
15
|
+
readonly getConstants: () => {};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Enable session replay and start recording session.
|
|
19
|
+
* @param replaySampleRate: The sample rate applied for session replay.
|
|
20
|
+
* @param defaultPrivacyLevel: The privacy level used for replay.
|
|
21
|
+
*/
|
|
22
|
+
enable(
|
|
23
|
+
replaySampleRate: number,
|
|
24
|
+
defaultPrivacyLevel: string
|
|
25
|
+
): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default TurboModuleRegistry.get<Spec>('DdSessionReplay');
|