@guidelytech/react-native 0.16.0 → 0.17.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/dist/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { SelectorStrategy, Placement, AutocaptureSettings, HeatmapPoint, MessengerConfig, MessengerMessage, MessengerConversation, SdkArticlesResponse, ResourceCenterArticle, PublishedGuide, ProjectTheme, GuideStep, SdkConfigResponse, ChecklistTask, SdkEvent, TargetingContext, StepButton, ResourceCenterConfig, RuleGroup, ResourceCenterAnnouncement } from '@guidelytech/shared';
3
+ import { SelectorStrategy, Placement, AutocaptureSettings, HeatmapPoint, PublishedGuide, ProjectTheme, GuideStep, SdkConfigResponse, ChecklistTask, MessengerMessage, MessengerConversation, SdkEvent, MessengerConfig, SdkArticlesResponse, ResourceCenterArticle, TargetingContext, StepButton, ResourceCenterConfig, RuleGroup, ResourceCenterAnnouncement } from '@guidelytech/shared';
4
4
  export { AutocaptureSettings, GuideStep, HeatmapPoint, PublishedGuide, SdkConfigResponse } from '@guidelytech/shared';
5
5
  import { FlagsClientOptions, FlagsClient, JsonValue, FlagValue, FlagDetails, FlagsBootstrap, Attributes } from '@guidelytech/flags';
6
6
  export { Attributes, EvaluationResult, FlagDetails, FlagsBootstrap, FlagsClient, FlagsClientOptions, FlagsPayload, InMemoryStickyBucketStore, JsonValue, createFlagsClient } from '@guidelytech/flags';
7
- import { ResourceCenterModuleId } from '@guidelytech/shared/runtime';
8
- import { KeyValueStore, ServerHealth, ChecklistProgressState, GuidelyEnvironment, ConsentState, GuidelyUser, GuidelyAccount, GuideLocalState, SessionState } from '@guidelytech/sdk-core/headless';
7
+ import { ErrorLevelName, ExceptionProperties, ExceptionDetail, ErrorFilterPattern, Breadcrumb, ResourceCenterModuleId, StackFrame } from '@guidelytech/shared/runtime';
8
+ export { Breadcrumb, ErrorFilterPattern, ErrorLevelName, ExceptionDetail } from '@guidelytech/shared/runtime';
9
+ import { ChecklistProgressState, GuidelyEnvironment, ConsentState, GuidelyUser, KeyValueStore, ServerHealth, GuidelyAccount, GuideLocalState, SessionState } from '@guidelytech/sdk-core/headless';
9
10
  export { ChecklistProgressState, ConsentState, GuidelyAccount, GuidelyEnvironment, GuidelyUser } from '@guidelytech/sdk-core/headless';
10
11
  import { ViewProps, StyleProp, ViewStyle, View, GestureResponderEvent } from 'react-native';
11
12
 
@@ -194,6 +195,333 @@ declare class TapTracker {
194
195
  cancel(): void;
195
196
  }
196
197
 
