react-native-clarity 0.0.5 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -3
- package/android/build.gradle +1 -1
- package/android/gradle.properties +3 -2
- package/android/src/main/java/com/microsoft/clarity/reactnative/ClarityModule.kt +10 -0
- package/lib/commonjs/index.js +31 -6
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +29 -6
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +36 -6
package/README.md
CHANGED
|
@@ -11,9 +11,7 @@ npm install react-native-clarity
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
|
-
import { initialize } from 'react-native-clarity';
|
|
15
|
-
import { setCustomUserId } from 'react-native-clarity';
|
|
16
|
-
import { getCurrentSessionId } from 'react-native-clarity';
|
|
14
|
+
import { initialize, setCustomUserId, getCurrentSessionId, setCurrentScreenName, setCustomTag } from 'react-native-clarity';
|
|
17
15
|
|
|
18
16
|
// Initialize Clarity.
|
|
19
17
|
initialize("<ProjectId>");
|
|
@@ -21,8 +19,26 @@ initialize("<ProjectId>");
|
|
|
21
19
|
// Set custom user id.
|
|
22
20
|
setCustomUserId("react@native.com");
|
|
23
21
|
|
|
22
|
+
// Set custom tag.
|
|
23
|
+
setCustomTag("key", "value");
|
|
24
|
+
|
|
24
25
|
// Get current session id to correlate with other tools.
|
|
25
26
|
getCurrentSessionId().then((id) => {...});
|
|
27
|
+
|
|
28
|
+
// Setting the current screen name when using React Navigation
|
|
29
|
+
import { ..., useFocusEffect } from '@react-navigation/native';
|
|
30
|
+
|
|
31
|
+
const HomeScreen = ({...}) => {
|
|
32
|
+
useFocusEffect(
|
|
33
|
+
React.useCallback(() => {
|
|
34
|
+
setCurrentScreenName("Home");
|
|
35
|
+
|
|
36
|
+
// To clear the current screen name when the screen goes out of focus:
|
|
37
|
+
return () => { setCurrentScreenName(undefined); }
|
|
38
|
+
}, [])
|
|
39
|
+
);
|
|
40
|
+
...
|
|
41
|
+
};
|
|
26
42
|
```
|
|
27
43
|
|
|
28
44
|
### Initialization arguments
|
package/android/build.gradle
CHANGED
|
@@ -69,7 +69,7 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
|
69
69
|
dependencies {
|
|
70
70
|
implementation "com.facebook.react:react-native:+"
|
|
71
71
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
72
|
-
implementation "com.microsoft.clarity:clarity:1.3.
|
|
72
|
+
implementation "com.microsoft.clarity:clarity:1.3.3"
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
if (isNewArchitectureEnabled()) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
#make sure these are acutally used
|
|
1
2
|
Clarity_kotlinVersion=1.7.0
|
|
2
3
|
Clarity_minSdkVersion=21
|
|
3
|
-
Clarity_targetSdkVersion=
|
|
4
|
-
Clarity_compileSdkVersion=
|
|
4
|
+
Clarity_targetSdkVersion=33
|
|
5
|
+
Clarity_compileSdkVersion=33
|
|
5
6
|
Clarity_ndkversion=21.4.7075529
|
|
6
7
|
android.useAndroidX=true
|
|
@@ -46,6 +46,16 @@ class ClarityModule(reactContext: ReactApplicationContext) :
|
|
|
46
46
|
promise.resolve(Clarity.getCurrentSessionId())
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
@ReactMethod
|
|
50
|
+
fun setCurrentScreenName(screenName: String?, promise: Promise) {
|
|
51
|
+
promise.resolve(Clarity.setCurrentScreenName(screenName))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@ReactMethod
|
|
55
|
+
fun setCustomTag(key: String?, value: String?, promise: Promise) {
|
|
56
|
+
promise.resolve(Clarity.setCustomTag(key, value))
|
|
57
|
+
}
|
|
58
|
+
|
|
49
59
|
private fun readableArrayToList(arr: ReadableArray): List<String> {
|
|
50
60
|
val ret = mutableListOf<String>()
|
|
51
61
|
|
package/lib/commonjs/index.js
CHANGED
|
@@ -5,12 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getCurrentSessionId = getCurrentSessionId;
|
|
7
7
|
exports.initialize = initialize;
|
|
8
|
+
exports.setCurrentScreenName = setCurrentScreenName;
|
|
9
|
+
exports.setCustomTag = setCustomTag;
|
|
8
10
|
exports.setCustomUserId = setCustomUserId;
|
|
9
11
|
var _reactNative = require("react-native");
|
|
10
12
|
const LINKING_ERROR = `The package 'react-native-clarity' doesn't seem to be linked. Make sure: \n\n` +
|
|
11
13
|
// Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) + TODO: add back when iOS is supported.
|
|
12
14
|
'- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
13
15
|
const Clarity = _reactNative.NativeModules.Clarity;
|
|
16
|
+
const SupportedPlatforms = ['android'];
|
|
14
17
|
|
|
15
18
|
/**
|
|
16
19
|
* Initializes the Clarity plugin with the provided parameters.
|
|
@@ -32,8 +35,8 @@ function initialize(projectId, userId) {
|
|
|
32
35
|
let allowMeteredNetworkUsage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
33
36
|
let enableWebViewCapture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
34
37
|
let allowedDomains = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : ["*"];
|
|
35
|
-
if (_reactNative.Platform.OS
|
|
36
|
-
console.warn("Clarity supports
|
|
38
|
+
if (!SupportedPlatforms.includes(_reactNative.Platform.OS)) {
|
|
39
|
+
console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
|
|
37
40
|
return;
|
|
38
41
|
}
|
|
39
42
|
if (Clarity === null) {
|
|
@@ -54,8 +57,8 @@ function initialize(projectId, userId) {
|
|
|
54
57
|
* @param customUserId The custom user id to set.
|
|
55
58
|
*/
|
|
56
59
|
function setCustomUserId(customUserId) {
|
|
57
|
-
if (_reactNative.Platform.OS
|
|
58
|
-
console.warn("Clarity supports
|
|
60
|
+
if (!SupportedPlatforms.includes(_reactNative.Platform.OS)) {
|
|
61
|
+
console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
|
|
59
62
|
return;
|
|
60
63
|
}
|
|
61
64
|
if (Clarity === null) {
|
|
@@ -71,8 +74,8 @@ function setCustomUserId(customUserId) {
|
|
|
71
74
|
* @returns a promise that resolves to the current session id.
|
|
72
75
|
*/
|
|
73
76
|
function getCurrentSessionId() {
|
|
74
|
-
if (_reactNative.Platform.OS
|
|
75
|
-
console.warn("Clarity supports
|
|
77
|
+
if (!SupportedPlatforms.includes(_reactNative.Platform.OS)) {
|
|
78
|
+
console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
|
|
76
79
|
return new Promise(resolve => {
|
|
77
80
|
resolve("Undefined");
|
|
78
81
|
});
|
|
@@ -85,4 +88,26 @@ function getCurrentSessionId() {
|
|
|
85
88
|
}
|
|
86
89
|
return Clarity.getCurrentSessionId();
|
|
87
90
|
}
|
|
91
|
+
function setCurrentScreenName(screenName) {
|
|
92
|
+
if (!SupportedPlatforms.includes(_reactNative.Platform.OS)) {
|
|
93
|
+
console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (Clarity === null) {
|
|
97
|
+
console.error("Clarity did not initialize properly.", LINKING_ERROR);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
Clarity.setCurrentScreenName(screenName);
|
|
101
|
+
}
|
|
102
|
+
function setCustomTag(key, value) {
|
|
103
|
+
if (!SupportedPlatforms.includes(_reactNative.Platform.OS)) {
|
|
104
|
+
console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (Clarity === null) {
|
|
108
|
+
console.error("Clarity did not initialize properly.", LINKING_ERROR);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
Clarity.setCustomTag(key, value);
|
|
112
|
+
}
|
|
88
113
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Clarity","NativeModules","initialize","projectId","userId","logLevel","arguments","length","undefined","allowMeteredNetworkUsage","enableWebViewCapture","allowedDomains","Platform","OS","console","warn","error","setCustomUserId","customUserId","getCurrentSessionId","Promise","resolve"],"sourceRoot":"..\\..\\src","sources":["index.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Clarity","NativeModules","SupportedPlatforms","initialize","projectId","userId","logLevel","arguments","length","undefined","allowMeteredNetworkUsage","enableWebViewCapture","allowedDomains","includes","Platform","OS","console","warn","join","error","setCustomUserId","customUserId","getCurrentSessionId","Promise","resolve","setCurrentScreenName","screenName","setCustomTag","key","value"],"sourceRoot":"..\\..\\src","sources":["index.tsx"],"mappings":";;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GAChB,+EAA8E;AAC/E;AACA,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,OAAO,GAAGC,0BAAa,CAACD,OAAO;AAErC,MAAME,kBAAkB,GAAG,CAAC,SAAS,CAAC;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,UAAUA,CACxBC,SAAiB,EACjBC,MAAe,EAImB;EAAA,IAHlCC,QAAgB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,MAAM;EAAA,IACzBG,wBAAiC,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAAA,IACzCI,oBAA6B,GAAAJ,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAA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package/lib/module/index.js
CHANGED
|
@@ -3,6 +3,7 @@ const LINKING_ERROR = `The package 'react-native-clarity' doesn't seem to be lin
|
|
|
3
3
|
// Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) + TODO: add back when iOS is supported.
|
|
4
4
|
'- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
5
5
|
const Clarity = NativeModules.Clarity;
|
|
6
|
+
const SupportedPlatforms = ['android'];
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Initializes the Clarity plugin with the provided parameters.
|
|
@@ -24,8 +25,8 @@ export function initialize(projectId, userId) {
|
|
|
24
25
|
let allowMeteredNetworkUsage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
25
26
|
let enableWebViewCapture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
26
27
|
let allowedDomains = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : ["*"];
|
|
27
|
-
if (Platform.OS
|
|
28
|
-
console.warn("Clarity supports
|
|
28
|
+
if (!SupportedPlatforms.includes(Platform.OS)) {
|
|
29
|
+
console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
32
|
if (Clarity === null) {
|
|
@@ -46,8 +47,8 @@ export function initialize(projectId, userId) {
|
|
|
46
47
|
* @param customUserId The custom user id to set.
|
|
47
48
|
*/
|
|
48
49
|
export function setCustomUserId(customUserId) {
|
|
49
|
-
if (Platform.OS
|
|
50
|
-
console.warn("Clarity supports
|
|
50
|
+
if (!SupportedPlatforms.includes(Platform.OS)) {
|
|
51
|
+
console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
|
|
51
52
|
return;
|
|
52
53
|
}
|
|
53
54
|
if (Clarity === null) {
|
|
@@ -63,8 +64,8 @@ export function setCustomUserId(customUserId) {
|
|
|
63
64
|
* @returns a promise that resolves to the current session id.
|
|
64
65
|
*/
|
|
65
66
|
export function getCurrentSessionId() {
|
|
66
|
-
if (Platform.OS
|
|
67
|
-
console.warn("Clarity supports
|
|
67
|
+
if (!SupportedPlatforms.includes(Platform.OS)) {
|
|
68
|
+
console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
|
|
68
69
|
return new Promise(resolve => {
|
|
69
70
|
resolve("Undefined");
|
|
70
71
|
});
|
|
@@ -77,4 +78,26 @@ export function getCurrentSessionId() {
|
|
|
77
78
|
}
|
|
78
79
|
return Clarity.getCurrentSessionId();
|
|
79
80
|
}
|
|
81
|
+
export function setCurrentScreenName(screenName) {
|
|
82
|
+
if (!SupportedPlatforms.includes(Platform.OS)) {
|
|
83
|
+
console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (Clarity === null) {
|
|
87
|
+
console.error("Clarity did not initialize properly.", LINKING_ERROR);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
Clarity.setCurrentScreenName(screenName);
|
|
91
|
+
}
|
|
92
|
+
export function setCustomTag(key, value) {
|
|
93
|
+
if (!SupportedPlatforms.includes(Platform.OS)) {
|
|
94
|
+
console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (Clarity === null) {
|
|
98
|
+
console.error("Clarity did not initialize properly.", LINKING_ERROR);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
Clarity.setCustomTag(key, value);
|
|
102
|
+
}
|
|
80
103
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","Clarity","initialize","projectId","userId","logLevel","arguments","length","undefined","allowMeteredNetworkUsage","enableWebViewCapture","allowedDomains","OS","console","warn","error","setCustomUserId","customUserId","getCurrentSessionId","Promise","resolve"],"sourceRoot":"..\\..\\src","sources":["index.tsx"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GAChB,+EAA8E;AAC/E;AACA,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,OAAO,GAAGH,aAAa,CAACG,OAAO;;
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","Clarity","SupportedPlatforms","initialize","projectId","userId","logLevel","arguments","length","undefined","allowMeteredNetworkUsage","enableWebViewCapture","allowedDomains","includes","OS","console","warn","join","error","setCustomUserId","customUserId","getCurrentSessionId","Promise","resolve","setCurrentScreenName","screenName","setCustomTag","key","value"],"sourceRoot":"..\\..\\src","sources":["index.tsx"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GAChB,+EAA8E;AAC/E;AACA,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,OAAO,GAAGH,aAAa,CAACG,OAAO;AAErC,MAAMC,kBAAkB,GAAG,CAAC,SAAS,CAAC;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CACxBC,SAAiB,EACjBC,MAAe,EAImB;EAAA,IAHlCC,QAAgB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,MAAM;EAAA,IACzBG,wBAAiC,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAAA,IACzCI,oBAA6B,GAAAJ,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;EAAA,IACpCK,cAAwB,GAAAL,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,GAAG,CAAC;EAChC,IAAI,CAACL,kBAAkB,CAACW,QAAQ,CAACd,QA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G,KAAK,CAAC,sCAAsC,EAAElB,aAAa,CAAC;IACpE,OAAO,IAAIsB,OAAO,CAAEC,OAAO,IAAK;MAC9BA,OAAO,CAAC,WAAW,CAAC;IACtB,CAAC,CAAC;EACJ;EAEA,OAAOtB,OAAO,CAACoB,mBAAmB,CAAC,CAAC;AACtC;AAEA,OAAO,SAASG,oBAAoBA,CAACC,UAAkB,EAAE;EACvD,IAAI,CAACvB,kBAAkB,CAACW,QAAQ,CAACd,QAAQ,CAACe,EAAE,CAAC,EAAE;IAC7CC,OAAO,CAACC,IAAI,CAAC,mBAAmB,GAAGd,kBAAkB,CAACe,IAAI,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC;IACpF;EACF;EAEA,IAAIhB,OAAO,KAAK,IAAI,EAAE;IACpBc,OAAO,CAACG,KAAK,CAAC,sCAAsC,EAAElB,aAAa,CAAC;IACpE;EACF;EAEAC,OAAO,CAACuB,oBAAoB,CAACC,UAAU,CAAC;AAC1C;AAEA,OAAO,SAASC,YAAYA,CAACC,GAAW,EAAEC,KAAa,EAAE;EACvD,IAAI,CAAC1B,kBAAkB,CAACW,QAAQ,CAACd,QAAQ,CAACe,EAAE,CAAC,EAAE;IAC7CC,OAAO,CAACC,IAAI,CAAC,mBAAmB,GAAGd,kBAAkB,CAACe,IAAI,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC;IACpF;EACF;EAEA,IAAIhB,OAAO,KAAK,IAAI,EAAE;IACpBc,OAAO,CAACG,KAAK,CAAC,sCAAsC,EAAElB,aAAa,CAAC;IACpE;EACF;EAEAC,OAAO,CAACyB,YAAY,CAACC,GAAG,EAAEC,KAAK,CAAC;AAClC"}
|
|
@@ -31,4 +31,6 @@ export declare function setCustomUserId(customUserId: string): void;
|
|
|
31
31
|
* @returns a promise that resolves to the current session id.
|
|
32
32
|
*/
|
|
33
33
|
export declare function getCurrentSessionId(): Promise<string>;
|
|
34
|
+
export declare function setCurrentScreenName(screenName: string): void;
|
|
35
|
+
export declare function setCustomTag(key: string, value: string): void;
|
|
34
36
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,GAAE,MAAe,EACzB,wBAAwB,GAAE,OAAe,EACzC,oBAAoB,GAAE,OAAc,EACpC,cAAc,GAAE,MAAM,EAAU,QAYjC;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,QAYnD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,CAgBrD;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,QAYtD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAYtD"}
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -8,6 +8,8 @@ const LINKING_ERROR =
|
|
|
8
8
|
|
|
9
9
|
const Clarity = NativeModules.Clarity;
|
|
10
10
|
|
|
11
|
+
const SupportedPlatforms = ['android']
|
|
12
|
+
|
|
11
13
|
/**
|
|
12
14
|
* Initializes the Clarity plugin with the provided parameters.
|
|
13
15
|
*
|
|
@@ -30,8 +32,8 @@ export function initialize(
|
|
|
30
32
|
allowMeteredNetworkUsage: boolean = false,
|
|
31
33
|
enableWebViewCapture: boolean = true,
|
|
32
34
|
allowedDomains: string[] = ["*"]) {
|
|
33
|
-
if (Platform.OS
|
|
34
|
-
console.warn("Clarity supports
|
|
35
|
+
if (!SupportedPlatforms.includes(Platform.OS)) {
|
|
36
|
+
console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
|
|
35
37
|
return;
|
|
36
38
|
}
|
|
37
39
|
|
|
@@ -54,8 +56,8 @@ export function initialize(
|
|
|
54
56
|
* @param customUserId The custom user id to set.
|
|
55
57
|
*/
|
|
56
58
|
export function setCustomUserId(customUserId: string) {
|
|
57
|
-
if (Platform.OS
|
|
58
|
-
console.warn("Clarity supports
|
|
59
|
+
if (!SupportedPlatforms.includes(Platform.OS)) {
|
|
60
|
+
console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
|
|
59
61
|
return;
|
|
60
62
|
}
|
|
61
63
|
|
|
@@ -73,8 +75,8 @@ export function setCustomUserId(customUserId: string) {
|
|
|
73
75
|
* @returns a promise that resolves to the current session id.
|
|
74
76
|
*/
|
|
75
77
|
export function getCurrentSessionId(): Promise<string> {
|
|
76
|
-
if (Platform.OS
|
|
77
|
-
console.warn("Clarity supports
|
|
78
|
+
if (!SupportedPlatforms.includes(Platform.OS)) {
|
|
79
|
+
console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
|
|
78
80
|
return new Promise((resolve) => {
|
|
79
81
|
resolve("Undefined");
|
|
80
82
|
});
|
|
@@ -89,3 +91,31 @@ export function getCurrentSessionId(): Promise<string> {
|
|
|
89
91
|
|
|
90
92
|
return Clarity.getCurrentSessionId();
|
|
91
93
|
}
|
|
94
|
+
|
|
95
|
+
export function setCurrentScreenName(screenName: string) {
|
|
96
|
+
if (!SupportedPlatforms.includes(Platform.OS)) {
|
|
97
|
+
console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (Clarity === null) {
|
|
102
|
+
console.error("Clarity did not initialize properly.", LINKING_ERROR);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
Clarity.setCurrentScreenName(screenName);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function setCustomTag(key: string, value: string) {
|
|
110
|
+
if (!SupportedPlatforms.includes(Platform.OS)) {
|
|
111
|
+
console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (Clarity === null) {
|
|
116
|
+
console.error("Clarity did not initialize properly.", LINKING_ERROR);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
Clarity.setCustomTag(key, value);
|
|
121
|
+
}
|