react-native-clarity 2.0.0 → 2.2.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/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Microsoft - Clarity
4
- Permission is hereby granted, free of charge, to any person obtaining a copy
5
- of this software and associated documentation files (the "Software"), to deal
6
- in the Software without restriction, including without limitation the rights
7
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the Software is
9
- furnished to do so, subject to the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be included in all
12
- copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Microsoft - Clarity
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
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:
@@ -74,6 +93,7 @@ function initialize(projectId: string, config?: ClarityConfig)
74
93
  * @param allowedDomains [OPTIONAL default = ["*"]] The whitelisted domains to allow Clarity to capture their DOM content.
75
94
  * If it contains "*" as an element, all domains will be captured.
76
95
  * @param disableOnLowEndDevices [OPTIONAL default = false] Disable Clarity on low-end devices.
96
+ * @param maximumDailyNetworkUsageInMB [OPTIONAL default = null] Maximum daily network usage for Clarity (null = No limit). When the limit is reached, Clarity will turn on lean mode.
77
97
  */
78
98
 
79
99
  interface ClarityConfig {
@@ -83,6 +103,7 @@ interface ClarityConfig {
83
103
  enableWebViewCapture?: boolean;
84
104
  allowedDomains?: string[];
85
105
  disableOnLowEndDevices?: Boolean;
106
+ maximumDailyNetworkUsageInMB?: number;
86
107
  }
87
108
  ```
88
109
 
@@ -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.2.0-manual20240317193429"
73
73
  }
74
74
 
75
75
  if (isNewArchitectureEnabled()) {
@@ -1,7 +1,8 @@
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
8
+ org.gradle.java.home=C\:\\Program Files\\OpenLogic\\jdk-17.0.10.7-hotspot
@@ -1,5 +1,7 @@
1
1
  package com.microsoft.clarity.reactnative
2
2
 
3
+ import android.os.Handler
4
+ import android.os.Looper
3
5
  import com.facebook.react.bridge.*
4
6
  import com.microsoft.clarity.Clarity
5
7
  import com.microsoft.clarity.ClarityConfig
@@ -22,10 +24,17 @@ class ClarityModule(reactContext: ReactApplicationContext) :
22
24
  enableWebViewCapture: Boolean,
23
25
  allowedDomains: ReadableArray,
24
26
  disableOnLowEndDevices: Boolean,
27
+ enableDailyNetworkUsageLimit: Boolean,
28
+ maximumDailyNetworkUsageInMB: Double,
25
29
  promise: Promise
26
30
  ) {
27
- val allowedActivities = listOf<String>(); //not supported
28
- val disallowedActivities = listOf<String>(); //not supported
31
+ val allowedActivities = listOf<String>(); // not supported
32
+ val disallowedActivities = listOf<String>(); // not supported
33
+
34
+ // We use two parameters because the react method parameters do not accept nullable primitive types.
35
+ // Moreover, the Long data type is not supported. Js numbers are translated into doubles.
36
+ val maximumDailyNetworkUsageInMBLong = if (enableDailyNetworkUsageLimit) maximumDailyNetworkUsageInMB.toLong() else null
37
+
29
38
  val config = ClarityConfig(
30
39
  projectId,
31
40
  userId,
@@ -36,10 +45,14 @@ class ClarityModule(reactContext: ReactApplicationContext) :
36
45
  ApplicationFramework.ReactNative,
37
46
  allowedActivities,
38
47
  disallowedActivities,
39
- disableOnLowEndDevices
48
+ disableOnLowEndDevices,
49
+ maximumDailyNetworkUsageInMBLong
40
50
  )
41
51
 
42
- promise.resolve(Clarity.initialize(currentActivity, config))
52
+ // Run on the main thread as recommended by the native Clarity SDK.
53
+ Handler(Looper.getMainLooper()).post {
54
+ promise.resolve(Clarity.initialize(currentActivity, config))
55
+ }
43
56
  }
44
57
 
45
58
  @ReactMethod
@@ -67,6 +80,12 @@ class ClarityModule(reactContext: ReactApplicationContext) :
67
80
  promise.resolve(Clarity.setCurrentScreenName(screenName))
68
81
  }
69
82
 
83
+ @ReactMethod
84
+ fun getCurrentSessionUrl(promise: Promise) {
85
+ promise.resolve(Clarity.getCurrentSessionUrl())
86
+ }
87
+
88
+
70
89
  private fun readableArrayToList(arr: ReadableArray): List<String> {
71
90
  val ret = mutableListOf<String>()
72
91
 
package/ios/Clarity.h CHANGED
@@ -1,12 +1,12 @@
1
-
2
- #ifdef RCT_NEW_ARCH_ENABLED
3
- #import "RNClaritySpec.h"
4
-
5
- @interface Clarity : NSObject <NativeClaritySpec>
6
- #else
7
- #import <React/RCTBridgeModule.h>
8
-
9
- @interface Clarity : NSObject <RCTBridgeModule>
10
- #endif
11
-
12
- @end
1
+
2
+ #ifdef RCT_NEW_ARCH_ENABLED
3
+ #import "RNClaritySpec.h"
4
+
5
+ @interface Clarity : NSObject <NativeClaritySpec>
6
+ #else
7
+ #import <React/RCTBridgeModule.h>
8
+
9
+ @interface Clarity : NSObject <RCTBridgeModule>
10
+ #endif
11
+
12
+ @end
package/ios/Clarity.mm CHANGED
@@ -1,15 +1,15 @@
1
- #import "Clarity.h"
2
-
3
- @implementation Clarity
4
- RCT_EXPORT_MODULE()
5
-
6
- // Don't compile this code when we build for the old architecture.
7
- #ifdef RCT_NEW_ARCH_ENABLED
8
- - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
9
- (const facebook::react::ObjCTurboModule::InitParams &)params
10
- {
11
- return std::make_shared<facebook::react::NativeClaritySpecJSI>(params);
12
- }
13
- #endif
14
-
15
- @end
1
+ #import "Clarity.h"
2
+
3
+ @implementation Clarity
4
+ RCT_EXPORT_MODULE()
5
+
6
+ // Don't compile this code when we build for the old architecture.
7
+ #ifdef RCT_NEW_ARCH_ENABLED
8
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
9
+ (const facebook::react::ObjCTurboModule::InitParams &)params
10
+ {
11
+ return std::make_shared<facebook::react::NativeClaritySpecJSI>(params);
12
+ }
13
+ #endif
14
+
15
+ @end
@@ -1,274 +1,274 @@
1
- // !$*UTF8*$!
2
- {
3
- archiveVersion = 1;
4
- classes = {
5
- };
6
- objectVersion = 46;
7
- objects = {
8
-
9
- /* Begin PBXBuildFile section */
10
- 5E555C0D2413F4C50049A1A2 /* Clarity.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* Clarity.m */; };
11
- /* End PBXBuildFile section */
12
-
13
- /* Begin PBXCopyFilesBuildPhase section */
14
- 58B511D91A9E6C8500147676 /* CopyFiles */ = {
15
- isa = PBXCopyFilesBuildPhase;
16
- buildActionMask = 2147483647;
17
- dstPath = "include/$(PRODUCT_NAME)";
18
- dstSubfolderSpec = 16;
19
- files = (
20
- );
21
- runOnlyForDeploymentPostprocessing = 0;
22
- };
23
- /* End PBXCopyFilesBuildPhase section */
24
-
25
- /* Begin PBXFileReference section */
26
- 134814201AA4EA6300B7C361 /* libClarity.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libClarity.a; sourceTree = BUILT_PRODUCTS_DIR; };
27
- B3E7B5881CC2AC0600A0062D /* Clarity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Clarity.h; sourceTree = "<group>"; };
28
- B3E7B5891CC2AC0600A0062D /* Clarity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Clarity.m; sourceTree = "<group>"; };
29
- /* End PBXFileReference section */
30
-
31
- /* Begin PBXFrameworksBuildPhase section */
32
- 58B511D81A9E6C8500147676 /* Frameworks */ = {
33
- isa = PBXFrameworksBuildPhase;
34
- buildActionMask = 2147483647;
35
- files = (
36
- );
37
- runOnlyForDeploymentPostprocessing = 0;
38
- };
39
- /* End PBXFrameworksBuildPhase section */
40
-
41
- /* Begin PBXGroup section */
42
- 134814211AA4EA7D00B7C361 /* Products */ = {
43
- isa = PBXGroup;
44
- children = (
45
- 134814201AA4EA6300B7C361 /* libClarity.a */,
46
- );
47
- name = Products;
48
- sourceTree = "<group>";
49
- };
50
- 58B511D21A9E6C8500147676 = {
51
- isa = PBXGroup;
52
- children = (
53
- B3E7B5881CC2AC0600A0062D /* Clarity.h */,
54
- B3E7B5891CC2AC0600A0062D /* Clarity.m */,
55
- 134814211AA4EA7D00B7C361 /* Products */,
56
- );
57
- sourceTree = "<group>";
58
- };
59
- /* End PBXGroup section */
60
-
61
- /* Begin PBXNativeTarget section */
62
- 58B511DA1A9E6C8500147676 /* Clarity */ = {
63
- isa = PBXNativeTarget;
64
- buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Clarity" */;
65
- buildPhases = (
66
- 58B511D71A9E6C8500147676 /* Sources */,
67
- 58B511D81A9E6C8500147676 /* Frameworks */,
68
- 58B511D91A9E6C8500147676 /* CopyFiles */,
69
- );
70
- buildRules = (
71
- );
72
- dependencies = (
73
- );
74
- name = Clarity;
75
- productName = RCTDataManager;
76
- productReference = 134814201AA4EA6300B7C361 /* libClarity.a */;
77
- productType = "com.apple.product-type.library.static";
78
- };
79
- /* End PBXNativeTarget section */
80
-
81
- /* Begin PBXProject section */
82
- 58B511D31A9E6C8500147676 /* Project object */ = {
83
- isa = PBXProject;
84
- attributes = {
85
- LastUpgradeCheck = 0920;
86
- ORGANIZATIONNAME = Facebook;
87
- TargetAttributes = {
88
- 58B511DA1A9E6C8500147676 = {
89
- CreatedOnToolsVersion = 6.1.1;
90
- };
91
- };
92
- };
93
- buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Clarity" */;
94
- compatibilityVersion = "Xcode 3.2";
95
- developmentRegion = English;
96
- hasScannedForEncodings = 0;
97
- knownRegions = (
98
- English,
99
- en,
100
- );
101
- mainGroup = 58B511D21A9E6C8500147676;
102
- productRefGroup = 58B511D21A9E6C8500147676;
103
- projectDirPath = "";
104
- projectRoot = "";
105
- targets = (
106
- 58B511DA1A9E6C8500147676 /* Clarity */,
107
- );
108
- };
109
- /* End PBXProject section */
110
-
111
- /* Begin PBXSourcesBuildPhase section */
112
- 58B511D71A9E6C8500147676 /* Sources */ = {
113
- isa = PBXSourcesBuildPhase;
114
- buildActionMask = 2147483647;
115
- files = (
116
- B3E7B58A1CC2AC0600A0062D /* Clarity.m in Sources */,
117
- );
118
- runOnlyForDeploymentPostprocessing = 0;
119
- };
120
- /* End PBXSourcesBuildPhase section */
121
-
122
- /* Begin XCBuildConfiguration section */
123
- 58B511ED1A9E6C8500147676 /* Debug */ = {
124
- isa = XCBuildConfiguration;
125
- buildSettings = {
126
- ALWAYS_SEARCH_USER_PATHS = NO;
127
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
128
- CLANG_CXX_LIBRARY = "libc++";
129
- CLANG_ENABLE_MODULES = YES;
130
- CLANG_ENABLE_OBJC_ARC = YES;
131
- CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
132
- CLANG_WARN_BOOL_CONVERSION = YES;
133
- CLANG_WARN_COMMA = YES;
134
- CLANG_WARN_CONSTANT_CONVERSION = YES;
135
- CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
136
- CLANG_WARN_EMPTY_BODY = YES;
137
- CLANG_WARN_ENUM_CONVERSION = YES;
138
- CLANG_WARN_INFINITE_RECURSION = YES;
139
- CLANG_WARN_INT_CONVERSION = YES;
140
- CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
141
- CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
142
- CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
143
- CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
144
- CLANG_WARN_STRICT_PROTOTYPES = YES;
145
- CLANG_WARN_SUSPICIOUS_MOVE = YES;
146
- CLANG_WARN_UNREACHABLE_CODE = YES;
147
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
148
- COPY_PHASE_STRIP = NO;
149
- ENABLE_STRICT_OBJC_MSGSEND = YES;
150
- ENABLE_TESTABILITY = YES;
151
- "EXCLUDED_ARCHS[sdk=*]" = arm64;
152
- GCC_C_LANGUAGE_STANDARD = gnu99;
153
- GCC_DYNAMIC_NO_PIC = NO;
154
- GCC_NO_COMMON_BLOCKS = YES;
155
- GCC_OPTIMIZATION_LEVEL = 0;
156
- GCC_PREPROCESSOR_DEFINITIONS = (
157
- "DEBUG=1",
158
- "$(inherited)",
159
- );
160
- GCC_SYMBOLS_PRIVATE_EXTERN = NO;
161
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
162
- GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
163
- GCC_WARN_UNDECLARED_SELECTOR = YES;
164
- GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
165
- GCC_WARN_UNUSED_FUNCTION = YES;
166
- GCC_WARN_UNUSED_VARIABLE = YES;
167
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
168
- MTL_ENABLE_DEBUG_INFO = YES;
169
- ONLY_ACTIVE_ARCH = YES;
170
- SDKROOT = iphoneos;
171
- };
172
- name = Debug;
173
- };
174
- 58B511EE1A9E6C8500147676 /* Release */ = {
175
- isa = XCBuildConfiguration;
176
- buildSettings = {
177
- ALWAYS_SEARCH_USER_PATHS = NO;
178
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
179
- CLANG_CXX_LIBRARY = "libc++";
180
- CLANG_ENABLE_MODULES = YES;
181
- CLANG_ENABLE_OBJC_ARC = YES;
182
- CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
183
- CLANG_WARN_BOOL_CONVERSION = YES;
184
- CLANG_WARN_COMMA = YES;
185
- CLANG_WARN_CONSTANT_CONVERSION = YES;
186
- CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
187
- CLANG_WARN_EMPTY_BODY = YES;
188
- CLANG_WARN_ENUM_CONVERSION = YES;
189
- CLANG_WARN_INFINITE_RECURSION = YES;
190
- CLANG_WARN_INT_CONVERSION = YES;
191
- CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
192
- CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
193
- CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
194
- CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
195
- CLANG_WARN_STRICT_PROTOTYPES = YES;
196
- CLANG_WARN_SUSPICIOUS_MOVE = YES;
197
- CLANG_WARN_UNREACHABLE_CODE = YES;
198
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
199
- COPY_PHASE_STRIP = YES;
200
- ENABLE_NS_ASSERTIONS = NO;
201
- ENABLE_STRICT_OBJC_MSGSEND = YES;
202
- "EXCLUDED_ARCHS[sdk=*]" = arm64;
203
- GCC_C_LANGUAGE_STANDARD = gnu99;
204
- GCC_NO_COMMON_BLOCKS = YES;
205
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
206
- GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
207
- GCC_WARN_UNDECLARED_SELECTOR = YES;
208
- GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
209
- GCC_WARN_UNUSED_FUNCTION = YES;
210
- GCC_WARN_UNUSED_VARIABLE = YES;
211
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
212
- MTL_ENABLE_DEBUG_INFO = NO;
213
- SDKROOT = iphoneos;
214
- VALIDATE_PRODUCT = YES;
215
- };
216
- name = Release;
217
- };
218
- 58B511F01A9E6C8500147676 /* Debug */ = {
219
- isa = XCBuildConfiguration;
220
- buildSettings = {
221
- HEADER_SEARCH_PATHS = (
222
- "$(inherited)",
223
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
224
- "$(SRCROOT)/../../../React/**",
225
- "$(SRCROOT)/../../react-native/React/**",
226
- );
227
- LIBRARY_SEARCH_PATHS = "$(inherited)";
228
- OTHER_LDFLAGS = "-ObjC";
229
- PRODUCT_NAME = Clarity;
230
- SKIP_INSTALL = YES;
231
- };
232
- name = Debug;
233
- };
234
- 58B511F11A9E6C8500147676 /* Release */ = {
235
- isa = XCBuildConfiguration;
236
- buildSettings = {
237
- HEADER_SEARCH_PATHS = (
238
- "$(inherited)",
239
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
240
- "$(SRCROOT)/../../../React/**",
241
- "$(SRCROOT)/../../react-native/React/**",
242
- );
243
- LIBRARY_SEARCH_PATHS = "$(inherited)";
244
- OTHER_LDFLAGS = "-ObjC";
245
- PRODUCT_NAME = Clarity;
246
- SKIP_INSTALL = YES;
247
- };
248
- name = Release;
249
- };
250
- /* End XCBuildConfiguration section */
251
-
252
- /* Begin XCConfigurationList section */
253
- 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Clarity" */ = {
254
- isa = XCConfigurationList;
255
- buildConfigurations = (
256
- 58B511ED1A9E6C8500147676 /* Debug */,
257
- 58B511EE1A9E6C8500147676 /* Release */,
258
- );
259
- defaultConfigurationIsVisible = 0;
260
- defaultConfigurationName = Release;
261
- };
262
- 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Clarity" */ = {
263
- isa = XCConfigurationList;
264
- buildConfigurations = (
265
- 58B511F01A9E6C8500147676 /* Debug */,
266
- 58B511F11A9E6C8500147676 /* Release */,
267
- );
268
- defaultConfigurationIsVisible = 0;
269
- defaultConfigurationName = Release;
270
- };
271
- /* End XCConfigurationList section */
272
- };
273
- rootObject = 58B511D31A9E6C8500147676 /* Project object */;
274
- }
1
+ // !$*UTF8*$!
2
+ {
3
+ archiveVersion = 1;
4
+ classes = {
5
+ };
6
+ objectVersion = 46;
7
+ objects = {
8
+
9
+ /* Begin PBXBuildFile section */
10
+ 5E555C0D2413F4C50049A1A2 /* Clarity.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* Clarity.m */; };
11
+ /* End PBXBuildFile section */
12
+
13
+ /* Begin PBXCopyFilesBuildPhase section */
14
+ 58B511D91A9E6C8500147676 /* CopyFiles */ = {
15
+ isa = PBXCopyFilesBuildPhase;
16
+ buildActionMask = 2147483647;
17
+ dstPath = "include/$(PRODUCT_NAME)";
18
+ dstSubfolderSpec = 16;
19
+ files = (
20
+ );
21
+ runOnlyForDeploymentPostprocessing = 0;
22
+ };
23
+ /* End PBXCopyFilesBuildPhase section */
24
+
25
+ /* Begin PBXFileReference section */
26
+ 134814201AA4EA6300B7C361 /* libClarity.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libClarity.a; sourceTree = BUILT_PRODUCTS_DIR; };
27
+ B3E7B5881CC2AC0600A0062D /* Clarity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Clarity.h; sourceTree = "<group>"; };
28
+ B3E7B5891CC2AC0600A0062D /* Clarity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Clarity.m; sourceTree = "<group>"; };
29
+ /* End PBXFileReference section */
30
+
31
+ /* Begin PBXFrameworksBuildPhase section */
32
+ 58B511D81A9E6C8500147676 /* Frameworks */ = {
33
+ isa = PBXFrameworksBuildPhase;
34
+ buildActionMask = 2147483647;
35
+ files = (
36
+ );
37
+ runOnlyForDeploymentPostprocessing = 0;
38
+ };
39
+ /* End PBXFrameworksBuildPhase section */
40
+
41
+ /* Begin PBXGroup section */
42
+ 134814211AA4EA7D00B7C361 /* Products */ = {
43
+ isa = PBXGroup;
44
+ children = (
45
+ 134814201AA4EA6300B7C361 /* libClarity.a */,
46
+ );
47
+ name = Products;
48
+ sourceTree = "<group>";
49
+ };
50
+ 58B511D21A9E6C8500147676 = {
51
+ isa = PBXGroup;
52
+ children = (
53
+ B3E7B5881CC2AC0600A0062D /* Clarity.h */,
54
+ B3E7B5891CC2AC0600A0062D /* Clarity.m */,
55
+ 134814211AA4EA7D00B7C361 /* Products */,
56
+ );
57
+ sourceTree = "<group>";
58
+ };
59
+ /* End PBXGroup section */
60
+
61
+ /* Begin PBXNativeTarget section */
62
+ 58B511DA1A9E6C8500147676 /* Clarity */ = {
63
+ isa = PBXNativeTarget;
64
+ buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Clarity" */;
65
+ buildPhases = (
66
+ 58B511D71A9E6C8500147676 /* Sources */,
67
+ 58B511D81A9E6C8500147676 /* Frameworks */,
68
+ 58B511D91A9E6C8500147676 /* CopyFiles */,
69
+ );
70
+ buildRules = (
71
+ );
72
+ dependencies = (
73
+ );
74
+ name = Clarity;
75
+ productName = RCTDataManager;
76
+ productReference = 134814201AA4EA6300B7C361 /* libClarity.a */;
77
+ productType = "com.apple.product-type.library.static";
78
+ };
79
+ /* End PBXNativeTarget section */
80
+
81
+ /* Begin PBXProject section */
82
+ 58B511D31A9E6C8500147676 /* Project object */ = {
83
+ isa = PBXProject;
84
+ attributes = {
85
+ LastUpgradeCheck = 0920;
86
+ ORGANIZATIONNAME = Facebook;
87
+ TargetAttributes = {
88
+ 58B511DA1A9E6C8500147676 = {
89
+ CreatedOnToolsVersion = 6.1.1;
90
+ };
91
+ };
92
+ };
93
+ buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Clarity" */;
94
+ compatibilityVersion = "Xcode 3.2";
95
+ developmentRegion = English;
96
+ hasScannedForEncodings = 0;
97
+ knownRegions = (
98
+ English,
99
+ en,
100
+ );
101
+ mainGroup = 58B511D21A9E6C8500147676;
102
+ productRefGroup = 58B511D21A9E6C8500147676;
103
+ projectDirPath = "";
104
+ projectRoot = "";
105
+ targets = (
106
+ 58B511DA1A9E6C8500147676 /* Clarity */,
107
+ );
108
+ };
109
+ /* End PBXProject section */
110
+
111
+ /* Begin PBXSourcesBuildPhase section */
112
+ 58B511D71A9E6C8500147676 /* Sources */ = {
113
+ isa = PBXSourcesBuildPhase;
114
+ buildActionMask = 2147483647;
115
+ files = (
116
+ B3E7B58A1CC2AC0600A0062D /* Clarity.m in Sources */,
117
+ );
118
+ runOnlyForDeploymentPostprocessing = 0;
119
+ };
120
+ /* End PBXSourcesBuildPhase section */
121
+
122
+ /* Begin XCBuildConfiguration section */
123
+ 58B511ED1A9E6C8500147676 /* Debug */ = {
124
+ isa = XCBuildConfiguration;
125
+ buildSettings = {
126
+ ALWAYS_SEARCH_USER_PATHS = NO;
127
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
128
+ CLANG_CXX_LIBRARY = "libc++";
129
+ CLANG_ENABLE_MODULES = YES;
130
+ CLANG_ENABLE_OBJC_ARC = YES;
131
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
132
+ CLANG_WARN_BOOL_CONVERSION = YES;
133
+ CLANG_WARN_COMMA = YES;
134
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
135
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
136
+ CLANG_WARN_EMPTY_BODY = YES;
137
+ CLANG_WARN_ENUM_CONVERSION = YES;
138
+ CLANG_WARN_INFINITE_RECURSION = YES;
139
+ CLANG_WARN_INT_CONVERSION = YES;
140
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
141
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
142
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
143
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
144
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
145
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
146
+ CLANG_WARN_UNREACHABLE_CODE = YES;
147
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
148
+ COPY_PHASE_STRIP = NO;
149
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
150
+ ENABLE_TESTABILITY = YES;
151
+ "EXCLUDED_ARCHS[sdk=*]" = arm64;
152
+ GCC_C_LANGUAGE_STANDARD = gnu99;
153
+ GCC_DYNAMIC_NO_PIC = NO;
154
+ GCC_NO_COMMON_BLOCKS = YES;
155
+ GCC_OPTIMIZATION_LEVEL = 0;
156
+ GCC_PREPROCESSOR_DEFINITIONS = (
157
+ "DEBUG=1",
158
+ "$(inherited)",
159
+ );
160
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
161
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
162
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
163
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
164
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
165
+ GCC_WARN_UNUSED_FUNCTION = YES;
166
+ GCC_WARN_UNUSED_VARIABLE = YES;
167
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
168
+ MTL_ENABLE_DEBUG_INFO = YES;
169
+ ONLY_ACTIVE_ARCH = YES;
170
+ SDKROOT = iphoneos;
171
+ };
172
+ name = Debug;
173
+ };
174
+ 58B511EE1A9E6C8500147676 /* Release */ = {
175
+ isa = XCBuildConfiguration;
176
+ buildSettings = {
177
+ ALWAYS_SEARCH_USER_PATHS = NO;
178
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
179
+ CLANG_CXX_LIBRARY = "libc++";
180
+ CLANG_ENABLE_MODULES = YES;
181
+ CLANG_ENABLE_OBJC_ARC = YES;
182
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
183
+ CLANG_WARN_BOOL_CONVERSION = YES;
184
+ CLANG_WARN_COMMA = YES;
185
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
186
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
187
+ CLANG_WARN_EMPTY_BODY = YES;
188
+ CLANG_WARN_ENUM_CONVERSION = YES;
189
+ CLANG_WARN_INFINITE_RECURSION = YES;
190
+ CLANG_WARN_INT_CONVERSION = YES;
191
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
192
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
193
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
194
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
195
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
196
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
197
+ CLANG_WARN_UNREACHABLE_CODE = YES;
198
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
199
+ COPY_PHASE_STRIP = YES;
200
+ ENABLE_NS_ASSERTIONS = NO;
201
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
202
+ "EXCLUDED_ARCHS[sdk=*]" = arm64;
203
+ GCC_C_LANGUAGE_STANDARD = gnu99;
204
+ GCC_NO_COMMON_BLOCKS = YES;
205
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
206
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
207
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
208
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
209
+ GCC_WARN_UNUSED_FUNCTION = YES;
210
+ GCC_WARN_UNUSED_VARIABLE = YES;
211
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
212
+ MTL_ENABLE_DEBUG_INFO = NO;
213
+ SDKROOT = iphoneos;
214
+ VALIDATE_PRODUCT = YES;
215
+ };
216
+ name = Release;
217
+ };
218
+ 58B511F01A9E6C8500147676 /* Debug */ = {
219
+ isa = XCBuildConfiguration;
220
+ buildSettings = {
221
+ HEADER_SEARCH_PATHS = (
222
+ "$(inherited)",
223
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
224
+ "$(SRCROOT)/../../../React/**",
225
+ "$(SRCROOT)/../../react-native/React/**",
226
+ );
227
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
228
+ OTHER_LDFLAGS = "-ObjC";
229
+ PRODUCT_NAME = Clarity;
230
+ SKIP_INSTALL = YES;
231
+ };
232
+ name = Debug;
233
+ };
234
+ 58B511F11A9E6C8500147676 /* Release */ = {
235
+ isa = XCBuildConfiguration;
236
+ buildSettings = {
237
+ HEADER_SEARCH_PATHS = (
238
+ "$(inherited)",
239
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
240
+ "$(SRCROOT)/../../../React/**",
241
+ "$(SRCROOT)/../../react-native/React/**",
242
+ );
243
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
244
+ OTHER_LDFLAGS = "-ObjC";
245
+ PRODUCT_NAME = Clarity;
246
+ SKIP_INSTALL = YES;
247
+ };
248
+ name = Release;
249
+ };
250
+ /* End XCBuildConfiguration section */
251
+
252
+ /* Begin XCConfigurationList section */
253
+ 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Clarity" */ = {
254
+ isa = XCConfigurationList;
255
+ buildConfigurations = (
256
+ 58B511ED1A9E6C8500147676 /* Debug */,
257
+ 58B511EE1A9E6C8500147676 /* Release */,
258
+ );
259
+ defaultConfigurationIsVisible = 0;
260
+ defaultConfigurationName = Release;
261
+ };
262
+ 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Clarity" */ = {
263
+ isa = XCConfigurationList;
264
+ buildConfigurations = (
265
+ 58B511F01A9E6C8500147676 /* Debug */,
266
+ 58B511F11A9E6C8500147676 /* Release */,
267
+ );
268
+ defaultConfigurationIsVisible = 0;
269
+ defaultConfigurationName = Release;
270
+ };
271
+ /* End XCConfigurationList section */
272
+ };
273
+ rootObject = 58B511D31A9E6C8500147676 /* Project object */;
274
+ }
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ </Workspace>
@@ -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;
@@ -31,6 +32,7 @@ const SupportedPlatforms = ['android'];
31
32
  * @param allowedDomains [OPTIONAL default = ["*"]] The whitelisted domains to allow Clarity to capture their DOM content.
32
33
  * If it contains "*" as an element, all domains will be captured.
33
34
  * @param disableOnLowEndDevices [OPTIONAL default = false] Disable Clarity on low-end devices.
35
+ * @param maximumDailyNetworkUsageInMB [OPTIONAL default = null] Maximum daily network usage for Clarity (null = No limit). When the limit is reached, Clarity will turn on lean mode.
34
36
  */
35
37
  /**
36
38
  * The level of logging to show in the device logcat stream.
@@ -62,7 +64,8 @@ function initialize(projectId, config) {
62
64
  allowMeteredNetworkUsage = false,
63
65
  enableWebViewCapture = true,
64
66
  allowedDomains = ["*"],
65
- disableOnLowEndDevices = false
67
+ disableOnLowEndDevices = false,
68
+ maximumDailyNetworkUsageInMB = null
66
69
  } = config ?? {};
67
70
  if (!SupportedPlatforms.includes(_reactNative.Platform.OS)) {
68
71
  console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
@@ -72,7 +75,11 @@ function initialize(projectId, config) {
72
75
  console.error("Clarity did not initialize properly.", LINKING_ERROR);
73
76
  return;
74
77
  }
75
- Clarity.initialize(projectId, userId, logLevel, allowMeteredNetworkUsage, enableWebViewCapture, allowedDomains, disableOnLowEndDevices);
78
+
79
+ // We use two parameters because the react method parameters do not accept nullable primitive types.
80
+ let enableDailyNetworkUsageLimit = maximumDailyNetworkUsageInMB != null;
81
+ let refinedMaximumDailyNetworkUsageInMB = maximumDailyNetworkUsageInMB ?? 0;
82
+ Clarity.initialize(projectId, userId, logLevel, allowMeteredNetworkUsage, enableWebViewCapture, allowedDomains, disableOnLowEndDevices, enableDailyNetworkUsageLimit, refinedMaximumDailyNetworkUsageInMB);
76
83
  }
77
84
 
78
85
  /**
@@ -160,16 +167,30 @@ function setCurrentScreenName(screenName) {
160
167
  function getCurrentSessionId() {
161
168
  if (!SupportedPlatforms.includes(_reactNative.Platform.OS)) {
162
169
  console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
163
- return new Promise(resolve => {
164
- resolve("Undefined");
165
- });
170
+ return Promise.resolve("Undefined");
166
171
  }
167
172
  if (Clarity === null) {
168
173
  console.error("Clarity did not initialize properly.", LINKING_ERROR);
169
- return new Promise(resolve => {
170
- resolve("Undefined");
171
- });
174
+ return Promise.resolve("Undefined");
172
175
  }
173
176
  return Clarity.getCurrentSessionId();
174
177
  }
178
+
179
+ /**
180
+ * Returns the active session url. This can be used to correlate the Clarity session with other
181
+ * analytics tools that the developer may be using.
182
+ *
183
+ * @returns a promise that resolves to the current session url if there is an active one.
184
+ */
185
+ function getCurrentSessionUrl() {
186
+ if (!SupportedPlatforms.includes(_reactNative.Platform.OS)) {
187
+ console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
188
+ return Promise.resolve("Undefined");
189
+ }
190
+ if (Clarity === null) {
191
+ console.error("Clarity did not initialize properly.", LINKING_ERROR);
192
+ return Promise.resolve("Undefined");
193
+ }
194
+ return Clarity.getCurrentSessionUrl();
195
+ }
175
196
  //# 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","maximumDailyNetworkUsageInMB","includes","Platform","OS","console","warn","join","error","enableDailyNetworkUsageLimit","refinedMaximumDailyNetworkUsageInMB","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;AACA;AAWA;AACA;AACA;AAFA,IAGYC,QAAQ,0BAAR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,OAAO,CAACC,IAAI,CAAC,mBAAmB,GAAGnB,kBAAkB,CAACoB,IAAI,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC;IACpF,OAAOc,OAAO,CAACC,OAAO,CAAC,WAAW,CAAC;EACrC;EAEA,IAAIrC,OAAO,KAAK,IAAI,EAAE;IACpBoB,OAAO,CAACG,KAAK,CAAC,sCAAsC,EAAExB,aAAa,CAAC;IACpE,OAAOqC,OAAO,CAACC,OAAO,CAAC,WAAW,CAAC;EACrC;EAEA,OAAOrC,OAAO,CAACsC,oBAAoB,CAAC,CAAC;AACvC"}
@@ -19,6 +19,7 @@ const SupportedPlatforms = ['android'];
19
19
  * @param allowedDomains [OPTIONAL default = ["*"]] The whitelisted domains to allow Clarity to capture their DOM content.
20
20
  * If it contains "*" as an element, all domains will be captured.
21
21
  * @param disableOnLowEndDevices [OPTIONAL default = false] Disable Clarity on low-end devices.
22
+ * @param maximumDailyNetworkUsageInMB [OPTIONAL default = null] Maximum daily network usage for Clarity (null = No limit). When the limit is reached, Clarity will turn on lean mode.
22
23
  */
23
24
 
24
25
  /**
@@ -51,7 +52,8 @@ export function initialize(projectId, config) {
51
52
  allowMeteredNetworkUsage = false,
52
53
  enableWebViewCapture = true,
53
54
  allowedDomains = ["*"],
54
- disableOnLowEndDevices = false
55
+ disableOnLowEndDevices = false,
56
+ maximumDailyNetworkUsageInMB = null
55
57
  } = config ?? {};
56
58
  if (!SupportedPlatforms.includes(Platform.OS)) {
57
59
  console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
@@ -61,7 +63,11 @@ export function initialize(projectId, config) {
61
63
  console.error("Clarity did not initialize properly.", LINKING_ERROR);
62
64
  return;
63
65
  }
64
- Clarity.initialize(projectId, userId, logLevel, allowMeteredNetworkUsage, enableWebViewCapture, allowedDomains, disableOnLowEndDevices);
66
+
67
+ // We use two parameters because the react method parameters do not accept nullable primitive types.
68
+ let enableDailyNetworkUsageLimit = maximumDailyNetworkUsageInMB != null;
69
+ let refinedMaximumDailyNetworkUsageInMB = maximumDailyNetworkUsageInMB ?? 0;
70
+ Clarity.initialize(projectId, userId, logLevel, allowMeteredNetworkUsage, enableWebViewCapture, allowedDomains, disableOnLowEndDevices, enableDailyNetworkUsageLimit, refinedMaximumDailyNetworkUsageInMB);
65
71
  }
66
72
 
67
73
  /**
@@ -149,16 +155,30 @@ export function setCurrentScreenName(screenName) {
149
155
  export function getCurrentSessionId() {
150
156
  if (!SupportedPlatforms.includes(Platform.OS)) {
151
157
  console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
152
- return new Promise(resolve => {
153
- resolve("Undefined");
154
- });
158
+ return Promise.resolve("Undefined");
155
159
  }
156
160
  if (Clarity === null) {
157
161
  console.error("Clarity did not initialize properly.", LINKING_ERROR);
158
- return new Promise(resolve => {
159
- resolve("Undefined");
160
- });
162
+ return Promise.resolve("Undefined");
161
163
  }
162
164
  return Clarity.getCurrentSessionId();
163
165
  }
166
+
167
+ /**
168
+ * Returns the active session url. This can be used to correlate the Clarity session with other
169
+ * analytics tools that the developer may be using.
170
+ *
171
+ * @returns a promise that resolves to the current session url if there is an active one.
172
+ */
173
+ export function getCurrentSessionUrl() {
174
+ if (!SupportedPlatforms.includes(Platform.OS)) {
175
+ console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
176
+ return Promise.resolve("Undefined");
177
+ }
178
+ if (Clarity === null) {
179
+ console.error("Clarity did not initialize properly.", LINKING_ERROR);
180
+ return Promise.resolve("Undefined");
181
+ }
182
+ return Clarity.getCurrentSessionUrl();
183
+ }
164
184
  //# 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":["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,GAAG,KAAK;IAChCC,oBAAoB,GAAG,IAAI;IAC3BC,cAAc,GAAG,CAAC,GAAG,CAAC;IACtBC,sBAAsB,GAAG;EAAM,CAAC,GAAGR,MAAM,IAAI,CAAC,CAAC;EAEjD,IAAI,CAACJ,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;EACF;EAEA,IAAIlB,OAAO,KA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C,sCAAsC,EAAEpB,aAAa,CAAC;IACpE,OAAO,IAAI+B,OAAO,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","maximumDailyNetworkUsageInMB","includes","OS","console","warn","join","error","enableDailyNetworkUsageLimit","refinedMaximumDailyNetworkUsageInMB","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;AACA;;AAWA;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,CA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AAO,CAACmC,oBAAoB,CAAC,CAAC;AACvC"}
@@ -12,6 +12,7 @@
12
12
  * @param allowedDomains [OPTIONAL default = ["*"]] The whitelisted domains to allow Clarity to capture their DOM content.
13
13
  * If it contains "*" as an element, all domains will be captured.
14
14
  * @param disableOnLowEndDevices [OPTIONAL default = false] Disable Clarity on low-end devices.
15
+ * @param maximumDailyNetworkUsageInMB [OPTIONAL default = null] Maximum daily network usage for Clarity (null = No limit). When the limit is reached, Clarity will turn on lean mode.
15
16
  */
16
17
  export interface ClarityConfig {
17
18
  userId?: string | null;
@@ -20,6 +21,7 @@ export interface ClarityConfig {
20
21
  enableWebViewCapture?: boolean;
21
22
  allowedDomains?: string[];
22
23
  disableOnLowEndDevices?: Boolean;
24
+ maximumDailyNetworkUsageInMB?: number;
23
25
  }
24
26
  /**
25
27
  * The level of logging to show in the device logcat stream.
@@ -70,11 +72,18 @@ export declare function setCustomTag(key: string, value: string): void;
70
72
  * You can it set to `null` to remove the latest set value.
71
73
  * @param screenName The current screen name to set.
72
74
  */
73
- export declare function setCurrentScreenName(screenName: string): void;
75
+ export declare function setCurrentScreenName(screenName: string | null): void;
74
76
  /**
75
77
  * Returns the active session id. This can be used to correlate the Clarity session with other
76
78
  * analytics tools that the developer may be using.
77
79
  * @returns a promise that resolves to the current session id.
78
80
  */
79
81
  export declare function getCurrentSessionId(): Promise<string>;
82
+ /**
83
+ * Returns the active session url. This can be used to correlate the Clarity session with other
84
+ * analytics tools that the developer may be using.
85
+ *
86
+ * @returns a promise that resolves to the current session url if there is an active one.
87
+ */
88
+ export declare function getCurrentSessionUrl(): Promise<string>;
80
89
  //# 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,E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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,QAwCnE;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.2.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",
@@ -1,35 +1,35 @@
1
- require "json"
2
-
3
- package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
- folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
-
6
- Pod::Spec.new do |s|
7
- s.name = "react-native-clarity"
8
- s.version = package["version"]
9
- s.summary = package["description"]
10
- s.homepage = package["homepage"]
11
- s.license = package["license"]
12
- s.authors = package["author"]
13
-
14
- s.platforms = { :ios => "11.0" }
15
- s.source = { :git => "https://msasg.visualstudio.com/Clarity/_git/clarity-react-native.git", :tag => "#{s.version}" }
16
-
17
- s.source_files = "ios/**/*.{h,m,mm}"
18
-
19
- s.dependency "React-Core"
20
-
21
- # Don't install the dependencies when we run `pod install` in the old architecture.
22
- if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
23
- s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
24
- s.pod_target_xcconfig = {
25
- "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
26
- "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
27
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
28
- }
29
- s.dependency "React-Codegen"
30
- s.dependency "RCT-Folly"
31
- s.dependency "RCTRequired"
32
- s.dependency "RCTTypeSafety"
33
- s.dependency "ReactCommon/turbomodule/core"
34
- end
35
- end
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "react-native-clarity"
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
12
+ s.authors = package["author"]
13
+
14
+ s.platforms = { :ios => "11.0" }
15
+ s.source = { :git => "https://msasg.visualstudio.com/Clarity/_git/clarity-react-native.git", :tag => "#{s.version}" }
16
+
17
+ s.source_files = "ios/**/*.{h,m,mm}"
18
+
19
+ s.dependency "React-Core"
20
+
21
+ # Don't install the dependencies when we run `pod install` in the old architecture.
22
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
23
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
24
+ s.pod_target_xcconfig = {
25
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
26
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
27
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
28
+ }
29
+ s.dependency "React-Codegen"
30
+ s.dependency "RCT-Folly"
31
+ s.dependency "RCTRequired"
32
+ s.dependency "RCTTypeSafety"
33
+ s.dependency "ReactCommon/turbomodule/core"
34
+ end
35
+ end
package/src/index.tsx CHANGED
@@ -24,6 +24,7 @@ const SupportedPlatforms = ['android']
24
24
  * @param allowedDomains [OPTIONAL default = ["*"]] The whitelisted domains to allow Clarity to capture their DOM content.
25
25
  * If it contains "*" as an element, all domains will be captured.
26
26
  * @param disableOnLowEndDevices [OPTIONAL default = false] Disable Clarity on low-end devices.
27
+ * @param maximumDailyNetworkUsageInMB [OPTIONAL default = null] Maximum daily network usage for Clarity (null = No limit). When the limit is reached, Clarity will turn on lean mode.
27
28
  */
28
29
  export interface ClarityConfig {
29
30
  userId?: string | null;
@@ -32,6 +33,7 @@ export interface ClarityConfig {
32
33
  enableWebViewCapture?: boolean;
33
34
  allowedDomains?: string[];
34
35
  disableOnLowEndDevices?: Boolean;
36
+ maximumDailyNetworkUsageInMB?: number;
35
37
  }
36
38
 
37
39
  /**
@@ -63,7 +65,8 @@ export function initialize(projectId: string, config?: ClarityConfig) {
63
65
  allowMeteredNetworkUsage = false,
64
66
  enableWebViewCapture = true,
65
67
  allowedDomains = ["*"],
66
- disableOnLowEndDevices = false } = config ?? {};
68
+ disableOnLowEndDevices = false,
69
+ maximumDailyNetworkUsageInMB = null } = config ?? {};
67
70
 
68
71
  if (!SupportedPlatforms.includes(Platform.OS)) {
69
72
  console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
@@ -75,7 +78,21 @@ export function initialize(projectId: string, config?: ClarityConfig) {
75
78
  return;
76
79
  }
77
80
 
78
- Clarity.initialize(projectId, userId, logLevel, allowMeteredNetworkUsage, enableWebViewCapture, allowedDomains, disableOnLowEndDevices);
81
+ // We use two parameters because the react method parameters do not accept nullable primitive types.
82
+ let enableDailyNetworkUsageLimit = maximumDailyNetworkUsageInMB != null;
83
+ let refinedMaximumDailyNetworkUsageInMB = maximumDailyNetworkUsageInMB ?? 0;
84
+
85
+ Clarity.initialize(
86
+ projectId,
87
+ userId,
88
+ logLevel,
89
+ allowMeteredNetworkUsage,
90
+ enableWebViewCapture,
91
+ allowedDomains,
92
+ disableOnLowEndDevices,
93
+ enableDailyNetworkUsageLimit,
94
+ refinedMaximumDailyNetworkUsageInMB
95
+ );
79
96
  }
80
97
 
81
98
  /**
@@ -114,12 +131,12 @@ export function setCustomSessionId(customSessionId: string) {
114
131
  console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
115
132
  return;
116
133
  }
117
-
134
+
118
135
  if (Clarity === null) {
119
136
  console.error("Clarity did not initialize properly.", LINKING_ERROR);
120
137
  return;
121
138
  }
122
-
139
+
123
140
  Clarity.setCustomSessionId(customSessionId);
124
141
  }
125
142
 
@@ -149,7 +166,7 @@ export function setCustomTag(key: string, value: string) {
149
166
  * You can it set to `null` to remove the latest set value.
150
167
  * @param screenName The current screen name to set.
151
168
  */
152
- export function setCurrentScreenName(screenName: string) {
169
+ export function setCurrentScreenName(screenName: string | null) {
153
170
  if (!SupportedPlatforms.includes(Platform.OS)) {
154
171
  console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
155
172
  return;
@@ -171,17 +188,33 @@ export function setCurrentScreenName(screenName: string) {
171
188
  export function getCurrentSessionId(): Promise<string> {
172
189
  if (!SupportedPlatforms.includes(Platform.OS)) {
173
190
  console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
174
- return new Promise((resolve) => {
175
- resolve("Undefined");
176
- });
191
+ return Promise.resolve("Undefined");
177
192
  }
178
193
 
179
194
  if (Clarity === null) {
180
195
  console.error("Clarity did not initialize properly.", LINKING_ERROR);
181
- return new Promise((resolve) => {
182
- resolve("Undefined");
183
- });
196
+ return Promise.resolve("Undefined");
184
197
  }
185
198
 
186
199
  return Clarity.getCurrentSessionId();
187
200
  }
201
+
202
+ /**
203
+ * Returns the active session url. This can be used to correlate the Clarity session with other
204
+ * analytics tools that the developer may be using.
205
+ *
206
+ * @returns a promise that resolves to the current session url if there is an active one.
207
+ */
208
+ export function getCurrentSessionUrl(): Promise<string> {
209
+ if (!SupportedPlatforms.includes(Platform.OS)) {
210
+ console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
211
+ return Promise.resolve("Undefined");
212
+ }
213
+
214
+ if (Clarity === null) {
215
+ console.error("Clarity did not initialize properly.", LINKING_ERROR);
216
+ return Promise.resolve("Undefined");
217
+ }
218
+
219
+ return Clarity.getCurrentSessionUrl();
220
+ }