react-native-clarity 2.0.0 → 2.1.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/README.md CHANGED
@@ -8,16 +8,18 @@ A ReactNative plugin that allows integrating Clarity with your application.
8
8
  npm install react-native-clarity
9
9
  ```
10
10
 
11
+ **Note**: The Clarity package depends on native code to run, therefore you have to ship a new build after integrating the package.
12
+
11
13
  ## Usage
12
14
 
13
15
  ```js
14
- import {LogLevel, initialize, setCustomUserId, setCustomSessionId, setCustomTag, setCurrentScreenName, getCurrentSessionId } from 'react-native-clarity';
16
+ import { LogLevel, initialize, setCustomUserId, setCustomSessionId, setCustomTag, setCurrentScreenName, getCurrentSessionId } from 'react-native-clarity';
15
17
 
16
18
  // Initialize Clarity.
17
- let clarityConfig = {
19
+ const clarityConfig = {
18
20
  logLevel: LogLevel.Verbose,
19
21
  allowMeteredNetworkUsage: true
20
- }
22
+ };
21
23
 
22
24
  initialize('<ProjectId>', clarityConfig);
23
25
 
@@ -31,22 +33,39 @@ setCustomSessionId("<CustomSessionId>");
31
33
  setCustomTag("key", "value");
32
34
 
33
35
  // Setting the current screen name when using React Navigation
34
- import { ..., useFocusEffect } from '@react-navigation/native';
36
+ import { NavigationContainer useNavigationContainerRef } from '@react-navigation/native';
35
37
 
