@genesislcap/foundation-utils 15.55.0 → 15.57.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.
@@ -636,13 +636,39 @@ export declare interface ErrorMonitoringContext {
636
636
  */
637
637
  export declare type ErrorMonitoringEnvironmentResolver = (location: Location) => string | undefined;
638
638
 
639
+ /**
640
+ * An event about to be sent, with the page it happened on.
641
+ * @public
642
+ */
643
+ export declare interface ErrorMonitoringEvent {
644
+ request?: {
645
+ url?: string;
646
+ };
647
+ }
648
+
639
649
  /**
640
650
  * Extra options for the client's `init`, merged into what {@link setupErrorMonitoring} passes.
641
651
  * @public
642
652
  */
643
653
  export declare interface ErrorMonitoringExtraInitOptions {
654
+ /**
655
+ * Merged over the defaults, which turn off user info, cookies, headers other than `User-Agent`,
656
+ * bodies and URL query strings. Other settings keep the SDK's defaults.
657
+ */
658
+ dataCollection?: Record<string, unknown>;
659
+ /**
660
+ * Added to the default integrations that are kept, replacing any of the same name. A function
661
+ * receives those kept defaults instead and returns the full list.
662
+ */
663
+ integrations?: ErrorMonitoringIntegration[] | ((defaults: ErrorMonitoringIntegration[]) => ErrorMonitoringIntegration[]);
644
664
  /** Runs after the built-in filter, for breadcrumbs it keeps, with the SDK's hint. */
645
665
  beforeBreadcrumb?: (breadcrumb: ErrorMonitoringBreadcrumb, hint?: ErrorMonitoringBreadcrumbHint) => ErrorMonitoringBreadcrumb | null;
666
+ /** Runs after the page URL's query string and fragment are stripped, with the SDK's hint. */
667
+ beforeSend?(event: ErrorMonitoringEvent, hint?: unknown): ErrorMonitoringEvent | null | PromiseLike<ErrorMonitoringEvent | null>;
668
+ /** Like `beforeSend`, for transactions. Wrapped only with `traceLifecycle: 'static'`. */
669
+ beforeSendTransaction?(event: ErrorMonitoringEvent, hint?: unknown): ErrorMonitoringEvent | null | PromiseLike<ErrorMonitoringEvent | null>;
670
+ /** Runs after span URLs and resource span names lose their query string and fragment. */
671
+ beforeSendSpan?(span: ErrorMonitoringSpan): ErrorMonitoringSpan;
646
672
  [key: string]: unknown;
647
673
  }
648
674
 
@@ -656,11 +682,33 @@ export declare interface ErrorMonitoringExtraInitOptions {
656
682
  export declare interface ErrorMonitoringInitOptions {
657
683
  dsn: string;
658
684
  environment: string;
659
- /** Drops the console breadcrumbs foundation loggers write; see {@link isFoundationLoggerConsoleBreadcrumb}. */
685
+ /** Turns off Sentry 11's user info, cookies, headers but `User-Agent`, bodies and URL queries. */
686
+ dataCollection: Record<string, unknown>;
687
+ /** Keeps only the SDK's default integrations that send nothing from the page, plus the app's. */
688
+ integrations: <I extends ErrorMonitoringIntegration>(defaults: I[]) => I[];
689
+ /** Drops console, click and input breadcrumbs, and strips queries and fragments from URLs. */
660
690
  beforeBreadcrumb?: <B extends ErrorMonitoringBreadcrumb>(breadcrumb: B, hint?: ErrorMonitoringBreadcrumbHint) => B | null;
691
+ /** Strips the query string and fragment from the page URL. */
692
+ beforeSend: <E extends ErrorMonitoringEvent>(event: E, hint?: unknown) => E | null | PromiseLike<E | null>;
693
+ /**
694
+ * Strips the query string and fragment from the page URL on transactions. Set only with
695
+ * `traceLifecycle: 'static'`: streamed spans, Sentry 11's default, send no transactions, and
696
+ * Sentry warns on every page load when the option is set without them.
697
+ */
698
+ beforeSendTransaction?: <E extends ErrorMonitoringEvent>(event: E, hint?: unknown) => E | null | PromiseLike<E | null>;
699
+ /** Strips queries and fragments from span URLs and resource span names, when tracing is on. */
700
+ beforeSendSpan: <S extends ErrorMonitoringSpan>(span: S) => S;
661
701
  [key: string]: unknown;
662
702
  }
663
703
 
704
+ /**
705
+ * An SDK integration, such as one of Sentry's default integrations.
706
+ * @public
707
+ */
708
+ export declare interface ErrorMonitoringIntegration {
709
+ name: string;
710
+ }
711
+
664
712
  /**
665
713
  * Severity of a monitoring event or breadcrumb.
666
714
  * @public
@@ -681,14 +729,30 @@ export declare interface ErrorMonitoringOptions {
681
729
  * and shared (`100.64.0.0/10`, as Tailscale uses) IP addresses, IPv4-mapped IPv6 included.
682
730
  */
683
731
  environment?: string | ErrorMonitoringEnvironmentResolver;
684
- /** Extra options merged into what the client's `init` receives, e.g. Sentry's `dataCollection`. */
732
+ /** Extra options for the client's `init`, combined with the defaults as each one describes. */
685
733
  initOptions?: ErrorMonitoringExtraInitOptions;
686
- /** Initialises the client in place of calling `client.init`. */
734
+ /**
735
+ * Initialises the client in place of calling `client.init`. Set `traceLifecycle` in
736
+ * `initOptions`, not here: the defaults for tracing depend on it.
737
+ */
687
738
  init?: (options: ErrorMonitoringInitOptions) => unknown;
688
739
  /** Records non-error foundation logs as breadcrumbs. Defaults to `true`. */
689
740
  breadcrumbs?: boolean;
690
741
  }
691
742
 
743
+ /**
744
+ * A tracing span about to be sent: its `attributes` when spans are streamed, or its `data` inside a
745
+ * transaction.
746
+ * @public
747
+ */
748
+ export declare interface ErrorMonitoringSpan {
749
+ name?: string;
750
+ description?: string;
751
+ op?: string;
752
+ attributes?: Record<string, unknown>;
753
+ data?: Record<string, unknown>;
754
+ }
755
+
692
756
  declare type EventListener_2<T = any> = (data: T) => void;
693
757
 
694
758
  /**
@@ -2480,12 +2544,18 @@ export declare type SetActivatedFeaturesOptions = {
2480
2544
  * @remarks
2481
2545
  * Without a DSN, or when no environment applies (by default on local hosts such as `localhost` or
2482
2546
  * a private IP address), it does nothing and resolves `false`. The environment defaults to the
2483
- * page's hostname, so one image promoted across environments reports each under its own name; pass
2484
- * a function to map hostnames to names such as `uat`. Otherwise it:
2547
+ * page's hostname, so one image promoted across environments reports each under its own name. To
2548
+ * use names such as `uat`, read one the deployment sets rather than listing hostnames, which would
2549
+ * show everyone who loads the bundle where the other environments are. Otherwise it:
2485
2550
  *
2486
- * - initialises the client (`client.init`, or `options.init`) with the DSN, environment, a
2487
- * `beforeBreadcrumb` that drops the SDK's console breadcrumbs for foundation logger output (they
2488
- * carry the logged arguments), and any `initOptions`;
2551
+ * - initialises the client (`client.init`, or `options.init`) with the DSN, the environment, any
2552
+ * `initOptions`, and defaults that keep page data out of what the SDK collects by itself: Sentry
2553
+ * 11's `dataCollection` off for user info, cookies, headers but `User-Agent`, bodies and URL
2554
+ * queries; only the default integrations that send nothing from the page (so not `Console`); no
2555
+ * console, click or input breadcrumbs; and no query strings or fragments in breadcrumb URLs, the
2556
+ * page URL, or span URLs and resource span names when tracing is on. The app's
2557
+ * `beforeBreadcrumb`, `beforeSend`, `beforeSendTransaction` and `beforeSendSpan` run after
2558
+ * these, and its `integrations` are added;
2489
2559
  * - registers a global log reporter ({@link createErrorMonitoringReporter}), so errors logged by
2490
2560
  * every foundation logger, including those Genesis packages create at import time, are reported,
2491
2561
  * and other logs become breadcrumbs. Only log messages and exceptions are sent, never logged data.
@@ -2510,7 +2580,8 @@ export declare type SetActivatedFeaturesOptions = {
2510
2580
  *
2511
2581
  * setupErrorMonitoring(Sentry, {
2512
2582
  * dsn: 'https://<key>@<org>.ingest.sentry.io/<project>',
2513
- * environment: ({ hostname }) => ({ 'app-uat.example.com': 'uat', 'app.example.com': 'prod' })[hostname],
2583
+ * environment: () =>
2584
+ * document.querySelector<HTMLMetaElement>('meta[name="error-monitoring-environment"]')?.content,
2514
2585
  * });
2515
2586
  * ```
2516
2587
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-utils",
3
3
  "description": "Genesis Foundation Utils",
4
- "version": "15.55.0",
4
+ "version": "15.57.0",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -29,17 +29,17 @@
29
29
  }
30
30
  },
31
31
  "devDependencies": {
32
- "@genesislcap/foundation-testing": "15.55.0",
33
- "@genesislcap/genx": "15.55.0",
34
- "@genesislcap/ts-builder": "15.55.0",
35
- "@genesislcap/uvu-playwright-builder": "15.55.0",
36
- "@genesislcap/vite-builder": "15.55.0",
37
- "@genesislcap/webpack-builder": "15.55.0",
32
+ "@genesislcap/foundation-testing": "15.57.0",
33
+ "@genesislcap/genx": "15.57.0",
34
+ "@genesislcap/ts-builder": "15.57.0",
35
+ "@genesislcap/uvu-playwright-builder": "15.57.0",
36
+ "@genesislcap/vite-builder": "15.57.0",
37
+ "@genesislcap/webpack-builder": "15.57.0",
38
38
  "@types/json-schema": "^7.0.11"
39
39
  },
40
40
  "dependencies": {
41
- "@genesislcap/expression-builder": "15.55.0",
42
- "@genesislcap/foundation-logger": "15.55.0",
41
+ "@genesislcap/expression-builder": "15.57.0",
42
+ "@genesislcap/foundation-logger": "15.57.0",
43
43
  "@microsoft/fast-components": "2.30.6",
44
44
  "@microsoft/fast-element": "1.14.0",
45
45
  "@microsoft/fast-foundation": "2.50.0",