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.
@@ -1,102 +1,106 @@
1
- /**
2
- * The configuration that will be used to customize the Clarity behaviour.
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
- * @param disableOnLowEndDevices [OPTIONAL default = false] Disable Clarity on low-end devices.
15
- * @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.
16
- */
17
- export interface ClarityConfig {
18
- userId?: string | null;
19
- logLevel?: LogLevel;
20
- allowMeteredNetworkUsage?: boolean;
21
- enableWebViewCapture?: boolean;
22
- allowedDomains?: string[];
23
- disableOnLowEndDevices?: Boolean;
24
- maximumDailyNetworkUsageInMB?: number;
25
- }
26
- /**
27
- * The level of logging to show in the device logcat stream.
28
- */
29
- export declare enum LogLevel {
30
- Verbose = "Verbose",
31
- Debug = "Debug",
32
- Info = "Info",
33
- Warning = "Warning",
34
- Error = "Error",
35
- None = "None"
36
- }
37
- /**
38
- * Initializes the Clarity SDK if the API level is supported.
39
- * @param projectId [REQUIRED] The Clarity project id to send data to.
40
- * @param config [OPTIONAL] The clarity config, if not provided default values are used.
41
- */
42
- export declare function initialize(projectId: string, config?: ClarityConfig): void;
43
- /**
44
- * Pauses the Clarity capturing processes until the next resume() is called.
45
- */
46
- export declare function pause(): void;
47
- /**
48
- * Resumes the Clarity capturing processes if they are not already resumed.
49
- * Note: Clarity starts capturing data right on initialization.
50
- */
51
- export declare function resume(): void;
52
- /**
53
- * Returns true if Clarity has been paused by the user.
54
- */
55
- export declare function isPaused(): Promise<Boolean | undefined>;
56
- /**
57
- * Sets a custom user id that can be used to identify the user. It has less
58
- * restrictions than the userId parameter. You can pass any string and
59
- * you can filter on it on the dashboard side. If you need the most efficient
60
- * filtering on the dashboard, use the userId parameter if possible.
61
- * <p>
62
- * Note: custom user id cannot be null or empty, or consists only of whitespaces.
63
- * </p>
64
- * @param customUserId The custom user id to set.
65
- */
66
- export declare function setCustomUserId(customUserId: string): void;
67
- /**
68
- * Sets a custom session id that can be used to identify the session.
69
- * <p>
70
- * Note: custom session id cannot be null or empty, or consists only of whitespaces.
71
- * </p>
72
- * @param customSessionId The custom session id to set.
73
- */
74
- export declare function setCustomSessionId(customSessionId: string): void;
75
- /**
76
- * Sets a custom tag for the current session.
77
- * @param key The tag key to set.
78
- * @param value The tag value to set.
79
- */
80
- export declare function setCustomTag(key: string, value: string): void;
81
- /**
82
- * For React Native applications only, this function is used to set the current screen name
83
- * in case the ReactNative Navigation package is used.
84
- * This will allow you to split and analyze your data on the screen names.
85
- * You can it set to `null` to remove the latest set value.
86
- * @param screenName The current screen name to set.
87
- */
88
- export declare function setCurrentScreenName(screenName: string | null): void;
89
- /**
90
- * Returns the active session id. This can be used to correlate the Clarity session with other
91
- * analytics tools that the developer may be using.
92
- * @returns a promise that resolves to the current session id.
93
- */
94
- export declare function getCurrentSessionId(): Promise<string>;
95
- /**
96
- * Returns the active session url. This can be used to correlate the Clarity session with other
97
- * analytics tools that the developer may be using.
98
- *
99
- * @returns a promise that resolves to the current session url if there is an active one.
100
- */
101
- export declare function getCurrentSessionUrl(): Promise<string>;
1
+ /**
2
+ * The configuration that will be used to customize the Clarity behaviour.
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.
19
+ */
20
+ export interface ClarityConfig {
21
+ userId?: string | null;
22
+ logLevel?: LogLevel;
23
+ allowMeteredNetworkUsage?: boolean;
24
+ enableWebViewCapture?: boolean;
25
+ allowedDomains?: string[];
26
+ disableOnLowEndDevices?: Boolean;
27
+ maximumDailyNetworkUsageInMB?: number;
28
+ enableIOS_experimental?: boolean;
29
+ }
30
+ /**
31
+ * The level of logging to show in the device logcat stream.
32
+ */
33
+ export declare enum LogLevel {
34
+ Verbose = "Verbose",
35
+ Debug = "Debug",
36
+ Info = "Info",
37
+ Warning = "Warning",
38
+ Error = "Error",
39
+ None = "None"
40
+ }
41
+ /**
42
+ * Initializes the Clarity SDK if the API level is supported.
43
+ * @param projectId [REQUIRED] The Clarity project id to send data to.
44
+ * @param config [OPTIONAL] The clarity config, if not provided default values are used.
45
+ */
46
+ export declare function initialize(projectId: string, config?: ClarityConfig): void;
47
+ /**
48
+ * Pauses the Clarity capturing processes until the next resume() is called.
49
+ */
50
+ export declare function pause(): Promise<boolean | undefined>;
51
+ /**
52
+ * Resumes the Clarity capturing processes if they are not already resumed.
53
+ * Note: Clarity starts capturing data right on initialization.
54
+ */
55
+ export declare function resume(): Promise<boolean | undefined>;
56
+ /**
57
+ * Returns true if Clarity has been paused by the user.
58
+ */
59
+ export declare function isPaused(): Promise<Boolean | undefined>;
60
+ /**
61
+ * Sets a custom user id that can be used to identify the user. It has less
62
+ * restrictions than the userId parameter. You can pass any string and
63
+ * you can filter on it on the dashboard side. If you need the most efficient
64
+ * filtering on the dashboard, use the userId parameter if possible.
65
+ * <p>
66
+ * Note: custom user id cannot be null or empty, or consists only of whitespaces.
67
+ * </p>
68
+ * @param customUserId The custom user id to set.
69
+ */
70
+ export declare function setCustomUserId(customUserId: string): Promise<boolean | undefined>;
71
+ /**
72
+ * Sets a custom session id that can be used to identify the session.
73
+ * <p>
74
+ * Note: custom session id cannot be null or empty, or consists only of whitespaces.
75
+ * </p>
76
+ * @param customSessionId The custom session id to set.
77
+ */
78
+ export declare function setCustomSessionId(customSessionId: string): Promise<boolean | undefined>;
79
+ /**
80
+ * Sets a custom tag for the current session.
81
+ * @param key The tag key to set.
82
+ * @param value The tag value to set.
83
+ */
84
+ export declare function setCustomTag(key: string, value: string): Promise<boolean | undefined>;
85
+ /**
86
+ * For React Native applications only, this function is used to set the current screen name
87
+ * in case the ReactNative Navigation package is used.
88
+ * This will allow you to split and analyze your data on the screen names.
89
+ * You can it set to `null` to remove the latest set value.
90
+ * @param screenName The current screen name to set.
91
+ */
92
+ export declare function setCurrentScreenName(screenName: string | null): Promise<boolean | undefined>;
93
+ /**
94
+ * Returns the active session id. This can be used to correlate the Clarity session with other
95
+ * analytics tools that the developer may be using.
96
+ * @returns a promise that resolves to the current session id.
97
+ */
98
+ export declare function getCurrentSessionId(): Promise<string>;
99
+ /**
100
+ * Returns the active session url. This can be used to correlate the Clarity session with other
101
+ * analytics tools that the developer may be using.
102
+ *
103
+ * @returns a promise that resolves to the current session url if there is an active one.
104
+ */
105
+ export declare function getCurrentSessionUrl(): Promise<string>;
102
106
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,4BAA4B,CAAC,EAAE,MAAM,CAAC;CACvC;AAED;;GAEG;AACH,oBAAY,QAAQ;IAClB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAED;;;;EAIE;AACF,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,QAwCnE;AAED;;GAEG;AACH,wBAAgB,KAAK,SAYpB;AAED;;;GAGG;AACH,wBAAgB,MAAM,SAYrB;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAYvD;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,QAYnD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,MAAM,QAYzD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAYtD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,QAY7D;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,CAYrD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAYtD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED;;GAEG;AACH,oBAAY,QAAQ;IAClB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAyBD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,QA6CnE;AAED;;GAEG;AACH,wBAAgB,KAAK,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAMpD;AAED;;;GAGG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAMrD;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAMvD;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAMlF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAMxF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAMrF;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,GAAG,IAAI,GACxB,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAM9B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,CAMrD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAMtD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-clarity",
3
- "version": "2.3.0",
3
+ "version": "3.0.1",
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",
@@ -77,7 +77,13 @@
77
77
  },
