react-native-clarity 2.3.0 → 3.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/LICENSE +20 -20
- package/README.md +9 -3
- package/android/build.gradle +1 -1
- package/android/src/main/AndroidManifest.xml +4 -4
- package/android/src/main/java/com/microsoft/clarity/reactnative/ClarityPackage.kt +17 -17
- package/ios/Clarity.h +12 -12
- package/ios/Clarity.m +131 -0
- package/ios/Clarity.xcodeproj/project.pbxproj +280 -274
- package/lib/commonjs/index.js +60 -83
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +58 -81
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +105 -101
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +8 -2
- package/react-native-clarity.podspec +36 -35
- package/src/index.tsx +89 -104
- package/ios/Clarity.mm +0 -15
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,12 +8,15 @@ A ReactNative plugin that allows integrating Clarity with your application.
|
|
|
8
8
|
npm install react-native-clarity
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
### Notes
|
|
12
|
+
|
|
13
|
+
- The Clarity package depends on native code to run, therefore you have to ship a new build after integrating the package.
|
|
14
|
+
- **For `react-native-svg` Users**: Clarity is currently incompatible with `react-native-svg` version 13.x due to a known bug that causes user interaction and playback issues. To ensure proper functionality, please upgrade to `react-native-svg` version 14 or later.
|
|
12
15
|
|
|
13
16
|
## Usage
|
|
14
17
|
|
|
15
18
|
```js
|
|
16
|
-
import { LogLevel, initialize, setCustomUserId, setCustomSessionId, setCustomTag, setCurrentScreenName, getCurrentSessionId } from 'react-native-clarity';
|
|
19
|
+
import { LogLevel, initialize, setCustomUserId, setCustomSessionId, setCustomTag, setCurrentScreenName, getCurrentSessionId, getCurrentSessionUrl } from 'react-native-clarity';
|
|
17
20
|
|
|
18
21
|
// Initialize Clarity.
|
|
19
22
|
const clarityConfig = {
|
|
@@ -101,10 +104,12 @@ function initialize(projectId: string, config?: ClarityConfig)
|
|
|
101
104
|
* @param enableWebViewCapture [OPTIONAL default = true] Allows Clarity to capture the web views DOM content.
|
|
102
105
|
* @param allowedDomains [OPTIONAL default = ["*"]] The whitelisted domains to allow Clarity to capture their DOM content.
|
|
103
106
|
* If it contains "*" as an element, all domains will be captured.
|
|
107
|
+
* Note: iOS currently does not support allowedDomains feature.
|
|
104
108
|
* @param disableOnLowEndDevices [OPTIONAL default = false] Disable Clarity on low-end devices.
|
|
105
109
|
* @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.
|
|
110
|
+
* Note: iOS currently does not support limiting network usage.
|
|
111
|
+
* @param enableIOS_experimental [OPTIONAL default = false] Experimental flag to enable Clarity on iOS platform.
|
|
106
112
|
*/
|
|
107
|
-
|
|
108
113
|
interface ClarityConfig {
|
|
109
114
|
userId?: string | null;
|
|
110
115
|
logLevel?: LogLevel;
|
|
@@ -113,6 +118,7 @@ interface ClarityConfig {
|
|
|
113
118
|
allowedDomains?: string[];
|
|
114
119
|
disableOnLowEndDevices?: Boolean;
|
|
115
120
|
maximumDailyNetworkUsageInMB?: number;
|
|
121
|
+
enableIOS_experimental?: boolean;
|
|
116
122
|
}
|
|
117
123
|
```
|
|
118
124
|
|
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:2.
|
|
72
|
+
implementation "com.microsoft.clarity:clarity:2.4.0"
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
if (isNewArchitectureEnabled()) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
-
package="com.microsoft.clarity.reactnative">
|
|
3
|
-
|
|
4
|
-
</manifest>
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
package="com.microsoft.clarity.reactnative">
|
|
3
|
+
|
|
4
|
+
</manifest>
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
package com.microsoft.clarity.reactnative
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.ReactPackage
|
|
4
|
-
import com.facebook.react.bridge.JavaScriptModule
|
|
5
|
-
import com.facebook.react.bridge.NativeModule
|
|
6
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
-
import com.facebook.react.uimanager.ViewManager
|
|
8
|
-
|
|
9
|
-
class ClarityPackage : ReactPackage {
|
|
10
|
-
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
11
|
-
return listOf(ClarityModule(reactContext))
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
15
|
-
return emptyList()
|
|
16
|
-
}
|
|
17
|
-
}
|
|
1
|
+
package com.microsoft.clarity.reactnative
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.JavaScriptModule
|
|
5
|
+
import com.facebook.react.bridge.NativeModule
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.uimanager.ViewManager
|
|
8
|
+
|
|
9
|
+
class ClarityPackage : ReactPackage {
|
|
10
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
11
|
+
return listOf(ClarityModule(reactContext))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
15
|
+
return emptyList()
|
|
16
|
+
}
|
|
17
|
+
}
|
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.m
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
#import "Clarity.h"
|
|
2
|
+
#import <React/RCTLog.h>
|
|
3
|
+
|
|
4
|
+
@import Clarity;
|
|
5
|
+
|
|
6
|
+
@implementation Clarity
|
|
7
|
+
RCT_EXPORT_MODULE()
|
|
8
|
+
|
|
9
|
+
RCT_EXPORT_METHOD(initialize:(NSString *)projectId
|
|
10
|
+
userId:(NSString *)userId
|
|
11
|
+
logLevel:(NSString *)logLevel
|
|
12
|
+
allowMeteredNetworkUsage:(BOOL)allowMeteredNetworkUsage
|
|
13
|
+
enableWebViewCapture:(BOOL)enableWebViewCapture
|
|
14
|
+
allowedDomains:(NSArray *)allowedDomains
|
|
15
|
+
disableOnLowEndDevices:(BOOL)disableOnLowEndDevices
|
|
16
|
+
enableDailyNetworkUsageLimit:(BOOL)enableDailyNetworkUsageLimit
|
|
17
|
+
maximumDailyNetworkUsageInMB:(double)maximumDailyNetworkUsageInMB
|
|
18
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
19
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
20
|
+
{
|
|
21
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
22
|
+
ClarityConfig* config = [[ClarityConfig alloc]
|
|
23
|
+
initWithProjectId:projectId
|
|
24
|
+
userId:userId
|
|
25
|
+
logLevel:[self convertLogLevelToEnum:logLevel]
|
|
26
|
+
allowMeteredNetworkUsage:allowMeteredNetworkUsage
|
|
27
|
+
enableWebViewCapture:enableWebViewCapture
|
|
28
|
+
disableOnLowEndDevices:disableOnLowEndDevices
|
|
29
|
+
applicationFramework:ApplicationFrameworkReactNative];
|
|
30
|
+
|
|
31
|
+
[ClaritySDK initializeWithConfig:config];
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
resolve(@(true));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
RCT_EXPORT_METHOD(pause:(RCTPromiseResolveBlock)resolve
|
|
38
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
39
|
+
{
|
|
40
|
+
[ClaritySDK pause];
|
|
41
|
+
resolve(@([ClaritySDK isPaused]));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
RCT_EXPORT_METHOD(resume:(RCTPromiseResolveBlock)resolve
|
|
45
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
46
|
+
{
|
|
47
|
+
[ClaritySDK resume];
|
|
48
|
+
resolve(@((BOOL)(![ClaritySDK isPaused])));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
RCT_EXPORT_METHOD(isPaused:(RCTPromiseResolveBlock)resolve
|
|
52
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
53
|
+
{
|
|
54
|
+
resolve(@([ClaritySDK isPaused]));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
RCT_EXPORT_METHOD(setCustomUserId:(NSString *)customUserId
|
|
58
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
59
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
60
|
+
{
|
|
61
|
+
resolve(@([ClaritySDK setCustomUserId:customUserId]));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
RCT_EXPORT_METHOD(setCustomSessionId:(NSString *)customSessionId
|
|
65
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
66
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
67
|
+
{
|
|
68
|
+
resolve(@([ClaritySDK setCustomSessionId:customSessionId]));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
RCT_EXPORT_METHOD(getCurrentSessionId:(RCTPromiseResolveBlock)resolve
|
|
72
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
73
|
+
{
|
|
74
|
+
resolve([ClaritySDK getCurrentSessionId]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
RCT_EXPORT_METHOD(setCustomTag:(NSString *)key value:(NSString *)value
|
|
78
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
79
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
80
|
+
{
|
|
81
|
+
resolve(@([ClaritySDK setCustomTagWithKey:key value:value]));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
RCT_EXPORT_METHOD(setCurrentScreenName:(NSString *)currentScreenName
|
|
85
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
86
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
87
|
+
{
|
|
88
|
+
resolve(@([ClaritySDK setCurrentScreenNameWithName:currentScreenName]));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
RCT_EXPORT_METHOD(getCurrentSessionUrl:(RCTPromiseResolveBlock)resolve
|
|
92
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
93
|
+
{
|
|
94
|
+
resolve([ClaritySDK getCurrentSessionUrl]);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
- (LogLevel)convertLogLevelToEnum:(NSString*)logLevel
|
|
98
|
+
{
|
|
99
|
+
if ([logLevel isEqual:@"Verbose"]) {
|
|
100
|
+
return LogLevelVerbose;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if ([logLevel isEqual:@"Debug"]) {
|
|
104
|
+
return LogLevelDebug;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if ([logLevel isEqual:@"Info"]) {
|
|
108
|
+
return LogLevelInfo;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if ([logLevel isEqual:@"Warning"]) {
|
|
112
|
+
return LogLevelWarning;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if ([logLevel isEqual:@"Error"]) {
|
|
116
|
+
return LogLevelError;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return LogLevelNone;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Don't compile this code when we build for the old architecture.
|
|
123
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
124
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
125
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
126
|
+
{
|
|
127
|
+
return std::make_shared<facebook::react::NativeClaritySpecJSI>(params);
|
|
128
|
+
}
|
|
129
|
+
#endif
|
|
130
|
+
|
|
131
|
+
@end
|