@marktiderman/genesis-native 0.12.0 → 0.13.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/README.md +5 -0
- package/dist/{block-DlGnjjps.d.ts → block-BfJT3F6B.d.ts} +3 -3
- package/dist/{blocks-CF0agqxk.d.ts → blocks-DoY_Z-Lh.d.ts} +21 -4
- package/dist/{chunk-5STOXRTS.js → chunk-6UVWYJPZ.js} +7 -4
- package/dist/chunk-6UVWYJPZ.js.map +1 -0
- package/dist/{chunk-ZQVRCW5J.js → chunk-JWIBRHDE.js} +3 -3
- package/dist/{chunk-ZQVRCW5J.js.map → chunk-JWIBRHDE.js.map} +1 -1
- package/dist/{chunk-YIF4BFQH.js → chunk-JZHDEU4Q.js} +130 -13
- package/dist/chunk-JZHDEU4Q.js.map +1 -0
- package/dist/devtools.d.ts +36 -6
- package/dist/devtools.js +138 -98
- package/dist/devtools.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/observability.d.ts +5 -5
- package/dist/observability.js +3 -3
- package/dist/persist.d.ts +1 -1
- package/dist/push.d.ts +3 -3
- package/dist/{query--ihYsJWC.d.ts → query-DJFrykK_.d.ts} +38 -2
- package/dist/{screen-boundary-B8DlsLwb.d.ts → screen-boundary-Da3qleNz.d.ts} +5 -1
- package/dist/updates.d.ts +2 -2
- package/dist/updates.js +2 -2
- package/package.json +4 -4
- package/src/blocks.tsx +18 -3
- package/src/devtools/block.tsx +244 -144
- package/src/devtools/index.ts +1 -1
- package/src/errors.tsx +144 -13
- package/src/index.ts +4 -0
- package/src/screen-boundary.tsx +13 -2
- package/src/updates/signature.ts +13 -2
- package/dist/chunk-5STOXRTS.js.map +0 -1
- package/dist/chunk-M7S7F6L5.js +0 -49
- package/dist/chunk-M7S7F6L5.js.map +0 -1
- package/dist/chunk-YIF4BFQH.js.map +0 -1
package/README.md
CHANGED
|
@@ -450,6 +450,9 @@ shows `fallback` (default `ScreenErrorScreen`, Genesis UI) with "Try again" (Exp
|
|
|
450
450
|
reports the error itself (with the route attached), the block doesn't send it to Sentry twice.
|
|
451
451
|
Without the block, `createScreenErrorBoundary()` reports through `reportError`. Outside Expo
|
|
452
452
|
Router, wrap a subtree in `<ScreenErrorBoundary>`.
|
|
453
|
+
`createScreenErrorBoundary({ contact: () => support.contact() })` (and `<FatalScreen contact>`)
|
|
454
|
+
adds "Contact support" under "Try again": the support page, else a mailto (`contactHref`), from
|
|
455
|
+
genesis-support's `support.contactEmail` / `support.contactUrl` settings.
|
|
453
456
|
- `useRecentActivity()` gives the last breadcrumbs and errors, scrubbed (the devtools overlay
|
|
454
457
|
shows them).
|
|
455
458
|
|
|
@@ -482,6 +485,8 @@ builds. It opens with a three-finger hold (every build, no native module), a sha
|
|
|
482
485
|
`channels`: off where that block has it off; "Back to the build's channel" always works);
|
|
483
486
|
- the signed-in user's id, the server's base URL, the blocks in effect (`useBlocks`) and your flags;
|
|
484
487
|
- the recent errors and breadcrumbs from the observability block (scrubbed);
|
|
488
|
+
- the health checks (`checks`: genesis-support's `healthChecks` registry), run when the sheet opens
|
|
489
|
+
and again with "Run checks", each with ok, warn or fail and its message;
|
|
485
490
|
- "Copy debug info" (your `copy`, else the share sheet), "Crash test" (a render error, to check the
|
|
486
491
|
fatal screen and reporting end to end), "Clear cache" (the query cache, then your `clearCache`)
|
|
487
492
|
and "Sign out" (your `signOut`);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ComponentType, ReactNode } from 'react';
|
|
3
|
-
import { c as ScreenErrorProps } from './screen-boundary-
|
|
4
|
-
import { N as NativeBlock, s as NativeBlockRootProps } from './blocks-
|
|
5
|
-
import {
|
|
3
|
+
import { c as ScreenErrorProps } from './screen-boundary-Da3qleNz.js';
|
|
4
|
+
import { N as NativeBlock, s as NativeBlockRootProps } from './blocks-DoY_Z-Lh.js';
|
|
5
|
+
import { c as ErrorReport } from './query-DJFrykK_.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Typed analytics events: the app lists every event and the props each may
|
|
@@ -2,7 +2,7 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode, ComponentType } from 'react';
|
|
3
3
|
import { Slots, SlotPropsFor } from '@marktiderman/genesis-core/slots';
|
|
4
4
|
import { BlockDef, Contributed, BlockSettingsRow, ResolvedBlocks } from '@marktiderman/genesis-config/blocks';
|
|
5
|
-
import {
|
|
5
|
+
import { h as FatalScreenProps, j as GenesisErrorBoundaryProps, m as QueryPersistence, d as ErrorUtilsLike, E as EnableRejectionTracker, l as QueryLifecycleOptions, O as OnError, c as ErrorReport } from './query-DJFrykK_.js';
|
|
6
6
|
import { QueryClient, QueryClientConfig } from '@tanstack/react-query';
|
|
7
7
|
import { CanonicalBrand } from '@marktiderman/genesis-design-system';
|
|
8
8
|
import { SupabaseClientInput, DataProvider } from '@marktiderman/genesis-core/provider';
|
|
@@ -525,6 +525,8 @@ interface VersionSignature {
|
|
|
525
525
|
otaNumber?: string | null;
|
|
526
526
|
/** The release's name (`buildMetadata`), or null. */
|
|
527
527
|
release?: string | null;
|
|
528
|
+
/** When it was built (`buildMetadata`), ISO, or null. */
|
|
529
|
+
builtAt?: string | null;
|
|
528
530
|
/** One line, for an About row. */
|
|
529
531
|
short: string;
|
|
530
532
|
/** Several lines, for a support report. */
|
|
@@ -535,6 +537,12 @@ interface VersionSignature {
|
|
|
535
537
|
* every field optional.
|
|
536
538
|
*/
|
|
537
539
|
interface BuildMetadata {
|
|
540
|
+
/** The app's version at build time (`genesis build-stamp`). */
|
|
541
|
+
version?: string | null;
|
|
542
|
+
/** The channel it was built or published for. */
|
|
543
|
+
channel?: string | null;
|
|
544
|
+
/** When it was built, ISO. */
|
|
545
|
+
builtAt?: string | null;
|
|
538
546
|
/** The commit the bundle was built from, full or short. */
|
|
539
547
|
commit?: string | null;
|
|
540
548
|
commitMessage?: string | null;
|
|
@@ -1539,6 +1547,14 @@ interface NativeBlock<Id extends string = string> extends BlockDef<Id, Component
|
|
|
1539
1547
|
* throw is ignored.
|
|
1540
1548
|
*/
|
|
1541
1549
|
readonly onError?: (error: Error, report: ErrorReport) => void;
|
|
1550
|
+
/**
|
|
1551
|
+
* "Report this" on the fatal and screen error screens: the support block opens its feedback form
|
|
1552
|
+
* with the error attached. `app`: the app's screens were replaced by the fatal screen, and are
|
|
1553
|
+
* remounting ("Try again") as this is called.
|
|
1554
|
+
*/
|
|
1555
|
+
readonly reportProblem?: (error: Error, where: {
|
|
1556
|
+
kind: "app" | "screen";
|
|
1557
|
+
}) => void;
|
|
1542
1558
|
}
|
|
1543
1559
|
/**
|
|
1544
1560
|
* The resolved blocks: their ids, nav entries, Settings rows, routes and the
|
|
@@ -1578,14 +1594,15 @@ interface UseBlockSettingsOptions {
|
|
|
1578
1594
|
* at the end of the section its `section` names (by `order`, then block
|
|
1579
1595
|
* order), and a section no one has yet is added after the rest.
|
|
1580
1596
|
*
|
|
1581
|
-
*
|
|
1597
|
+
* A row whose `useShown` hook says false is left out. Calls each row's `useSubtitle` and
|
|
1598
|
+
* `useShown` hooks, so call it unconditionally at the top
|
|
1582
1599
|
* of the Settings screen. The blocks are fixed for the life of the app, so
|
|
1583
1600
|
* the hooks run in the same order on every render.
|
|
1584
1601
|
*
|
|
1585
1602
|
* @stability Beta
|
|
1586
1603
|
*/
|
|
1587
1604
|
declare function useBlockSettings<R extends SettingsRowLike>(sections: readonly BlockSettingsSection<R>[], options?: UseBlockSettingsOptions): BlockSettingsSection<R | SettingsRowLike>[];
|
|
1588
|
-
/** The merge `useBlockSettings` does, without hooks (subtitles already read). @stability Beta */
|
|
1589
|
-
declare function mergeBlockSettings<R extends SettingsRowLike>(sections: readonly BlockSettingsSection<R>[], rows: readonly Contributed<BlockSettingsRow>[], subtitles?: readonly (string | null | undefined)[], options?: UseBlockSettingsOptions): BlockSettingsSection<R | SettingsRowLike>[];
|
|
1605
|
+
/** The merge `useBlockSettings` does, without hooks (subtitles and `shown` already read; a row shown false is left out). @stability Beta */
|
|
1606
|
+
declare function mergeBlockSettings<R extends SettingsRowLike>(sections: readonly BlockSettingsSection<R>[], rows: readonly Contributed<BlockSettingsRow>[], subtitles?: readonly (string | null | undefined)[], options?: UseBlockSettingsOptions, shown?: readonly boolean[]): BlockSettingsSection<R | SettingsRowLike>[];
|
|
1590
1607
|
|
|
1591
1608
|
export { type QuietHours as $, type AuthClientLike as A, type BlockSettingsSection as B, type SplashModule as C, type DevtoolsDiagnosticsProps as D, type UseBlockSettingsOptions as E, type UseBootReturn as F, GenesisNativeApp as G, type HeldLinkAuth as H, type UseHeldLinkOptions as I, createBoot as J, createLinkHold as K, type LinkHold as L, createSessionStore as M, type NativeBlock as N, mergeBlockSettings as O, normalizeLink as P, useBlockSettings as Q, useBlocks as R, SessionProvider as S, useBoot as T, type UpdatesBlock as U, type VersionSignature as V, useHeldLink as W, useSession as X, type PushPermissionStatus as Y, type NotificationResponseLike as Z, type NotificationLike as _, type DevtoolsFeedbackProps as a, type ForceUpgradeProps as a$, type ChannelImportance as a0, type ChannelInputLike as a1, DEFAULT_PREFERENCES as a2, type NotificationActionLike as a3, type NotificationBehaviorLike as a4, type NotificationCategory as a5, type NotificationPreferences as a6, type NotificationsModuleLike as a7, type PermissionRequestLike as a8, type PermissionState as a9, type RegistrationState as aA, type RegistrationStatus as aB, type SubscriptionLike as aC, canPush as aD, createPermissionStore as aE, createPreferencesStore as aF, createPromptStore as aG, createPush as aH, createRegistration as aI, statusOf as aJ, supabasePushBackend as aK, useBadge as aL, useNotificationPreferences as aM, useOptionalPush as aN, usePush as aO, usePushPermissionState as aP, usePushPrompt as aQ, usePushRegistration as aR, useSuppressNotifications as aS, validPreferences as aT, type ApplicationLike as aU, type BuildMetadata as aV, CLOCK_SKEW_MS as aW, type ChannelSwitchResult as aX, type ChannelSwitcher as aY, type ChannelSwitcherOptions as aZ, type EvaluatePolicyOptions as a_, type PermissionStatusLike as aa, type PermissionStore as ab, type PreferencesState as ac, type PreferencesStatus as ad, type PreferencesStore as ae, type PromptOptions as af, type PromptState as ag, type PromptStore as ah, type PushAppStateLike as ai, type PushBackend as aj, PushBackendError as ak, type PushBlock as al, type PushChannel as am, type PushDeviceCategory as an, type PushErrorSource as ao, type PushOnError as ap, type PushOptions as aq, type PushPromptProps as ar, PushPromptSheet as as, PushProvider as at, PushRoot as au, type PushRootProps as av, type PushSlots as aw, type PushStorageLike as ax, type PushSupabaseLike as ay, type Registration as az, type DevtoolsSlots as b, ForceUpgradeScreen as b0, type MaintenanceProps as b1, MaintenanceScreen as b2, type PolicyClientLike as b3, type PolicyOrigin as b4, type PolicyState as b5, type PolicyStore as b6, type PolicyStoreOptions as b7, type ReleaseNote as b8, type ReloadGuard as b9, WhatsNewSheet as bA, type WhatsNewState as bB, type WhatsNewStore as bC, createChannelSwitcher as bD, createPolicyStore as bE, createReloadGuard as bF, createUpdateChecker as bG, createUpdates as bH, createWhatsNewStore as bI, evaluatePolicy as bJ, notesSince as bK, sanitizePolicy as bL, staticPolicySource as bM, supabasePolicySource as bN, useBlockReload as bO, useCanReload as bP, useForceUpgrade as bQ, useMaintenance as bR, useUpdateBanner as bS, useUpdateCheck as bT, useUpdatePolicy as bU, useUpdateVerdict as bV, useUpdates as bW, useVersionSignature as bX, useWhatsNew as bY, versionSignature as bZ, type SupabasePolicySourceOptions as ba, UPDATES_BLOCK_ID as bb, UpdateBanner as bc, type UpdateBannerProps as bd, type UpdateCheckState as be, type UpdateCheckStatus as bf, type UpdateChecker as bg, type UpdateCheckerOptions as bh, type UpdatePlatform as bi, type UpdatePolicy as bj, type UpdatePolicySource as bk, type UpdateVerdict as bl, type UpdatesAppStateLike as bm, type UpdatesErrorSource as bn, type UpdatesModuleLike as bo, type UpdatesOnError as bp, type UpdatesOptions as bq, UpdatesProvider as br, UpdatesRoot as bs, type UpdatesRootProps as bt, type UpdatesSlots as bu, type UpdatesStorageLike as bv, type VersionSignatureInput as bw, WEEK_MS as bx, type WhatsNewOptions as by, type WhatsNewProps as bz, AuthGate as c, type AuthGateProps as d, type BootController as e, type BootOptions as f, BootProvider as g, BootScreen as h, type BootScreenProps as i, type BootState as j, type BootStatus as k, type BootStep as l, type BootStepContext as m, BootTimeoutError as n, type GenesisNativeAppProps as o, type LinkOptions as p, type LinkTarget as q, type NativeAppSlots as r, type NativeBlockRootProps as s, type NativeQueryClientOptions as t, type SessionState as u, type SessionStatus as v, type SessionStore as w, type SessionStoreOptions as x, type SettingsRowLike as y, type SignedOutProps as z };
|
|
@@ -3,7 +3,7 @@ var UNKNOWN = "unknown";
|
|
|
3
3
|
var given = (value) => typeof value === "string" && value.trim() !== "" ? value : null;
|
|
4
4
|
var metaText = (value) => typeof value === "number" && Number.isFinite(value) ? String(value) : given(typeof value === "string" ? value : null);
|
|
5
5
|
function versionSignature({ application, updates, platform, requestedChannel = null, buildMetadata = null }) {
|
|
6
|
-
const version = given(application?.nativeApplicationVersion);
|
|
6
|
+
const version = given(application?.nativeApplicationVersion) ?? metaText(buildMetadata?.version);
|
|
7
7
|
const build = given(application?.nativeBuildVersion);
|
|
8
8
|
const on = Boolean(updates?.isEnabled);
|
|
9
9
|
const channel = on ? given(updates?.channel) : null;
|
|
@@ -36,9 +36,12 @@ function versionSignature({ application, updates, platform, requestedChannel = n
|
|
|
36
36
|
if (commit) lines.push(`Commit ${commit}`);
|
|
37
37
|
if (otaNumber) lines.push(`OTA ${otaNumber}`);
|
|
38
38
|
if (release) lines.push(`Release ${release}`);
|
|
39
|
-
|
|
39
|
+
const builtAt = metaText(buildMetadata?.builtAt);
|
|
40
|
+
const builtFor = metaText(buildMetadata?.channel);
|
|
41
|
+
if (builtAt || builtFor) lines.push(`Built ${builtAt ?? UNKNOWN}${builtFor ? ` for ${builtFor}` : ""}`);
|
|
42
|
+
return { version, build, platform, channel, requestedChannel, runtimeVersion, updateId, launch, emergency, commit, otaNumber, release, builtAt, short, text: lines.join("\n") };
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
export { versionSignature };
|
|
43
|
-
//# sourceMappingURL=chunk-
|
|
44
|
-
//# sourceMappingURL=chunk-
|
|
46
|
+
//# sourceMappingURL=chunk-6UVWYJPZ.js.map
|
|
47
|
+
//# sourceMappingURL=chunk-6UVWYJPZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/updates/signature.ts"],"names":[],"mappings":";AAiFA,IAAM,OAAA,GAAU,SAAA;AAGhB,IAAM,KAAA,GAAQ,CAAC,KAAA,KAAqD,OAAO,KAAA,KAAU,YAAY,KAAA,CAAM,IAAA,EAAK,KAAM,EAAA,GAAK,KAAA,GAAQ,IAAA;AAE/H,IAAM,WAAW,CAAC,KAAA,KAA8D,OAAO,KAAA,KAAU,QAAA,IAAY,OAAO,QAAA,CAAS,KAAK,CAAA,GAAI,MAAA,CAAO,KAAK,CAAA,GAAI,KAAA,CAAM,OAAO,KAAA,KAAU,QAAA,GAAW,QAAQ,IAAI,CAAA;AAE7L,SAAS,gBAAA,CAAiB,EAAE,WAAA,EAAa,OAAA,EAAS,UAAU,gBAAA,GAAmB,IAAA,EAAM,aAAA,GAAgB,IAAA,EAAK,EAA4C;AAC3J,EAAA,MAAM,UAAU,KAAA,CAAM,WAAA,EAAa,wBAAwB,CAAA,IAAK,QAAA,CAAS,eAAe,OAAO,CAAA;AAC/F,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,WAAA,EAAa,kBAAkB,CAAA;AACnD,EAAA,MAAM,EAAA,GAAK,OAAA,CAAQ,OAAA,EAAS,SAAS,CAAA;AACrC,EAAA,MAAM,OAAA,GAAU,EAAA,GAAK,KAAA,CAAM,OAAA,EAAS,OAAO,CAAA,GAAI,IAAA;AAC/C,EAAA,MAAM,QAAA,GAAW,EAAA,GAAK,KAAA,CAAM,OAAA,EAAS,QAAQ,CAAA,GAAI,IAAA;AACjD,EAAA,MAAM,cAAA,GAAiB,KAAA,CAAM,OAAA,EAAS,cAAc,CAAA;AACpD,EA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AE;AAChL","file":"chunk-6UVWYJPZ.js","sourcesContent":["/**\n * The version signature: which binary and which update this is, in one\n * line for Settings \"About\" and in a few lines for a support report.\n *\n * 1.4.0 (37) · preview · 3f2a9c1b\n * 1.4.0 (37) · production · embedded\n * 1.4.0 (37) · updates off\n *\n * A value the modules can't give is printed as `unknown`, never left out\n * (an empty string counts as not given: expo-updates gives `\"\"` for the\n * runtime version in a development build); one that doesn't apply, with\n * updates off, as `none`.\n *\n * With `buildMetadata` (a module the app writes at publish time: the commit,\n * the OTA number, the release), the signature also carries `commit`,\n * `otaNumber` and `release`, and the text names them. Without it they are\n * null and the text is as before.\n */\nimport type { ApplicationLike, UpdatesModuleLike } from \"./modules\";\n\nexport interface VersionSignature {\n version: string | null;\n build: string | null;\n platform: string;\n /** The build's channel (expo-updates). */\n channel: string | null;\n /** A channel picked on this device (a test build switched channels); `null` when it follows the build. */\n requestedChannel: string | null;\n runtimeVersion: string | null;\n updateId: string | null;\n /** `update`: a downloaded update runs. `embedded`: the binary's own code. `off`: updates are off (development, Expo Go). */\n launch: \"update\" | \"embedded\" | \"off\";\n /** expo-updates fell back to the embedded code after a failed launch. */\n emergency: boolean;\n /** The commit the bundle was built from (`buildMetadata`), or null. Optional for signatures made by hand. */\n commit?: string | null;\n /** The OTA number (`buildMetadata`), or null. */\n otaNumber?: string | null;\n /** The release's name (`buildMetadata`), or null. */\n release?: string | null;\n /** When it was built (`buildMetadata`), ISO, or null. */\n builtAt?: string | null;\n /** One line, for an About row. */\n short: string;\n /** Several lines, for a support report. */\n text: string;\n}\n\n/**\n * What the app stamps into its bundle when it publishes (a generated `build-metadata.ts` or JSON):\n * every field optional.\n */\nexport interface BuildMetadata {\n /** The app's version at build time (`genesis build-stamp`). */\n version?: string | null;\n /** The channel it was built or published for. */\n channel?: string | null;\n /** When it was built, ISO. */\n builtAt?: string | null;\n /** The commit the bundle was built from, full or short. */\n commit?: string | null;\n commitMessage?: string | null;\n branch?: string | null;\n /** The over-the-air update's number on its channel. */\n otaNumber?: string | number | null;\n /** The release's name (a tag, a date, a version). */\n release?: string | null;\n /** When the release or update was published, ISO. */\n publishedAt?: string | null;\n}\n\nexport interface VersionSignatureInput {\n application?: ApplicationLike;\n updates?: UpdatesModuleLike;\n /** `Platform.OS`. */\n platform: string;\n requestedChannel?: string | null;\n /** The commit, OTA number and release the app stamped at publish time. */\n buildMetadata?: BuildMetadata | null;\n}\n\nconst UNKNOWN = \"unknown\";\n\n/** A module's value, or null when it gave none (undefined, null or an empty string). */\nconst given = (value: string | null | undefined): string | null => (typeof value === \"string\" && value.trim() !== \"\" ? value : null);\n\nconst metaText = (value: string | number | null | undefined): string | null => (typeof value === \"number\" && Number.isFinite(value) ? String(value) : given(typeof value === \"string\" ? value : null));\n\nexport function versionSignature({ application, updates, platform, requestedChannel = null, buildMetadata = null }: VersionSignatureInput): VersionSignature {\n const version = given(application?.nativeApplicationVersion) ?? metaText(buildMetadata?.version);\n const build = given(application?.nativeBuildVersion);\n const on = Boolean(updates?.isEnabled);\n const channel = on ? given(updates?.channel) : null;\n const updateId = on ? given(updates?.updateId) : null;\n const runtimeVersion = given(updates?.runtimeVersion);\n const launch: VersionSignature[\"launch\"] = !on ? \"off\" : updates?.isEmbeddedLaunch ? \"embedded\" : \"update\";\n const emergency = on && updates?.isEmergencyLaunch === true;\n const shownChannel = requestedChannel ?? channel;\n\n const head = `${version ?? UNKNOWN} (${build ?? UNKNOWN})`;\n const parts = [head];\n if (launch === \"off\") {\n parts.push(\"updates off\");\n } else {\n parts.push(shownChannel ?? \"no channel\");\n parts.push(launch === \"embedded\" ? \"embedded\" : (updateId?.slice(0, 8) ?? UNKNOWN));\n }\n if (emergency) parts.push(\"emergency launch\");\n const short = parts.join(\" · \");\n\n const lines = [\n `Version ${head}`,\n `Platform ${platform}`,\n `Channel ${channel ?? (on ? UNKNOWN : \"none\")}${requestedChannel && requestedChannel !== channel ? ` (switched to ${requestedChannel})` : \"\"}`,\n `Runtime ${runtimeVersion ?? (on ? UNKNOWN : \"none\")}`,\n `Update ${launch === \"off\" ? \"updates off\" : launch === \"embedded\" ? \"embedded\" : (updateId ?? UNKNOWN)}`,\n ];\n if (emergency) lines.push(`Emergency launch: ${updates?.emergencyLaunchReason ?? UNKNOWN}`);\n const commit = metaText(buildMetadata?.commit);\n const otaNumber = metaText(buildMetadata?.otaNumber);\n const release = metaText(buildMetadata?.release);\n if (commit) lines.push(`Commit ${commit}`);\n if (otaNumber) lines.push(`OTA ${otaNumber}`);\n if (release) lines.push(`Release ${release}`);\n const builtAt = metaText(buildMetadata?.builtAt);\n const builtFor = metaText(buildMetadata?.channel);\n if (builtAt || builtFor) lines.push(`Built ${builtAt ?? UNKNOWN}${builtFor ? ` for ${builtFor}` : \"\"}`);\n return { version, build, platform, channel, requestedChannel, runtimeVersion, updateId, launch, emergency, commit, otaNumber, release, builtAt, short, text: lines.join(\"\\n\") };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createScreenErrorBoundary } from './chunk-
|
|
1
|
+
import { createScreenErrorBoundary } from './chunk-JZHDEU4Q.js';
|
|
2
2
|
import { onBeforeReload } from './chunk-VIC2KXMA.js';
|
|
3
3
|
import { useSession } from './chunk-NGYNYJPL.js';
|
|
4
4
|
import { createContext, useContext, useSyncExternalStore, useEffect, useRef } from 'react';
|
|
@@ -470,5 +470,5 @@ var EMPTY_STORE = { getState: () => EMPTY, subscribe: () => () => {
|
|
|
470
470
|
}};
|
|
471
471
|
|
|
472
472
|
export { FILTERED, OBSERVABILITY_BLOCK_ID, ObservabilityProvider, checkEvent, consoleSink, createObservability, defineEvents, isSecretKey, observeSink, scrubBreadcrumb, scrubEvent, scrubRecord, scrubString, scrubUrl, scrubValue, scrubValueStrict, scrubbedError, useObservability, useRecentActivity };
|
|
473
|
-
//# sourceMappingURL=chunk-
|
|
474
|
-
//# sourceMappingURL=chunk-
|
|
473
|
+
//# sourceMappingURL=chunk-JWIBRHDE.js.map
|
|
474
|
+
//# sourceMappingURL=chunk-JWIBRHDE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/observability/events.ts","../src/observability/scrub.ts","../src/observability/sink.ts","../src/observability/block.tsx"],"names":[],"mappings":";;;;;;;;;AAkCA,IAAM,UAAA,GAAa,yCAAA;AACnB,IAAM,SAAA,GAAY,mBAAA;AAClB,IAAM,SAAA,GAAY,EAAA;AAClB,IAAM,WAAA,GAAc,EAAA;AASb,SAAS,aAA0C,MAAA,EAAc;AACtE,EAAA,MAAM,WAAqB,EAAC;AAC5B,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,EAAG;AAClD,IAAA,IAAI,CAAC,WAAW,IAAA,CAAK,IAAI,GAAG,QAAA,CAAS,IAAA,CAAK,CAAA,CAAA,EAAI,IAAI,CAAA,mEAAA,CAAqE,CAAA;AACvH,IAAA,MAAM,IAAA,GAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA;AAC9B,IAAA,IAAI,IAAA,CAAK,SAAS,SAAA,EAAW,QAAA,CAAS,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,WAAA,EAAc,SAAS,CAAA,MAAA,CAAQ,CAAA;AAClF,IAAA,KAAA,MAAW,OAAO,IAAA,EAAM;AACtB,MAAA,MAAM,IAAA,GAAO,MAAM,GAAG,CAAA;AACtB,MAAA,IAAI,CAAC,SAAA,CAAU,IAAA,CAAK,GAAG,CAAA,EAAG,QAAA,CAAS,IAAA,CAAK,CAAA,CAAA,EAAI,IAAI,CAAA,EAAA,EAAK,GAAG,CAAA,mDAAA,CAAqD,CAAA;AAC7G,MAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,EAAG;AACvB,QAAA,IAAI,IAAA,CAAK,WAAW,CAAA,EAAG,QAAA,CAAS,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,EAAA,EAAK,GAAG,CAAA,8BAAA,CAAgC,CAAA;AACrF,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,OAAO,WAAW,oBAAoB,CAAA;AACxC;AAGO,SAAS,kBAAkB,KAAA,EAAmD;AACnF,EAAA,MAAM,cAAc,gBAAA,EAAiB;AACrC,EAAA,MAAM,KAAA,GAAA,CAAS,KAAA,IAAS,WAAA,GAAc,MAAA,IAAU,WAAA;AAChD,EAAA,OAAO,qBAAqB,KAAA,CAAM,SAAA,EAAW,KAAA,CAAM,QAAA,EAAU,MAAM,QAAQ,CAAA;AAC7E;AAEA,IAAM,QAAwB,EAAE,WAAA,EAAa,EAAC,EAAG,MAAA,EAAQ,EAAC,EAAE;AAC5D,IAAM,cAA2B,EAAE,QAAA,EAAU,MAAM,KAAA,EAAO,SAAA,EAAW,MAAM,MAAM;AAAC,CAAmB,CAAA","file":"chunk-ZQVRCW5J.js","sourcesContent":["/**\n * Typed analytics events: the app lists every event and the props each may\n * carry once, and `track(name, props)` accepts nothing else. A prop is a\n * closed list of strings, a number or a boolean, never free text, so an\n * event can't carry a name, an email or a message someone typed.\n *\n * ```ts\n * export const events = defineEvents({\n * \"auth.signed_in\": { method: [\"email\", \"apple\"] },\n * \"settings.opened\": {},\n * \"checkin.saved\": { mood: \"number\", first: \"boolean\" },\n * });\n * ```\n *\n * At run time an unknown event, an unknown prop or a value outside its list\n * is dropped and reported (a `console.warn` in development, `onInvalid`\n * always), so a bad call is loud and still sends nothing.\n */\n\n/** A closed list of strings, `\"number\"` (finite) or `\"boolean\"`. */\nexport type EventPropSpec = readonly string[] | \"number\" | \"boolean\";\n\n/** Every event, by name, with the props it may carry. */\nexport type EventSchema = Readonly<Record<string, Readonly<Record<string, EventPropSpec>>>>;\n\ntype PropValue<S> = S extends readonly (infer L)[] ? L : S extends \"number\" ? number : S extends \"boolean\" ? boolean : never;\n\n/** The props of one event: every prop optional, each its spec's type. */\nexport type EventProps<S extends Readonly<Record<string, EventPropSpec>>> = { readonly [K in keyof S]?: PropValue<S[K]> };\n\n/** What a sink receives: the checked props. */\nexport type EventValues = Readonly<Record<string, string | number | boolean>>;\n\n// Lower-case words joined by `.` or `_`: `auth.signed_in`, `checkin.saved`.\nconst EVENT_NAME = /^[a-z][a-z0-9_]*(?:\\.[a-z][a-z0-9_]*)*$/;\nconst PROP_NAME = /^[a-z][a-z0-9_]*$/;\nconst MAX_PROPS = 25;\nconst MAX_LITERAL = 64;\n\n/**\n * Declare the app's events. Checks names (lower-case, dot-separated), prop\n * names, and that each list has at least one short value, and throws listing\n * every problem, so a bad schema fails where it is written.\n *\n * @stability Beta\n */\nexport function defineEvents<const E extends EventSchema>(schema: E): E {\n const problems: string[] = [];\n for (const [name, props] of Object.entries(schema)) {\n if (!EVENT_NAME.test(name)) problems.push(`\"${name}\": an event name is lower-case words joined by \".\" (auth.signed_in)`);\n const keys = Object.keys(props);\n if (keys.length > MAX_PROPS) problems.push(`\"${name}\": at most ${MAX_PROPS} props`);\n for (const key of keys) {\n const spec = props[key];\n if (!PROP_NAME.test(key)) problems.push(`\"${name}\".${key}: a prop name is lower-case letters, digits and \"_\"`);\n if (Array.isArray(spec)) {\n if (spec.length === 0) problems.push(`\"${name}\".${key}: an empty list allows nothing`);\n for (const v of spec) if (typeof v !== \"string\" || v.length === 0 || v.length > MAX_LITERAL) problems.push(`\"${name}\".${key}: \"${String(v)}\" must be 1-${MAX_LITERAL} characters`);\n } else if (spec !== \"number\" && spec !== \"boolean\") {\n problems.push(`\"${name}\".${key}: a prop is a list of strings, \"number\" or \"boolean\" (free text is not allowed)`);\n }\n }\n }\n if (problems.length) throw new Error(`Invalid events:\\n${problems.map((p) => ` - ${p}`).join(\"\\n\")}`);\n return Object.freeze(schema);\n}\n\nexport type EventCheck = { ok: true; props: EventValues } | { ok: false; problem: string };\n\n/** Check one call against the schema: the props to send, or why nothing is sent. */\nexport function checkEvent(schema: EventSchema, name: string, props: Readonly<Record<string, unknown>> | undefined): EventCheck {\n if (!Object.prototype.hasOwnProperty.call(schema, name)) return { ok: false, problem: `\"${name}\" is not in the event schema` };\n const specs = schema[name] ?? {};\n const out: Record<string, string | number | boolean> = {};\n for (const [key, value] of Object.entries(props ?? {})) {\n if (value === undefined) continue;\n if (!Object.prototype.hasOwnProperty.call(specs, key)) return { ok: false, problem: `\"${name}\" has no prop \"${key}\"` };\n const spec = specs[key];\n const fits =\n spec === \"number\"\n ? typeof value === \"number\" && Number.isFinite(value)\n : spec === \"boolean\"\n ? typeof value === \"boolean\"\n : typeof value === \"string\" && (spec as readonly string[]).includes(value);\n if (!fits) return { ok: false, problem: `\"${name}\".${key}: ${JSON.stringify(value)} is not allowed` };\n out[key] = value as string | number | boolean;\n }\n return { ok: true, props: out };\n}\n","/**\n * The PII scrubber every sink's input goes through by default: text is\n * rewritten by pattern (an email, a phone number, a JWT, a Supabase key, a\n * bearer token, a token in a query string, row values in a database error),\n * values under a key that names a secret or a contact detail are replaced\n * whole, and URLs lose their query and fragment (PostgREST filters carry\n * record ids, auth callbacks carry codes). Strings are cut at 4 KB first, so\n * a huge log line can't stall the JS thread.\n *\n * What it can't know: a person's name in free text. Keep names out of error\n * messages and breadcrumbs; touch breadcrumbs lose their labels in\n * `sentrySink` for this reason.\n *\n * Pattern-based on values, not an allowlist of keys: a key allowlist misses\n * `refresh failed: eyJhbGciOi…`, which is the shape that actually occurs.\n *\n * Fail closed: `scrubEvent` and `scrubRecord` return `null` (drop it) when\n * scrubbing itself throws, never the unscrubbed input.\n */\n\n/** What replaces a value under a secret-looking key. */\nexport const FILTERED = \"[Filtered]\";\n\n// Keys whose value is a secret (or a contact detail) whatever it looks like.\n// Matched case-insensitively with `-`, `_`, `.` and spaces removed: exactly\n// for the short, ambiguous ones, as a part of the key for the rest\n// (`x-supabase-api-key`, `user.email`, `refresh_token_hash`).\nconst SECRET_KEY_EXACT = /^(session|sessionid|dsn|otp|code|verifier|codeverifier|privatekey|refresh|pwd|key)$/;\nconst SECRET_KEY_PART = /(authoriz|cookie|passw|secret|token|apikey|credential|jwt|email|phone|servicerole)/;\n\n/** True when a value under `key` is a secret (or contact detail) whatever it looks like. */\nexport function isSecretKey(key: string): boolean {\n const k = key.replace(/[-_.\\s]/g, \"\").toLowerCase();\n return SECRET_KEY_EXACT.test(k) || SECRET_KEY_PART.test(k);\n}\n\n// Sentry's own ids and envelope fields: 32-hex values the hex rule would break, never PII.\nconst ID_KEY = /^(event_id|trace_id|span_id|parent_span_id|profile_id|replay_id|debug_id|code_id|public_key|segment_id|sampled|release|dist|environment)$/;\n\n// Fields dropped whole: query strings travel as their own fields too (Sentry's http breadcrumbs,\n// spans and requests), and bodies and PostgREST `details` carry row values.\nconst DROPPED_KEY = /^(query_string|http\\.query|http\\.fragment|url\\.query|url\\.fragment|request_body|response_body|body|cookies|details)$/i;\n\n/** Longest string scrubbed in full; the rest is cut off (the patterns stay fast on huge logs). */\nexport const MAX_STRING = 4096;\n\nconst PATTERNS: readonly [RegExp, string][] = [\n // The query string and fragment of a URL with a scheme anywhere in text (a span's\n // \"GET https://…?id=eq.42\", a deep link \"myapp://reset?token_hash=…\").\n [/\\b([a-z][a-z0-9+.-]{0,31}:\\/\\/[^\\s?#\"'<>]{0,2048})[?#][^\\s\"'<>]*/gi, \"$1\"],\n // …and of a path (\"POST /rest/v1/rpc/find?email=eq.…\").\n [/(^|[\\s\"'(=])(\\/[^\\s?#\"'<>]{0,2048})\\?[^\\s\"'<>]*/g, \"$1$2\"],\n // JWTs: Supabase access tokens and the legacy anon / service_role keys.\n [/\\beyJ[A-Za-z0-9_-]{5,}\\.[A-Za-z0-9_-]{5,}\\.[A-Za-z0-9_-]*/g, \"[jwt]\"],\n // Supabase's API keys (sb_secret_…, sb_publishable_…).\n [/\\bsb_(?:secret|publishable)_[A-Za-z0-9_-]{8,}/g, \"[supabase-key]\"],\n // `Authorization: Bearer …` copied into a message.\n [/\\b(Bearer|Basic)\\s+[A-Za-z0-9._~+/=-]+/gi, \"$1 [token]\"],\n // Tokens in a query string or a fragment left without a scheme.\n [\n /([?&#](?:access_token|refresh_token|id_token|provider_token|provider_refresh_token|token|token_hash|code|apikey|api_key|key|password|secret|email|phone)=)[^&#\\s\"']+/gi,\n \"$1[Filtered]\",\n ],\n // Row values in PostgreSQL errors: `Failing row contains (…)`, `Key (email)=(…)`.\n [/(Failing row contains )\\([^)]*\\)/g, \"$1(…)\"],\n [/(Key \\([^)]{0,256}\\)=)\\([^)]*\\)/g, \"$1(…)\"],\n // Email addresses, also percent-encoded (`a%40b.co`). Bounded, so a long run of letters can't backtrack.\n [/[A-Za-z0-9._%+-]{1,64}(?:@|%40)(?:[A-Za-z0-9-]{1,63}\\.){1,8}[A-Za-z]{2,24}/g, \"[email]\"],\n // Phone numbers: international (`+1 555 555 0101`) and North American (`555-555-0101`).\n [/\\+\\d[\\d\\s().-]{6,18}\\d/g, \"[phone]\"],\n [/\\b\\(?\\d{3}\\)?[-.\\s]\\d{3}[-.\\s]\\d{4}\\b/g, \"[phone]\"],\n // …national numbers in space-separated groups, which start with a trunk 0 (`020 7946 0958`), and\n // international ones without the + (`44 20 7946 0958`: a country code, then two groups of 4).\n // Plain counts, durations and dates (`120 340 560`, `2024 11 19`) don't have either shape.\n [/\\b0\\d{2,4} \\d{3,4} \\d{3,4}\\b/g, \"[phone]\"],\n [/\\b\\d{2,3} \\d{1,4} \\d{4} \\d{4}\\b/g, \"[phone]\"],\n // …and North American numbers with no separator (`5555550101`, `15555550101`): an area code and an\n // exchange that start with 2-9. A whole word only, so a hex id, a longer number or an epoch\n // time (which starts with 1) is left alone.\n [/\\b1?[2-9]\\d{2}[2-9]\\d{6}\\b/g, \"[phone]\"],\n // Long opaque hex runs: API keys, refresh tokens, DSN secrets. Linear: a run starts only after a non-hex character.\n [/(^|[^A-Fa-f0-9])[A-Fa-f0-9]{32,}(?![A-Fa-f0-9])/g, \"$1[hex]\"],\n];\n\n/** A string with every URL query, email, phone number, JWT, Supabase key, bearer token and query-string token replaced. */\nexport function scrubString(value: string): string {\n let out = value.length > MAX_STRING ? `${value.slice(0, MAX_STRING)}…[truncated]` : value;\n for (const [pattern, replacement] of PATTERNS) out = out.replace(pattern, replacement);\n return out;\n}\n\n/** A URL without its query string and fragment, then scrubbed (an email in a path). */\nexport function scrubUrl(value: string): string {\n const cut = value.search(/[?#]/);\n return scrubString(cut === -1 ? value : value.slice(0, cut));\n}\n\n// Keys whose string value is cut at `?` when it is a URL.\nconst URL_KEY = /^(url|href|from|to|uri|description|http\\.url|url\\.full)$/i;\nconst MAX_DEPTH = 8;\n\n/**\n * A deep copy of `value` with every string scrubbed and every value under a\n * secret key replaced. Cycles become `\"[Circular]\"`; past 8 levels,\n * `\"[Truncated]\"`. Errors become `{ name, message }`. Header lists\n * (`[[\"authorization\", \"…\"]]`) are treated like objects.\n */\nexport function scrubValue(value: unknown, key = \"\", depth = 0, seen: WeakSet<object> = new WeakSet(), keepIds = true): unknown {\n if (key && isSecretKey(key)) return value === undefined || value === null || value === \"\" ? value : FILTERED;\n if (typeof value === \"string\") {\n if (keepIds && key && ID_KEY.test(key)) return value;\n return URL_KEY.test(key) ? scrubUrl(value) : scrubString(value);\n }\n if (value === null || typeof value !== \"object\") return value;\n if (seen.has(value)) return \"[Circular]\";\n if (depth >= MAX_DEPTH) return \"[Truncated]\";\n seen.add(value);\n if (value instanceof Error) return { name: value.name, message: scrubString(value.message) };\n if (Array.isArray(value)) {\n // A `[name, value]` pair (fetch's header lists): the name decides, as for an object key.\n if (value.length === 2 && typeof value[0] === \"string\" && isSecretKey(value[0])) return [value[0], FILTERED];\n return value.map((item) => scrubValue(item, \"\", depth + 1, seen, keepIds));\n }\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) {\n if (DROPPED_KEY.test(k)) continue;\n out[k] = scrubValue(v, k, depth + 1, seen, keepIds);\n }\n return out;\n}\n\n/**\n * `scrubValue` without the pass for Sentry's own id fields (`release`, `environment`,\n * `event_id`, …): for data that isn't a Sentry envelope (a support dump, an app's own\n * object), where a key named like one can hold anything.\n */\nexport function scrubValueStrict(value: unknown): unknown {\n return scrubValue(value, \"\", 0, new WeakSet(), false);\n}\n\n/** The fields of a Sentry-shaped event `scrubEvent` treats specially. Anything else is scrubbed by value. */\nexport interface ScrubbableEvent {\n user?: { id?: unknown; [key: string]: unknown } | null;\n request?: { url?: unknown; method?: unknown; headers?: unknown; [key: string]: unknown };\n [key: string]: unknown;\n}\n\n/**\n * The event with the user reduced to its id, the request reduced to its\n * method, URL (cut at `?`) and scrubbed headers, and every other value\n * scrubbed. `null` when scrubbing threw: fail closed, send nothing rather\n * than PII.\n */\nexport function scrubEvent<E extends ScrubbableEvent>(event: E): E | null {\n try {\n // Sentry's processing metadata (scopes, the sampling context its envelope header is built\n // from) is never sent as part of the event: pass it through, or the envelope breaks.\n const { user, request, sdkProcessingMetadata, ...rest } = event;\n const out = scrubValue(rest) as E;\n if (sdkProcessingMetadata !== undefined) (out as ScrubbableEvent).sdkProcessingMetadata = sdkProcessingMetadata;\n if (user !== undefined) {\n (out as ScrubbableEvent).user = user && user.id !== undefined && user.id !== null ? { id: scrubString(String(user.id)) } : null;\n }\n if (request && typeof request === \"object\") {\n const safe: Record<string, unknown> = {};\n if (typeof request.url === \"string\") safe.url = scrubUrl(request.url);\n if (typeof request.method === \"string\") safe.method = request.method;\n if (request.headers && typeof request.headers === \"object\") safe.headers = scrubValue(request.headers);\n (out as ScrubbableEvent).request = safe;\n }\n return out;\n } catch {\n return null;\n }\n}\n\n/** A breadcrumb, span or any record, scrubbed by value. `null` when scrubbing threw (fail closed). */\nexport function scrubRecord<R extends object>(record: R): R | null {\n try {\n return scrubValue(record) as R;\n } catch {\n return null;\n }\n}\n","/**\n * The vendor-neutral seam: a sink is where errors, breadcrumbs, the user id,\n * analytics events and timings go. `createObservability` fans every call out\n * to its sinks, scrubbed first; a sink that throws is reported to\n * `onSinkError` and never takes the others (or the app) down with it.\n *\n * Shipped sinks: `sentrySink` (Sentry), `observeSink` (EAS Observe) and\n * `consoleSink` (development). A vendor adapter (PostHog, Datadog…) is one\n * object with the methods it supports.\n */\nimport type { ComponentType } from \"react\";\nimport { scrubString, scrubValue } from \"./scrub\";\nimport type { EventValues } from \"./events\";\n\n/** Where a caught error came from and whether the app could go on. */\nexport interface ErrorContext {\n /** True when the app could not go on (a render error, a failed boot, a fatal global error). */\n fatal: boolean;\n /**\n * `boundary`, `global`, `boot`, `rejection`, `screen`, `query`, `mutation`\n * (the shell's), a package's (`chat:attachment-action`, through\n * `reportError` from genesis-core) or the app's own (`updates:policy`, `sync`).\n */\n source: string;\n componentStack?: string;\n /** The route pattern on screen (`/(app)/settings`), when known. */\n route?: string | null;\n /**\n * False when nothing caught it (an unhandled promise rejection): release\n * health counts it. Default: handled unless `fatal`.\n */\n handled?: boolean;\n /** Low-cardinality labels (`query.key: \"tasks\"`), scrubbed like everything else. */\n tags?: Readonly<Record<string, string>>;\n}\n\nexport type BreadcrumbLevel = \"debug\" | \"info\" | \"warning\" | \"error\";\n\n/** One step that led up to an error: a navigation, a tap, a request. */\nexport interface Breadcrumb {\n /** `navigation`, `ui`, `http`, `event`, or the app's own. */\n category: string;\n message?: string;\n level?: BreadcrumbLevel;\n data?: Readonly<Record<string, unknown>>;\n /** Milliseconds since the epoch. Default now. */\n timestamp?: number;\n}\n\n/** Low-cardinality labels on a timing (`route`, `step`), never ids or text someone typed. */\nexport type TimingTags = Readonly<Record<string, string>>;\n\n/**\n * One destination. Every method is optional: a sink takes what its vendor\n * supports. Errors arrive as an `Error` whose message is already scrubbed,\n * unless the sink sets `scrubsErrors` (it scrubs the whole event itself and\n * needs the original object, as Sentry does to deduplicate).\n *\n * @stability Beta\n */\nexport interface ObservabilitySink {\n readonly name: string;\n /** The sink scrubs error events itself; give it the original `Error`. */\n readonly scrubsErrors?: boolean;\n captureError?(error: Error, context: ErrorContext): void;\n breadcrumb?(crumb: Breadcrumb): void;\n /** The signed-in login's id, or `null` when signed out. Never an email or a name. */\n setUser?(id: string | null): void;\n /** An analytics event, its props checked against the schema. */\n event?(name: string, props: EventValues): void;\n timing?(name: string, ms: number, tags?: TimingTags): void;\n /** Wraps the root layout (Sentry's `wrap`, EAS Observe's `ObserveRoot.wrap`). */\n wrap?<P extends Record<string, unknown>>(root: ComponentType<P>): ComponentType<P>;\n /**\n * Wraps an Expo Router per-route `ErrorBoundary` (Sentry's\n * `wrapExpoRouterErrorBoundary`). A sink that wraps reports the route's\n * error itself, so the block's screen boundary doesn't send it to that sink again.\n */\n wrapRouteErrorBoundary?(boundary: ComponentType<RouteErrorBoundaryProps>): ComponentType<RouteErrorBoundaryProps>;\n /** Send what is queued, within `timeoutMs`; resolves false when it didn't finish. Called before an update reloads the app. */\n flush?(timeoutMs: number): PromiseLike<boolean> | boolean | void;\n /** The id of the last error event this sink sent, for a support request or feedback. */\n lastEventId?(): string | undefined;\n /** The current session replay's id, when replay is on. */\n replayId?(): string | undefined;\n}\n\n/** What Expo Router gives a route's `ErrorBoundary`: the error, and `retry` to render the route again. */\nexport interface RouteErrorBoundaryProps {\n error: Error;\n retry: () => Promise<void>;\n}\n\n/** A copy of `error` whose message and stack have been scrubbed (for sinks that don't scrub themselves). */\nexport function scrubbedError(error: Error): Error {\n const copy = new Error(scrubString(error.message));\n copy.name = error.name;\n if (error.stack) copy.stack = scrubString(error.stack);\n return copy;\n}\n\nexport interface ConsoleSinkOptions {\n /** Default `console`. */\n console?: Pick<Console, \"log\" | \"warn\" | \"error\">;\n /** Also log breadcrumbs (noisy). Default false. */\n breadcrumbs?: boolean;\n}\n\n/**\n * Logs what would be sent, for development: fatal errors with `console.error`, others with `console.warn`,\n * events and timings with `console.log`. Already scrubbed, so what you read\n * is what a vendor sink would get.\n *\n * @stability Beta\n */\nexport function consoleSink(options: ConsoleSinkOptions = {}): ObservabilitySink {\n const out = options.console ?? console;\n return {\n name: \"console\",\n // `warn` for what the app survives: `console.error` would raise a LogBox error for every one in development.\n captureError: (error, context) => {\n const line = `[observability] ${context.fatal ? \"fatal \" : \"\"}${context.source}: ${error.message}`;\n if (context.fatal) out.error(line);\n else out.warn(line);\n },\n breadcrumb: options.breadcrumbs ? (crumb) => out.log(`[observability] · ${crumb.category} ${crumb.message ?? \"\"}`) : undefined,\n setUser: (id) => out.log(`[observability] user ${id ?? \"(signed out)\"}`),\n event: (name, props) => out.log(`[observability] event ${name}`, props),\n timing: (name, ms, tags) => out.log(`[observability] timing ${name} ${Math.round(ms)}ms`, tags ?? {}),\n };\n}\n\n/**\n * `expo-observe`'s `Observe` (SDK 56+), or a stand-in: the calls `observeSink`\n * uses. Pass `import { Observe } from \"expo-observe\"`.\n */\nexport interface ObserveLike {\n logEvent(name: string, options?: { severity?: \"debug\" | \"info\" | \"warn\" | \"error\"; body?: string; attributes?: Record<string, unknown> }): void;\n /** Error reporting, in preview on SDK 57+. */\n reportError?(error: unknown): void;\n}\n\nexport interface ObserveSinkOptions {\n /** Report caught errors with `Observe.reportError` (in preview). Default false: Sentry is the error tracker. */\n errors?: boolean;\n}\n\n/**\n * EAS Observe. It measures launch (cold, warm, bundle load, first render),\n * time to interactive and, with its Expo Router integration, per-route\n * render times on its own; it has no API for a custom timing metric, so\n * `timing` is logged as an event (`timing.<name>` with `duration_ms`) and\n * shows on the Events page, not as a metric. Analytics events go to\n * `Observe.logEvent` as they are.\n *\n * @stability Beta\n */\nexport function observeSink(observe: ObserveLike, options: ObserveSinkOptions = {}): ObservabilitySink {\n return {\n name: \"eas-observe\",\n event: (name, props) => observe.logEvent(name, { attributes: { ...props } }),\n timing: (name, ms, tags) => observe.logEvent(`timing.${name}`, { severity: \"info\", attributes: { duration_ms: Math.round(ms), ...(tags ?? {}) } }),\n captureError: options.errors && observe.reportError ? (error) => observe.reportError?.(error) : undefined,\n };\n}\n\n/** Breadcrumb data scrubbed and made plain (for sinks and the devtools overlay). */\nexport function scrubBreadcrumb(crumb: Breadcrumb): Breadcrumb {\n return {\n category: scrubString(crumb.category),\n level: crumb.level,\n timestamp: crumb.timestamp,\n ...(crumb.message !== undefined ? { message: scrubString(crumb.message) } : {}),\n ...(crumb.data ? { data: scrubValue(crumb.data) as Record<string, unknown> } : {}),\n };\n}\n","/**\n * `createObservability(options)`: the observability block. Build it once at\n * module scope (it starts the sinks, Sentry's `init` included), then:\n *\n * <GenesisNativeApp blocks={[observability]}> every error the shell catches → captureError\n * export default observability.wrap(RootLayout) Sentry's `wrap` (touch and profiler boundaries)\n * observability.track(\"auth.signed_in\", { method: \"email\" })\n *\n * Its root (inside the shell) sets the user to the signed-in login's id and,\n * with `useSegments` from expo-router, leaves a breadcrumb per route change\n * and a `route.time_on_screen` timing for the route left. Route patterns\n * (`/(app)/clients/[id]`) are used, never the values in them.\n *\n * Creating it also:\n * - registers it as genesis-core's error reporter (`setErrorReporter`), so a\n * package's `reportError(e, \"chat:…\")` reaches the sinks as a non-fatal error;\n * - registers a before-reload hook (`onBeforeReload`) that flushes the sinks\n * before an update reloads the app.\n *\n * `observability.screenBoundary()` is an Expo Router `ErrorBoundary` for a\n * route (reported non-fatal, wrapped by Sentry's route wrapper), and\n * `lastEventId()` / `replayId()` let a support or feedback screen point at\n * the event.\n *\n * Everything a sink receives has been scrubbed (see `scrub.ts`), and the\n * last breadcrumbs and errors are kept, scrubbed, for the devtools overlay\n * (`recent`).\n */\nimport { createContext, useContext, useEffect, useRef, useSyncExternalStore, type ComponentType, type ReactNode } from \"react\";\nimport { defineBlock } from \"@marktiderman/genesis-config/blocks\";\nimport { setErrorReporter } from \"@marktiderman/genesis-core/errors\";\nimport { useSession } from \"../auth\";\nimport { onBeforeReload } from \"../reload\";\nimport { createScreenErrorBoundary, type ScreenErrorProps } from \"../screen-boundary\";\nimport type { NativeBlock, NativeBlockRootProps } from \"../blocks\";\nimport type { ErrorReport } from \"../errors\";\nimport { checkEvent, type EventProps, type EventSchema } from \"./events\";\nimport { scrubString, scrubValue } from \"./scrub\";\nimport { scrubBreadcrumb, scrubbedError, type Breadcrumb, type ErrorContext, type ObservabilitySink, type TimingTags } from \"./sink\";\n\n/** The FeatureId of the observability block. */\nexport const OBSERVABILITY_BLOCK_ID = \"observability\";\n\n/** A caught error as the devtools overlay shows it (scrubbed). */\nexport interface RecentError {\n at: number;\n name: string;\n message: string;\n source: string;\n fatal: boolean;\n}\n\nexport interface RecentActivity {\n /** Oldest first. Navigation, events and the app's breadcrumbs. */\n breadcrumbs: readonly Breadcrumb[];\n /** Oldest first. */\n errors: readonly RecentError[];\n}\n\nexport interface RecentStore {\n getState(): RecentActivity;\n subscribe(listener: () => void): () => void;\n clear(): void;\n}\n\nexport interface ObservabilityOptions<E extends EventSchema = EventSchema> {\n /** Where everything goes: `sentrySink(Sentry, …)`, `consoleSink()` in development, `observeSink(Observe)`. */\n sinks: readonly (ObservabilitySink | null | undefined | false)[];\n /** The app's analytics events (`defineEvents`). Without it, `track` accepts nothing. */\n events?: E;\n /** `useSegments` from expo-router: route breadcrumbs and `route.time_on_screen` timings. */\n useSegments?: () => readonly string[];\n /** How many breadcrumbs and errors `recent` keeps. Default 50 and 20. */\n recent?: { breadcrumbs?: number; errors?: number };\n /** A sink threw, or `track` was called with something the schema doesn't allow. Default `console.warn` in development. */\n onProblem?: (problem: string, error?: unknown) => void;\n /**\n * Become genesis-core's error reporter, so packages' `reportError` calls\n * reach the sinks. Default true; the last block created wins.\n */\n reportErrors?: boolean;\n /** Flush the sinks before an update reloads the app, within this many milliseconds. Default 2000; 0 turns it off. */\n flushBeforeReloadMs?: number;\n now?: () => number;\n}\n\nexport interface ObservabilityBlock<E extends EventSchema = EventSchema> extends NativeBlock<typeof OBSERVABILITY_BLOCK_ID> {\n readonly sinks: readonly ObservabilitySink[];\n readonly events: E | undefined;\n /** Report an error. The shell calls it for every error it catches. */\n captureError(error: unknown, context?: Partial<ErrorContext>): void;\n breadcrumb(crumb: Breadcrumb): void;\n /** The login's id only. The block's root sets it from the session. */\n setUser(id: string | null): void;\n /** An analytics event from the schema. Anything else is dropped and reported. */\n track<N extends keyof E & string>(name: N, props?: EventProps<E[N]>): void;\n timing(name: string, ms: number, tags?: TimingTags): void;\n /** The root layout wrapped by each sink that wraps (Sentry's `wrap`). Use once: `export default observability.wrap(RootLayout)`. */\n wrap<P extends Record<string, unknown>>(root: ComponentType<P>): ComponentType<P>;\n /** The last breadcrumbs and errors, scrubbed, for the devtools overlay. */\n readonly recent: RecentStore;\n /** Send what every sink has queued; resolves false when one didn't finish within `timeoutMs` (default 2000). */\n flush(timeoutMs?: number): Promise<boolean>;\n /** The id of the last error event a sink sent (Sentry's), for a support request or feedback. */\n lastEventId(): string | undefined;\n /** The current session replay's id, when a sink records replays. */\n replayId(): string | undefined;\n /**\n * An Expo Router `ErrorBoundary` for a route: reports the error non-fatal\n * (source `screen`), shows `fallback` (default `<FatalScreen kind=\"screen\" />`) with\n * \"Try again\", and is wrapped by each sink's route wrapper (Sentry's\n * `wrapExpoRouterErrorBoundary`). Build it once, at module scope.\n */\n screenBoundary(fallback?: ComponentType<ScreenErrorProps>): ComponentType<ScreenErrorProps>;\n /** For the shell: every error it catches. */\n readonly onError: (error: Error, report: ErrorReport) => void;\n readonly Root: ComponentType<NativeBlockRootProps>;\n}\n\ndeclare const __DEV__: boolean | undefined;\n\nlet releaseReloadHook: (() => void) | undefined;\n\nconst TIMING_NAME = /^[a-z][a-z0-9_]*(?:\\.[a-z][a-z0-9_]*)*$/;\n\nfunction createRecentStore(maxCrumbs: number, maxErrors: number): RecentStore & { addCrumb(c: Breadcrumb): void; addError(e: RecentError): void } {\n let state: RecentActivity = { breadcrumbs: [], errors: [] };\n const listeners = new Set<() => void>();\n const emit = () => listeners.forEach((l) => l());\n const push = <T,>(list: readonly T[], item: T, max: number) => (list.length >= max ? [...list.slice(list.length - max + 1), item] : [...list, item]);\n return {\n getState: () => state,\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n clear() {\n state = { breadcrumbs: [], errors: [] };\n emit();\n },\n addCrumb(crumb) {\n state = { ...state, breadcrumbs: push(state.breadcrumbs, crumb, maxCrumbs) };\n emit();\n },\n addError(error) {\n state = { ...state, errors: push(state.errors, error, maxErrors) };\n emit();\n },\n };\n}\n\nfunction toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(typeof value === \"string\" ? value : \"Unknown error\");\n}\n\n/** Build the block once, at module scope, before the root layout renders. @stability Beta */\nexport function createObservability<const E extends EventSchema = EventSchema>(options: ObservabilityOptions<E>): ObservabilityBlock<E> {\n const sinks = options.sinks.filter((s): s is ObservabilitySink => Boolean(s));\n const now = options.now ?? Date.now;\n const problem =\n options.onProblem ??\n ((message: string, error?: unknown) => {\n // genesis-allow-console: the block's own development warning; it can't report to itself.\n if (typeof __DEV__ !== \"undefined\" && __DEV__) console.warn(`[observability] ${message}`, error ?? \"\");\n });\n const recent = createRecentStore(options.recent?.breadcrumbs ?? 50, options.recent?.errors ?? 20);\n let route: string | null = null;\n let user: string | null | undefined;\n\n // One sink failing never stops the others, and never throws into the caller (an error handler, a render).\n const each = (method: string, call: (sink: ObservabilitySink) => void) => {\n for (const sink of sinks) {\n try {\n call(sink);\n } catch (error) {\n try {\n problem(`${sink.name}.${method} threw`, error);\n } catch {\n // ignore a failing reporter\n }\n }\n }\n };\n\n // Never throws into the caller (an effect, a handler): a record that can't be scrubbed is dropped.\n const breadcrumb = (input: Breadcrumb) => {\n let crumb: Breadcrumb;\n try {\n crumb = scrubBreadcrumb({ ...input, timestamp: input.timestamp ?? now() });\n } catch (error) {\n problem(\"breadcrumb dropped: it could not be scrubbed\", error);\n return;\n }\n recent.addCrumb(crumb);\n each(\"breadcrumb\", (s) => s.breadcrumb?.(crumb));\n };\n\n const captureError = (value: unknown, context: Partial<ErrorContext> = {}, skip?: ReadonlySet<ObservabilitySink>) => {\n const error = toError(value);\n const full: ErrorContext = {\n fatal: context.fatal ?? false,\n source: context.source ?? \"app\",\n route: context.route ?? route,\n componentStack: context.componentStack,\n ...(context.handled !== undefined ? { handled: context.handled } : {}),\n ...(context.tags ? { tags: context.tags } : {}),\n };\n let safe: Error | undefined;\n const scrubbed = () => (safe ??= scrubbedError(error));\n try {\n recent.addError({ at: now(), name: error.name, message: scrubString(error.message), source: full.source, fatal: full.fatal });\n } catch {\n // never let the overlay's list stop a report\n }\n let forSinks: ErrorContext = full;\n try {\n forSinks = {\n ...full,\n ...(full.componentStack ? { componentStack: scrubString(full.componentStack) } : {}),\n ...(full.tags ? { tags: scrubValue(full.tags) as Record<string, string> } : {}),\n };\n } catch {\n // Tags that can't be scrubbed are dropped, never sent raw.\n forSinks = { ...full, componentStack: undefined, tags: undefined };\n }\n each(\"captureError\", (s) => {\n if (skip?.has(s)) return;\n s.captureError?.(s.scrubsErrors ? error : scrubbed(), s.scrubsErrors ? full : forSinks);\n });\n };\n\n const flush = async (timeoutMs = 2000): Promise<boolean> => {\n const results = sinks.map(async (sink) => {\n if (!sink.flush) return true;\n try {\n return (await sink.flush(timeoutMs)) !== false;\n } catch (error) {\n problem(`${sink.name}.flush threw`, error);\n return false;\n }\n });\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<boolean>((resolve) => {\n timer = setTimeout(() => resolve(false), timeoutMs);\n });\n try {\n return await Promise.race([Promise.all(results).then((all) => all.every(Boolean)), deadline]);\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n }\n };\n\n const firstOf = (read: (sink: ObservabilitySink) => string | undefined): string | undefined => {\n for (const sink of sinks) {\n try {\n const value = read(sink);\n if (value) return value;\n } catch (error) {\n problem(`${sink.name} threw reading an id`, error);\n }\n }\n return undefined;\n };\n\n const setUser = (id: string | null) => {\n if (id === user) return;\n user = id;\n each(\"setUser\", (s) => s.setUser?.(id));\n };\n\n const track = (name: string, props?: Readonly<Record<string, unknown>>) => {\n const check = options.events ? checkEvent(options.events, name, props) : ({ ok: false, problem: \"no event schema: pass `events: defineEvents({…})`\" } as const);\n if (!check.ok) {\n problem(`track dropped: ${check.problem}`);\n return;\n }\n recent.addCrumb({ category: \"event\", message: name, level: \"info\", data: check.props, timestamp: now() });\n each(\"event\", (s) => s.event?.(name, check.props));\n };\n\n const timing = (name: string, ms: number, tags?: TimingTags) => {\n if (!Number.isFinite(ms) || ms < 0) return;\n // A name like an event's (`route.time_on_screen`), never text with values in it.\n if (!TIMING_NAME.test(name)) {\n problem(`timing dropped: \"${scrubString(name)}\" is not lower-case words joined by \".\"`);\n return;\n }\n let safeTags: TimingTags | undefined;\n try {\n safeTags = tags ? (scrubValue(tags) as TimingTags) : undefined;\n } catch (error) {\n problem(\"timing dropped: its tags could not be scrubbed\", error);\n return;\n }\n each(\"timing\", (s) => s.timing?.(name, ms, safeTags));\n };\n\n const declaration = defineBlock<typeof OBSERVABILITY_BLOCK_ID, ComponentType<never>>({\n id: OBSERVABILITY_BLOCK_ID,\n platforms: [\"native\"],\n contributes: {\n privacy: {\n collects: [\n // genesis-cli's PRIVACY_BLOCKS.observability mirrors this (with events) for the iOS\n // privacy manifest; observability/block.test.tsx keeps the two the same.\n { type: \"crash data\", purposes: [\"app functionality\"], linked: true, tracking: false },\n { type: \"performance data\", purposes: [\"app functionality\"], linked: true, tracking: false },\n // Sentry's device and OS details, breadcrumbs and sessions.\n { type: \"other diagnostic data\", purposes: [\"app functionality\"], linked: true, tracking: false },\n { type: \"user id\", purposes: options.events ? [\"app functionality\", \"analytics\"] : [\"app functionality\"], linked: true, tracking: false },\n ...(options.events ? [{ type: \"product interaction\", purposes: [\"analytics\"], linked: true, tracking: false }] : []),\n ],\n notes: [\n \"Crash reports, timings and analytics events carry the login's id only; emails, tokens, keys and query strings are removed on the device before anything is sent.\",\n ],\n },\n },\n });\n\n const useSegments = options.useSegments;\n function RouteTracker() {\n const segments = (useSegments as () => readonly string[])();\n const path = `/${segments.join(\"/\")}`;\n const last = useRef<{ path: string; at: number } | null>(null);\n useEffect(() => {\n const at = now();\n const previous = last.current;\n if (previous?.path === path) return;\n route = path;\n breadcrumb({ category: \"navigation\", message: path, data: previous ? { from: previous.path } : undefined, timestamp: at });\n if (previous) timing(\"route.time_on_screen\", at - previous.at, { route: previous.path });\n last.current = { path, at };\n }, [path]);\n return null;\n }\n\n function UserTracker() {\n const { userId } = useSession();\n useEffect(() => setUser(userId ?? null), [userId]);\n return null;\n }\n\n const block: ObservabilityBlock<E> = {\n ...declaration,\n sinks,\n events: options.events,\n captureError,\n breadcrumb,\n setUser,\n track: track as ObservabilityBlock<E>[\"track\"],\n timing,\n recent,\n wrap(root) {\n return sinks.reduce((wrapped, sink) => (sink.wrap ? sink.wrap(wrapped) : wrapped), root);\n },\n onError: (error, report) =>\n captureError(error, {\n fatal: report.fatal,\n source: report.source,\n componentStack: report.componentStack,\n ...(report.handled !== undefined ? { handled: report.handled } : {}),\n ...(report.tags ? { tags: report.tags } : {}),\n }),\n flush,\n lastEventId: () => firstOf((s) => s.lastEventId?.()),\n replayId: () => firstOf((s) => s.replayId?.()),\n screenBoundary(fallback) {\n const wrapping = sinks.filter((s) => s.wrapRouteErrorBoundary);\n // A sink whose wrapper reports the route's error (Sentry's) isn't sent it a second time.\n const skip = new Set(wrapping);\n return createScreenErrorBoundary({\n fallback,\n onError: (error, report) => captureError(error, { fatal: report.fatal, source: report.source }, skip),\n wrap: wrapping.map((sink) => (boundary: ComponentType<ScreenErrorProps>) => {\n try {\n return sink.wrapRouteErrorBoundary!(boundary);\n } catch (error) {\n problem(`${sink.name}.wrapRouteErrorBoundary threw`, error);\n skip.delete(sink);\n return boundary;\n }\n }),\n });\n },\n Root: function ObservabilityRoot({ children }: NativeBlockRootProps) {\n return (\n <ObservabilityContext.Provider value={block as ObservabilityBlock}>\n <UserTracker />\n {useSegments ? <RouteTracker /> : null}\n {children}\n </ObservabilityContext.Provider>\n );\n },\n };\n if (options.reportErrors !== false) {\n setErrorReporter((value, context) =>\n captureError(value, { fatal: context.fatal ?? false, source: context.source, ...(context.tags ? { tags: context.tags } : {}) }),\n );\n }\n const flushMs = options.flushBeforeReloadMs ?? 2000;\n // The newest block replaces the last one's hook (Fast Refresh builds the block again).\n releaseReloadHook?.();\n releaseReloadHook = flushMs > 0 && sinks.some((s) => s.flush) ? onBeforeReload(() => flush(flushMs)) : undefined;\n return block;\n}\n\nconst ObservabilityContext = createContext<ObservabilityBlock | null>(null);\n\n/** Provides a block to the hooks without its root (rung 4). @stability Beta */\nexport function ObservabilityProvider({ block, children }: { block: ObservabilityBlock; children?: ReactNode }) {\n return <ObservabilityContext.Provider value={block}>{children}</ObservabilityContext.Provider>;\n}\n\n/** The block, or `null` when it is off (so a screen can call it whether or not the block is on). @stability Beta */\nexport function useObservability(): ObservabilityBlock | null {\n return useContext(ObservabilityContext);\n}\n\n/** The last breadcrumbs and errors, scrubbed; empty when the block is off. @stability Beta */\nexport function useRecentActivity(block?: ObservabilityBlock | null): RecentActivity {\n const fromContext = useObservability();\n const store = (block ?? fromContext)?.recent ?? EMPTY_STORE;\n return useSyncExternalStore(store.subscribe, store.getState, store.getState);\n}\n\nconst EMPTY: RecentActivity = { breadcrumbs: [], errors: [] };\nconst EMPTY_STORE: RecentStore = { getState: () => EMPTY, subscribe: () => () => {}, clear: () => {} };\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/observability/events.ts","../src/observability/scrub.ts","../src/observability/sink.ts","../src/observability/block.tsx"],"names":[],"mappings":";;;;;;;;;AAkCA,IAAM,UAAA,GAAa,yCAAA;AACnB,IAAM,SAAA,GAAY,mBAAA;AAClB,IAAM,SAAA,GAAY,EAAA;AAClB,IAAM,WAAA,GAAc,EAAA;AASb,SAAS,aAA0C,MAAA,EAAc;AACtE,EAAA,MAAM,WAAqB,EAAC;AAC5B,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,EAAG;AAClD,IAAA,IAAI,CAAC,WAAW,IAAA,CAAK,IAAI,GAAG,QAAA,CAAS,IAAA,CAAK,CAAA,CAAA,EAAI,IAAI,CAAA,mEAAA,CAAqE,CAAA;AACvH,IAAA,MAAM,IAAA,GAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA;AAC9B,IAAA,IAAI,IAAA,CAAK,SAAS,SAAA,EAAW,QAAA,CAAS,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,WAAA,EAAc,SAAS,CAAA,MAAA,CAAQ,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AA,IAAoB;AACpB,EAAA,iBAAA,GAAoB,OAAA,GAAU,CAAA,IAAK,KAAA,CAAM,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,KAAK,CAAA,GAAI,cAAA,CAAe,MAAM,KAAA,CAAM,OAAO,CAAC,CAAA,GAAI,MAAA;AACvG,EAAA,OAAO,KAAA;AACT;AAEA,IAAM,oBAAA,GAAuB,cAAyC,IAAI,CAAA;AAGnE,SAAS,qBAAA,CAAsB,EAAE,KAAA,EAAO,QAAA,EAAS,EAAwD;AAC9G,EAAA,2BAAQ,oBAAA,CAAqB,QAAA,EAArB,EAA8B,KAAA,EAAO,OAAQ,QAAA,EAAS,CAAA;AAChE;AAGO,SAAS,gBAAA,GAA8C;AAC5D,EAAA,OAAO,WAAW,oBAAoB,CAAA;AACxC;AAGO,SAAS,kBAAkB,KAAA,EAAmD;AACnF,EAAA,MAAM,cAAc,gBAAA,EAAiB;AACrC,EAAA,MAAM,KAAA,GAAA,CAAS,KAAA,IAAS,WAAA,GAAc,MAAA,IAAU,WAAA;AAChD,EAAA,OAAO,qBAAqB,KAAA,CAAM,SAAA,EAAW,KAAA,CAAM,QAAA,EAAU,MAAM,QAAQ,CAAA;AAC7E;AAEA,IAAM,QAAwB,EAAE,WAAA,EAAa,EAAC,EAAG,MAAA,EAAQ,EAAC,EAAE;AAC5D,IAAM,cAA2B,EAAE,QAAA,EAAU,MAAM,KAAA,EAAO,SAAA,EAAW,MAAM,MAAM;AAAC,CAAmB,CAAA","file":"chunk-JWIBRHDE.js","sourcesContent":["/**\n * Typed analytics events: the app lists every event and the props each may\n * carry once, and `track(name, props)` accepts nothing else. A prop is a\n * closed list of strings, a number or a boolean, never free text, so an\n * event can't carry a name, an email or a message someone typed.\n *\n * ```ts\n * export const events = defineEvents({\n * \"auth.signed_in\": { method: [\"email\", \"apple\"] },\n * \"settings.opened\": {},\n * \"checkin.saved\": { mood: \"number\", first: \"boolean\" },\n * });\n * ```\n *\n * At run time an unknown event, an unknown prop or a value outside its list\n * is dropped and reported (a `console.warn` in development, `onInvalid`\n * always), so a bad call is loud and still sends nothing.\n */\n\n/** A closed list of strings, `\"number\"` (finite) or `\"boolean\"`. */\nexport type EventPropSpec = readonly string[] | \"number\" | \"boolean\";\n\n/** Every event, by name, with the props it may carry. */\nexport type EventSchema = Readonly<Record<string, Readonly<Record<string, EventPropSpec>>>>;\n\ntype PropValue<S> = S extends readonly (infer L)[] ? L : S extends \"number\" ? number : S extends \"boolean\" ? boolean : never;\n\n/** The props of one event: every prop optional, each its spec's type. */\nexport type EventProps<S extends Readonly<Record<string, EventPropSpec>>> = { readonly [K in keyof S]?: PropValue<S[K]> };\n\n/** What a sink receives: the checked props. */\nexport type EventValues = Readonly<Record<string, string | number | boolean>>;\n\n// Lower-case words joined by `.` or `_`: `auth.signed_in`, `checkin.saved`.\nconst EVENT_NAME = /^[a-z][a-z0-9_]*(?:\\.[a-z][a-z0-9_]*)*$/;\nconst PROP_NAME = /^[a-z][a-z0-9_]*$/;\nconst MAX_PROPS = 25;\nconst MAX_LITERAL = 64;\n\n/**\n * Declare the app's events. Checks names (lower-case, dot-separated), prop\n * names, and that each list has at least one short value, and throws listing\n * every problem, so a bad schema fails where it is written.\n *\n * @stability Beta\n */\nexport function defineEvents<const E extends EventSchema>(schema: E): E {\n const problems: string[] = [];\n for (const [name, props] of Object.entries(schema)) {\n if (!EVENT_NAME.test(name)) problems.push(`\"${name}\": an event name is lower-case words joined by \".\" (auth.signed_in)`);\n const keys = Object.keys(props);\n if (keys.length > MAX_PROPS) problems.push(`\"${name}\": at most ${MAX_PROPS} props`);\n for (const key of keys) {\n const spec = props[key];\n if (!PROP_NAME.test(key)) problems.push(`\"${name}\".${key}: a prop name is lower-case letters, digits and \"_\"`);\n if (Array.isArray(spec)) {\n if (spec.length === 0) problems.push(`\"${name}\".${key}: an empty list allows nothing`);\n for (const v of spec) if (typeof v !== \"string\" || v.length === 0 || v.length > MAX_LITERAL) problems.push(`\"${name}\".${key}: \"${String(v)}\" must be 1-${MAX_LITERAL} characters`);\n } else if (spec !== \"number\" && spec !== \"boolean\") {\n problems.push(`\"${name}\".${key}: a prop is a list of strings, \"number\" or \"boolean\" (free text is not allowed)`);\n }\n }\n }\n if (problems.length) throw new Error(`Invalid events:\\n${problems.map((p) => ` - ${p}`).join(\"\\n\")}`);\n return Object.freeze(schema);\n}\n\nexport type EventCheck = { ok: true; props: EventValues } | { ok: false; problem: string };\n\n/** Check one call against the schema: the props to send, or why nothing is sent. */\nexport function checkEvent(schema: EventSchema, name: string, props: Readonly<Record<string, unknown>> | undefined): EventCheck {\n if (!Object.prototype.hasOwnProperty.call(schema, name)) return { ok: false, problem: `\"${name}\" is not in the event schema` };\n const specs = schema[name] ?? {};\n const out: Record<string, string | number | boolean> = {};\n for (const [key, value] of Object.entries(props ?? {})) {\n if (value === undefined) continue;\n if (!Object.prototype.hasOwnProperty.call(specs, key)) return { ok: false, problem: `\"${name}\" has no prop \"${key}\"` };\n const spec = specs[key];\n const fits =\n spec === \"number\"\n ? typeof value === \"number\" && Number.isFinite(value)\n : spec === \"boolean\"\n ? typeof value === \"boolean\"\n : typeof value === \"string\" && (spec as readonly string[]).includes(value);\n if (!fits) return { ok: false, problem: `\"${name}\".${key}: ${JSON.stringify(value)} is not allowed` };\n out[key] = value as string | number | boolean;\n }\n return { ok: true, props: out };\n}\n","/**\n * The PII scrubber every sink's input goes through by default: text is\n * rewritten by pattern (an email, a phone number, a JWT, a Supabase key, a\n * bearer token, a token in a query string, row values in a database error),\n * values under a key that names a secret or a contact detail are replaced\n * whole, and URLs lose their query and fragment (PostgREST filters carry\n * record ids, auth callbacks carry codes). Strings are cut at 4 KB first, so\n * a huge log line can't stall the JS thread.\n *\n * What it can't know: a person's name in free text. Keep names out of error\n * messages and breadcrumbs; touch breadcrumbs lose their labels in\n * `sentrySink` for this reason.\n *\n * Pattern-based on values, not an allowlist of keys: a key allowlist misses\n * `refresh failed: eyJhbGciOi…`, which is the shape that actually occurs.\n *\n * Fail closed: `scrubEvent` and `scrubRecord` return `null` (drop it) when\n * scrubbing itself throws, never the unscrubbed input.\n */\n\n/** What replaces a value under a secret-looking key. */\nexport const FILTERED = \"[Filtered]\";\n\n// Keys whose value is a secret (or a contact detail) whatever it looks like.\n// Matched case-insensitively with `-`, `_`, `.` and spaces removed: exactly\n// for the short, ambiguous ones, as a part of the key for the rest\n// (`x-supabase-api-key`, `user.email`, `refresh_token_hash`).\nconst SECRET_KEY_EXACT = /^(session|sessionid|dsn|otp|code|verifier|codeverifier|privatekey|refresh|pwd|key)$/;\nconst SECRET_KEY_PART = /(authoriz|cookie|passw|secret|token|apikey|credential|jwt|email|phone|servicerole)/;\n\n/** True when a value under `key` is a secret (or contact detail) whatever it looks like. */\nexport function isSecretKey(key: string): boolean {\n const k = key.replace(/[-_.\\s]/g, \"\").toLowerCase();\n return SECRET_KEY_EXACT.test(k) || SECRET_KEY_PART.test(k);\n}\n\n// Sentry's own ids and envelope fields: 32-hex values the hex rule would break, never PII.\nconst ID_KEY = /^(event_id|trace_id|span_id|parent_span_id|profile_id|replay_id|debug_id|code_id|public_key|segment_id|sampled|release|dist|environment)$/;\n\n// Fields dropped whole: query strings travel as their own fields too (Sentry's http breadcrumbs,\n// spans and requests), and bodies and PostgREST `details` carry row values.\nconst DROPPED_KEY = /^(query_string|http\\.query|http\\.fragment|url\\.query|url\\.fragment|request_body|response_body|body|cookies|details)$/i;\n\n/** Longest string scrubbed in full; the rest is cut off (the patterns stay fast on huge logs). */\nexport const MAX_STRING = 4096;\n\nconst PATTERNS: readonly [RegExp, string][] = [\n // The query string and fragment of a URL with a scheme anywhere in text (a span's\n // \"GET https://…?id=eq.42\", a deep link \"myapp://reset?token_hash=…\").\n [/\\b([a-z][a-z0-9+.-]{0,31}:\\/\\/[^\\s?#\"'<>]{0,2048})[?#][^\\s\"'<>]*/gi, \"$1\"],\n // …and of a path (\"POST /rest/v1/rpc/find?email=eq.…\").\n [/(^|[\\s\"'(=])(\\/[^\\s?#\"'<>]{0,2048})\\?[^\\s\"'<>]*/g, \"$1$2\"],\n // JWTs: Supabase access tokens and the legacy anon / service_role keys.\n [/\\beyJ[A-Za-z0-9_-]{5,}\\.[A-Za-z0-9_-]{5,}\\.[A-Za-z0-9_-]*/g, \"[jwt]\"],\n // Supabase's API keys (sb_secret_…, sb_publishable_…).\n [/\\bsb_(?:secret|publishable)_[A-Za-z0-9_-]{8,}/g, \"[supabase-key]\"],\n // `Authorization: Bearer …` copied into a message.\n [/\\b(Bearer|Basic)\\s+[A-Za-z0-9._~+/=-]+/gi, \"$1 [token]\"],\n // Tokens in a query string or a fragment left without a scheme.\n [\n /([?&#](?:access_token|refresh_token|id_token|provider_token|provider_refresh_token|token|token_hash|code|apikey|api_key|key|password|secret|email|phone)=)[^&#\\s\"']+/gi,\n \"$1[Filtered]\",\n ],\n // Row values in PostgreSQL errors: `Failing row contains (…)`, `Key (email)=(…)`.\n [/(Failing row contains )\\([^)]*\\)/g, \"$1(…)\"],\n [/(Key \\([^)]{0,256}\\)=)\\([^)]*\\)/g, \"$1(…)\"],\n // Email addresses, also percent-encoded (`a%40b.co`). Bounded, so a long run of letters can't backtrack.\n [/[A-Za-z0-9._%+-]{1,64}(?:@|%40)(?:[A-Za-z0-9-]{1,63}\\.){1,8}[A-Za-z]{2,24}/g, \"[email]\"],\n // Phone numbers: international (`+1 555 555 0101`) and North American (`555-555-0101`).\n [/\\+\\d[\\d\\s().-]{6,18}\\d/g, \"[phone]\"],\n [/\\b\\(?\\d{3}\\)?[-.\\s]\\d{3}[-.\\s]\\d{4}\\b/g, \"[phone]\"],\n // …national numbers in space-separated groups, which start with a trunk 0 (`020 7946 0958`), and\n // international ones without the + (`44 20 7946 0958`: a country code, then two groups of 4).\n // Plain counts, durations and dates (`120 340 560`, `2024 11 19`) don't have either shape.\n [/\\b0\\d{2,4} \\d{3,4} \\d{3,4}\\b/g, \"[phone]\"],\n [/\\b\\d{2,3} \\d{1,4} \\d{4} \\d{4}\\b/g, \"[phone]\"],\n // …and North American numbers with no separator (`5555550101`, `15555550101`): an area code and an\n // exchange that start with 2-9. A whole word only, so a hex id, a longer number or an epoch\n // time (which starts with 1) is left alone.\n [/\\b1?[2-9]\\d{2}[2-9]\\d{6}\\b/g, \"[phone]\"],\n // Long opaque hex runs: API keys, refresh tokens, DSN secrets. Linear: a run starts only after a non-hex character.\n [/(^|[^A-Fa-f0-9])[A-Fa-f0-9]{32,}(?![A-Fa-f0-9])/g, \"$1[hex]\"],\n];\n\n/** A string with every URL query, email, phone number, JWT, Supabase key, bearer token and query-string token replaced. */\nexport function scrubString(value: string): string {\n let out = value.length > MAX_STRING ? `${value.slice(0, MAX_STRING)}…[truncated]` : value;\n for (const [pattern, replacement] of PATTERNS) out = out.replace(pattern, replacement);\n return out;\n}\n\n/** A URL without its query string and fragment, then scrubbed (an email in a path). */\nexport function scrubUrl(value: string): string {\n const cut = value.search(/[?#]/);\n return scrubString(cut === -1 ? value : value.slice(0, cut));\n}\n\n// Keys whose string value is cut at `?` when it is a URL.\nconst URL_KEY = /^(url|href|from|to|uri|description|http\\.url|url\\.full)$/i;\nconst MAX_DEPTH = 8;\n\n/**\n * A deep copy of `value` with every string scrubbed and every value under a\n * secret key replaced. Cycles become `\"[Circular]\"`; past 8 levels,\n * `\"[Truncated]\"`. Errors become `{ name, message }`. Header lists\n * (`[[\"authorization\", \"…\"]]`) are treated like objects.\n */\nexport function scrubValue(value: unknown, key = \"\", depth = 0, seen: WeakSet<object> = new WeakSet(), keepIds = true): unknown {\n if (key && isSecretKey(key)) return value === undefined || value === null || value === \"\" ? value : FILTERED;\n if (typeof value === \"string\") {\n if (keepIds && key && ID_KEY.test(key)) return value;\n return URL_KEY.test(key) ? scrubUrl(value) : scrubString(value);\n }\n if (value === null || typeof value !== \"object\") return value;\n if (seen.has(value)) return \"[Circular]\";\n if (depth >= MAX_DEPTH) return \"[Truncated]\";\n seen.add(value);\n if (value instanceof Error) return { name: value.name, message: scrubString(value.message) };\n if (Array.isArray(value)) {\n // A `[name, value]` pair (fetch's header lists): the name decides, as for an object key.\n if (value.length === 2 && typeof value[0] === \"string\" && isSecretKey(value[0])) return [value[0], FILTERED];\n return value.map((item) => scrubValue(item, \"\", depth + 1, seen, keepIds));\n }\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) {\n if (DROPPED_KEY.test(k)) continue;\n out[k] = scrubValue(v, k, depth + 1, seen, keepIds);\n }\n return out;\n}\n\n/**\n * `scrubValue` without the pass for Sentry's own id fields (`release`, `environment`,\n * `event_id`, …): for data that isn't a Sentry envelope (a support dump, an app's own\n * object), where a key named like one can hold anything.\n */\nexport function scrubValueStrict(value: unknown): unknown {\n return scrubValue(value, \"\", 0, new WeakSet(), false);\n}\n\n/** The fields of a Sentry-shaped event `scrubEvent` treats specially. Anything else is scrubbed by value. */\nexport interface ScrubbableEvent {\n user?: { id?: unknown; [key: string]: unknown } | null;\n request?: { url?: unknown; method?: unknown; headers?: unknown; [key: string]: unknown };\n [key: string]: unknown;\n}\n\n/**\n * The event with the user reduced to its id, the request reduced to its\n * method, URL (cut at `?`) and scrubbed headers, and every other value\n * scrubbed. `null` when scrubbing threw: fail closed, send nothing rather\n * than PII.\n */\nexport function scrubEvent<E extends ScrubbableEvent>(event: E): E | null {\n try {\n // Sentry's processing metadata (scopes, the sampling context its envelope header is built\n // from) is never sent as part of the event: pass it through, or the envelope breaks.\n const { user, request, sdkProcessingMetadata, ...rest } = event;\n const out = scrubValue(rest) as E;\n if (sdkProcessingMetadata !== undefined) (out as ScrubbableEvent).sdkProcessingMetadata = sdkProcessingMetadata;\n if (user !== undefined) {\n (out as ScrubbableEvent).user = user && user.id !== undefined && user.id !== null ? { id: scrubString(String(user.id)) } : null;\n }\n if (request && typeof request === \"object\") {\n const safe: Record<string, unknown> = {};\n if (typeof request.url === \"string\") safe.url = scrubUrl(request.url);\n if (typeof request.method === \"string\") safe.method = request.method;\n if (request.headers && typeof request.headers === \"object\") safe.headers = scrubValue(request.headers);\n (out as ScrubbableEvent).request = safe;\n }\n return out;\n } catch {\n return null;\n }\n}\n\n/** A breadcrumb, span or any record, scrubbed by value. `null` when scrubbing threw (fail closed). */\nexport function scrubRecord<R extends object>(record: R): R | null {\n try {\n return scrubValue(record) as R;\n } catch {\n return null;\n }\n}\n","/**\n * The vendor-neutral seam: a sink is where errors, breadcrumbs, the user id,\n * analytics events and timings go. `createObservability` fans every call out\n * to its sinks, scrubbed first; a sink that throws is reported to\n * `onSinkError` and never takes the others (or the app) down with it.\n *\n * Shipped sinks: `sentrySink` (Sentry), `observeSink` (EAS Observe) and\n * `consoleSink` (development). A vendor adapter (PostHog, Datadog…) is one\n * object with the methods it supports.\n */\nimport type { ComponentType } from \"react\";\nimport { scrubString, scrubValue } from \"./scrub\";\nimport type { EventValues } from \"./events\";\n\n/** Where a caught error came from and whether the app could go on. */\nexport interface ErrorContext {\n /** True when the app could not go on (a render error, a failed boot, a fatal global error). */\n fatal: boolean;\n /**\n * `boundary`, `global`, `boot`, `rejection`, `screen`, `query`, `mutation`\n * (the shell's), a package's (`chat:attachment-action`, through\n * `reportError` from genesis-core) or the app's own (`updates:policy`, `sync`).\n */\n source: string;\n componentStack?: string;\n /** The route pattern on screen (`/(app)/settings`), when known. */\n route?: string | null;\n /**\n * False when nothing caught it (an unhandled promise rejection): release\n * health counts it. Default: handled unless `fatal`.\n */\n handled?: boolean;\n /** Low-cardinality labels (`query.key: \"tasks\"`), scrubbed like everything else. */\n tags?: Readonly<Record<string, string>>;\n}\n\nexport type BreadcrumbLevel = \"debug\" | \"info\" | \"warning\" | \"error\";\n\n/** One step that led up to an error: a navigation, a tap, a request. */\nexport interface Breadcrumb {\n /** `navigation`, `ui`, `http`, `event`, or the app's own. */\n category: string;\n message?: string;\n level?: BreadcrumbLevel;\n data?: Readonly<Record<string, unknown>>;\n /** Milliseconds since the epoch. Default now. */\n timestamp?: number;\n}\n\n/** Low-cardinality labels on a timing (`route`, `step`), never ids or text someone typed. */\nexport type TimingTags = Readonly<Record<string, string>>;\n\n/**\n * One destination. Every method is optional: a sink takes what its vendor\n * supports. Errors arrive as an `Error` whose message is already scrubbed,\n * unless the sink sets `scrubsErrors` (it scrubs the whole event itself and\n * needs the original object, as Sentry does to deduplicate).\n *\n * @stability Beta\n */\nexport interface ObservabilitySink {\n readonly name: string;\n /** The sink scrubs error events itself; give it the original `Error`. */\n readonly scrubsErrors?: boolean;\n captureError?(error: Error, context: ErrorContext): void;\n breadcrumb?(crumb: Breadcrumb): void;\n /** The signed-in login's id, or `null` when signed out. Never an email or a name. */\n setUser?(id: string | null): void;\n /** An analytics event, its props checked against the schema. */\n event?(name: string, props: EventValues): void;\n timing?(name: string, ms: number, tags?: TimingTags): void;\n /** Wraps the root layout (Sentry's `wrap`, EAS Observe's `ObserveRoot.wrap`). */\n wrap?<P extends Record<string, unknown>>(root: ComponentType<P>): ComponentType<P>;\n /**\n * Wraps an Expo Router per-route `ErrorBoundary` (Sentry's\n * `wrapExpoRouterErrorBoundary`). A sink that wraps reports the route's\n * error itself, so the block's screen boundary doesn't send it to that sink again.\n */\n wrapRouteErrorBoundary?(boundary: ComponentType<RouteErrorBoundaryProps>): ComponentType<RouteErrorBoundaryProps>;\n /** Send what is queued, within `timeoutMs`; resolves false when it didn't finish. Called before an update reloads the app. */\n flush?(timeoutMs: number): PromiseLike<boolean> | boolean | void;\n /** The id of the last error event this sink sent, for a support request or feedback. */\n lastEventId?(): string | undefined;\n /** The current session replay's id, when replay is on. */\n replayId?(): string | undefined;\n}\n\n/** What Expo Router gives a route's `ErrorBoundary`: the error, and `retry` to render the route again. */\nexport interface RouteErrorBoundaryProps {\n error: Error;\n retry: () => Promise<void>;\n}\n\n/** A copy of `error` whose message and stack have been scrubbed (for sinks that don't scrub themselves). */\nexport function scrubbedError(error: Error): Error {\n const copy = new Error(scrubString(error.message));\n copy.name = error.name;\n if (error.stack) copy.stack = scrubString(error.stack);\n return copy;\n}\n\nexport interface ConsoleSinkOptions {\n /** Default `console`. */\n console?: Pick<Console, \"log\" | \"warn\" | \"error\">;\n /** Also log breadcrumbs (noisy). Default false. */\n breadcrumbs?: boolean;\n}\n\n/**\n * Logs what would be sent, for development: fatal errors with `console.error`, others with `console.warn`,\n * events and timings with `console.log`. Already scrubbed, so what you read\n * is what a vendor sink would get.\n *\n * @stability Beta\n */\nexport function consoleSink(options: ConsoleSinkOptions = {}): ObservabilitySink {\n const out = options.console ?? console;\n return {\n name: \"console\",\n // `warn` for what the app survives: `console.error` would raise a LogBox error for every one in development.\n captureError: (error, context) => {\n const line = `[observability] ${context.fatal ? \"fatal \" : \"\"}${context.source}: ${error.message}`;\n if (context.fatal) out.error(line);\n else out.warn(line);\n },\n breadcrumb: options.breadcrumbs ? (crumb) => out.log(`[observability] · ${crumb.category} ${crumb.message ?? \"\"}`) : undefined,\n setUser: (id) => out.log(`[observability] user ${id ?? \"(signed out)\"}`),\n event: (name, props) => out.log(`[observability] event ${name}`, props),\n timing: (name, ms, tags) => out.log(`[observability] timing ${name} ${Math.round(ms)}ms`, tags ?? {}),\n };\n}\n\n/**\n * `expo-observe`'s `Observe` (SDK 56+), or a stand-in: the calls `observeSink`\n * uses. Pass `import { Observe } from \"expo-observe\"`.\n */\nexport interface ObserveLike {\n logEvent(name: string, options?: { severity?: \"debug\" | \"info\" | \"warn\" | \"error\"; body?: string; attributes?: Record<string, unknown> }): void;\n /** Error reporting, in preview on SDK 57+. */\n reportError?(error: unknown): void;\n}\n\nexport interface ObserveSinkOptions {\n /** Report caught errors with `Observe.reportError` (in preview). Default false: Sentry is the error tracker. */\n errors?: boolean;\n}\n\n/**\n * EAS Observe. It measures launch (cold, warm, bundle load, first render),\n * time to interactive and, with its Expo Router integration, per-route\n * render times on its own; it has no API for a custom timing metric, so\n * `timing` is logged as an event (`timing.<name>` with `duration_ms`) and\n * shows on the Events page, not as a metric. Analytics events go to\n * `Observe.logEvent` as they are.\n *\n * @stability Beta\n */\nexport function observeSink(observe: ObserveLike, options: ObserveSinkOptions = {}): ObservabilitySink {\n return {\n name: \"eas-observe\",\n event: (name, props) => observe.logEvent(name, { attributes: { ...props } }),\n timing: (name, ms, tags) => observe.logEvent(`timing.${name}`, { severity: \"info\", attributes: { duration_ms: Math.round(ms), ...(tags ?? {}) } }),\n captureError: options.errors && observe.reportError ? (error) => observe.reportError?.(error) : undefined,\n };\n}\n\n/** Breadcrumb data scrubbed and made plain (for sinks and the devtools overlay). */\nexport function scrubBreadcrumb(crumb: Breadcrumb): Breadcrumb {\n return {\n category: scrubString(crumb.category),\n level: crumb.level,\n timestamp: crumb.timestamp,\n ...(crumb.message !== undefined ? { message: scrubString(crumb.message) } : {}),\n ...(crumb.data ? { data: scrubValue(crumb.data) as Record<string, unknown> } : {}),\n };\n}\n","/**\n * `createObservability(options)`: the observability block. Build it once at\n * module scope (it starts the sinks, Sentry's `init` included), then:\n *\n * <GenesisNativeApp blocks={[observability]}> every error the shell catches → captureError\n * export default observability.wrap(RootLayout) Sentry's `wrap` (touch and profiler boundaries)\n * observability.track(\"auth.signed_in\", { method: \"email\" })\n *\n * Its root (inside the shell) sets the user to the signed-in login's id and,\n * with `useSegments` from expo-router, leaves a breadcrumb per route change\n * and a `route.time_on_screen` timing for the route left. Route patterns\n * (`/(app)/clients/[id]`) are used, never the values in them.\n *\n * Creating it also:\n * - registers it as genesis-core's error reporter (`setErrorReporter`), so a\n * package's `reportError(e, \"chat:…\")` reaches the sinks as a non-fatal error;\n * - registers a before-reload hook (`onBeforeReload`) that flushes the sinks\n * before an update reloads the app.\n *\n * `observability.screenBoundary()` is an Expo Router `ErrorBoundary` for a\n * route (reported non-fatal, wrapped by Sentry's route wrapper), and\n * `lastEventId()` / `replayId()` let a support or feedback screen point at\n * the event.\n *\n * Everything a sink receives has been scrubbed (see `scrub.ts`), and the\n * last breadcrumbs and errors are kept, scrubbed, for the devtools overlay\n * (`recent`).\n */\nimport { createContext, useContext, useEffect, useRef, useSyncExternalStore, type ComponentType, type ReactNode } from \"react\";\nimport { defineBlock } from \"@marktiderman/genesis-config/blocks\";\nimport { setErrorReporter } from \"@marktiderman/genesis-core/errors\";\nimport { useSession } from \"../auth\";\nimport { onBeforeReload } from \"../reload\";\nimport { createScreenErrorBoundary, type ScreenErrorProps } from \"../screen-boundary\";\nimport type { NativeBlock, NativeBlockRootProps } from \"../blocks\";\nimport type { ErrorReport } from \"../errors\";\nimport { checkEvent, type EventProps, type EventSchema } from \"./events\";\nimport { scrubString, scrubValue } from \"./scrub\";\nimport { scrubBreadcrumb, scrubbedError, type Breadcrumb, type ErrorContext, type ObservabilitySink, type TimingTags } from \"./sink\";\n\n/** The FeatureId of the observability block. */\nexport const OBSERVABILITY_BLOCK_ID = \"observability\";\n\n/** A caught error as the devtools overlay shows it (scrubbed). */\nexport interface RecentError {\n at: number;\n name: string;\n message: string;\n source: string;\n fatal: boolean;\n}\n\nexport interface RecentActivity {\n /** Oldest first. Navigation, events and the app's breadcrumbs. */\n breadcrumbs: readonly Breadcrumb[];\n /** Oldest first. */\n errors: readonly RecentError[];\n}\n\nexport interface RecentStore {\n getState(): RecentActivity;\n subscribe(listener: () => void): () => void;\n clear(): void;\n}\n\nexport interface ObservabilityOptions<E extends EventSchema = EventSchema> {\n /** Where everything goes: `sentrySink(Sentry, …)`, `consoleSink()` in development, `observeSink(Observe)`. */\n sinks: readonly (ObservabilitySink | null | undefined | false)[];\n /** The app's analytics events (`defineEvents`). Without it, `track` accepts nothing. */\n events?: E;\n /** `useSegments` from expo-router: route breadcrumbs and `route.time_on_screen` timings. */\n useSegments?: () => readonly string[];\n /** How many breadcrumbs and errors `recent` keeps. Default 50 and 20. */\n recent?: { breadcrumbs?: number; errors?: number };\n /** A sink threw, or `track` was called with something the schema doesn't allow. Default `console.warn` in development. */\n onProblem?: (problem: string, error?: unknown) => void;\n /**\n * Become genesis-core's error reporter, so packages' `reportError` calls\n * reach the sinks. Default true; the last block created wins.\n */\n reportErrors?: boolean;\n /** Flush the sinks before an update reloads the app, within this many milliseconds. Default 2000; 0 turns it off. */\n flushBeforeReloadMs?: number;\n now?: () => number;\n}\n\nexport interface ObservabilityBlock<E extends EventSchema = EventSchema> extends NativeBlock<typeof OBSERVABILITY_BLOCK_ID> {\n readonly sinks: readonly ObservabilitySink[];\n readonly events: E | undefined;\n /** Report an error. The shell calls it for every error it catches. */\n captureError(error: unknown, context?: Partial<ErrorContext>): void;\n breadcrumb(crumb: Breadcrumb): void;\n /** The login's id only. The block's root sets it from the session. */\n setUser(id: string | null): void;\n /** An analytics event from the schema. Anything else is dropped and reported. */\n track<N extends keyof E & string>(name: N, props?: EventProps<E[N]>): void;\n timing(name: string, ms: number, tags?: TimingTags): void;\n /** The root layout wrapped by each sink that wraps (Sentry's `wrap`). Use once: `export default observability.wrap(RootLayout)`. */\n wrap<P extends Record<string, unknown>>(root: ComponentType<P>): ComponentType<P>;\n /** The last breadcrumbs and errors, scrubbed, for the devtools overlay. */\n readonly recent: RecentStore;\n /** Send what every sink has queued; resolves false when one didn't finish within `timeoutMs` (default 2000). */\n flush(timeoutMs?: number): Promise<boolean>;\n /** The id of the last error event a sink sent (Sentry's), for a support request or feedback. */\n lastEventId(): string | undefined;\n /** The current session replay's id, when a sink records replays. */\n replayId(): string | undefined;\n /**\n * An Expo Router `ErrorBoundary` for a route: reports the error non-fatal\n * (source `screen`), shows `fallback` (default `<FatalScreen kind=\"screen\" />`) with\n * \"Try again\", and is wrapped by each sink's route wrapper (Sentry's\n * `wrapExpoRouterErrorBoundary`). Build it once, at module scope.\n */\n screenBoundary(fallback?: ComponentType<ScreenErrorProps>): ComponentType<ScreenErrorProps>;\n /** For the shell: every error it catches. */\n readonly onError: (error: Error, report: ErrorReport) => void;\n readonly Root: ComponentType<NativeBlockRootProps>;\n}\n\ndeclare const __DEV__: boolean | undefined;\n\nlet releaseReloadHook: (() => void) | undefined;\n\nconst TIMING_NAME = /^[a-z][a-z0-9_]*(?:\\.[a-z][a-z0-9_]*)*$/;\n\nfunction createRecentStore(maxCrumbs: number, maxErrors: number): RecentStore & { addCrumb(c: Breadcrumb): void; addError(e: RecentError): void } {\n let state: RecentActivity = { breadcrumbs: [], errors: [] };\n const listeners = new Set<() => void>();\n const emit = () => listeners.forEach((l) => l());\n const push = <T,>(list: readonly T[], item: T, max: number) => (list.length >= max ? [...list.slice(list.length - max + 1), item] : [...list, item]);\n return {\n getState: () => state,\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n clear() {\n state = { breadcrumbs: [], errors: [] };\n emit();\n },\n addCrumb(crumb) {\n state = { ...state, breadcrumbs: push(state.breadcrumbs, crumb, maxCrumbs) };\n emit();\n },\n addError(error) {\n state = { ...state, errors: push(state.errors, error, maxErrors) };\n emit();\n },\n };\n}\n\nfunction toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(typeof value === \"string\" ? value : \"Unknown error\");\n}\n\n/** Build the block once, at module scope, before the root layout renders. @stability Beta */\nexport function createObservability<const E extends EventSchema = EventSchema>(options: ObservabilityOptions<E>): ObservabilityBlock<E> {\n const sinks = options.sinks.filter((s): s is ObservabilitySink => Boolean(s));\n const now = options.now ?? Date.now;\n const problem =\n options.onProblem ??\n ((message: string, error?: unknown) => {\n // genesis-allow-console: the block's own development warning; it can't report to itself.\n if (typeof __DEV__ !== \"undefined\" && __DEV__) console.warn(`[observability] ${message}`, error ?? \"\");\n });\n const recent = createRecentStore(options.recent?.breadcrumbs ?? 50, options.recent?.errors ?? 20);\n let route: string | null = null;\n let user: string | null | undefined;\n\n // One sink failing never stops the others, and never throws into the caller (an error handler, a render).\n const each = (method: string, call: (sink: ObservabilitySink) => void) => {\n for (const sink of sinks) {\n try {\n call(sink);\n } catch (error) {\n try {\n problem(`${sink.name}.${method} threw`, error);\n } catch {\n // ignore a failing reporter\n }\n }\n }\n };\n\n // Never throws into the caller (an effect, a handler): a record that can't be scrubbed is dropped.\n const breadcrumb = (input: Breadcrumb) => {\n let crumb: Breadcrumb;\n try {\n crumb = scrubBreadcrumb({ ...input, timestamp: input.timestamp ?? now() });\n } catch (error) {\n problem(\"breadcrumb dropped: it could not be scrubbed\", error);\n return;\n }\n recent.addCrumb(crumb);\n each(\"breadcrumb\", (s) => s.breadcrumb?.(crumb));\n };\n\n const captureError = (value: unknown, context: Partial<ErrorContext> = {}, skip?: ReadonlySet<ObservabilitySink>) => {\n const error = toError(value);\n const full: ErrorContext = {\n fatal: context.fatal ?? false,\n source: context.source ?? \"app\",\n route: context.route ?? route,\n componentStack: context.componentStack,\n ...(context.handled !== undefined ? { handled: context.handled } : {}),\n ...(context.tags ? { tags: context.tags } : {}),\n };\n let safe: Error | undefined;\n const scrubbed = () => (safe ??= scrubbedError(error));\n try {\n recent.addError({ at: now(), name: error.name, message: scrubString(error.message), source: full.source, fatal: full.fatal });\n } catch {\n // never let the overlay's list stop a report\n }\n let forSinks: ErrorContext = full;\n try {\n forSinks = {\n ...full,\n ...(full.componentStack ? { componentStack: scrubString(full.componentStack) } : {}),\n ...(full.tags ? { tags: scrubValue(full.tags) as Record<string, string> } : {}),\n };\n } catch {\n // Tags that can't be scrubbed are dropped, never sent raw.\n forSinks = { ...full, componentStack: undefined, tags: undefined };\n }\n each(\"captureError\", (s) => {\n if (skip?.has(s)) return;\n s.captureError?.(s.scrubsErrors ? error : scrubbed(), s.scrubsErrors ? full : forSinks);\n });\n };\n\n const flush = async (timeoutMs = 2000): Promise<boolean> => {\n const results = sinks.map(async (sink) => {\n if (!sink.flush) return true;\n try {\n return (await sink.flush(timeoutMs)) !== false;\n } catch (error) {\n problem(`${sink.name}.flush threw`, error);\n return false;\n }\n });\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<boolean>((resolve) => {\n timer = setTimeout(() => resolve(false), timeoutMs);\n });\n try {\n return await Promise.race([Promise.all(results).then((all) => all.every(Boolean)), deadline]);\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n }\n };\n\n const firstOf = (read: (sink: ObservabilitySink) => string | undefined): string | undefined => {\n for (const sink of sinks) {\n try {\n const value = read(sink);\n if (value) return value;\n } catch (error) {\n problem(`${sink.name} threw reading an id`, error);\n }\n }\n return undefined;\n };\n\n const setUser = (id: string | null) => {\n if (id === user) return;\n user = id;\n each(\"setUser\", (s) => s.setUser?.(id));\n };\n\n const track = (name: string, props?: Readonly<Record<string, unknown>>) => {\n const check = options.events ? checkEvent(options.events, name, props) : ({ ok: false, problem: \"no event schema: pass `events: defineEvents({…})`\" } as const);\n if (!check.ok) {\n problem(`track dropped: ${check.problem}`);\n return;\n }\n recent.addCrumb({ category: \"event\", message: name, level: \"info\", data: check.props, timestamp: now() });\n each(\"event\", (s) => s.event?.(name, check.props));\n };\n\n const timing = (name: string, ms: number, tags?: TimingTags) => {\n if (!Number.isFinite(ms) || ms < 0) return;\n // A name like an event's (`route.time_on_screen`), never text with values in it.\n if (!TIMING_NAME.test(name)) {\n problem(`timing dropped: \"${scrubString(name)}\" is not lower-case words joined by \".\"`);\n return;\n }\n let safeTags: TimingTags | undefined;\n try {\n safeTags = tags ? (scrubValue(tags) as TimingTags) : undefined;\n } catch (error) {\n problem(\"timing dropped: its tags could not be scrubbed\", error);\n return;\n }\n each(\"timing\", (s) => s.timing?.(name, ms, safeTags));\n };\n\n const declaration = defineBlock<typeof OBSERVABILITY_BLOCK_ID, ComponentType<never>>({\n id: OBSERVABILITY_BLOCK_ID,\n platforms: [\"native\"],\n contributes: {\n privacy: {\n collects: [\n // genesis-cli's PRIVACY_BLOCKS.observability mirrors this (with events) for the iOS\n // privacy manifest; observability/block.test.tsx keeps the two the same.\n { type: \"crash data\", purposes: [\"app functionality\"], linked: true, tracking: false },\n { type: \"performance data\", purposes: [\"app functionality\"], linked: true, tracking: false },\n // Sentry's device and OS details, breadcrumbs and sessions.\n { type: \"other diagnostic data\", purposes: [\"app functionality\"], linked: true, tracking: false },\n { type: \"user id\", purposes: options.events ? [\"app functionality\", \"analytics\"] : [\"app functionality\"], linked: true, tracking: false },\n ...(options.events ? [{ type: \"product interaction\", purposes: [\"analytics\"], linked: true, tracking: false }] : []),\n ],\n notes: [\n \"Crash reports, timings and analytics events carry the login's id only; emails, tokens, keys and query strings are removed on the device before anything is sent.\",\n ],\n },\n },\n });\n\n const useSegments = options.useSegments;\n function RouteTracker() {\n const segments = (useSegments as () => readonly string[])();\n const path = `/${segments.join(\"/\")}`;\n const last = useRef<{ path: string; at: number } | null>(null);\n useEffect(() => {\n const at = now();\n const previous = last.current;\n if (previous?.path === path) return;\n route = path;\n breadcrumb({ category: \"navigation\", message: path, data: previous ? { from: previous.path } : undefined, timestamp: at });\n if (previous) timing(\"route.time_on_screen\", at - previous.at, { route: previous.path });\n last.current = { path, at };\n }, [path]);\n return null;\n }\n\n function UserTracker() {\n const { userId } = useSession();\n useEffect(() => setUser(userId ?? null), [userId]);\n return null;\n }\n\n const block: ObservabilityBlock<E> = {\n ...declaration,\n sinks,\n events: options.events,\n captureError,\n breadcrumb,\n setUser,\n track: track as ObservabilityBlock<E>[\"track\"],\n timing,\n recent,\n wrap(root) {\n return sinks.reduce((wrapped, sink) => (sink.wrap ? sink.wrap(wrapped) : wrapped), root);\n },\n onError: (error, report) =>\n captureError(error, {\n fatal: report.fatal,\n source: report.source,\n componentStack: report.componentStack,\n ...(report.handled !== undefined ? { handled: report.handled } : {}),\n ...(report.tags ? { tags: report.tags } : {}),\n }),\n flush,\n lastEventId: () => firstOf((s) => s.lastEventId?.()),\n replayId: () => firstOf((s) => s.replayId?.()),\n screenBoundary(fallback) {\n const wrapping = sinks.filter((s) => s.wrapRouteErrorBoundary);\n // A sink whose wrapper reports the route's error (Sentry's) isn't sent it a second time.\n const skip = new Set(wrapping);\n return createScreenErrorBoundary({\n fallback,\n onError: (error, report) => captureError(error, { fatal: report.fatal, source: report.source }, skip),\n wrap: wrapping.map((sink) => (boundary: ComponentType<ScreenErrorProps>) => {\n try {\n return sink.wrapRouteErrorBoundary!(boundary);\n } catch (error) {\n problem(`${sink.name}.wrapRouteErrorBoundary threw`, error);\n skip.delete(sink);\n return boundary;\n }\n }),\n });\n },\n Root: function ObservabilityRoot({ children }: NativeBlockRootProps) {\n return (\n <ObservabilityContext.Provider value={block as ObservabilityBlock}>\n <UserTracker />\n {useSegments ? <RouteTracker /> : null}\n {children}\n </ObservabilityContext.Provider>\n );\n },\n };\n if (options.reportErrors !== false) {\n setErrorReporter((value, context) =>\n captureError(value, { fatal: context.fatal ?? false, source: context.source, ...(context.tags ? { tags: context.tags } : {}) }),\n );\n }\n const flushMs = options.flushBeforeReloadMs ?? 2000;\n // The newest block replaces the last one's hook (Fast Refresh builds the block again).\n releaseReloadHook?.();\n releaseReloadHook = flushMs > 0 && sinks.some((s) => s.flush) ? onBeforeReload(() => flush(flushMs)) : undefined;\n return block;\n}\n\nconst ObservabilityContext = createContext<ObservabilityBlock | null>(null);\n\n/** Provides a block to the hooks without its root (rung 4). @stability Beta */\nexport function ObservabilityProvider({ block, children }: { block: ObservabilityBlock; children?: ReactNode }) {\n return <ObservabilityContext.Provider value={block}>{children}</ObservabilityContext.Provider>;\n}\n\n/** The block, or `null` when it is off (so a screen can call it whether or not the block is on). @stability Beta */\nexport function useObservability(): ObservabilityBlock | null {\n return useContext(ObservabilityContext);\n}\n\n/** The last breadcrumbs and errors, scrubbed; empty when the block is off. @stability Beta */\nexport function useRecentActivity(block?: ObservabilityBlock | null): RecentActivity {\n const fromContext = useObservability();\n const store = (block ?? fromContext)?.recent ?? EMPTY_STORE;\n return useSyncExternalStore(store.subscribe, store.getState, store.getState);\n}\n\nconst EMPTY: RecentActivity = { breadcrumbs: [], errors: [] };\nconst EMPTY_STORE: RecentStore = { getState: () => EMPTY, subscribe: () => () => {}, clear: () => {} };\n"]}
|