react-native-clarity 3.1.1 → 4.0.2
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 +113 -59
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/microsoft/clarity/reactnative/ClarityEmitter.kt +55 -0
- package/android/src/main/java/com/microsoft/clarity/reactnative/ClarityModule.kt +12 -22
- package/android/src/main/java/com/microsoft/clarity/reactnative/ClarityPackage.kt +4 -1
- package/ios/Clarity.m +38 -22
- package/ios/Clarity.xcodeproj/project.pbxproj +6 -0
- package/ios/ClarityEmitter.h +6 -0
- package/ios/ClarityEmitter.m +50 -0
- package/lib/commonjs/index.js +198 -84
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +195 -85
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +130 -68
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +4 -3
- package/react-native-clarity.podspec +1 -1
- package/src/index.tsx +268 -120
|
@@ -1,34 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @param userId [OPTIONAL default = null] A custom identifier for the current user. If passed as null, the user id
|
|
5
|
-
* will be auto generated. The user id in general is sticky across sessions.
|
|
6
|
-
* The provided user id must follow these conditions:
|
|
7
|
-
* 1. Cannot be an empty string.
|
|
8
|
-
* 2. Should be base36 and smaller than "1Z141Z4".
|
|
9
|
-
* @param logLevel [OPTIONAL default = LogLevel.None] The level of logging to show in the device logcat stream.
|
|
10
|
-
* @param allowMeteredNetworkUsage [OPTIONAL default = false] Allows uploading session data to the servers on device metered network.
|
|
11
|
-
* @param enableWebViewCapture [OPTIONAL default = true] Allows Clarity to capture the web views DOM content.
|
|
12
|
-
* @param allowedDomains [OPTIONAL default = ["*"]] The whitelisted domains to allow Clarity to capture their DOM content.
|
|
13
|
-
* If it contains "*" as an element, all domains will be captured.
|
|
14
|
-
* Note: iOS currently does not support allowedDomains feature.
|
|
15
|
-
* @param disableOnLowEndDevices [OPTIONAL default = false] Disable Clarity on low-end devices.
|
|
16
|
-
* @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.
|
|
17
|
-
* Note: iOS currently does not support limiting network usage.
|
|
18
|
-
* @param enableIOS_experimental [OPTIONAL default = false] Experimental flag to enable Clarity on iOS platform.
|
|
2
|
+
* A class that allows you to configure the Clarity SDK behavior.
|
|
19
3
|
*/
|
|
20
4
|
export interface ClarityConfig {
|
|
21
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated This property is deprecated and would be removed in a future major version. Use {@linkcode setCustomSessionId} instead.
|
|
7
|
+
*
|
|
8
|
+
* The unique identifier associated with the application user. This ID persists across multiple sessions on the same device.
|
|
9
|
+
*
|
|
10
|
+
* **Notes:**
|
|
11
|
+
* - If {@linkcode userId} isn't provided, a random one is generated automatically.
|
|
12
|
+
* - Must be a base-36 string smaller than `1Z141Z4`.
|
|
13
|
+
* - If an invalid {@linkcode userId} is supplied:
|
|
14
|
+
* - If `customUserId` isn't specified, {@linkcode userId} acts as the `customUserId`, and a new random {@linkcode userId} is assigned.
|
|
15
|
+
* - If `customUserId` is specified, the invalid {@linkcode userID} is ignored.
|
|
16
|
+
* - For more flexibility in user identification, consider using the {@linkcode setCustomUserId} API. However, keep in mind that `customUserId` length must be between 1 and 255 characters.
|
|
17
|
+
*/
|
|
18
|
+
userId?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The level of logging to show in the device’s logging stream while debugging. By default, the SDK logs nothing.
|
|
21
|
+
*/
|
|
22
22
|
logLevel?: LogLevel;
|
|
23
|
-
allowMeteredNetworkUsage?: boolean;
|
|
24
|
-
enableWebViewCapture?: boolean;
|
|
25
|
-
allowedDomains?: string[];
|
|
26
|
-
disableOnLowEndDevices?: Boolean;
|
|
27
|
-
maximumDailyNetworkUsageInMB?: number;
|
|
28
|
-
enableIOS_experimental?: boolean;
|
|
29
23
|
}
|
|
30
24
|
/**
|
|
31
|
-
* The level of logging to show in the device
|
|
25
|
+
* The level of logging to show in the device logging stream.
|
|
32
26
|
*/
|
|
33
27
|
export declare enum LogLevel {
|
|
34
28
|
Verbose = "Verbose",
|
|
@@ -39,68 +33,136 @@ export declare enum LogLevel {
|
|
|
39
33
|
None = "None"
|
|
40
34
|
}
|
|
41
35
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @param
|
|
44
|
-
*
|
|
36
|
+
* @param projectId - The unique identifier assigned to your Clarity project. You can find it on the **Settings** page of Clarity dashboard. This ID is essential for routing data to the correct Clarity project (required).
|
|
37
|
+
* @param config - Configuration of Clarity that tunes the SDK behavior (for example, which log level to use, and so on).
|
|
38
|
+
*
|
|
39
|
+
* **Notes:**
|
|
40
|
+
* - The initialization function is asynchronous, meaning it returns before Clarity is fully initialized.
|
|
41
|
+
* - For actions that require Clarity to be fully initialized, it's recommended to use the {@linkcode setOnSessionStartedCallback} function.
|
|
45
42
|
*/
|
|
46
43
|
export declare function initialize(projectId: string, config?: ClarityConfig): void;
|
|
47
44
|
/**
|
|
48
|
-
* Pauses the Clarity capturing
|
|
45
|
+
* Pauses the Clarity session capturing until a call to the {@linkcode resume} function is made.
|
|
46
|
+
*
|
|
47
|
+
* @returns {Promise<boolean>} A Promise that resolves with `true` if Clarity session capturing was paused successfully; otherwise `false`.
|
|
49
48
|
*/
|
|
50
|
-
export declare function pause(): Promise<boolean
|
|
49
|
+
export declare function pause(): Promise<boolean>;
|
|
51
50
|
/**
|
|
52
|
-
* Resumes the Clarity capturing
|
|
53
|
-
*
|
|
51
|
+
* Resumes the Clarity session capturing only if it was previously paused by a call to the {@linkcode pause} function.
|
|
52
|
+
*
|
|
53
|
+
* @returns {Promise<boolean>} A Promise that resolves with `true` if Clarity session capturing was resumed successfully; otherwise `false`.
|
|
54
54
|
*/
|
|
55
|
-
export declare function resume(): Promise<boolean
|
|
55
|
+
export declare function resume(): Promise<boolean>;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* Checks if Clarity session capturing is currently paused based on an earlier call to the {@linkcode pause} function.
|
|
58
|
+
*
|
|
59
|
+
* @returns {Promise<boolean>} A Promise that resolves with `true` if Clarity session capturing is currently in the paused state based on an earlier call to the {@linkcode pause} function; otherwise `false`.
|
|
58
60
|
*/
|
|
59
|
-
export declare function isPaused(): Promise<
|
|
61
|
+
export declare function isPaused(): Promise<boolean>;
|
|
60
62
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
63
|
+
* Forces Clarity to start a new session asynchronously.
|
|
64
|
+
*
|
|
65
|
+
* @param callback - A callback that is invoked when the new session starts. The callback receives the new session ID as a string parameter.
|
|
66
|
+
*
|
|
67
|
+
* **Notes:**
|
|
68
|
+
* - This function is asynchronous, meaning it returns before the new session is started.
|
|
69
|
+
* - Use the {@linkcode callback} parameter to execute logic that needs to run after the new session begins.
|
|
70
|
+
* - Events that occur before invoking the callback are associated with the previous session.
|
|
71
|
+
* - To ensure proper association of custom tags, user ID, or session ID with the new session, set them within the callback.
|
|
69
72
|
*/
|
|
70
|
-
export declare function
|
|
73
|
+
export declare function startNewSession(callback: (sessionId: String) => void): void;
|
|
71
74
|
/**
|
|
72
|
-
* Sets a custom session
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
75
|
+
* Sets a custom user ID for the current session. This ID can be used to filter sessions on the Clarity dashboard.
|
|
76
|
+
*
|
|
77
|
+
* @param customUserId - The custom user ID to associate with the current session. The value must be a nonempty string, with a maximum length of 255 characters, and can't consist only of whitespace.
|
|
78
|
+
* @returns {Promise<boolean>} A Promise that resolves with `true` if the custom user ID was set successfully; otherwise `false`.
|
|
79
|
+
*
|
|
80
|
+
* **Notes:**
|
|
81
|
+
* - To ensure that the custom user ID is associated with the correct session, it's recommended to call this function within the callbacks of {@linkcode setOnSessionStartedCallback} or {@linkcode startNewSession}.
|
|
82
|
+
* - Unlike the `userID`, the {@linkcode customUserId} value has fewer restrictions.
|
|
83
|
+
* - We recommend **not** to set any Personally Identifiable Information (PII) values inside this field.
|
|
77
84
|
*/
|
|
78
|
-
export declare function
|
|
85
|
+
export declare function setCustomUserId(customUserId: string): Promise<boolean>;
|
|
79
86
|
/**
|
|
80
|
-
* Sets a custom
|
|
81
|
-
*
|
|
82
|
-
* @param
|
|
87
|
+
* Sets a custom session ID for the current session. This ID can be used to filter sessions on the Clarity dashboard.
|
|
88
|
+
*
|
|
89
|
+
* @param customSessionId - The custom session ID to associate with the current session. The value must be a nonempty string, with a maximum length of 255 characters, and can't consist only of whitespace.
|
|
90
|
+
* @returns {Promise<boolean>} A Promise that resolves with `true` if the custom session ID was set successfully; otherwise `false`.
|
|
91
|
+
*
|
|
92
|
+
* **Notes:**
|
|
93
|
+
* - To ensure that the custom session ID is associated with the correct session, it's recommended to call this function within the callbacks of {@linkcode setOnSessionStartedCallback} or {@linkcode startNewSession}.
|
|
83
94
|
*/
|
|
84
|
-
export declare function
|
|
95
|
+
export declare function setCustomSessionId(customSessionId: string): Promise<boolean>;
|
|
85
96
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* @
|
|
97
|
+
* Sets a custom tag for the current session. This tag can be used to filter sessions on the Clarity dashboard.
|
|
98
|
+
*
|
|
99
|
+
* @param key - The key for the custom tag. The value must be a nonempty string, with a maximum length of 255 characters, and can't consist only of whitespace.
|
|
100
|
+
* @param value - The value for the custom tag. The value must be a nonempty string, with a maximum length of 255 characters, and can't consist only of whitespace.
|
|
101
|
+
* @returns {Promise<boolean>} A Promise that resolves with `true` if the custom tag was set successfully; otherwise `false`.
|
|
102
|
+
*
|
|
103
|
+
* **Notes:**
|
|
104
|
+
* - To ensure that the custom tag is associated with the correct session, it's recommended to call this function within the callbacks of {@linkcode setOnSessionStartedCallback} or {@linkcode startNewSession}.
|
|
91
105
|
*/
|
|
92
|
-
export declare function
|
|
106
|
+
export declare function setCustomTag(key: string, value: string): Promise<boolean>;
|
|
93
107
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* @
|
|
108
|
+
* Sends a custom event to the current Clarity session. These custom events can be used to track specific user interactions or actions that Clarity's built-in event tracking doesn't capture.
|
|
109
|
+
*
|
|
110
|
+
* @param value - The name of the custom event. The value must be a nonempty string, with a maximum length of 254 characters, and can't consist only of whitespace.
|
|
111
|
+
* @returns {Promise<boolean>} A Promise that resolves with `true` if the custom event was sent successfully; otherwise `false`.
|
|
112
|
+
*
|
|
113
|
+
* **Notes:**
|
|
114
|
+
* - This API can be called multiple times per page to track various user actions.
|
|
115
|
+
* - Each custom event is logged individually and can be filtered, viewed, and analyzed on the Clarity dashboard.
|
|
97
116
|
*/
|
|
98
|
-
export declare function
|
|
117
|
+
export declare function sendCustomEvent(value: string): Promise<boolean>;
|
|
99
118
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
119
|
+
* Sets a callback function that's invoked whenever a new Clarity session starts or an existing session is resumed at app startup.
|
|
120
|
+
*
|
|
121
|
+
* @param callback - The callback to be invoked whenever a Clarity session starts. The callback receives the new or resumed session ID as a string parameter.
|
|
122
|
+
* @returns {boolean} `true` if the callback was set successfully; otherwise `false`.
|
|
123
|
+
*
|
|
124
|
+
* **Notes:**
|
|
125
|
+
* - If the callback is set after a session has already started, the callback is invoked right away with the current session ID.
|
|
126
|
+
* - The specified callback is guaranteed to run on the main thread.
|
|
127
|
+
*/
|
|
128
|
+
export declare function setOnSessionStartedCallback(callback: (sessionId: String) => void): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* This function allows you to provide a custom screen name tag that's added as a suffix to the base screen name. The base name is automatically generated based on the current activity in Android, or the currently presented view controller's title or type in iOS.
|
|
131
|
+
*
|
|
132
|
+
* @param screenName - The desired screen name tag. The value must be a nonempty string, with a maximum length of 255 characters, and can't consist only of whitespace nor contain `/` character. Set to `null` to reset.
|
|
133
|
+
* @returns {Promise<boolean>} A Promise that resolves with `true` if the specified screen name tag was set successfully; otherwise `false`.
|
|
134
|
+
*
|
|
135
|
+
* **Example:**
|
|
136
|
+
* - If the presented iOS view controller is a `UIViewController`, and `setCurrentScreenName("Settings")` is called, the screen name is tracked as "UIViewController/Settings".
|
|
137
|
+
* - If `setCurrentScreenName(nil)` is called on the same view controller, the screen name is tracked as "UIViewController".
|
|
138
|
+
*
|
|
139
|
+
* **Notes:**
|
|
140
|
+
* - Clarity starts a new page whenever either the base screen name (generated from the Android activity or iOS view controller) or the custom name tag changes.
|
|
141
|
+
* - To mask or disallow a screen, specify the base screen name without the custom tag suffix. For example, to mask the iOS view controller in the previous example, mask the "UIViewController" screen instead of "UIViewController/Settings".
|
|
142
|
+
* - The screen name tag is set globally and persists across all subsequent Android activities or iOS view controllers until explicitly reset.
|
|
143
|
+
*/
|
|
144
|
+
export declare function setCurrentScreenName(screenName: string | null): Promise<boolean>;
|
|
145
|
+
/**
|
|
146
|
+
* @deprecated This function is deprecated and would be removed in a future major version. Use {@linkcode getCurrentSessionUrl} instead.
|
|
147
|
+
*
|
|
148
|
+
* Returns the ID of the currently active Clarity session if a session has already started; otherwise `undefined`.
|
|
149
|
+
*
|
|
150
|
+
* @returns {Promise<string | undefined>} A Promise that resolves with a string representing the ID of the currently active Clarity session if a session has already started; otherwise `undefined`.
|
|
151
|
+
*
|
|
152
|
+
* **Note:**
|
|
153
|
+
* - The session ID can be used to correlate Clarity sessions with other telemetry services.
|
|
154
|
+
* - Initially, this function might return `undefined` until a Clarity session begins.
|
|
155
|
+
* - To ensure a valid session ID, use this method within the callbacks of {@linkcode setOnSessionStartedCallback} or {@linkcode startNewSession}.
|
|
156
|
+
*/
|
|
157
|
+
export declare function getCurrentSessionId(): Promise<string | undefined>;
|
|
158
|
+
/**
|
|
159
|
+
* Returns the URL of the current Clarity session recording on the Clarity dashboard if a session has already started; otherwise `undefined`.
|
|
160
|
+
*
|
|
161
|
+
* @returns {Promise<string | undefined>} A Promise that resolves with a string representing the URL of the current Clarity session recording on the Clarity dashboard if a session has already started; otherwise `undefined`.
|
|
102
162
|
*
|
|
103
|
-
*
|
|
163
|
+
* **Notes:**
|
|
164
|
+
* - Initially, this function might return `undefined` until a Clarity session begins.
|
|
165
|
+
* - To ensure a valid session URL, use this method within the callbacks of {@linkcode setOnSessionStartedCallback} or {@linkcode startNewSession}.
|
|
104
166
|
*/
|
|
105
|
-
export declare function getCurrentSessionUrl(): Promise<string>;
|
|
167
|
+
export declare function getCurrentSessionUrl(): Promise<string | undefined>;
|
|
106
168
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AA0BA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAiBD;;GAEG;AACH,oBAAY,QAAQ;IAClB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AA2ED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,QAiBnE;AAED;;;;GAIG;AACH,wBAAgB,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAMxC;AAED;;;;GAIG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,CAMzC;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,CAM3C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAM3E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAMtE;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAM5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAMzE;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAM/D;AAKD;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,GACpC,OAAO,CAmBT;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,GAAG,IAAI,GACxB,OAAO,CAAC,OAAO,CAAC,CAMlB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAMjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAMlE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-clarity",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.2",
|
|
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",
|
|
@@ -37,8 +37,9 @@
|
|
|
37
37
|
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build *.tgz"
|
|
38
38
|
},
|
|
39
39
|
"keywords": [
|
|
40
|
-
"
|
|
41
|
-
"
|
|
40
|
+
"android",
|
|
41
|
+
"ios",
|
|
42
|
+
"react-native"
|
|
42
43
|
],
|
|
43
44
|
"repository": "https://github.com/microsoft/clarity-apps",
|
|
44
45
|
"author": "Microsoft - Clarity <clarity-apps-support@microsoft.com> (https://github.com/microsoft/clarity-apps)",
|
|
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
|
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm}"
|
|
18
18
|
|
|
19
19
|
s.dependency "React-Core"
|
|
20
|
-
s.dependency "Clarity", '
|
|
20
|
+
s.dependency "Clarity", '3.0.0'
|
|
21
21
|
|
|
22
22
|
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
23
23
|
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|