78
78
  "peerDependencies": {
79
79
  "react": "*",
80
- "react-native": "*"
80
+ "react-native": "*",
81
+ "react-native-svg": ">=14.0.0"
82
+ },
83
+ "peerDependenciesMeta": {
84
+ "react-native-svg": {
85
+ "optional": true
86
+ }
81
87
  },
82
88
  "engines": {
83
89
  "node": ">= 16.0.0"
@@ -1,35 +1,36 @@
1
- require "json"
2
-
3
- package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
- folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
-
6
- Pod::Spec.new do |s|
7
- s.name = "react-native-clarity"
8
- s.version = package["version"]
9
- s.summary = package["description"]
10
- s.homepage = package["homepage"]
11
- s.license = package["license"]
12
- s.authors = package["author"]
13
-
14
- s.platforms = { :ios => "11.0" }
15
- s.source = { :git => "https://msasg.visualstudio.com/Clarity/_git/clarity-react-native.git", :tag => "#{s.version}" }
16
-
17
- s.source_files = "ios/**/*.{h,m,mm}"
18
-
19
- s.dependency "React-Core"
20
-
21
- # Don't install the dependencies when we run `pod install` in the old architecture.
22
- if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
23
- s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
24
- s.pod_target_xcconfig = {
25
- "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
26
- "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
27
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
28
- }
29
- s.dependency "React-Codegen"
30
- s.dependency "RCT-Folly"
31
- s.dependency "RCTRequired"
32
- s.dependency "RCTTypeSafety"
33
- s.dependency "ReactCommon/turbomodule/core"
34
- end
35
- end
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "react-native-clarity"
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
12
+ s.authors = package["author"]
13
+
14
+ s.platforms = { :ios => "13.0" }
15
+ s.source = { :git => "https://msasg.visualstudio.com/Clarity/_git/clarity-react-native.git", :tag => "#{s.version}" }
16
+
17
+ s.source_files = "ios/**/*.{h,m,mm}"
18
+
19
+ s.dependency "React-Core"
20
+ s.dependency "Clarity", '1.0.0'
21
+
22
+ # Don't install the dependencies when we run `pod install` in the old architecture.
23
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
24
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
25
+ s.pod_target_xcconfig = {
26
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
27
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
28
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
29
+ }
30
+ s.dependency "React-Codegen"
31
+ s.dependency "RCT-Folly"
32
+ s.dependency "RCTRequired"
33
+ s.dependency "RCTTypeSafety"
34
+ s.dependency "ReactCommon/turbomodule/core"
35
+ end
36
+ end
package/src/index.tsx CHANGED
@@ -2,13 +2,18 @@ import { NativeModules, Platform } from 'react-native';
2
2
 
3
3
  const LINKING_ERROR =
4
4
  `The package 'react-native-clarity' doesn't seem to be linked. Make sure: \n\n` +
5
- // Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) + TODO: add back when iOS is supported.
5
+ Platform.select({
6
+ ios: "- You have run 'pod install --repo-update'\n",
7
+ default: '',
8
+ }) +
6
9
  '- You rebuilt the app after installing the package\n' +
7
10
  '- You are not using Expo Go\n';
8
11
 
9
12
  const Clarity = NativeModules.Clarity;
10
13
 
11
- const SupportedPlatforms = ['android']
14
+ const SupportedPlatforms = ['android'];
15
+
16
+ let SupportWarningWasShown = false;
12
17
 
13
18
  /**
14
19
  * The configuration that will be used to customize the Clarity behaviour.
@@ -23,8 +28,11 @@ const SupportedPlatforms = ['android']
23
28
  * @param enableWebViewCapture [OPTIONAL default = true] Allows Clarity to capture the web views DOM content.
24
29
  * @param allowedDomains [OPTIONAL default = ["*"]] The whitelisted domains to allow Clarity to capture their DOM content.
25
30
  * If it contains "*" as an element, all domains will be captured.
31
+ * Note: iOS currently does not support allowedDomains feature.
26
32
  * @param disableOnLowEndDevices [OPTIONAL default = false] Disable Clarity on low-end devices.
27
33
  * @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.
34
+ * Note: iOS currently does not support limiting network usage.
35
+ * @param enableIOS_experimental [OPTIONAL default = false] Experimental flag to enable Clarity on iOS platform.
28
36
  */
29
37
  export interface ClarityConfig {
30
38
  userId?: string | null;
@@ -34,47 +42,76 @@ export interface ClarityConfig {
34
42
  allowedDomains?: string[];
35
43
  disableOnLowEndDevices?: Boolean;
36
44
  maximumDailyNetworkUsageInMB?: number;
45
+ enableIOS_experimental?: boolean;
37
46
  }
38
47
 
39
48
  /**
40
49
  * The level of logging to show in the device logcat stream.
41
50
  */
42
51
  export enum LogLevel {
43
- Verbose = "Verbose",
44
- Debug = "Debug",
45
- Info = "Info",
46
- Warning = "Warning",
47
- Error = "Error",
48
- None = "None"
52
+ Verbose = 'Verbose',
53
+ Debug = 'Debug',
54
+ Info = 'Info',
55
+ Warning = 'Warning',
56
+ Error = 'Error',
57
+ None = 'None',
58
+ }
59
+
60
+ function isClarityUnavailable(): boolean {
61
+ if (!SupportedPlatforms.includes(Platform.OS)) {
62
+ let warningMessage = 'Clarity supports ' + SupportedPlatforms.join(', ') + ' only for now.';
63
+ if (Platform.OS === 'ios') {
64
+ warningMessage = `${warningMessage} To enable experimental iOS support, set the 'enableIOS_experimental' config value to true.`;
65
+ }
66
+
67
+ if (!SupportWarningWasShown) {
68
+ console.warn(warningMessage);
69
+ SupportWarningWasShown = true;
70
+ }
71
+
72
+ return true;
73
+ }
74
+
75
+ if (Clarity === null) {
76
+ console.error('Clarity did not initialize properly.', LINKING_ERROR);
77
+ return true;
78
+ }
79
+
80
+ return false;
49
81
  }
50
82
 
51
83
  /**
52
84
  * Initializes the Clarity SDK if the API level is supported.
53
85
  * @param projectId [REQUIRED] The Clarity project id to send data to.
54
86
  * @param config [OPTIONAL] The clarity config, if not provided default values are used.
55
- */
87
+ */
56
88
  export function initialize(projectId: string, config?: ClarityConfig) {
57
-
58
- if (typeof projectId !== "string" || !(typeof config === "object" || typeof config === "undefined")) {
59
- throw Error("Invalid Clarity initialization arguments. Please check the docs for assitance.")
89
+ if (
90
+ typeof projectId !== 'string' ||
91
+ !(typeof config === 'object' || typeof config === 'undefined')
92
+ ) {
93
+ throw Error(
94
+ 'Invalid Clarity initialization arguments. Please check the docs for assitance.'
95
+ );
60
96
  }
61
97
 
62
98
  // applying default values
63
- let { userId = null,
99
+ let {
100
+ userId = null,
64
101
  logLevel = LogLevel.None,
65
102
  allowMeteredNetworkUsage = false,
66
103
  enableWebViewCapture = true,
67
- allowedDomains = ["*"],
104
+ allowedDomains = ['*'],
68
105
  disableOnLowEndDevices = false,
69
- maximumDailyNetworkUsageInMB = null } = config ?? {};
106
+ maximumDailyNetworkUsageInMB = null,
107
+ enableIOS_experimental = false,
108
+ } = config ?? {};
70
109
 
71
- if (!SupportedPlatforms.includes(Platform.OS)) {
72
- console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
73
- return;
110
+ if (enableIOS_experimental === true && !SupportedPlatforms.includes('ios')) {
111
+ SupportedPlatforms.push('ios');
74
112
  }
75
113
 
76
- if (Clarity === null) {
77
- console.error("Clarity did not initialize properly.", LINKING_ERROR);
114
+ if (isClarityUnavailable()) {
78
115
  return;
79
116
  }
80
117
 
@@ -98,49 +135,31 @@ export function initialize(projectId: string, config?: ClarityConfig) {
98
135
  /**
99
136
  * Pauses the Clarity capturing processes until the next resume() is called.
100
137
  */
101
- export function pause(){
102
- if (!SupportedPlatforms.includes(Platform.OS)) {
103
- console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
104
- return;
138
+ export function pause(): Promise<boolean | undefined> {
139
+ if (isClarityUnavailable()) {
140
+ return Promise.resolve(undefined);
105
141
  }
106
142
 
107
- if (Clarity === null) {
108
- console.error("Clarity did not initialize properly.", LINKING_ERROR);
109
- return;
110
- }
111
-
112
- Clarity.pause();
143
+ return Clarity.pause();
113
144
  }
114
145
 
115
146
  /**
116
147
  * Resumes the Clarity capturing processes if they are not already resumed.
117
148
  * Note: Clarity starts capturing data right on initialization.
118
149
  */
119
- export function resume(){
120
- if (!SupportedPlatforms.includes(Platform.OS)) {
121
- console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
122
- return;
150
+ export function resume(): Promise<boolean | undefined> {
151
+ if (isClarityUnavailable()) {
152
+ return Promise.resolve(undefined);
123
153
  }
124
154
 
125
- if (Clarity === null) {
126
- console.error("Clarity did not initialize properly.", LINKING_ERROR);
127
- return;
128
- }
129
-
130
- Clarity.resume();
155
+ return Clarity.resume();
131
156
  }
132
157
 
133
158
  /**
134
159
  * Returns true if Clarity has been paused by the user.
135
160
  */
136
- export function isPaused(): Promise<Boolean | undefined>{
137
- if (!SupportedPlatforms.includes(Platform.OS)) {
138
- console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
139
- return Promise.resolve(undefined);
140
- }
141
-
142
- if (Clarity === null) {
143
- console.error("Clarity did not initialize properly.", LINKING_ERROR);
161
+ export function isPaused(): Promise<Boolean | undefined> {
162
+ if (isClarityUnavailable()) {
144
163
  return Promise.resolve(undefined);
145
164
  }
146
165
 
@@ -157,18 +176,12 @@ export function isPaused(): Promise<Boolean | undefined>{
157
176
  * </p>
158
177
  * @param customUserId The custom user id to set.
159
178
  */
160
- export function setCustomUserId(customUserId: string) {
161
- if (!SupportedPlatforms.includes(Platform.OS)) {
162
- console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
163
- return;
164
- }
165
-
166
- if (Clarity === null) {
167
- console.error("Clarity did not initialize properly.", LINKING_ERROR);
168
- return;
179
+ export function setCustomUserId(customUserId: string): Promise<boolean | undefined> {
180
+ if (isClarityUnavailable()) {
181
+ return Promise.resolve(undefined);
169
182
  }
170
183
 
171
- Clarity.setCustomUserId(customUserId);
184
+ return Clarity.setCustomUserId(customUserId);
172
185
  }
173
186
 
174
187
  /**
@@ -178,18 +191,12 @@ export function setCustomUserId(customUserId: string) {
178
191
  * </p>
179
192
  * @param customSessionId The custom session id to set.
180
193
  */
181
- export function setCustomSessionId(customSessionId: string) {
182
- if (!SupportedPlatforms.includes(Platform.OS)) {
183
- console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
184
- return;
185
- }
186
-
187
- if (Clarity === null) {
188
- console.error("Clarity did not initialize properly.", LINKING_ERROR);
189
- return;
194
+ export function setCustomSessionId(customSessionId: string): Promise<boolean | undefined> {
195
+ if (isClarityUnavailable()) {
196
+ return Promise.resolve(undefined);
190
197
  }
191
198
 
192
- Clarity.setCustomSessionId(customSessionId);
199
+ return Clarity.setCustomSessionId(customSessionId);
193
200
  }
194
201
 
195
202
  /**
@@ -197,18 +204,12 @@ export function setCustomSessionId(customSessionId: string) {
197
204
  * @param key The tag key to set.
198
205
  * @param value The tag value to set.
199
206
  */
200
- export function setCustomTag(key: string, value: string) {
201
- if (!SupportedPlatforms.includes(Platform.OS)) {
202
- console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
203
- return;
204
- }
205
-
206
- if (Clarity === null) {
207
- console.error("Clarity did not initialize properly.", LINKING_ERROR);
208
- return;
207
+ export function setCustomTag(key: string, value: string): Promise<boolean | undefined> {
208
+ if (isClarityUnavailable()) {
209
+ return Promise.resolve(undefined);
209
210
  }
210
211
 
211
- Clarity.setCustomTag(key, value);
212
+ return Clarity.setCustomTag(key, value);
212
213
  }
213
214
 
214
215
  /**
@@ -218,18 +219,14 @@ export function setCustomTag(key: string, value: string) {
218
219
  * You can it set to `null` to remove the latest set value.
219
220
  * @param screenName The current screen name to set.
220
221
  */
221
- export function setCurrentScreenName(screenName: string | null) {
222
- if (!SupportedPlatforms.includes(Platform.OS)) {
223
- console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
224
- return;
225
- }
226
-
227
- if (Clarity === null) {
228
- console.error("Clarity did not initialize properly.", LINKING_ERROR);
229
- return;
222
+ export function setCurrentScreenName(
223
+ screenName: string | null
224
+ ): Promise<boolean | undefined> {
225
+ if (isClarityUnavailable()) {
226
+ return Promise.resolve(undefined);
230
227
  }
231
228
 
232
- Clarity.setCurrentScreenName(screenName);
229
+ return Clarity.setCurrentScreenName(screenName);
233
230
  }
234
231
 
235
232
  /**
@@ -238,14 +235,8 @@ export function setCurrentScreenName(screenName: string | null) {
238
235
  * @returns a promise that resolves to the current session id.
239
236
  */
240
237
  export function getCurrentSessionId(): Promise<string> {
241
- if (!SupportedPlatforms.includes(Platform.OS)) {
242
- console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
243
- return Promise.resolve("Undefined");
244
- }
245
-
246
- if (Clarity === null) {
247
- console.error("Clarity did not initialize properly.", LINKING_ERROR);
248
- return Promise.resolve("Undefined");
238
+ if (isClarityUnavailable()) {
239
+ return Promise.resolve('Undefined');
249
240
  }
250
241
 
251
242
  return Clarity.getCurrentSessionId();
@@ -258,14 +249,8 @@ export function getCurrentSessionId(): Promise<string> {
258
249
  * @returns a promise that resolves to the current session url if there is an active one.
259
250
  */
260
251
  export function getCurrentSessionUrl(): Promise<string> {
261
- if (!SupportedPlatforms.includes(Platform.OS)) {
262
- console.warn("Clarity supports " + SupportedPlatforms.join(", ") + " only for now.");
263
- return Promise.resolve("Undefined");
264
- }
265
-
266
- if (Clarity === null) {
267
- console.error("Clarity did not initialize properly.", LINKING_ERROR);
268
- return Promise.resolve("Undefined");
252
+ if (isClarityUnavailable()) {
253
+ return Promise.resolve('Undefined');
269
254
  }
270
255
 
271
256
  return Clarity.getCurrentSessionUrl();
package/ios/Clarity.mm DELETED
@@ -1,15 +0,0 @@
1
- #import "Clarity.h"
2
-
3
- @implementation Clarity
4
- RCT_EXPORT_MODULE()
5
-
6
- // Don't compile this code when we build for the old architecture.
7
- #ifdef RCT_NEW_ARCH_ENABLED
8
- - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
9
- (const facebook::react::ObjCTurboModule::InitParams &)params
10
- {
11
- return std::make_shared<facebook::react::NativeClaritySpecJSI>(params);
12
- }
13
- #endif
14
-
15
- @end