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/src/index.tsx CHANGED
@@ -1,4 +1,9 @@
1
- import { NativeModules, Platform } from 'react-native';
1
+ import {
2
+ NativeModules,
3
+ NativeEventEmitter,
4
+ Platform,
5
+ EmitterSubscription,
6
+ } from 'react-native';
2
7
 
3
8
  const LINKING_ERROR =
4
9
  `The package 'react-native-clarity' doesn't seem to be linked. Make sure: \n\n` +
@@ -9,44 +14,58 @@ const LINKING_ERROR =
9
14
  '- You rebuilt the app after installing the package\n' +
10
15
  '- You are not using Expo Go\n';
11
16
 
17
+ const ReferToDocs =
18
+ 'Please check the docs at https://www.npmjs.com/package/react-native-clarity for assistance.';
19
+
12
20
  const Clarity = NativeModules.Clarity;
21
+ const ClarityEmitter = new NativeEventEmitter(NativeModules.ClarityEmitter);
13
22
 
14
- const SupportedPlatforms = ['android'];
23
+ const SupportedPlatforms = ['android', 'ios'];
15
24
 
16
25
  let SupportWarningWasShown = false;
17
26
 
18
27
  /**
19
- * The configuration that will be used to customize the Clarity behaviour.
20
- *
21
- * @param userId [OPTIONAL default = null] A custom identifier for the current user. If passed as null, the user id
22
- * will be auto generated. The user id in general is sticky across sessions.
23
- * The provided user id must follow these conditions:
24
- * 1. Cannot be an empty string.
25
- * 2. Should be base36 and smaller than "1Z141Z4".
26
- * @param logLevel [OPTIONAL default = LogLevel.None] The level of logging to show in the device logcat stream.
27
- * @param allowMeteredNetworkUsage [OPTIONAL default = false] Allows uploading session data to the servers on device metered network.
28
- * @param enableWebViewCapture [OPTIONAL default = true] Allows Clarity to capture the web views DOM content.
29
- * @param allowedDomains [OPTIONAL default = ["*"]] The whitelisted domains to allow Clarity to capture their DOM content.
30
- * If it contains "*" as an element, all domains will be captured.
31
- * Note: iOS currently does not support allowedDomains feature.
32
- * @param disableOnLowEndDevices [OPTIONAL default = false] Disable Clarity on low-end devices.
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
+ * A class that allows you to configure the Clarity SDK behavior.
36
29
  */
37
30
  export interface ClarityConfig {
38
- userId?: string | null;
31
+ /**
32
+ * @deprecated This property is deprecated and would be removed in a future major version. Use {@linkcode setCustomSessionId} instead.
33
+ *
34
+ * The unique identifier associated with the application user. This ID persists across multiple sessions on the same device.
35
+ *
36
+ * **Notes:**
37
+ * - If {@linkcode userId} isn't provided, a random one is generated automatically.
38
+ * - Must be a base-36 string smaller than `1Z141Z4`.
39
+ * - If an invalid {@linkcode userId} is supplied:
40
+ * - If `customUserId` isn't specified, {@linkcode userId} acts as the `customUserId`, and a new random {@linkcode userId} is assigned.
41
+ * - If `customUserId` is specified, the invalid {@linkcode userID} is ignored.
42
+ * - 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.
43
+ */
44
+ userId?: string;
45
+
46
+ /**
47
+ * The level of logging to show in the device’s logging stream while debugging. By default, the SDK logs nothing.
48
+ */
39
49
  logLevel?: LogLevel;
40
- allowMeteredNetworkUsage?: boolean;
41
- enableWebViewCapture?: boolean;
42
- allowedDomains?: string[];
43
- disableOnLowEndDevices?: Boolean;
44
- maximumDailyNetworkUsageInMB?: number;
45
- enableIOS_experimental?: boolean;
46
50
  }
47
51
 
52
+ const ValidConfigKeys = new Set(
53
+ Object.keys({
54
+ userId: undefined, // Deprecated.
55
+ logLevel: undefined,
56
+ } as ClarityConfig)
57
+ );
58
+
59
+ const RemovedDynamicConfigKeys = new Set([
60
+ 'allowMeteredNetworkUsage',
61
+ 'enableWebViewCapture',
62
+ 'allowedDomains',
63
+ 'disableOnLowEndDevices',
64
+ 'maximumDailyNetworkUsageInMB',
65
+ ]);
66
+
48
67
  /**
49
- * The level of logging to show in the device logcat stream.
68
+ * The level of logging to show in the device logging stream.
50
69
  */
