react-native-clarity 2.3.0 → 3.0.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
@@ -1,121 +1,127 @@
1
- # react-native-clarity
2
-
3
- A ReactNative plugin that allows integrating Clarity with your application.
4
-
5
- ## Installation
6
-
7
- ```sh
8
- npm install react-native-clarity
9
- ```
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
-
13
- ## Usage
14
-
15
- ```js
16
- import { LogLevel, initialize, setCustomUserId, setCustomSessionId, setCustomTag, setCurrentScreenName, getCurrentSessionId } from 'react-native-clarity';
17
-
18
- // Initialize Clarity.
19
- const clarityConfig = {
20
- logLevel: LogLevel.Verbose,
21
- allowMeteredNetworkUsage: true
22
- };
23
-
24
- initialize('<ProjectId>', clarityConfig);
25
-
26
- // Pause Clarity capturing.
27
- pause();
28
-
29
- // Resume Clarity capturing if paused.
30
- resume();
31
-
32
- // Returns true if clarity was paused.
33
- isPaused().then((paused) => {...});
34
-
35
- // Set custom user id.
36
- setCustomUserId("<CustomUserId>");
37
-
38
- // Set custom session id.
39
- setCustomSessionId("<CustomSessionId>");
40
-
41
- // Set custom tag.
42
- setCustomTag("key", "value");
43
-
44
- // Setting the current screen name when using React Navigation
45
- import { NavigationContainer useNavigationContainerRef } from '@react-navigation/native';
46
-
47
- const HomeScreen = ({...}) => {
48
- const navigationRef = useNavigationContainerRef();
49
- const routeNameRef = React.useRef();
50
-
51
- return (
52
- <NavigationContainer
53
- ref={navigationRef}
54
- onReady={() => {
55
- routeNameRef.current = navigationRef.getCurrentRoute().name;
56
- setCurrentScreenName(routeNameRef.current);
57
- }}
58
- onStateChange={() => {
59
- const previousRouteName = routeNameRef.current;
60
- const currentRouteName = navigationRef.getCurrentRoute().name;
61
-
62
- if (previousRouteName !== currentRouteName) {
63
- routeNameRef.current = currentRouteName;
64
- setCurrentScreenName(currentRouteName);
65
- }
66
- }}
67
- >
68
- {/* ... */}
69
- </NavigationContainer>
70
- );
71
- };
72
-
73
- // Get current session id to correlate with other tools.
74
- getCurrentSessionId().then((id) => {...});
75
-
76
- // Get current session url to correlate with other tools.
77
- getCurrentSessionUrl().then((url) => {...});
78
- ```
79
-
80
- ### Initialization arguments
81
-
82
- ```ts
83
- /**
84
- * Initializes the Clarity SDK if the API level is supported.
85
- *
86
- * @param projectId [REQUIRED] The Clarity project id to send data to.
87
- * @param config [OPTIONAL] The clarity config, if not provided default values are used.
88
- */
89
- function initialize(projectId: string, config?: ClarityConfig)
90
-
91
- /**
92
- * The configuration that will be used to customize the Clarity behaviour.
93
- *
94
- * @param userId [OPTIONAL default = null] A custom identifier for the current user. If passed as null, the user id
95
- * will be auto generated. The user id in general is sticky across sessions.
96
- * The provided user id must follow these conditions:
97
- * 1. Cannot be an empty string.
98
- * 2. Should be base36 and smaller than "1Z141Z4".
99
- * @param logLevel [OPTIONAL default = LogLevel.None] The level of logging to show in the device logcat stream.
100
- * @param allowMeteredNetworkUsage [OPTIONAL default = false] Allows uploading session data to the servers on device metered network.
101
- * @param enableWebViewCapture [OPTIONAL default = true] Allows Clarity to capture the web views DOM content.
102
- * @param allowedDomains [OPTIONAL default = ["*"]] The whitelisted domains to allow Clarity to capture their DOM content.
103
- * If it contains "*" as an element, all domains will be captured.
104
- * @param disableOnLowEndDevices [OPTIONAL default = false] Disable Clarity on low-end devices.
105
- * @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.
106
- */
107
-
108
- interface ClarityConfig {
109
- userId?: string | null;
110
- logLevel?: LogLevel;
111
- allowMeteredNetworkUsage?: boolean;
112
- enableWebViewCapture?: boolean;
113
- allowedDomains?: string[];
114
- disableOnLowEndDevices?: Boolean;
115
- maximumDailyNetworkUsageInMB?: number;
116
- }
117
- ```
118
-
119
- ## License
120
-
121
- MIT
1
+ # react-native-clarity
2
+
3
+ A ReactNative plugin that allows integrating Clarity with your application.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install react-native-clarity
9
+ ```
10
+
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.
15
+
16
+ ## Usage
17
+
18
+ ```js
19
+ import { LogLevel, initialize, setCustomUserId, setCustomSessionId, setCustomTag, setCurrentScreenName, getCurrentSessionId, getCurrentSessionUrl } from 'react-native-clarity';
20
+
21
+ // Initialize Clarity.
22
+ const clarityConfig = {
23
+ logLevel: LogLevel.Verbose,
24
+ allowMeteredNetworkUsage: true
25
+ };
26
+
27
+ initialize('<ProjectId>', clarityConfig);
28
+
29
+ // Pause Clarity capturing.
30
+ pause();
31
+
32
+ // Resume Clarity capturing if paused.
33
+ resume();
34
+
35
+ // Returns true if clarity was paused.
36
+ isPaused().then((paused) => {...});
37
+
38
+ // Set custom user id.
39
+ setCustomUserId("<CustomUserId>");
40
+
41
+ // Set custom session id.
42
+ setCustomSessionId("<CustomSessionId>");
43
+
44
+ // Set custom tag.
45
+ setCustomTag("key", "value");
46
+
47
+ // Setting the current screen name when using React Navigation
48
+ import { NavigationContainer useNavigationContainerRef } from '@react-navigation/native';
49
+
50
+ const HomeScreen = ({...}) => {
51
+ const navigationRef = useNavigationContainerRef();
52
+ const routeNameRef = React.useRef();
53
+
54
+ return (
55
+ <NavigationContainer
56
+ ref={navigationRef}
57
+ onReady={() => {
58
+ routeNameRef.current = navigationRef.getCurrentRoute().name;
59
+ setCurrentScreenName(routeNameRef.current);
60
+ }}
61
+ onStateChange={() => {
62
+ const previousRouteName = routeNameRef.current;
63
+ const currentRouteName = navigationRef.getCurrentRoute().name;
64
+
65
+ if (previousRouteName !== currentRouteName) {
66
+ routeNameRef.current = currentRouteName;
67
+ setCurrentScreenName(currentRouteName);
68
+ }
69
+ }}
70
+ >
71
+ {/* ... */}
72
+ </NavigationContainer>
73
+ );
74
+ };
75
+
76
+ // Get current session id to correlate with other tools.
77
+ getCurrentSessionId().then((id) => {...});
78
+
79
+ // Get current session url to correlate with other tools.
80
+ getCurrentSessionUrl().then((url) => {...});
81
+ ```
82
+
83
+ ### Initialization arguments
84
+
85
+ ```ts
86
+ /**
87
+ * Initializes the Clarity SDK if the API level is supported.
88
+ *
89
+ * @param projectId [REQUIRED] The Clarity project id to send data to.
90
+ * @param config [OPTIONAL] The clarity config, if not provided default values are used.
91
+ */
92
+ function initialize(projectId: string, config?: ClarityConfig)
93
+
94
+ /**
95
+ * The configuration that will be used to customize the Clarity behaviour.
96
+ *
97
+ * @param userId [OPTIONAL default = null] A custom identifier for the current user. If passed as null, the user id
98
+ * will be auto generated. The user id in general is sticky across sessions.
99
+ * The provided user id must follow these conditions:
100
+ * 1. Cannot be an empty string.
101
+ * 2. Should be base36 and smaller than "1Z141Z4".
102
+ * @param logLevel [OPTIONAL default = LogLevel.None] The level of logging to show in the device logcat stream.
103
+ * @param allowMeteredNetworkUsage [OPTIONAL default = false] Allows uploading session data to the servers on device metered network.
104
+ * @param enableWebViewCapture [OPTIONAL default = true] Allows Clarity to capture the web views DOM content.
105
+ * @param allowedDomains [OPTIONAL default = ["*"]] The whitelisted domains to allow Clarity to capture their DOM content.
106
+ * If it contains "*" as an element, all domains will be captured.
107
+ * Note: iOS currently does not support allowedDomains feature.
108
+ * @param disableOnLowEndDevices [OPTIONAL default = false] Disable Clarity on low-end devices.
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.
112
+ */
113
+ interface ClarityConfig {
114
+ userId?: string | null;
115
+ logLevel?: LogLevel;
116
+ allowMeteredNetworkUsage?: boolean;
117
+ enableWebViewCapture?: boolean;
118
+ allowedDomains?: string[];
119
+ disableOnLowEndDevices?: Boolean;
120
+ maximumDailyNetworkUsageInMB?: number;
121
+ enableIOS_experimental?: boolean;
122
+ }
123
+ ```
124
+
125
+ ## License
126
+
127
+ MIT
@@ -1,81 +1,81 @@
1
- buildscript {
2
- // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
- def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["Clarity_kotlinVersion"]
4
-
5
- repositories {
6
- google()
7
- mavenCentral()
8
- }
9
-
10
- dependencies {
11
- classpath "com.android.tools.build:gradle:7.2.1"
12
- // noinspection DifferentKotlinGradleVersion
13
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
- }
15
- }
16
-
17
- def isNewArchitectureEnabled() {
18
- return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
19
- }
20
-
21
- apply plugin: "com.android.library"
22
- apply plugin: "kotlin-android"
23
-
24
- if (isNewArchitectureEnabled()) {
25
- apply plugin: "com.facebook.react"
26
- }
27
-
28
- def getExtOrDefault(name) {
29
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Clarity_" + name]
30
- }
31
-
32
- def getExtOrIntegerDefault(name) {
33
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Clarity_" + name]).toInteger()
34
- }
35
-
36
- android {
37
- compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
38
-
39
- defaultConfig {
40
- minSdkVersion getExtOrIntegerDefault("minSdkVersion")
41
- targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
42
- buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
43
- }
44
- buildTypes {
45
- release {
46
- minifyEnabled false
47
- }
48
- }
49
-
50
- lintOptions {
51
- disable "GradleCompatible"
52
- }
53
-
54
- compileOptions {
55
- sourceCompatibility JavaVersion.VERSION_1_8
56
- targetCompatibility JavaVersion.VERSION_1_8
57
- }
58
-
59
- }
60
-
61
- repositories {
62
- mavenCentral()
63
- google()
64
- mavenLocal()
65
- }
66
-
67
- def kotlin_version = getExtOrDefault("kotlinVersion")
68
-
69
- dependencies {
70
- implementation "com.facebook.react:react-native:+"
71
- implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
72
- implementation "com.microsoft.clarity:clarity:2.3.0"
73
- }
74
-
75
- if (isNewArchitectureEnabled()) {
76
- react {
77
- jsRootDir = file("../src/")
78
- libraryName = "Clarity"
79
- codegenJavaPackageName = "com.microsoft.clarity.reactnative"
80
- }
81
- }
1
+ buildscript {
2
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["Clarity_kotlinVersion"]
4
+
5
+ repositories {
6
+ google()
7
+ mavenCentral()
8
+ }
9
+
10
+ dependencies {
11
+ classpath "com.android.tools.build:gradle:7.2.1"
12
+ // noinspection DifferentKotlinGradleVersion
13
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
+ }
15
+ }
16
+
17
+ def isNewArchitectureEnabled() {
18
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
19
+ }
20
+
21
+ apply plugin: "com.android.library"
22
+ apply plugin: "kotlin-android"
23
+
24
+ if (isNewArchitectureEnabled()) {
25
+ apply plugin: "com.facebook.react"
26
+ }
27
+
28
+ def getExtOrDefault(name) {
29
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Clarity_" + name]
30
+ }
31
+
32
+ def getExtOrIntegerDefault(name) {
33
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Clarity_" + name]).toInteger()
34
+ }
35
+
36
+ android {
37
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
38
+
39
+ defaultConfig {
40
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
41
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
42
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
43
+ }
44
+ buildTypes {
45
+ release {
46
+ minifyEnabled false
47
+ }
48
+ }
49
+
50
+ lintOptions {
51
+ disable "GradleCompatible"
52
+ }
53
+
54
+ compileOptions {
55
+ sourceCompatibility JavaVersion.VERSION_1_8
56
+ targetCompatibility JavaVersion.VERSION_1_8
57
+ }
58
+
59
+ }
60
+
61
+ repositories {
62
+ mavenCentral()
63
+ google()
64
+ mavenLocal()
65
+ }
66
+
67
+ def kotlin_version = getExtOrDefault("kotlinVersion")
68
+
69
+ dependencies {
70
+ implementation "com.facebook.react:react-native:+"
71
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
72
+ implementation "com.microsoft.clarity:clarity:2.4.0"
73
+ }
74
+
75
+ if (isNewArchitectureEnabled()) {
76
+ react {
77
+ jsRootDir = file("../src/")
78
+ libraryName = "Clarity"
79
+ codegenJavaPackageName = "com.microsoft.clarity.reactnative"
80
+ }
81
+ }
@@ -1,7 +1,7 @@
1
- #make sure these are acutally used
2
- Clarity_kotlinVersion=1.7.0
3
- Clarity_minSdkVersion=21
4
- Clarity_targetSdkVersion=34
5
- Clarity_compileSdkVersion=34
6
- Clarity_ndkversion=21.4.7075529
7
- android.useAndroidX=true
1
+ #make sure these are acutally used
2
+ Clarity_kotlinVersion=1.7.0
3
+ Clarity_minSdkVersion=21
4
+ Clarity_targetSdkVersion=34
5
+ Clarity_compileSdkVersion=34
6
+ Clarity_ndkversion=21.4.7075529
7
+ android.useAndroidX=true