198
+ interface HttpGlobals {
199
+ fetch?: unknown;
200
+ XMLHttpRequest?: unknown;
201
+ }
202
+
203
+ /**
204
+ * React Native's crash hooks, looked up on the JS global (never imported, so Expo Go, web and tests
205
+ * without them simply get no automatic capture):
206
+ *
207
+ * * `ErrorUtils.setGlobalHandler`: every uncaught JS error, `isFatal` for the ones that kill the
208
+ * app in release builds (React Native's default handler shows the red box in development and
209
+ * crashes the app in release).
210
+ * * `HermesInternal.enablePromiseRejectionTracker`, or any tracker with the same `enable()` shape
211
+ * (`promise/setimmediate/rejection-tracking` on JavaScriptCore): unhandled promise rejections.
212
+ */
213
+ type GlobalErrorHandler = (error: unknown, isFatal?: boolean) => void;
214
+ interface ErrorUtilsLike {
215
+ getGlobalHandler?(): GlobalErrorHandler | undefined;
216
+ setGlobalHandler(handler: GlobalErrorHandler): void;
217
+ }
218
+ interface RejectionTrackerOptions {
219
+ allRejections: boolean;
220
+ onUnhandled: (id: number, rejection: unknown) => void;
221
+ onHandled: (id: number) => void;
222
+ }
223
+ /** `HermesInternal.enablePromiseRejectionTracker`, or `require("promise/setimmediate/rejection-tracking")`. */
224
+ interface RejectionTracker {
225
+ enable(options: RejectionTrackerOptions): void;
226
+ }
227
+ interface HermesInternalLike {
228
+ hasPromise?(): boolean;
229
+ enablePromiseRejectionTracker?(options: RejectionTrackerOptions): void;
230
+ getRuntimeProperties?(): Record<string, unknown>;
231
+ }
232
+ /** The globals crash capture and breadcrumbs hook into (`globalThis` in an app; fakes in tests). */
233
+ interface RuntimeGlobals extends HttpGlobals {
234
+ ErrorUtils?: ErrorUtilsLike;
235
+ HermesInternal?: HermesInternalLike;
236
+ console?: Record<string, unknown>;
237
+ __DEV__?: boolean;
238
+ addEventListener?: (type: string, listener: (event: unknown) => void) => void;
239
+ removeEventListener?: (type: string, listener: (event: unknown) => void) => void;
240
+ nativeFabricUIManager?: unknown;
241
+ __turboModuleProxy?: unknown;
242
+ RN$Bridgeless?: unknown;
243
+ expo?: unknown;
244
+ }
245
+ /** How long a fatal error may hold React Native's handler back while its report is saved and sent. */
246
+ declare const FATAL_FLUSH_MS = 2000;
247
+
248
+ /**
249
+ * AsyncStorage-compatible key/value storage (`@react-native-async-storage/async-storage`,
250
+ * `expo-secure-store` wrappers, MMKV adapters…). Synchronous implementations work too.
251
+ */
252
+ interface GuidelyStorage {
253
+ getItem(key: string): Promise<string | null> | string | null;
254
+ setItem(key: string, value: string): Promise<void> | void;
255
+ removeItem(key: string): Promise<void> | void;
256
+ }
257
+ /** Device facts the engine needs. The provider fills these in from React Native APIs. */
258
+ interface DeviceEnvironment {
259
+ platform: "ios" | "android";
260
+ deviceType: "mobile" | "tablet";
261
+ locale?: string;
262
+ /** Host app version, detected from a linked native module (see `core/device.ts`). */
263
+ appVersion?: string;
264
+ /** Host app build number (`CFBundleVersion` / `versionCode`). */
265
+ appBuild?: string;
266
+ /** OS version: `18.1` on iOS, `14` on Android. */
267
+ osVersion?: string;
268
+ /** Device model (`Pixel 8`, `iPhone16,2`), manufacturer and brand, for error reports (see `detectDeviceModel`). */
269
+ model?: string;
270
+ manufacturer?: string;
271
+ brand?: string;
272
+ /** True on a simulator / emulator, when a linked module says. */
273
+ simulator?: boolean;
274
+ /** React Native's version (`Platform.constants.reactNativeVersion`), for error reports. */
275
+ reactNativeVersion?: string | {
276
+ major: number;
277
+ minor?: number;
278
+ patch?: number;
279
+ prerelease?: string | number | null;
280
+ };
281
+ }
282
+ interface GuidelyOptions {
283
+ /** Environment public key, e.g. `pk_dev_…`. Not a secret. */
284
+ projectId: string;
285
+ environment?: GuidelyEnvironment;
286
+ /** Base URL of your Guidely deployment, e.g. `https://guidelytech.com`. */
287
+ apiUrl?: string;
288
+ /**
289
+ * Where identity, cached config, queued events and unsent survey answers are persisted. Pass AsyncStorage
290
+ * (`@react-native-async-storage/async-storage`); without it state lasts only for the app session,
291
+ * so anything not yet sent during a Guidely outage is lost when the app restarts.
292
+ */
293
+ storage?: GuidelyStorage;
294
+ debug?: boolean;
295
+ /** Send analytics events (default `true`). Guides still render when disabled. */
296
+ analytics?: boolean;
297
+ consent?: ConsentState;
298
+ /**
299
+ * Host app version for `app.version` targeting rules, every event's `appVersion` and `app_install` /
300
+ * `app_update`. Detected on iOS and Android when `@guidelytech/react-native-replay`, `expo-application`
301
+ * or `react-native-device-info` is linked; pass it to override that (or when none is).
302
+ */
303
+ appVersion?: string;
304
+ /** Host app build number (`CFBundleVersion` / `versionCode`), sent as `build` with app lifecycle events. Detected like `appVersion`. */
305
+ appBuild?: string;
306
+ /**
307
+ * Release errors are reported under (`properties.release`), which picks the uploaded source maps:
308
+ * pass the same value as `--release` to `npx @guidelytech/sourcemaps upload`. Defaults to the app version.
309
+ */
310
+ release?: string;
311
+ /**
312
+ * Error monitoring, as in Sentry SDKs: `captureErrors`, `sampleRate`, `ignoreErrors`, `denyUrls` /
313
+ * `allowUrls`, `beforeSend`, `beforeBreadcrumb`, which automatic breadcrumbs to record and `dist`
314
+ * (docs/error-monitoring/sdks.md). Errors need the project's error tracking on, plus analytics and consent.
315
+ */
316
+ errors?: ErrorMonitoringOptions;
317
+ /**
318
+ * Product analytics autocapture: taps (`click`), rage taps, heatmaps, time on screen
319
+ * (`page_leave`) and app lifecycle events. Each capability runs when the project enables it in
320
+ * Settings → Product analytics; this option can only turn things off: `false` for everything,
321
+ * or `{ clicks: false, heatmaps: false, … }` per capability. `false` also removes the provider's
322
+ * touch-observing wrapper view.
323
+ */
324
+ autocapture?: boolean | Partial<AutocaptureSettings>;
325
+ /**
326
+ * Session replay (off by default). Recording also needs replay enabled in the project settings and
327
+ * the native `@guidelytech/react-native-replay` module installed; sampling, consent and `analytics`
328
+ * apply too. Text inputs are always masked; wrap anything else in `<GuidelyMask>`.
329
+ */
330
+ sessionReplay?: SessionReplayOptions;
331
+ /** How often to refresh the published config (default 5 minutes). */
332
+ configRefreshMs?: number;
333
+ /** Overrides for the project theme. */
334
+ theme?: Partial<ProjectTheme>;
335
+ /** Identify this user as soon as the client initialises. */
336
+ user?: GuidelyUser;
337
+ /**
338
+ * Language for guides and the resource center (BCP 47, e.g. `fr` or `pt-BR`). Defaults to the
339
+ * user's `language` / `locale` trait, then the device language. Change it later with `setLocale()`.
340
+ */
341
+ locale?: string;
342
+ /** Handles relative and custom-scheme URLs from buttons, links and tasks (deep links, in-app routes). Return `true` when handled. */
343
+ onNavigate?: (url: string) => boolean | void;
344
+ onError?: (error: Error) => void;
345
+ /** Custom fetch (tests / polyfills). */
346
+ fetch?: typeof fetch;
347
+ /** Show the floating checklist launcher (default `true`). */
348
+ showChecklistLauncher?: boolean;
349
+ /** Show a floating resource-center launcher (default `false`; call `openResourceCenter()` instead). */
350
+ showResourceCenterLauncher?: boolean;
351
+ /** Show the Scout chat bubble when the messenger is on for this platform (default `true`). */
352
+ showMessengerLauncher?: boolean;
353
+ /**
354
+ * Feature flags (on by default, same key and API URL; the last payload is kept in `storage` so
355
+ * flags work offline at cold start). `false` turns them off; an object passes options to the
356
+ * flags client (`attributes`, `payload`, `remoteEval`, `pollingMode`…).
357
+ */
358
+ flags?: false | Partial<FlagsClientOptions>;
359
+ }
360
+ interface SessionReplayOptions {
361
+ /** Record sessions (when the project setting allows it and the session is sampled). */
362
+ enabled?: boolean;
363
+ /** Mask all text; also forced on by the project's "mask all text" setting. */
364
+ maskAllText?: boolean;
365
+ /** Mask all images. */
366
+ maskAllImages?: boolean;
367
+ /** Time between screenshots in ms (default 1000, minimum 500). */
368
+ captureIntervalMs?: number;
369
+ }
370
+ interface GuideStepInfo {
371
+ guide: PublishedGuide;
372
+ stepId: string;
373
+ stepIndex: number;
374
+ }
375
+ interface GuidelyEvents {
376
+ ready: (config: SdkConfigResponse) => void;
377
+ config: (config: SdkConfigResponse) => void;
378
+ "guide:start": (guide: PublishedGuide) => void;
379
+ "guide:step": (info: GuideStepInfo) => void;
380
+ "guide:complete": (guide: PublishedGuide) => void;
381
+ "guide:dismiss": (guide: PublishedGuide) => void;
382
+ "guide:skip": (guide: PublishedGuide) => void;
383
+ "checklist:task": (info: {
384
+ guide: PublishedGuide;
385
+ task: ChecklistTask;
386
+ progress: ChecklistProgressState;
387
+ }) => void;
388
+ "checklist:complete": (guide: PublishedGuide) => void;
389
+ "survey:submit": (info: {
390
+ guide: PublishedGuide;
391
+ answers: Record<string, unknown>;
392
+ responseId: string;
393
+ }) => void;
394
+ "resource-center:open": () => void;
395
+ /** The Scout messenger opened. */
396
+ "messenger:open": () => void;
397
+ /** Scout or a teammate replied in a conversation. */
398
+ "conversation:message": (info: {
399
+ message: MessengerMessage;
400
+ conversation: MessengerConversation;
401
+ }) => void;
402
+ error: (error: Error) => void;
403
+ track: (event: SdkEvent) => void;
404
+ identify: (info: {
405
+ userId: string | null;
406
+ anonymousId: string;
407
+ }) => void;
408
+ /** Feature flags loaded (bootstrap, storage or network) — or failed to and serve fallbacks. */
409
+ "flags:ready": () => void;
410
+ /** New flag rules arrived. */
411
+ "flags:change": () => void;
412
+ }
413
+ type GuidelyEventName = keyof GuidelyEvents;
414
+ /** A rendered step, as the overlay sees it. */
415
+ interface StepView {
416
+ /** Stable per rendered step; changes when the step changes. */
417
+ key: string;
418
+ guide: PublishedGuide;
419
+ step: GuideStep;
420
+ index: number;
421
+ total: number;
422
+ canGoBack: boolean;
423
+ /** Guidely id of the resolved target, or null for unanchored / fallback-to-modal steps. */
424
+ targetId: string | null;
425
+ asModal: boolean;
426
+ /** Hotspots render collapsed until tapped. */
427
+ expanded: boolean;
428
+ }
429
+ interface ChecklistView {
430
+ guide: PublishedGuide;
431
+ progress: ChecklistProgressState;
432
+ open: boolean;
433
+ }
434
+ interface SurveyView {
435
+ key: string;
436
+ guide: PublishedGuide;
437
+ submitted: boolean;
438
+ }
439
+ /** Everything the overlay renders. Immutable snapshots; a new object on every change. */
440
+ interface UiState {
441
+ steps: StepView[];
442
+ checklists: ChecklistView[];
443
+ survey: SurveyView | null;
444
+ resourceCenterOpen: boolean;
445
+ /** An article to show in the resource center (from a help-article link); `seq` changes per request. */
446
+ resourceCenterArticle?: {
447
+ id: string;
448
+ seq: number;
449
+ } | null;
450
+ theme: Partial<ProjectTheme>;
451
+ /** Scout is on for this platform; the overlay renders the messenger (see `client.getMessenger()`). */
452
+ messenger: boolean;
453
+ }
454
+
455
+ /** What `beforeSend` gets (and may change): the indexed properties and the detail. */
456
+ interface ErrorEvent {
457
+ properties: ExceptionProperties & Record<string, unknown>;
458
+ detail: ExceptionDetail;
459
+ }
460
+ interface BreadcrumbHint {
461
+ /** The console arguments or request the breadcrumb came from. */
462
+ event?: unknown;
463
+ }
464
+ /** `<GuidelyProvider errors={{ … }}>` / `GuidelyOptions.errors`. */
465
+ interface ErrorMonitoringOptions {
466
+ /**
467
+ * Automatic capture (default `true`): uncaught JS errors through `ErrorUtils` and unhandled promise
468
+ * rejections. `false` leaves `captureException` / `captureMessage` working.
469
+ */
470
+ captureErrors?: boolean;
471
+ /** Share of errors sent, 0–1 (default 1). Crashes included. */
472
+ sampleRate?: number;
473
+ /** Errors whose `"<type>: <message>"` or message contains a string / matches a RegExp are not sent. */
474
+ ignoreErrors?: ErrorFilterPattern[];
475
+ /** Errors whose innermost frame file matches are not sent (`app:///index.android.bundle`, dev-server URLs). */
476
+ denyUrls?: ErrorFilterPattern[];
477
+ /** When set, only errors whose innermost frame file matches are sent. */
478
+ allowUrls?: ErrorFilterPattern[];
479
+ /** Last say over each error: return it (changed or not), or null to drop it. A hook that throws sends the event unchanged. */
480
+ beforeSend?: (event: ErrorEvent) => ErrorEvent | null;
481
+ /** Last say over each breadcrumb: return it (changed or not), or null to drop it. */
482
+ beforeBreadcrumb?: (crumb: Breadcrumb, hint?: BreadcrumbHint) => Breadcrumb | null;
483
+ /** Automatic breadcrumbs (all on by default); `false` turns them all off. */
484
+ breadcrumbs?: false | BreadcrumbOptions;
485
+ /** Breadcrumbs kept (default and maximum 100). */
486
+ maxBreadcrumbs?: number;
487
+ /** Sentry `dist`: tells builds of one release apart (default: the app build number). */
488
+ dist?: string;
489
+ /**
490
+ * Unhandled promise rejections on engines other than Hermes: pass
491
+ * `require("promise/setimmediate/rejection-tracking")` (React Native's Promise polyfill). Hermes'
492
+ * own tracker is used without it.
493
+ */
494
+ rejectionTracker?: RejectionTracker | null;
495
+ }
496
+ interface BreadcrumbOptions {
497
+ /** `ui.click`: taps the SDK observes (the element's `selector`; never its text). */
498
+ taps?: boolean;
499
+ /** `navigation`: `screen()` changes. */
500
+ navigation?: boolean;
501
+ /** `app.lifecycle`: foreground / background. */
502
+ appLifecycle?: boolean;
503
+ /** `console`: `console.warn` / `console.error`. */
504
+ console?: boolean;
505
+ /** `fetch` / `xhr`: method, URL without query, status, duration. */
506
+ http?: boolean;
507
+ /** `guide`: guides shown, stepped through, completed, dismissed. */
508
+ guides?: boolean;
509
+ }
510
+ /** The second argument of `captureException`; any other key becomes an event property. */
511
+ interface CaptureContext {
512
+ tags?: Record<string, string | number | boolean>;
513
+ extra?: Record<string, unknown>;
514
+ level?: ErrorLevelName;
515
+ /** `["{{ default }}", "checkout"]` splits an issue, `["checkout-timeout"]` merges errors into one. */
516
+ fingerprint?: string[];
517
+ contexts?: Record<string, Record<string, unknown> | null>;
518
+ user?: {
519
+ id?: string;
520
+ email?: string;
521
+ username?: string;
522
+ };
523
+ }
524
+
197
525
  /**
198
526
  * Scout messenger for React Native: the transport of `@guidelytech/sdk-core`'s messenger-api plus
199
527
  * the conversation state the web widget keeps, as a headless store the overlay renders.
@@ -512,191 +840,8 @@ declare class SessionRecorder {
512
840
  private onFrame;
513
841
  }
514
842
 
515
- /**
516
- * AsyncStorage-compatible key/value storage (`@react-native-async-storage/async-storage`,
517
- * `expo-secure-store` wrappers, MMKV adapters…). Synchronous implementations work too.
518
- */
519
- interface GuidelyStorage {
520
- getItem(key: string): Promise<string | null> | string | null;
521
- setItem(key: string, value: string): Promise<void> | void;
522
- removeItem(key: string): Promise<void> | void;
523
- }
524
- /** Device facts the engine needs. The provider fills these in from React Native APIs. */
525
- interface DeviceEnvironment {
526
- platform: "ios" | "android";
527
- deviceType: "mobile" | "tablet";
528
- locale?: string;
529
- /** Host app version, detected from a linked native module (see `core/device.ts`). */
530
- appVersion?: string;
531
- /** Host app build number (`CFBundleVersion` / `versionCode`). */
532
- appBuild?: string;
533
- /** OS version: `18.1` on iOS, `14` on Android. */
534
- osVersion?: string;
535
- }
536
- interface GuidelyOptions {
537
- /** Environment public key, e.g. `pk_dev_…`. Not a secret. */
538
- projectId: string;
539
- environment?: GuidelyEnvironment;
540
- /** Base URL of your Guidely deployment, e.g. `https://guidelytech.com`. */
541
- apiUrl?: string;
542
- /**
543
- * Where identity, cached config, queued events and unsent survey answers are persisted. Pass AsyncStorage
544
- * (`@react-native-async-storage/async-storage`); without it state lasts only for the app session,
545
- * so anything not yet sent during a Guidely outage is lost when the app restarts.
546
- */
547
- storage?: GuidelyStorage;
548
- debug?: boolean;
549
- /** Send analytics events (default `true`). Guides still render when disabled. */
550
- analytics?: boolean;
551
- consent?: ConsentState;
552
- /**
553
- * Host app version for `app.version` targeting rules, every event's `appVersion` and `app_install` /
554
- * `app_update`. Detected on iOS and Android when `@guidelytech/react-native-replay`, `expo-application`
555
- * or `react-native-device-info` is linked; pass it to override that (or when none is).
556
- */
557
- appVersion?: string;
558
- /** Host app build number (`CFBundleVersion` / `versionCode`), sent as `build` with app lifecycle events. Detected like `appVersion`. */
559
- appBuild?: string;
560
- /**
561
- * Product analytics autocapture: taps (`click`), rage taps, heatmaps, time on screen
562
- * (`page_leave`) and app lifecycle events. Each capability runs when the project enables it in
563
- * Settings → Product analytics; this option can only turn things off: `false` for everything,
564
- * or `{ clicks: false, heatmaps: false, … }` per capability. `false` also removes the provider's
565
- * touch-observing wrapper view.
566
- */
567
- autocapture?: boolean | Partial<AutocaptureSettings>;
568
- /**
569
- * Session replay (off by default). Recording also needs replay enabled in the project settings and
570
- * the native `@guidelytech/react-native-replay` module installed; sampling, consent and `analytics`
571
- * apply too. Text inputs are always masked; wrap anything else in `<GuidelyMask>`.
572
- */
573
- sessionReplay?: SessionReplayOptions;
574
- /** How often to refresh the published config (default 5 minutes). */
575
- configRefreshMs?: number;
576
- /** Overrides for the project theme. */
577
- theme?: Partial<ProjectTheme>;
578
- /** Identify this user as soon as the client initialises. */
579
- user?: GuidelyUser;
580
- /**
581
- * Language for guides and the resource center (BCP 47, e.g. `fr` or `pt-BR`). Defaults to the
582
- * user's `language` / `locale` trait, then the device language. Change it later with `setLocale()`.
583
- */
584
- locale?: string;
585
- /** Handles relative and custom-scheme URLs from buttons, links and tasks (deep links, in-app routes). Return `true` when handled. */
586
- onNavigate?: (url: string) => boolean | void;
587
- onError?: (error: Error) => void;
588
- /** Custom fetch (tests / polyfills). */
589
- fetch?: typeof fetch;
590
- /** Show the floating checklist launcher (default `true`). */
591
- showChecklistLauncher?: boolean;
592
- /** Show a floating resource-center launcher (default `false`; call `openResourceCenter()` instead). */
593
- showResourceCenterLauncher?: boolean;
594
- /** Show the Scout chat bubble when the messenger is on for this platform (default `true`). */
595
- showMessengerLauncher?: boolean;
596
- /**
597
- * Feature flags (on by default, same key and API URL; the last payload is kept in `storage` so
598
- * flags work offline at cold start). `false` turns them off; an object passes options to the
599
- * flags client (`attributes`, `payload`, `remoteEval`, `pollingMode`…).
600
- */
601
- flags?: false | Partial<FlagsClientOptions>;
602
- }
603
- interface SessionReplayOptions {
604
- /** Record sessions (when the project setting allows it and the session is sampled). */
605
- enabled?: boolean;
606
- /** Mask all text; also forced on by the project's "mask all text" setting. */
607
- maskAllText?: boolean;
608
- /** Mask all images. */
609
- maskAllImages?: boolean;
610
- /** Time between screenshots in ms (default 1000, minimum 500). */
611
- captureIntervalMs?: number;
612
- }
613
- interface GuideStepInfo {
614
- guide: PublishedGuide;
615
- stepId: string;
616
- stepIndex: number;
617
- }
618
- interface GuidelyEvents {
619
- ready: (config: SdkConfigResponse) => void;
620
- config: (config: SdkConfigResponse) => void;
621
- "guide:start": (guide: PublishedGuide) => void;
622
- "guide:step": (info: GuideStepInfo) => void;
623
- "guide:complete": (guide: PublishedGuide) => void;
624
- "guide:dismiss": (guide: PublishedGuide) => void;
625
- "guide:skip": (guide: PublishedGuide) => void;
626
- "checklist:task": (info: {
627
- guide: PublishedGuide;
628
- task: ChecklistTask;
629
- progress: ChecklistProgressState;
630
- }) => void;
631
- "checklist:complete": (guide: PublishedGuide) => void;
632
- "survey:submit": (info: {
633
- guide: PublishedGuide;
634
- answers: Record<string, unknown>;
635
- responseId: string;
636
- }) => void;
637
- "resource-center:open": () => void;
638
- /** The Scout messenger opened. */
639
- "messenger:open": () => void;
640
- /** Scout or a teammate replied in a conversation. */
641
- "conversation:message": (info: {
642
- message: MessengerMessage;
643
- conversation: MessengerConversation;
644
- }) => void;
645
- error: (error: Error) => void;
646
- track: (event: SdkEvent) => void;
647
- identify: (info: {
648
- userId: string | null;
649
- anonymousId: string;
650
- }) => void;
651
- /** Feature flags loaded (bootstrap, storage or network) — or failed to and serve fallbacks. */
652
- "flags:ready": () => void;
653
- /** New flag rules arrived. */
654
- "flags:change": () => void;
655
- }
656
- type GuidelyEventName = keyof GuidelyEvents;
657
- /** A rendered step, as the overlay sees it. */
658
- interface StepView {
659
- /** Stable per rendered step; changes when the step changes. */
660
- key: string;
661
- guide: PublishedGuide;
662
- step: GuideStep;
663
- index: number;
664
- total: number;
665
- canGoBack: boolean;
666
- /** Guidely id of the resolved target, or null for unanchored / fallback-to-modal steps. */
667
- targetId: string | null;
668
- asModal: boolean;
669
- /** Hotspots render collapsed until tapped. */
670
- expanded: boolean;
671
- }
672
- interface ChecklistView {
673
- guide: PublishedGuide;
674
- progress: ChecklistProgressState;
675
- open: boolean;
676
- }
677
- interface SurveyView {
678
- key: string;
679
- guide: PublishedGuide;
680
- submitted: boolean;
681
- }
682
- /** Everything the overlay renders. Immutable snapshots; a new object on every change. */
683
- interface UiState {
684
- steps: StepView[];
685
- checklists: ChecklistView[];
686
- survey: SurveyView | null;
687
- resourceCenterOpen: boolean;
688
- /** An article to show in the resource center (from a help-article link); `seq` changes per request. */
689
- resourceCenterArticle?: {
690
- id: string;
691
- seq: number;
692
- } | null;
693
- theme: Partial<ProjectTheme>;
694
- /** Scout is on for this platform; the overlay renders the messenger (see `client.getMessenger()`). */
695
- messenger: boolean;
696
- }
697
-
698
843
  declare const SDK_NAME = "@guidelytech/react-native";