51
70
  export enum LogLevel {
52
71
  Verbose = 'Verbose',
@@ -57,15 +76,19 @@ export enum LogLevel {
57
76
  None = 'None',
58
77
  }
59
78
 
79
+ class ClarityError extends Error {
80
+ constructor(message: string) {
81
+ super(message);
82
+ this.name = 'ClarityError';
83
+ }
84
+ }
85
+
60
86
  function isClarityUnavailable(): boolean {
61
87
  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
88
  if (!SupportWarningWasShown) {
68
- console.warn(warningMessage);
89
+ console.warn(
90
+ 'Clarity supports ' + SupportedPlatforms.join(', ') + ' only for now.'
91
+ );
69
92
  SupportWarningWasShown = true;
70
93
  }
71
94
 
@@ -80,177 +103,302 @@ function isClarityUnavailable(): boolean {
80
103
  return false;
81
104
  }
82
105
 
106
+ function validateClarityConfig(config?: ClarityConfig) {
107
+ if (typeof config === 'undefined') {
108
+ // Allow using defaults when config is `null` or `undefined`.
109
+ return;
110
+ }
111
+
112
+ if (typeof config !== 'object') {
113
+ throw new ClarityError(
114
+ `Invalid Clarity initialization \`config\` argument. Expected an object, but received ${typeof config}. ${ReferToDocs}`
115
+ );
116
+ }
117
+
118
+ if (config?.logLevel && !Object.values(LogLevel).includes(config.logLevel)) {
119
+ console.error(
120
+ `Invalid ClarityConfig \`logLevel\` property value: ${
121
+ config.logLevel
122
+ }. Valid values are: ${Object.values(LogLevel).join(
123
+ ', '
124
+ )}. ${ReferToDocs}`
125
+ );
126
+ }
127
+
128
+ for (const key in config) {
129
+ if (RemovedDynamicConfigKeys.has(key)) {
130
+ throw new ClarityError(
131
+ `The ClarityConfig \`${key}\` property is removed and it's configurable from Clarity dashboard.`
132
+ );
133
+ } else if (key === 'enableIOS_experimental') {
134
+ const errorMessage =
135
+ 'The ClarityConfig `enableIOS_experimental` property is removed and iOS is supported by default.';
136
+ if ((config as any).enableIOS_experimental) {
137
+ // Proceed with initialization if the user intended to enable iOS support.
138
+ console.error(errorMessage);
139
+ } else {
140
+ throw new ClarityError(errorMessage);
141
+ }
142
+ } else if (key === 'userId') {
143
+ console.warn(
144
+ 'The ClarityConfig `userId` property is deprecated and would be removed in a future major version. Use `setCustomUserId()` instead.'
145
+ );
146
+ } else if (!ValidConfigKeys.has(key)) {
147
+ console.warn(`Invalid ClarityConfig property: \`${key}\`.`);
148
+ }
149
+ }
150
+ }
151
+
83
152
  /**
84
- * Initializes the Clarity SDK if the API level is supported.
85
- * @param projectId [REQUIRED] The Clarity project id to send data to.
86
- * @param config [OPTIONAL] The clarity config, if not provided default values are used.
153
+ * @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).
154
+ * @param config - Configuration of Clarity that tunes the SDK behavior (for example, which log level to use, and so on).
155
+ *
156
+ * **Notes:**
157
+ * - The initialization function is asynchronous, meaning it returns before Clarity is fully initialized.
158
+ * - For actions that require Clarity to be fully initialized, it's recommended to use the {@linkcode setOnSessionStartedCallback} function.
87
159
  */
88
160
  export function initialize(projectId: string, config?: ClarityConfig) {
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.'
161
+ if (typeof projectId !== 'string') {
162
+ throw new ClarityError(
163
+ `Invalid Clarity initialization \`projectId\` argument. Expected a string, but received ${typeof projectId}. ${ReferToDocs}`
95
164
  );
96
165
  }
97
166
 
167
+ validateClarityConfig(config);
168
+
98
169
  // applying default values
99
- let {
100
- userId = null,
101
- logLevel = LogLevel.None,
102
- allowMeteredNetworkUsage = false,
103
- enableWebViewCapture = true,
104
- allowedDomains = ['*'],
105
- disableOnLowEndDevices = false,
106
- maximumDailyNetworkUsageInMB = null,
107
- enableIOS_experimental = false,
108
- } = config ?? {};
109
-
110
- if (enableIOS_experimental === true && !SupportedPlatforms.includes('ios')) {
111
- SupportedPlatforms.push('ios');
112
- }
170
+ let { userId = null, logLevel = LogLevel.None } = config ?? {};
113
171
 
114
172
  if (isClarityUnavailable()) {
115
173
  return;
116
174
  }
117
175
 
118
- // We use two parameters because the react method parameters do not accept nullable primitive types.
119
- let enableDailyNetworkUsageLimit = maximumDailyNetworkUsageInMB != null;
120
- let refinedMaximumDailyNetworkUsageInMB = maximumDailyNetworkUsageInMB ?? 0;
121
-
122
- Clarity.initialize(
123
- projectId,
124
- userId,
125
- logLevel,
126
- allowMeteredNetworkUsage,
127
- enableWebViewCapture,
128
- allowedDomains,
129
- disableOnLowEndDevices,
130
- enableDailyNetworkUsageLimit,
131
- refinedMaximumDailyNetworkUsageInMB
132
- );
176
+ Clarity.initialize(projectId, userId, logLevel);
133
177
  }
134
178
 
135
179
  /**
136
- * Pauses the Clarity capturing processes until the next resume() is called.
180
+ * Pauses the Clarity session capturing until a call to the {@linkcode resume} function is made.
181
+ *
182
+ * @returns {Promise<boolean>} A Promise that resolves with `true` if Clarity session capturing was paused successfully; otherwise `false`.
137
183
  */
138
- export function pause(): Promise<boolean | undefined> {
184
+ export function pause(): Promise<boolean> {
139
185
  if (isClarityUnavailable()) {
140
- return Promise.resolve(undefined);
186
+ return Promise.resolve(false);
141
187
  }
142
188
 
143
189
  return Clarity.pause();
144
190
  }
145
191
 
146
192
  /**
147
- * Resumes the Clarity capturing processes if they are not already resumed.
148
- * Note: Clarity starts capturing data right on initialization.
193
+ * Resumes the Clarity session capturing only if it was previously paused by a call to the {@linkcode pause} function.
194
+ *
195
+ * @returns {Promise<boolean>} A Promise that resolves with `true` if Clarity session capturing was resumed successfully; otherwise `false`.
149
196
  */
150
- export function resume(): Promise<boolean | undefined> {
197
+ export function resume(): Promise<boolean> {
151
198
  if (isClarityUnavailable()) {
152
- return Promise.resolve(undefined);
199
+ return Promise.resolve(false);
153
200
  }
154
201
 
155
202
  return Clarity.resume();
156
203
  }
157
204
 
158
205
  /**
159
- * Returns true if Clarity has been paused by the user.
206
+ * Checks if Clarity session capturing is currently paused based on an earlier call to the {@linkcode pause} function.
207
+ *
208
+ * @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`.
160
209
  */
161
- export function isPaused(): Promise<Boolean | undefined> {
210
+ export function isPaused(): Promise<boolean> {
162
211
  if (isClarityUnavailable()) {
163
- return Promise.resolve(undefined);
212
+ return Promise.resolve(false);
164
213
  }
165
214
 
166
215
  return Clarity.isPaused();
167
216
  }
168
217
 
169
218
  /**
170
- * Sets a custom user id that can be used to identify the user. It has less
171
- * restrictions than the userId parameter. You can pass any string and
172
- * you can filter on it on the dashboard side. If you need the most efficient
173
- * filtering on the dashboard, use the userId parameter if possible.
174
- * <p>
175
- * Note: custom user id cannot be null or empty, or consists only of whitespaces.
176
- * </p>
177
- * @param customUserId The custom user id to set.
219
+ * Forces Clarity to start a new session asynchronously.
220
+ *
221
+ * @param callback - A callback that is invoked when the new session starts. The callback receives the new session ID as a string parameter.
222
+ *
223
+ * **Notes:**
224
+ * - This function is asynchronous, meaning it returns before the new session is started.
225
+ * - Use the {@linkcode callback} parameter to execute logic that needs to run after the new session begins.
226
+ * - Events that occur before invoking the callback are associated with the previous session.
227
+ * - To ensure proper association of custom tags, user ID, or session ID with the new session, set them within the callback.
178
228
  */
179
- export function setCustomUserId(customUserId: string): Promise<boolean | undefined> {
229
+ export function startNewSession(callback: (sessionId: String) => void): void {
180
230
  if (isClarityUnavailable()) {
181
- return Promise.resolve(undefined);
231
+ return;
232
+ }
233
+
234
+ Clarity.startNewSession(callback);
235
+ }
236
+
237
+ /**
238
+ * Sets a custom user ID for the current session. This ID can be used to filter sessions on the Clarity dashboard.
239
+ *
240
+ * @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.
241
+ * @returns {Promise<boolean>} A Promise that resolves with `true` if the custom user ID was set successfully; otherwise `false`.
242
+ *
243
+ * **Notes:**
244
+ * - 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}.
245
+ * - Unlike the `userID`, the {@linkcode customUserId} value has fewer restrictions.
246
+ * - We recommend **not** to set any Personally Identifiable Information (PII) values inside this field.
247
+ */
248
+ export function setCustomUserId(customUserId: string): Promise<boolean> {
249
+ if (isClarityUnavailable()) {
250
+ return Promise.resolve(false);
182
251
  }
183
252
 
184
253
  return Clarity.setCustomUserId(customUserId);
185
254
  }
186
255
 
187
256
  /**
188
- * Sets a custom session id that can be used to identify the session.
189
- * <p>
190
- * Note: custom session id cannot be null or empty, or consists only of whitespaces.
191
- * </p>
192
- * @param customSessionId The custom session id to set.
257
+ * Sets a custom session ID for the current session. This ID can be used to filter sessions on the Clarity dashboard.
258
+ *
259
+ * @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.
260
+ * @returns {Promise<boolean>} A Promise that resolves with `true` if the custom session ID was set successfully; otherwise `false`.
261
+ *
262
+ * **Notes:**
263
+ * - 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}.
193
264
  */
194
- export function setCustomSessionId(customSessionId: string): Promise<boolean | undefined> {
265
+ export function setCustomSessionId(customSessionId: string): Promise<boolean> {
195
266
  if (isClarityUnavailable()) {
196
- return Promise.resolve(undefined);
267
+ return Promise.resolve(false);
197
268
  }
198
269
 
199
270
  return Clarity.setCustomSessionId(customSessionId);
200
271
  }
201
272
 
202
273
  /**
203
- * Sets a custom tag for the current session.
204
- * @param key The tag key to set.
205
- * @param value The tag value to set.
274
+ * Sets a custom tag for the current session. This tag can be used to filter sessions on the Clarity dashboard.
275
+ *
276
+ * @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.
277
+ * @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.
278
+ * @returns {Promise<boolean>} A Promise that resolves with `true` if the custom tag was set successfully; otherwise `false`.
279
+ *
280
+ * **Notes:**
281
+ * - 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}.
206
282
  */
207
- export function setCustomTag(key: string, value: string): Promise<boolean | undefined> {
283
+ export function setCustomTag(key: string, value: string): Promise<boolean> {
208
284
  if (isClarityUnavailable()) {
209
- return Promise.resolve(undefined);
285
+ return Promise.resolve(false);
210
286
  }
211
287
 
212
288
  return Clarity.setCustomTag(key, value);
213
289
  }
214
290
 
215
291
  /**
216
- * For React Native applications only, this function is used to set the current screen name
217
- * in case the ReactNative Navigation package is used.
218
- * This will allow you to split and analyze your data on the screen names.
219
- * You can it set to `null` to remove the latest set value.
220
- * @param screenName The current screen name to set.
292
+ * 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.
293
+ *
294
+ * @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.
295
+ * @returns {Promise<boolean>} A Promise that resolves with `true` if the custom event was sent successfully; otherwise `false`.
296
+ *
297
+ * **Notes:**
298
+ * - This API can be called multiple times per page to track various user actions.
299
+ * - Each custom event is logged individually and can be filtered, viewed, and analyzed on the Clarity dashboard.
300
+ */
301
+ export function sendCustomEvent(value: string): Promise<boolean> {
302
+ if (isClarityUnavailable()) {
303
+ return Promise.resolve(false);
304
+ }
305
+
306
+ return Clarity.sendCustomEvent(value);
307
+ }
308
+
309
+ let onSessionStartedSubscription: EmitterSubscription | null = null;
310
+ var onSessionStartedCallback: ((sessionId: string) => void) | null = null;
311
+
312
+ /**
313
+ * Sets a callback function that's invoked whenever a new Clarity session starts or an existing session is resumed at app startup.
314
+ *
315
+ * @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.
316
+ * @returns {boolean} `true` if the callback was set successfully; otherwise `false`.
317
+ *
318
+ * **Notes:**
319
+ * - If the callback is set after a session has already started, the callback is invoked right away with the current session ID.
320
+ * - The specified callback is guaranteed to run on the main thread.
321
+ */
322
+ export function setOnSessionStartedCallback(
323
+ callback: (sessionId: String) => void
324
+ ): boolean {
325
+ if (isClarityUnavailable()) {
326
+ return false;
327
+ }
328
+
329
+ onSessionStartedCallback = callback;
330
+
331
+ if (onSessionStartedSubscription === null) {
332
+ onSessionStartedSubscription = ClarityEmitter.addListener(
333
+ 'sessionStarted',
334
+ ({ sessionId }) => {
335
+ if (onSessionStartedCallback !== null) {
336
+ onSessionStartedCallback(sessionId);
337
+ }
338
+ }
339
+ );
340
+ }
341
+
342
+ return true;
343
+ }
344
+
345
+ /**
346
+ * 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.
347
+ *
348
+ * @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.
349
+ * @returns {Promise<boolean>} A Promise that resolves with `true` if the specified screen name tag was set successfully; otherwise `false`.
350
+ *
351
+ * **Example:**
352
+ * - If the presented iOS view controller is a `UIViewController`, and `setCurrentScreenName("Settings")` is called, the screen name is tracked as "UIViewController/Settings".
353
+ * - If `setCurrentScreenName(nil)` is called on the same view controller, the screen name is tracked as "UIViewController".
354
+ *
355
+ * **Notes:**
356
+ * - 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.
357
+ * - 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".
358
+ * - The screen name tag is set globally and persists across all subsequent Android activities or iOS view controllers until explicitly reset.
221
359
  */
222
360
  export function setCurrentScreenName(
223
361
  screenName: string | null
224
- ): Promise<boolean | undefined> {
362
+ ): Promise<boolean> {
225
363
  if (isClarityUnavailable()) {
226
- return Promise.resolve(undefined);
364
+ return Promise.resolve(false);
227
365
  }
228
366
 
229
367
  return Clarity.setCurrentScreenName(screenName);
230
368
  }
231
369
 
232
370
  /**
233
- * Returns the active session id. This can be used to correlate the Clarity session with other
234
- * analytics tools that the developer may be using.
235
- * @returns a promise that resolves to the current session id.
371
+ * @deprecated This function is deprecated and would be removed in a future major version. Use {@linkcode getCurrentSessionUrl} instead.
372
+ *
373
+ * Returns the ID of the currently active Clarity session if a session has already started; otherwise `undefined`.
374
+ *
375
+ * @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`.
376
+ *
377
+ * **Note:**
378
+ * - The session ID can be used to correlate Clarity sessions with other telemetry services.
379
+ * - Initially, this function might return `undefined` until a Clarity session begins.
380
+ * - To ensure a valid session ID, use this method within the callbacks of {@linkcode setOnSessionStartedCallback} or {@linkcode startNewSession}.
236
381
  */
237
- export function getCurrentSessionId(): Promise<string> {
382
+ export function getCurrentSessionId(): Promise<string | undefined> {
238
383
  if (isClarityUnavailable()) {
239
- return Promise.resolve('Undefined');
384
+ return Promise.resolve(undefined);
240
385
  }
241
386
 
242
387
  return Clarity.getCurrentSessionId();
243
388
  }
244
389
 
245
390
  /**
246
- * Returns the active session url. This can be used to correlate the Clarity session with other
247
- * analytics tools that the developer may be using.
391
+ * Returns the URL of the current Clarity session recording on the Clarity dashboard if a session has already started; otherwise `undefined`.
248
392
  *
249
- * @returns a promise that resolves to the current session url if there is an active one.
393
+ * @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`.
394
+ *
395
+ * **Notes:**
396
+ * - Initially, this function might return `undefined` until a Clarity session begins.
397
+ * - To ensure a valid session URL, use this method within the callbacks of {@linkcode setOnSessionStartedCallback} or {@linkcode startNewSession}.
250
398
  */
251
- export function getCurrentSessionUrl(): Promise<string> {
399
+ export function getCurrentSessionUrl(): Promise<string | undefined> {
252
400
  if (isClarityUnavailable()) {
253
- return Promise.resolve('Undefined');
401
+ return Promise.resolve(undefined);
254
402
  }
255
403
 
256
404
  return Clarity.getCurrentSessionUrl();