react-native-clarity 3.0.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 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
@@ -1,127 +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
- ### 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
+ # 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.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
+ 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
@@ -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>