699
- declare const SDK_VERSION = "0.16.0";
844
+ declare const SDK_VERSION = "0.17.0";
700
845
  declare const DEFAULT_API_URL = "https://guidelytech.com";
701
846
  /** Host-platform services the engine needs; the provider supplies React Native implementations. */
702
847
  interface PlatformBridge {
@@ -710,6 +855,12 @@ interface PlatformBridge {
710
855
  };
711
856
  /** Session-replay screenshots; absent where the native replay module is not installed. */
712
857
  capturer?: ScreenCapturer;
858
+ /**
859
+ * The JS globals crash capture and breadcrumbs hook into (`ErrorUtils`, `HermesInternal`,
860
+ * `console`, `fetch`, `XMLHttpRequest`): `globalThis` from the provider. Without it nothing is
861
+ * patched and only manual captures (`captureException`) are reported.
862
+ */
863
+ globals?: RuntimeGlobals;
713
864
  }
714
865
  /** Mobile sessions persist across launches and expire after the configured inactivity timeout. */
715
866
  interface MobileSession extends SessionState {
@@ -737,6 +888,8 @@ declare class GuidelyClient {
737
888
  /** Survey answers, guide completions/dismissals and checklist progress, kept until the server has them. */
738
889
  private outbox;
739
890
  private config;
891
+ /** The `environment` option as passed (the resolved one is in `options.environment`). */
892
+ private readonly envOption;
740
893
  private configFetchedAt;
741
894
  private etag;
742
895
  private anonymousId;
@@ -799,6 +952,15 @@ declare class GuidelyClient {
799
952
  private localizedRc;
800
953
  /** "What's new" last-seen time when the resource center opened (entries after it read as new). */
801
954
  private announcementsSeenAtOpen;
955
+ private readonly errorScope;
956
+ private readonly exceptionThrottle;
957
+ /** Errors captured before storage and a config were loaded (whether error tracking is on is unknown until then). */
958
+ private earlyErrors;
959
+ /** Crash reports left by earlier launches, sent once a config says error tracking is on. */
960
+ private storedCrashes;
961
+ /** This launch's crash reports (normally one: the app ends right after). */
962
+ private launchCrashes;
963
+ private lastAppState;
802
964
  private readonly customListeners;
803
965
  private readonly eventBus;
804
966
  constructor(options: GuidelyOptions, bridge: PlatformBridge);
@@ -808,6 +970,9 @@ declare class GuidelyClient {
808
970
  ready(): Promise<void>;
809
971
  private bootstrap;
810
972
  private whenHydrated;
973
+ /** Environment guides and flags target: the `environment` option, else the one the loaded config names, else a guess from the key. */
974
+ get environment(): GuidelyEnvironment;
975
+ private useConfig;
811
976
  private fetchConfig;
812
977
  private wireTimers;
813
978
  /** Re-fetches the published config and re-evaluates triggers. */
@@ -872,6 +1037,8 @@ declare class GuidelyClient {
872
1037
  private pageviewsOn;
873
1038
  /** True when taps are worth observing (clicks, rage taps or heatmaps are on); the provider skips resolving views otherwise. */
874
1039
  isTapCaptureOn(): boolean;
1040
+ /** Taps become `ui.click` breadcrumbs while errors can be reported (even with click autocapture off). */
1041
+ private tapBreadcrumbsOn;
875
1042
  /**
876
1043
  * Records a tap observed by the provider: `click` for an interactive element, `rage_click` for
877
1044
  * bursts and a heatmap point. A registered `<GuidelyTarget>` whose frame contains the point
@@ -893,6 +1060,72 @@ declare class GuidelyClient {
893
1060
  private checkLaunch;
894
1061
  private wentToBackground;
895
1062
  private cameToForeground;
1063
+ /**
1064
+ * Reports a caught error as an `exception` event (`handled: true`), grouped into an issue on the
1065
+ * Errors page. The second argument takes Sentry's capture context (`tags`, `extra`, `level`,
1066
+ * `fingerprint`, `contexts`, `user`); any other key is attached to the occurrence as a property.
1067
+ * Needs the project's error tracking on (plus analytics and consent); `errors.captureErrors: false`
1068
+ * does not stop it. Returns the event id (empty when nothing is sent).
1069
+ */
1070
+ captureException(error: unknown, hint?: CaptureContext & Record<string, unknown>): string;
1071
+ /** Reports a message (default level `info`) as its own issue, grouped by the message. */
1072
+ captureMessage(message: string, level?: ErrorLevelName, hint?: CaptureContext): string;
1073
+ /** Adds a breadcrumb (sent with the next errors; the last 100 are kept). */
1074
+ addBreadcrumb(crumb: Breadcrumb, hint?: BreadcrumbHint): void;
1075
+ /** Tags every later error (searchable on the issue page); `null` removes the tag. */
1076
+ setTag(key: string, value: string | number | boolean | null | undefined): void;
1077
+ setTags(tags: Record<string, string | number | boolean | null | undefined>): void;
1078
+ /** Arbitrary data attached to every later error. */
1079
+ setExtra(key: string, value: unknown): void;
1080
+ setExtras(extras: Record<string, unknown>): void;
1081
+ /** A named context (`setContext("cart", { items: 3 })`) on every later error; `null` removes it. */
1082
+ setContext(name: string, context: Record<string, unknown> | null): void;
1083
+ /**
1084
+ * Sentry's `setUser`: identifies the user by `id` (like `identify`) and keeps `email` / `username`
1085
+ * on their errors. `null` forgets the user (`reset()`).
1086
+ */
1087
+ setUser(user: {
1088
+ id?: string | number;
1089
+ email?: string;
1090
+ username?: string;
1091
+ [trait: string]: unknown;
1092
+ } | null): void;
1093
+ private crumbsOn;
1094
+ private autoBreadcrumb;
1095
+ /** Errors may be captured: analytics on, consent not denied and, once a config says, the project's error tracking on. */
1096
+ private errorsWanted;
1097
+ /** Errors may be queued now (a config is known and allows them). */
1098
+ private errorTrackingAllowed;
1099
+ /** Requests to the Guidely deployment never become breadcrumbs. */
1100
+ private isGuidelyUrl;
1101
+ private release;
1102
+ /** Builds and filters one error (`null` when dropped). */
1103
+ private prepareCapture;
1104
+ /** Queues a prepared error, or holds it until storage and a config are loaded. Returns its event id ("" when dropped). */
1105
+ private deliverError;
1106
+ private sendError;
1107
+ /** Sends what waited for storage and a config: earlier launches' crash reports, then early errors. */
1108
+ private drainErrors;
1109
+ private loadStoredCrashes;
1110
+ /**
1111
+ * Writes the unsent crash reports to storage, directly (not behind other pending writes) so the
1112
+ * write starts before the app ends. Resolves when the storage has it.
1113
+ */
1114
+ private writeCrashes;
1115
+ /**
1116
+ * A fatal JS error: React Native ends a release app right after the global handler, so the report
1117
+ * is written to storage at once (and sent on the next launch), and sent now as well when the
1118
+ * network allows. The promise tells the handler when React Native's own handler may run.
1119
+ */
1120
+ private saveCrash;
1121
+ /** An uncaught JS error from `ErrorUtils` (fatal ones end the app in release builds). */
1122
+ private captureGlobalError;
1123
+ private captureRejection;
1124
+ /**
1125
+ * Guide breadcrumbs, and (with the bridge's JS globals) the global error handler, promise
1126
+ * rejection tracking and console / network breadcrumbs. Undone by `destroy()`.
1127
+ */
1128
+ private installErrorMonitoring;
896
1129
  /** Builds the targeting context for the current moment. */
897
1130
  getContext(): TargetingContext;
898
1131
  private isTargeted;
@@ -1112,9 +1345,36 @@ interface NativeSources {
1112
1345
  }
1113
1346
  /** The host app's version and build, or `{}` when no linked module knows them. */
1114
1347
  declare function detectAppVersion(src: NativeSources): AppVersionInfo;
1348
+ interface DeviceModelInfo {
1349
+ model?: string;
1350
+ manufacturer?: string;
1351
+ brand?: string;
1352
+ simulator?: boolean;
1353
+ }
1354
+ /**
1355
+ * The device model, manufacturer and brand for error reports: from `expo-device`, then
1356
+ * `react-native-device-info`, then React Native's own Android constants (`Model`, `Manufacturer`,
1357
+ * `Brand`). iOS reports no model without one of the modules.
1358
+ */
1359
+ declare function detectDeviceModel(src: NativeSources): DeviceModelInfo;
1360
+ /** React Native's version from `Platform.constants.reactNativeVersion` (`{ major, minor, patch }`). */
1361
+ declare function detectReactNativeVersion(src: NativeSources): {
1362
+ major: number;
1363
+ minor: number;
1364
+ patch: number;
1365
+ prerelease?: string;
1366
+ } | undefined;
1115
1367
  /** The OS version: `18.1` on iOS, `14` on Android (falling back to the API level). */
1116
1368
  declare function detectOsVersion(src: NativeSources): string | undefined;
1117
1369
 
1370
+ /**
1371
+ * The frame file as the server matches it: dev-server URLs keep origin and path, installed bundles
1372
+ * become `app:///<basename>`, anything else loses `file://` and its query.
1373
+ */
1374
+ declare function normalizeBundleFile(file: string): string;
1375
+ /** Parses a Hermes, JavaScriptCore or V8 `Error.stack` into frames, innermost first. */
1376
+ declare function parseReactNativeStack(stack: string | undefined | null, max?: number): StackFrame[];
1377
+
1118
1378
  /**
1119
1379
  * Declares which screen its children are on, so targets on screens that are mounted but not
1120
1380
  * visible (inactive tabs, screens under a stack) are never used. `name` must match what you pass
@@ -1333,4 +1593,4 @@ declare function useGuideState(idOrKey: string): {
1333
1593
  /** The guide currently running exclusively (flow, modal, survey…), or null. */
1334
1594
  declare function useActiveGuide(): PublishedGuide | null;
1335
1595
 
1336
- export { type AppVersionInfo, type AutocaptureOption, type ChecklistView, DEFAULT_API_URL, type DeviceEnvironment, Feature, FeatureFlag, type FeatureProps, FeatureValue, type FeatureValueProps, FlagsProvider, type FlagsProviderProps, type GuideStepInfo, GuidelyClient, type GuidelyEventName, type GuidelyEvents, GuidelyMask, type GuidelyMaskProps, type GuidelyOptions, GuidelyOverlay, GuidelyProvider, type GuidelyProviderProps, GuidelyScreenScope, type GuidelyStorage, GuidelyTarget, type GuidelyTargetProps, HeatmapBuffer, type Insets, Messenger, type MessengerSnapshot, type MessengerTab, type MessengerThread, type MessengerView, type NativeSources, type PlatformBridge, RageClickDetector, type ReplayCaptureOptions, type ReplayFrame, ReplayUploader, RrwebEvents, SDK_NAME, SDK_VERSION, type ScreenCapturer, SessionRecorder, type SessionReplayOptions, type StepView, type SurveyView, type TapElement, type TapInfo, type TapProperties, TapTracker, TargetRegistry, type TouchPhase, type UiState, createSseParser, detectAppVersion, detectOsVersion, guidelyScreenLayout, htmlToText, noopClient, parseHtml, positionCard, targetIdsFor, useActiveGuide, useChecklistProgress, useFeatureValue, useFlag, useFlagDetails, useFlags, useFlagsClient, useFlagsReady, useGuideState, useGuidely, useGuidelyEvent, useGuidelyIdentify, useGuidelyNavigation, useGuidelyReady, useGuidelyScreen, useGuidelyTarget };
1596
+ export { type AppVersionInfo, type AutocaptureOption, type BreadcrumbHint, type BreadcrumbOptions, type CaptureContext, type ChecklistView, DEFAULT_API_URL, type DeviceEnvironment, type DeviceModelInfo, type ErrorEvent, type ErrorMonitoringOptions, FATAL_FLUSH_MS, Feature, FeatureFlag, type FeatureProps, FeatureValue, type FeatureValueProps, FlagsProvider, type FlagsProviderProps, type GuideStepInfo, GuidelyClient, type GuidelyEventName, type GuidelyEvents, GuidelyMask, type GuidelyMaskProps, type GuidelyOptions, GuidelyOverlay, GuidelyProvider, type GuidelyProviderProps, GuidelyScreenScope, type GuidelyStorage, GuidelyTarget, type GuidelyTargetProps, HeatmapBuffer, type Insets, Messenger, type MessengerSnapshot, type MessengerTab, type MessengerThread, type MessengerView, type NativeSources, type PlatformBridge, RageClickDetector, type RejectionTracker, type RejectionTrackerOptions, type ReplayCaptureOptions, type ReplayFrame, ReplayUploader, RrwebEvents, type RuntimeGlobals, SDK_NAME, SDK_VERSION, type ScreenCapturer, SessionRecorder, type SessionReplayOptions, type StepView, type SurveyView, type TapElement, type TapInfo, type TapProperties, TapTracker, TargetRegistry, type TouchPhase, type UiState, createSseParser, detectAppVersion, detectDeviceModel, detectOsVersion, detectReactNativeVersion, guidelyScreenLayout, htmlToText, noopClient, normalizeBundleFile, parseHtml, parseReactNativeStack, positionCard, targetIdsFor, useActiveGuide, useChecklistProgress, useFeatureValue, useFlag, useFlagDetails, useFlags, useFlagsClient, useFlagsReady, useGuideState, useGuidely, useGuidelyEvent, useGuidelyIdentify, useGuidelyNavigation, useGuidelyReady, useGuidelyScreen, useGuidelyTarget };