36
38
  const HomeScreen = ({...}) => {
37
- useFocusEffect(
38
- React.useCallback(() => {
39
- setCurrentScreenName("Home");
40
-
41
- // To clear the current screen name when the screen goes out of focus:
42
- return () => { setCurrentScreenName(undefined); }
43
- }, [])
39
+ const navigationRef = useNavigationContainerRef();
40
+ const routeNameRef = React.useRef();
41
+
42
+ return (
43
+ <NavigationContainer
44
+ ref={navigationRef}
45
+ onReady={() => {
46
+ routeNameRef.current = navigationRef.getCurrentRoute().name;
47
+ setCurrentScreenName(routeNameRef.current);
48
+ }}
49
+ onStateChange={() => {
50
+ const previousRouteName = routeNameRef.current;
51
+ const currentRouteName = navigationRef.getCurrentRoute().name;
52
+
53
+ if (previousRouteName !== currentRouteName) {
54
+ routeNameRef.current = currentRouteName;
55
+ setCurrentScreenName(currentRouteName);
56
+ }
57
+ }}
58
+ >
59
+ {/* ... */}
60
+ </NavigationContainer>
44
61
  );
45
- ...
46
62
  };
47
63
 
48
64
  // Get current session id to correlate with other tools.
49
65
  getCurrentSessionId().then((id) => {...});
66
+
67
+ // Get current session url to correlate with other tools.
68
+ getCurrentSessionUrl().then((url) => {...});
50
69
  ```
51
70
 
52
71
  ### Initialization arguments
@@ -54,15 +73,15 @@ getCurrentSessionId().then((id) => {...});
54
73
  ```ts
55
74
  /**
56
75
  * Initializes the Clarity SDK if the API level is supported.
57
- *
76
+ *
58
77
  * @param projectId [REQUIRED] The Clarity project id to send data to.
59
78
  * @param config [OPTIONAL] The clarity config, if not provided default values are used.
60
79
  */
61
- function initialize(projectId: string, config?: ClarityConfig)
80
+ function initialize(projectId: string, config?: ClarityConfig)
62
81
 
63
82
  /**
64
83
  * The configuration that will be used to customize the Clarity behaviour.
65
- *
84
+ *
66
85
  * @param userId [OPTIONAL default = null] A custom identifier for the current user. If passed as null, the user id
67
86
  * will be auto generated. The user id in general is sticky across sessions.
68
87
  * The provided user id must follow these conditions:
@@ -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:2.0.0"
72
+ implementation "com.microsoft.clarity:clarity:2.1.1"
73
73
  }
74
74
 
75
75
  if (isNewArchitectureEnabled()) {
@@ -1,7 +1,7 @@
1
1
  #make sure these are acutally used
2
2
  Clarity_kotlinVersion=1.7.0
3
3
  Clarity_minSdkVersion=21
4
- Clarity_targetSdkVersion=33
5
- Clarity_compileSdkVersion=33
4
+ Clarity_targetSdkVersion=34
5
+ Clarity_compileSdkVersion=34
6
6
  Clarity_ndkversion=21.4.7075529
7
7
  android.useAndroidX=true
@@ -67,6 +67,12 @@ class ClarityModule(reactContext: ReactApplicationContext) :
67
67
  promise.resolve(Clarity.setCurrentScreenName(screenName))
68
68
  }
69
69
 
70
+ @ReactMethod
71
+ fun getCurrentSessionUrl(promise: Promise) {
72
+ promise.resolve(Clarity.getCurrentSessionUrl())
73
+ }
74
+
75
+
70
76
  private fun readableArrayToList(arr: ReadableArray): List<String> {
71
77
  val ret = mutableListOf<String>()
72
78
 
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.LogLevel = void 0;
7
7
  exports.getCurrentSessionId = getCurrentSessionId;
8
+ exports.getCurrentSessionUrl = getCurrentSessionUrl;
8
9
  exports.initialize = initialize;
9
10
  exports.setCurrentScreenName = setCurrentScreenName;
10
11
  exports.setCustomSessionId = setCustomSessionId;
@@ -160,16 +161,30 @@ function setCurrentScreenName(screenName) {
160
161
  function getCurrentSessionId() {
161
162
  if (!SupportedPlatforms.includes(_reactNative.Platform.OS)) {
162
163
  console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
163
- return new Promise(resolve => {
164
- resolve("Undefined");
165
- });
164
+ return Promise.resolve("Undefined");
166
165
  }
167
166
  if (Clarity === null) {
168
167
  console.error("Clarity did not initialize properly.", LINKING_ERROR);
169
- return new Promise(resolve => {
170
- resolve("Undefined");
171
- });
168
+ return Promise.resolve("Undefined");
172
169
  }
173
170
  return Clarity.getCurrentSessionId();
174
171
  }
172
+
173
+ /**
174
+ * Returns the active session url. This can be used to correlate the Clarity session with other
175
+ * analytics tools that the developer may be using.
176
+ *
177
+ * @returns a promise that resolves to the current session url if there is an active one.
178
+ */
179
+ function getCurrentSessionUrl() {
180
+ if (!SupportedPlatforms.includes(_reactNative.Platform.OS)) {
181
+ console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
182
+ return Promise.resolve("Undefined");
183
+ }
184
+ if (Clarity === null) {
185
+ console.error("Clarity did not initialize properly.", LINKING_ERROR);
186
+ return Promise.resolve("Undefined");
187
+ }
188
+ return Clarity.getCurrentSessionUrl();
189
+ }
175
190
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","LINKING_ERROR","Clarity","NativeModules","SupportedPlatforms","LogLevel","exports","initialize","projectId","config","Error","userId","logLevel","None","allowMeteredNetworkUsage","enableWebViewCapture","allowedDomains","disableOnLowEndDevices","includes","Platform","OS","console","warn","join","error","setCustomUserId","customUserId","setCustomSessionId","customSessionId","setCustomTag","key","value","setCurrentScreenName","screenName","getCurrentSessionId","Promise","resolve"],"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;AAUA;AACA;AACA;AAFA,IAGYC,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AASpB;AACA;AACA;AACA;AACA;AAJAC,OAAA,CAAAD,QAAA,GAAAA,QAAA;AAKO,SAASE,UAAUA,CAACC,SAAiB,EAAEC,MAAsB,EAAE;EAEpE,IAAI,OAAOD,SAAS,KAAK,QAAQ,IAAI,EAAE,OAAOC,MAAM,KAAK,QAAQ,IAAI,OAAOA,MAAM,KAAK,WAAW,CAAC,EAAE;IACnG,MAAMC,KAAK,CAAC,gFAAgF,CAAC;EAC/F;;EAEA;EACA,IAAI;IAAEC,MAAM,GAAG,IAAI;IACjBC,QAAQ,GAAGP,QAAQ,CAACQ,IAAI;IACxBC,wBAAwB,GAA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AACc,QAAQ,CAACC,qBAAQ,CAACC,EAAE,CAAC,EAAE;IAC7CC,OAAO,CAACC,IAAI,CAAC,mBAAmB,GAAGlB,kBAAkB,CAACmB,IAAI,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC;IACpF,OAAO,IAAIY,OAAO,CAAEC,OAAO,IAAK;MAC9BA,OAAO,CAAC,WAAW,CAAC;IACtB,CAAC,CAAC;EACJ;EAEA,IAAIlC,OAAO,KAAK,IAAI,EAAE;IACpBmB,OAAO,CAACG,KAAK,CAAC,sCAAsC,EAAEvB,aAAa,CAAC;IACpE,OAAO,IAAIkC,OAAO,CAAEC,OAAO,IAAK;MAC9BA,OAAO,CAAC,WAAW,CAAC;IACtB,CAAC,CAAC;EACJ;EAEA,OAAOlC,OAAO,CAACgC,mBAAmB,CAAC,CAAC;AACtC"}
1
+ {"version":3,"names":["_reactNative","require","LINKING_ERROR","Clarity","NativeModules","SupportedPlatforms","LogLevel","exports","initialize","projectId","config","Error","userId","logLevel","None","allowMeteredNetworkUsage","enableWebViewCapture","allowedDomains","disableOnLowEndDevices","includes","Platform","OS","console","warn","join","error","setCustomUserId","customUserId","setCustomSessionId","customSessionId","setCustomTag","key","value","setCurrentScreenName","screenName","getCurrentSessionId","Promise","resolve","getCurrentSessionUrl"],"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;AAUA;AACA;AACA;AAFA,IAGYC,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,Q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AAK,CAAC,sCAAsC,EAAEvB,aAAa,CAAC;IACpE,OAAOkC,OAAO,CAACC,OAAO,CAAC,WAAW,CAAC;EACrC;EAEA,OAAOlC,OAAO,CAACmC,oBAAoB,CAAC,CAAC;AACvC"}
@@ -149,16 +149,30 @@ export function setCurrentScreenName(screenName) {
149
149
  export function getCurrentSessionId() {
150
150
  if (!SupportedPlatforms.includes(Platform.OS)) {
151
151
  console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
152
- return new Promise(resolve => {
153
- resolve("Undefined");
154
- });
152
+ return Promise.resolve("Undefined");
155
153
  }
156
154
  if (Clarity === null) {
157
155
  console.error("Clarity did not initialize properly.", LINKING_ERROR);
158
- return new Promise(resolve => {
159
- resolve("Undefined");
160
- });
156
+ return Promise.resolve("Undefined");
161
157
  }
162
158
  return Clarity.getCurrentSessionId();
163
159
  }
160
+
161
+ /**
162
+ * Returns the active session url. This can be used to correlate the Clarity session with other
163
+ * analytics tools that the developer may be using.
164
+ *
165
+ * @returns a promise that resolves to the current session url if there is an active one.
166
+ */
167
+ export function getCurrentSessionUrl() {
168
+ if (!SupportedPlatforms.includes(Platform.OS)) {
169
+ console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
170
+ return Promise.resolve("Undefined");
171
+ }
172
+ if (Clarity === null) {
173
+ console.error("Clarity did not initialize properly.", LINKING_ERROR);
174
+ return Promise.resolve("Undefined");
175
+ }
176
+ return Clarity.getCurrentSessionUrl();
177
+ }
164
178
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","Clarity","SupportedPlatforms","LogLevel","initialize","projectId","config","Error","userId","logLevel","None","allowMeteredNetworkUsage","enableWebViewCapture","allowedDomains","disableOnLowEndDevices","includes","OS","console","warn","join","error","setCustomUserId","customUserId","setCustomSessionId","customSessionId","setCustomTag","key","value","setCurrentScreenName","screenName","getCurrentSessionId","Promise","resolve"],"sourceRoot":"..\\..\\src","sources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O,CAAEC,OAAO,IAAK;MAC9BA,OAAO,CAAC,WAAW,CAAC;IACtB,CAAC,CAAC;EACJ;EAEA,OAAO/B,OAAO,CAAC6B,mBAAmB,CAAC,CAAC;AACtC"}
1
+ {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","Clarity","SupportedPlatforms","LogLevel","initialize","projectId","config","Error","userId","logLevel","None","allowMeteredNetworkUsage","enableWebViewCapture","allowedDomains","disableOnLowEndDevices","includes","OS","console","warn","join","error","setCustomUserId","customUserId","setCustomSessionId","customSessionId","setCustomTag","key","value","setCurrentScreenName","screenName","getCurrentSessionId","Promise","resolve","getCurrentSessionUrl"],"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;;AAUA;AACA;AACA;AACA,WAAYC,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;;AASpB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAACC,SAAiB,EAAEC,MAAsB,EAAE;EAEpE,IAAI,OAAOD,SAAS,KAAK,QAAQ,IAAI,EAAE,OAAOC,MAAM,KAAK,QAAQ,IAAI,OAAOA,MAAM,KAAK,WAAW,CAAC,EAAE;IACnG,MAAMC,KAAK,CAAC,gFAAgF,CAAC;EAC/F;;EAEA;EACA,IAAI;IAAEC,MAAM,GAAG,IAAI;IACjBC,QAAQ,GAAGN,QAAQ,CAACO,IAAI;IACxBC,wBAAwB,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,EAAoB;EACrD,IAAI,CAAC5B,kBAAkB,CAACa,QAAQ,CAAChB,QAAQ,CAACiB,EAAE,CAAC,EAAE;IAC7CC,OAAO,CAACC,IAAI,CAAC,mBAAmB,GAAGhB,kBAAkB,CAACiB,IAAI,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC;IACpF,OAAOY,OAAO,CAACC,OAAO,CAAC,WAAW,CAAC;EACrC;EAEA,IAAI/B,OAAO,KAAK,IAAI,EAAE;IACpBgB,OAAO,CAACG,KAAK,CAAC,sCAAsC,EAAEpB,aAAa,CAAC;IACpE,OAAO+B,OAAO,CAACC,OAAO,CAAC,WAAW,CAAC;EACrC;EAEA,OAAO/B,OAAO,CAAC6B,mBAAmB,CAAC,CAAC;AACtC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,oBAAoBA,CAAA,EAAoB;EACtD,IAAI,CAAC/B,kBAAkB,CAACa,QAAQ,CAAChB,QAAQ,CAACiB,EAAE,CAAC,EAAE;IAC7CC,OAAO,CAACC,IAAI,CAAC,mBAAmB,GAAGhB,kBAAkB,CAACiB,IAAI,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC;IACpF,OAAOY,OAAO,CAACC,OAAO,CAAC,WAAW,CAAC;EACrC;EAEA,IAAI/B,OAAO,KAAK,IAAI,EAAE;IACpBgB,OAAO,CAACG,KAAK,CAAC,sCAAsC,EAAEpB,aAAa,CAAC;IACpE,OAAO+B,OAAO,CAACC,OAAO,CAAC,WAAW,CAAC;EACrC;EAEA,OAAO/B,OAAO,CAACgC,oBAAoB,CAAC,CAAC;AACvC"}
@@ -70,11 +70,18 @@ export declare function setCustomTag(key: string, value: string): void;
70
70
  * You can it set to `null` to remove the latest set value.
71
71
  * @param screenName The current screen name to set.
72
72
  */
73
- export declare function setCurrentScreenName(screenName: string): void;
73
+ export declare function setCurrentScreenName(screenName: string | null): void;
74
74
  /**
75
75
  * Returns the active session id. This can be used to correlate the Clarity session with other
76
76
  * analytics tools that the developer may be using.
77
77
  * @returns a promise that resolves to the current session id.
78
78
  */
79
79
  export declare function getCurrentSessionId(): Promise<string>;
80
+ /**
81
+ * Returns the active session url. This can be used to correlate the Clarity session with other
82
+ * analytics tools that the developer may be using.
83
+ *
84
+ * @returns a promise that resolves to the current session url if there is an active one.
85
+ */
86
+ export declare function getCurrentSessionUrl(): Promise<string>;
80
87
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED;;GAEG;AACH,oBAAY,QAAQ;IAClB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAED;;;;EAIE;AACF,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,QAyBnE;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,QAYnD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,MAAM,QAYzD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAYtD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,QAYtD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,CAgBrD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED;;GAEG;AACH,oBAAY,QAAQ;IAClB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAED;;;;EAIE;AACF,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,QAyBnE;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,QAYnD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,MAAM,QAYzD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAYtD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,QAY7D;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,CAYrD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAYtD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-clarity",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "A plugin to provide the Clarity experience for the React Native applications.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
package/src/index.tsx CHANGED
@@ -114,12 +114,12 @@ export function setCustomSessionId(customSessionId: string) {
114
114
  console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
115
115
  return;
116
116
  }
117
-
117
+
118
118
  if (Clarity === null) {
119
119
  console.error("Clarity did not initialize properly.", LINKING_ERROR);
120
120
  return;
121
121
  }
122
-
122
+
123
123
  Clarity.setCustomSessionId(customSessionId);
124
124
  }
125
125
 
@@ -149,7 +149,7 @@ export function setCustomTag(key: string, value: string) {
149
149
  * You can it set to `null` to remove the latest set value.
150
150
  * @param screenName The current screen name to set.
151
151
  */
152
- export function setCurrentScreenName(screenName: string) {
152
+ export function setCurrentScreenName(screenName: string | null) {
153
153
  if (!SupportedPlatforms.includes(Platform.OS)) {
154
154
  console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
155
155
  return;
@@ -171,17 +171,33 @@ export function setCurrentScreenName(screenName: string) {
171
171
  export function getCurrentSessionId(): Promise<string> {
172
172
  if (!SupportedPlatforms.includes(Platform.OS)) {
173
173
  console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
174
- return new Promise((resolve) => {
175
- resolve("Undefined");
176
- });
174
+ return Promise.resolve("Undefined");
177
175
  }
178
176
 
179
177
  if (Clarity === null) {
180
178
  console.error("Clarity did not initialize properly.", LINKING_ERROR);
181
- return new Promise((resolve) => {
182
- resolve("Undefined");
183
- });
179
+ return Promise.resolve("Undefined");
184
180
  }
185
181
 
186
182
  return Clarity.getCurrentSessionId();
187
183
  }
184
+
185
+ /**
186
+ * Returns the active session url. This can be used to correlate the Clarity session with other
187
+ * analytics tools that the developer may be using.
188
+ *
189
+ * @returns a promise that resolves to the current session url if there is an active one.
190
+ */
191
+ export function getCurrentSessionUrl(): Promise<string> {
192
+ if (!SupportedPlatforms.includes(Platform.OS)) {
193
+ console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
194
+ return Promise.resolve("Undefined");
195
+ }
196
+
197
+ if (Clarity === null) {
198
+ console.error("Clarity did not initialize properly.", LINKING_ERROR);
199
+ return Promise.resolve("Undefined");
200
+ }
201
+
202
+ return Clarity.getCurrentSessionUrl();
203
+ }