react-native-clarity 2.2.0 → 2.3.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
@@ -1,112 +1,121 @@
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
- // Set custom user id.
27
- setCustomUserId("<CustomUserId>");
28
-
29
- // Set custom session id.
30
- setCustomSessionId("<CustomSessionId>");
31
-
32
- // Set custom tag.
33
- setCustomTag("key", "value");
34
-
35
- // Setting the current screen name when using React Navigation
36
- import { NavigationContainer useNavigationContainerRef } from '@react-navigation/native';
37
-
38
- const HomeScreen = ({...}) => {
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>
61
- );
62
- };
63
-
64
- // Get current session id to correlate with other tools.
65
- getCurrentSessionId().then((id) => {...});
66
-
67
- // Get current session url to correlate with other tools.
68
- getCurrentSessionUrl().then((url) => {...});
69
- ```
70
-
71
- ### Initialization arguments
72
-
73
- ```ts
74
- /**
75
- * Initializes the Clarity SDK if the API level is supported.
76
- *
77
- * @param projectId [REQUIRED] The Clarity project id to send data to.
78
- * @param config [OPTIONAL] The clarity config, if not provided default values are used.
79
- */
80
- function initialize(projectId: string, config?: ClarityConfig)
81
-
82
- /**
83
- * The configuration that will be used to customize the Clarity behaviour.
84
- *
85
- * @param userId [OPTIONAL default = null] A custom identifier for the current user. If passed as null, the user id
86
- * will be auto generated. The user id in general is sticky across sessions.
87
- * The provided user id must follow these conditions:
88
- * 1. Cannot be an empty string.
89
- * 2. Should be base36 and smaller than "1Z141Z4".
90
- * @param logLevel [OPTIONAL default = LogLevel.None] The level of logging to show in the device logcat stream.
91
- * @param allowMeteredNetworkUsage [OPTIONAL default = false] Allows uploading session data to the servers on device metered network.
92
- * @param enableWebViewCapture [OPTIONAL default = true] Allows Clarity to capture the web views DOM content.
93
- * @param allowedDomains [OPTIONAL default = ["*"]] The whitelisted domains to allow Clarity to capture their DOM content.
94
- * If it contains "*" as an element, all domains will be captured.
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.
97
- */
98
-
99
- interface ClarityConfig {
100
- userId?: string | null;
101
- logLevel?: LogLevel;
102
- allowMeteredNetworkUsage?: boolean;
103
- enableWebViewCapture?: boolean;
104
- allowedDomains?: string[];
105
- disableOnLowEndDevices?: Boolean;
106
- maximumDailyNetworkUsageInMB?: number;
107
- }
108
- ```
109
-
110
- ## License
111
-
112
- 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
+ **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,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.2.0-manual20240317193429"
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.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,8 +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
8
- org.gradle.java.home=C\:\\Program Files\\OpenLogic\\jdk-17.0.10.7-hotspot
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