lighthouse 13.6.0-dev.20261112 → 13.6.0-dev.20261116

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.
Files changed (98) hide show
  1. package/.agents/skills/update-ard-port/SKILL.md +1 -1
  2. package/cli/bin.js +8 -3
  3. package/cli/open-file.js +1 -1
  4. package/cli/printer.js +1 -1
  5. package/cli/run.js +4 -2
  6. package/cli/sentry-prompt.js +2 -1
  7. package/cli/test/smokehouse/frontends/smokehouse-bin.js +1 -1
  8. package/cli/test/smokehouse/lighthouse-runners/cli.js +1 -2
  9. package/cli/test/smokehouse/report-assert.js +1 -2
  10. package/cli/test/smokehouse/smokehouse.js +1 -2
  11. package/core/audits/autocomplete.js +1 -2
  12. package/core/audits/bootup-time.js +1 -2
  13. package/core/audits/errors-in-console.js +1 -2
  14. package/core/audits/mainthread-work-breakdown.js +1 -2
  15. package/core/audits/metrics.d.ts +2 -2
  16. package/core/audits/metrics.js +1 -1
  17. package/core/computed/computed-artifact.js +1 -2
  18. package/core/computed/entity-classification.d.ts +3 -3
  19. package/core/computed/entity-classification.js +5 -3
  20. package/core/computed/js-bundles.js +1 -2
  21. package/core/computed/load-simulator.d.ts +5 -3
  22. package/core/computed/load-simulator.js +9 -2
  23. package/core/computed/metrics/responsiveness.d.ts +5 -3
  24. package/core/computed/metrics/responsiveness.js +1 -1
  25. package/core/computed/metrics/time-to-first-byte.js +3 -1
  26. package/core/computed/metrics/timing-summary.d.ts +7 -5
  27. package/core/computed/metrics/timing-summary.js +3 -4
  28. package/core/computed/navigation-insights.d.ts +5 -3
  29. package/core/computed/navigation-insights.js +1 -1
  30. package/core/computed/network-analysis.js +1 -2
  31. package/core/computed/page-dependency-graph.d.ts +5 -3
  32. package/core/computed/page-dependency-graph.js +1 -1
  33. package/core/computed/trace-engine-result.d.ts +7 -5
  34. package/core/computed/trace-engine-result.js +9 -5
  35. package/core/computed/unused-css.d.ts +2 -2
  36. package/core/computed/unused-css.js +1 -1
  37. package/core/config/config.js +1 -2
  38. package/core/gather/base-artifacts.js +1 -2
  39. package/core/gather/driver/environment.js +1 -2
  40. package/core/gather/driver/navigation.js +1 -2
  41. package/core/gather/driver/network-monitor.js +1 -2
  42. package/core/gather/driver/prepare.js +1 -2
  43. package/core/gather/driver/storage.js +1 -2
  44. package/core/gather/driver/target-manager.js +1 -2
  45. package/core/gather/driver/wait-for-condition.js +1 -2
  46. package/core/gather/driver.js +1 -2
  47. package/core/gather/gatherers/agentic/ard.js +1 -1
  48. package/core/gather/gatherers/agentic/llms-txt.js +1 -2
  49. package/core/gather/gatherers/image-elements.js +1 -2
  50. package/core/gather/gatherers/seo/robots-txt.js +1 -2
  51. package/core/gather/gatherers/stacks.js +1 -2
  52. package/core/gather/gatherers/stylesheets.js +1 -2
  53. package/core/gather/navigation-runner.js +1 -1
  54. package/core/gather/runner-helpers.js +1 -2
  55. package/core/gather/session.js +1 -2
  56. package/core/gather/snapshot-runner.js +1 -2
  57. package/core/gather/timespan-runner.js +1 -2
  58. package/core/lib/asset-saver.js +1 -2
  59. package/core/lib/csp-evaluator.js +1 -1
  60. package/core/lib/i18n/i18n.js +1 -2
  61. package/core/lib/lighthouse-logger.d.ts +127 -0
  62. package/core/lib/lighthouse-logger.js +319 -0
  63. package/core/lib/median-run.d.ts +16 -6
  64. package/core/lib/median-run.js +13 -6
  65. package/core/lib/network-recorder.js +1 -2
  66. package/core/lib/network-request.d.ts +2 -2
  67. package/core/lib/network-request.js +1 -1
  68. package/core/lib/page-functions.js +2 -2
  69. package/core/lib/script-helpers.d.ts +23 -8
  70. package/core/lib/script-helpers.js +7 -6
  71. package/core/lib/sentry-reporter.d.ts +59 -0
  72. package/core/lib/sentry-reporter.js +281 -0
  73. package/core/lib/sentry.d.ts +7 -7
  74. package/core/lib/sentry.js +23 -40
  75. package/core/lib/stack-packs.js +1 -1
  76. package/core/lib/timing-trace-saver.d.ts +2 -2
  77. package/core/lib/timing-trace-saver.js +1 -1
  78. package/core/lib/tracehouse/task-summary.d.ts +16 -4
  79. package/core/lib/tracehouse/task-summary.js +6 -5
  80. package/core/lib/tracehouse/trace-processor.d.ts +6 -6
  81. package/core/lib/tracehouse/trace-processor.js +1 -1
  82. package/core/lib/traces/metric-trace-events.js +1 -2
  83. package/core/lib/url-utils.d.ts +4 -4
  84. package/core/lib/url-utils.js +1 -1
  85. package/core/runner.js +1 -2
  86. package/dist/report/bundle.esm.js +10 -10
  87. package/dist/report/flow.js +12 -12
  88. package/dist/report/standalone.js +11 -11
  89. package/package.json +2 -4
  90. package/report/renderer/text-encoding.d.ts +3 -5
  91. package/report/renderer/text-encoding.js +19 -33
  92. package/report/types/augment-dom.d.ts +0 -4
  93. package/third-party/ard/README.md +1 -1
  94. package/third-party/ard/ard.js +1 -1
  95. package/tsconfig.json +2 -42
  96. package/types/artifacts.d.ts +7 -1
  97. package/types/internal/test.d.ts +5 -0
  98. package/report/types/buffer.d.ts +0 -19
@@ -0,0 +1,281 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ /**
8
+ * A minimal Sentry client that sends events with `fetch` using Sentry's envelope protocol.
9
+ * See https://develop.sentry.dev/sdk/data-model/envelopes/
10
+ */
11
+
12
+ import os from 'os';
13
+ import path from 'path';
14
+ import {types} from 'util';
15
+
16
+ import log from './lighthouse-logger.js';
17
+
18
+ /** @typedef {'fatal'|'error'|'warning'|'log'|'info'|'debug'} SeverityLevel */
19
+ /** @typedef {{message?: string, category?: string, level?: SeverityLevel, data?: Record<string, any>, timestamp?: number}} Breadcrumb */
20
+ /** @typedef {{release?: string, environment?: string, serverName?: string}} EnvironmentData */
21
+ /** @typedef {{level?: SeverityLevel, tags?: Record<string, any>, extra?: Record<string, any>, fingerprint?: string[]}} CaptureOptions */
22
+
23
+ const MAX_BREADCRUMBS = 100;
24
+ const MAX_FRAMES = 50;
25
+ const MAX_LINKED_ERRORS = 5;
26
+ const SEND_TIMEOUT_MS = 5000;
27
+ const DEFAULT_RETRY_AFTER_S = 60;
28
+
29
+ // Same as @sentry/node's stack line parser so frames (and issue grouping) stay similar.
30
+ const FRAME_RE = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;
31
+
32
+ /**
33
+ * Same as @sentry/core: drop any Windows drive letter and use forward slashes.
34
+ * @param {string} p
35
+ */
36
+ function normalizePath(p) {
37
+ return p.replace(/^[A-Za-z]:/, '').replace(/\\/g, '/');
38
+ }
39
+
40
+ const BASE_PATH = normalizePath(process.argv[1] ? path.dirname(process.argv[1]) : process.cwd());
41
+
42
+ /**
43
+ * Same as @sentry/node's module naming, e.g. `core.lib:sentry` or `puppeteer-core.lib:foo`.
44
+ * @param {string} filename
45
+ */
46
+ function getModule(filename) {
47
+ const {dir, name} = path.posix.parse(normalizePath(filename));
48
+ const nodeModulesIndex = dir.lastIndexOf('/node_modules');
49
+ if (nodeModulesIndex > -1) {
50
+ return `${dir.slice(nodeModulesIndex + 14).replace(/\//g, '.')}:${name}`;
51
+ }
52
+ if (dir === BASE_PATH || dir.startsWith(`${BASE_PATH}/`)) {
53
+ const moduleName = dir.slice(BASE_PATH.length + 1).replace(/\//g, '.');
54
+ return moduleName ? `${moduleName}:${name}` : name;
55
+ }
56
+ return name;
57
+ }
58
+
59
+ /**
60
+ * Parses a V8 stack into Sentry frames, oldest call first.
61
+ * @param {unknown} stack
62
+ */
63
+ function parseStack(stack) {
64
+ if (typeof stack !== 'string') return [];
65
+
66
+ const frames = [];
67
+ const lines = stack.split('\n').filter(line => /^\s+at /.test(line)).slice(0, MAX_FRAMES);
68
+ for (const line of lines) {
69
+ const match = FRAME_RE.exec(line);
70
+ if (!match) continue;
71
+
72
+ let filename = match[2] || match[5];
73
+ if (filename.startsWith('file://')) {
74
+ filename = filename.slice(7);
75
+ // `file:///C:/foo.js` -> `C:/foo.js`
76
+ if (/^\/[A-Za-z]:/.test(filename)) filename = filename.slice(1);
77
+ try {
78
+ filename = decodeURI(filename);
79
+ } catch {}
80
+ }
81
+ const slashFilename = filename.replace(/\\/g, '/');
82
+ const isAbsolute = slashFilename.startsWith('/') || /^[A-Za-z]:\//.test(slashFilename);
83
+ const inApp = isAbsolute && !slashFilename.includes('/node_modules/');
84
+
85
+ frames.push({
86
+ filename,
87
+ module: getModule(filename),
88
+ function: match[1] || '<anonymous>',
89
+ lineno: match[3] ? Number(match[3]) : undefined,
90
+ colno: match[4] ? Number(match[4]) : undefined,
91
+ in_app: inApp,
92
+ });
93
+ }
94
+ return frames.reverse();
95
+ }
96
+
97
+ /**
98
+ * @param {unknown} value
99
+ * @return {value is Error}
100
+ */
101
+ function isError(value) {
102
+ // `isNativeError` also handles errors from other realms (e.g. `vm` contexts).
103
+ return value instanceof Error || types.isNativeError(value);
104
+ }
105
+
106
+ /**
107
+ * @param {unknown} err
108
+ */
109
+ function exceptionValues(err) {
110
+ const values = [];
111
+ /** @type {unknown} */
112
+ let current = err;
113
+ while (isError(current) && values.length < MAX_LINKED_ERRORS) {
114
+ values.push({
115
+ type: current.name,
116
+ value: current.message,
117
+ mechanism: {type: 'generic', handled: true},
118
+ stacktrace: {frames: parseStack(current.stack)},
119
+ });
120
+ current = current.cause;
121
+ }
122
+ // Non-Error throwables (strings, plain objects, ...).
123
+ if (!values.length) {
124
+ const message = err && typeof err === 'object' && 'message' in err ? err.message : err;
125
+ values.push({
126
+ type: 'Error',
127
+ value: String(message),
128
+ mechanism: {type: 'generic', handled: true},
129
+ });
130
+ }
131
+ // Sentry expects the root cause first, and the captured error last.
132
+ return values.reverse();
133
+ }
134
+
135
+ /**
136
+ * A JSON.stringify replacer that handles values that would otherwise throw or be lost.
137
+ * Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value
138
+ */
139
+ function safeJsonReplacer() {
140
+ /** @type {unknown[]} */
141
+ const ancestors = [];
142
+ /**
143
+ * @this {unknown}
144
+ * @param {string} key
145
+ * @param {unknown} value
146
+ */
147
+ return function(key, value) {
148
+ if (typeof value === 'bigint') return String(value);
149
+ if (value instanceof Error) {
150
+ value = {name: value.name, message: value.message, stack: value.stack};
151
+ }
152
+ if (typeof value !== 'object' || value === null) return value;
153
+
154
+ while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this) ancestors.pop();
155
+ if (ancestors.includes(value)) return '[Circular]';
156
+ ancestors.push(value);
157
+ return value;
158
+ };
159
+ }
160
+
161
+ /**
162
+ * @param {string} dsn
163
+ * @param {EnvironmentData=} environmentData
164
+ */
165
+ function createSentryReporter(dsn, environmentData = {}) {
166
+ const sdkVersion = environmentData.release || 'unknown';
167
+ const {protocol, username: publicKey, host, pathname} = new URL(dsn);
168
+ const endpoint = `${protocol}//${host}/api/${pathname.slice(1)}/envelope/`;
169
+ const auth = `Sentry sentry_version=7, sentry_key=${publicKey}, ` +
170
+ `sentry_client=lighthouse/${sdkVersion}`;
171
+
172
+ /** @type {Record<string, any>} */
173
+ const tags = {};
174
+ /** @type {Record<string, any>} */
175
+ const extra = {};
176
+ /** @type {Record<string, any>} */
177
+ const contexts = {
178
+ os: {name: os.type(), version: os.release()},
179
+ runtime: {name: 'node', version: process.version},
180
+ };
181
+ /** @type {Breadcrumb[]} */
182
+ const breadcrumbs = [];
183
+ // Set when Sentry rate limits us (HTTP 429); nothing is sent until then.
184
+ let disabledUntil = 0;
185
+
186
+ /**
187
+ * Never throws: a failure to report an error must not affect Lighthouse.
188
+ * @param {() => Record<string, any>} getEvent
189
+ * @param {CaptureOptions} opts
190
+ * @return {Promise<void>}
191
+ */
192
+ async function send(getEvent, opts) {
193
+ if (Date.now() < disabledUntil) return;
194
+
195
+ try {
196
+ const eventId = crypto.randomUUID().replace(/-/g, '');
197
+ const fullEvent = {
198
+ event_id: eventId,
199
+ timestamp: Date.now() / 1000,
200
+ platform: 'node',
201
+ level: opts.level,
202
+ release: environmentData.release,
203
+ environment: environmentData.environment,
204
+ server_name: environmentData.serverName,
205
+ tags: {...tags, ...opts.tags},
206
+ extra: {...extra, ...opts.extra},
207
+ contexts,
208
+ breadcrumbs,
209
+ fingerprint: opts.fingerprint,
210
+ sdk: {name: 'lighthouse', version: sdkVersion},
211
+ ...getEvent(),
212
+ };
213
+ const envelope = [
214
+ JSON.stringify({event_id: eventId, sent_at: new Date().toISOString()}),
215
+ JSON.stringify({type: 'event'}),
216
+ JSON.stringify(fullEvent, safeJsonReplacer()),
217
+ ].join('\n');
218
+
219
+ const response = await fetch(endpoint, {
220
+ method: 'POST',
221
+ headers: {'Content-Type': 'application/x-sentry-envelope', 'X-Sentry-Auth': auth},
222
+ body: envelope,
223
+ signal: AbortSignal.timeout(SEND_TIMEOUT_MS),
224
+ });
225
+ await response.body?.cancel();
226
+ if (!response.ok) log.verbose('sentry', `Failed to send event: HTTP ${response.status}`);
227
+ if (response.status === 429) {
228
+ const retryAfter = Number(response.headers.get('Retry-After'));
229
+ const seconds = retryAfter > 0 ? retryAfter : DEFAULT_RETRY_AFTER_S;
230
+ disabledUntil = Date.now() + seconds * 1000;
231
+ }
232
+ } catch (err) {
233
+ log.verbose('sentry', `Failed to send event: ${err}`);
234
+ }
235
+ }
236
+
237
+ return {
238
+ /** @param {Record<string, any>} newTags */
239
+ setTags(newTags) {
240
+ Object.assign(tags, newTags);
241
+ },
242
+ /** @param {Record<string, any>} newExtras */
243
+ setExtras(newExtras) {
244
+ Object.assign(extra, newExtras);
245
+ },
246
+ /**
247
+ * @param {string} name
248
+ * @param {Record<string, any>|null} context
249
+ */
250
+ setContext(name, context) {
251
+ if (context) contexts[name] = context;
252
+ else delete contexts[name];
253
+ },
254
+ /** @param {Breadcrumb} breadcrumb */
255
+ addBreadcrumb(breadcrumb) {
256
+ breadcrumbs.push({timestamp: Date.now() / 1000, ...breadcrumb});
257
+ if (breadcrumbs.length > MAX_BREADCRUMBS) breadcrumbs.shift();
258
+ },
259
+ /**
260
+ * @param {string} message
261
+ * @param {SeverityLevel|CaptureOptions=} levelOrOpts
262
+ */
263
+ captureMessage(message, levelOrOpts) {
264
+ const opts = typeof levelOrOpts === 'string' ? {level: levelOrOpts} : levelOrOpts;
265
+ return send(() => ({message}), {...opts, level: opts?.level || 'info'});
266
+ },
267
+ /**
268
+ * @param {unknown} err
269
+ * @param {CaptureOptions=} opts
270
+ */
271
+ captureException(err, opts) {
272
+ const getEvent = () => ({exception: {values: exceptionValues(err)}});
273
+ return send(getEvent, {...opts, level: opts?.level || 'error'});
274
+ },
275
+ };
276
+ }
277
+
278
+ export {
279
+ createSentryReporter,
280
+ parseStack,
281
+ };
@@ -1,6 +1,6 @@
1
1
  export namespace Sentry {
2
2
  export { init };
3
- export { noop as captureMessage };
3
+ export let captureMessage: (message: string, levelOrOpts?: SeverityLevel | CaptureOptions) => Promise<void>;
4
4
  export { noop as captureBreadcrumb };
5
5
  export { noop as getContext };
6
6
  export { noop as setContext };
@@ -15,19 +15,19 @@ export namespace Sentry {
15
15
  }) => Promise<void>;
16
16
  export function _shouldSample(): boolean;
17
17
  }
18
- export type Breadcrumb = import("@sentry/node").Breadcrumb;
19
- export type NodeClient = import("@sentry/node").NodeClient;
20
- export type NodeOptions = import("@sentry/node").NodeOptions;
21
- export type SeverityLevel = import("@sentry/node").SeverityLevel;
18
+ export type Breadcrumb = import("./sentry-reporter.js").Breadcrumb;
19
+ export type EnvironmentData = import("./sentry-reporter.js").EnvironmentData;
20
+ export type SeverityLevel = import("./sentry-reporter.js").SeverityLevel;
21
+ export type CaptureOptions = import("./sentry-reporter.js").CaptureOptions;
22
22
  /**
23
23
  * When called, replaces noops with actual Sentry implementation.
24
- * @param {{url: string, flags: LH.CliFlags, config?: LH.Config, environmentData: NodeOptions}} opts
24
+ * @param {{url: string, flags: LH.CliFlags, config?: LH.Config, environmentData: EnvironmentData}} opts
25
25
  */
26
26
  declare function init(opts: {
27
27
  url: string;
28
28
  flags: LH.CliFlags;
29
29
  config?: LH.Config;
30
- environmentData: NodeOptions;
30
+ environmentData: EnvironmentData;
31
31
  }): Promise<void>;
32
32
  declare function noop(): void;
33
33
  export {};
@@ -4,14 +4,13 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import log from 'lighthouse-logger';
8
-
7
+ import log from './lighthouse-logger.js';
9
8
  import {initializeConfig} from '../config/config.js';
10
9
 
11
- /** @typedef {import('@sentry/node').Breadcrumb} Breadcrumb */
12
- /** @typedef {import('@sentry/node').NodeClient} NodeClient */
13
- /** @typedef {import('@sentry/node').NodeOptions} NodeOptions */
14
- /** @typedef {import('@sentry/node').SeverityLevel} SeverityLevel */
10
+ /** @typedef {import('./sentry-reporter.js').Breadcrumb} Breadcrumb */
11
+ /** @typedef {import('./sentry-reporter.js').EnvironmentData} EnvironmentData */
12
+ /** @typedef {import('./sentry-reporter.js').SeverityLevel} SeverityLevel */
13
+ /** @typedef {import('./sentry-reporter.js').CaptureOptions} CaptureOptions */
15
14
 
16
15
  const SENTRY_URL = 'https://a6bb0da87ee048cc9ae2a345fc09ab2e:63a7029f46f74265981b7e005e0f69f8@sentry.io/174697';
17
16
 
@@ -26,8 +25,8 @@ const noop = () => { };
26
25
  */
27
26
  const sentryDelegate = {
28
27
  init,
29
- /** @type {(message: string, level?: SeverityLevel) => void} */
30
- captureMessage: noop,
28
+ /** @type {(message: string, levelOrOpts?: SeverityLevel|CaptureOptions) => Promise<void>} */
29
+ captureMessage: async () => { },
31
30
  /** @type {(breadcrumb: Breadcrumb) => void} */
32
31
  captureBreadcrumb: noop,
33
32
  /** @type {() => any} */
@@ -43,7 +42,7 @@ const sentryDelegate = {
43
42
 
44
43
  /**
45
44
  * When called, replaces noops with actual Sentry implementation.
46
- * @param {{url: string, flags: LH.CliFlags, config?: LH.Config, environmentData: NodeOptions}} opts
45
+ * @param {{url: string, flags: LH.CliFlags, config?: LH.Config, environmentData: EnvironmentData}} opts
47
46
  */
48
47
  async function init(opts) {
49
48
  // If error reporting is disabled, leave the functions as a noop
@@ -57,11 +56,8 @@ async function init(opts) {
57
56
  }
58
57
 
59
58
  try {
60
- const Sentry = await import('@sentry/node');
61
- Sentry.init({
62
- ...opts.environmentData,
63
- dsn: SENTRY_URL,
64
- });
59
+ const {createSentryReporter} = await import('./sentry-reporter.js');
60
+ const Sentry = createSentryReporter(SENTRY_URL, opts.environmentData);
65
61
 
66
62
  /** @type {LH.Config.Settings | LH.CliFlags} */
67
63
  let settings = opts.flags;
@@ -95,15 +91,16 @@ async function init(opts) {
95
91
  // Keep a record of exceptions per audit/gatherer so we can just report once
96
92
  const sentryExceptionCache = new Map();
97
93
  // Special case captureException to return a Promise so we don't process.exit too early
98
- sentryDelegate.captureException = async (err, opts = {}) => {
94
+ sentryDelegate.captureException = async (err, opts) => {
99
95
  // Ignore if there wasn't an error
100
96
  if (!err) return;
97
+ opts = opts || {};
101
98
 
102
99
  // Ignore expected errors
103
100
  // @ts-expect-error Non-standard property added to flag error as not needing capturing.
104
101
  if (err.expected) return;
105
102
 
106
- const tags = opts.tags || {};
103
+ const tags = {...opts.tags};
107
104
  if (tags.audit) {
108
105
  const key = `audit-${tags.audit}-${err.message}`;
109
106
  if (sentryExceptionCache.has(key)) return;
@@ -128,33 +125,19 @@ async function init(opts) {
128
125
  // @ts-expect-error - properties added to protocol method LighthouseErrors.
129
126
  fingerprint = ['{{ default }}', err.protocolMethod, protocolError];
130
127
 
131
- opts.tags = opts.tags || {};
132
128
  // @ts-expect-error - properties added to protocol method LighthouseErrors.
133
- opts.tags.protocolMethod = err.protocolMethod;
129
+ tags.protocolMethod = err.protocolMethod;
134
130
  }
135
131
 
136
- Sentry.withScope(scope => {
137
- if (opts.level) {
138
- // @ts-expect-error - allow any string.
139
- scope.setLevel(opts.level);
140
- }
141
- if (opts.tags) {
142
- scope.setTags(opts.tags);
143
- }
144
- if (fingerprint) {
145
- scope.setFingerprint(fingerprint);
146
- }
147
-
148
- // Add extra details
149
- let extra;
150
- if (opts.extra) extra = {...opts.extra};
151
- // @ts-expect-error Non-standard property
152
- if (err.extra) extra = {...extra, ...err.extra};
153
- if (extra) {
154
- scope.setExtras(extra);
155
- }
156
-
157
- Sentry.captureException(err);
132
+ // @ts-expect-error Non-standard property
133
+ const extra = {...opts.extra, ...err.extra};
134
+
135
+ await Sentry.captureException(err, {
136
+ // @ts-expect-error - allow any string.
137
+ level: opts.level,
138
+ tags,
139
+ extra,
140
+ fingerprint,
158
141
  });
159
142
  };
160
143
  } catch (e) {
@@ -4,9 +4,9 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import log from 'lighthouse-logger';
8
7
  import stackPacks from 'lighthouse-stack-packs';
9
8
 
9
+ import log from './lighthouse-logger.js';
10
10
  import * as i18n from './i18n/i18n.js';
11
11
 
12
12
  /**
@@ -14,8 +14,8 @@
14
14
  export function generateTraceEvents(entries: LH.Artifacts.MeasureEntry[], threadId?: number | undefined): import("..").TraceEvent[];
15
15
  /**
16
16
  * Writes a trace file to disk
17
- * @param {LH.Result} lhr
17
+ * @param {Pick<LH.Result, 'timing'>} lhr
18
18
  * @return {string}
19
19
  */
20
- export function createTraceString(lhr: LH.Result): string;
20
+ export function createTraceString(lhr: Pick<LH.Result, "timing">): string;
21
21
  //# sourceMappingURL=timing-trace-saver.d.ts.map
@@ -75,7 +75,7 @@ function generateTraceEvents(entries, threadId = 0) {
75
75
 
76
76
  /**
77
77
  * Writes a trace file to disk
78
- * @param {LH.Result} lhr
78
+ * @param {Pick<LH.Result, 'timing'>} lhr
79
79
  * @return {string}
80
80
  */
81
81
  function createTraceString(lhr) {
@@ -3,15 +3,27 @@
3
3
  */
4
4
  export function getJavaScriptURLs(records: LH.Artifacts.NetworkRequest[]): Set<string>;
5
5
  /**
6
- * @param {LH.Artifacts.TaskNode} task
6
+ * @param {{attributableURLs: string[], event?: {name: string}}} task
7
7
  * @param {Set<string>} jsURLs
8
8
  * @return {string}
9
9
  */
10
- export function getAttributableURLForTask(task: LH.Artifacts.TaskNode, jsURLs: Set<string>): string;
10
+ export function getAttributableURLForTask(task: {
11
+ attributableURLs: string[];
12
+ event?: {
13
+ name: string;
14
+ };
15
+ }, jsURLs: Set<string>): string;
11
16
  /**
12
- * @param {LH.Artifacts.TaskNode[]} tasks
17
+ * @param {Array<{attributableURLs: string[], selfTime: number, group: LH.Artifacts.TaskNode['group'], event?: {name: string}}>} tasks
13
18
  * @param {Array<LH.Artifacts.NetworkRequest>} networkRecords
14
19
  * @return {Map<string, Record<string, number>>}
15
20
  */
16
- export function getExecutionTimingsByURL(tasks: LH.Artifacts.TaskNode[], networkRecords: Array<LH.Artifacts.NetworkRequest>): Map<string, Record<string, number>>;
21
+ export function getExecutionTimingsByURL(tasks: Array<{
22
+ attributableURLs: string[];
23
+ selfTime: number;
24
+ group: LH.Artifacts.TaskNode["group"];
25
+ event?: {
26
+ name: string;
27
+ };
28
+ }>, networkRecords: Array<LH.Artifacts.NetworkRequest>): Map<string, Record<string, number>>;
17
29
  //# sourceMappingURL=task-summary.d.ts.map
@@ -38,7 +38,7 @@ function getJavaScriptURLs(records) {
38
38
  }
39
39
 
40
40
  /**
41
- * @param {LH.Artifacts.TaskNode} task
41
+ * @param {{attributableURLs: string[], event?: {name: string}}} task
42
42
  * @param {Set<string>} jsURLs
43
43
  * @return {string}
44
44
  */
@@ -49,16 +49,17 @@ function getAttributableURLForTask(task, jsURLs) {
49
49
  // If we can't find what URL was responsible for this execution, attribute it to the root page
50
50
  // or Chrome depending on the type of work.
51
51
  if (!attributableURL || attributableURL === 'about:blank') {
52
- if (BROWSER_TASK_NAMES_SET.has(task.event.name)) attributableURL = 'Browser';
53
- else if (BROWSER_GC_TASK_NAMES_SET.has(task.event.name)) attributableURL = 'Browser GC';
54
- else attributableURL = 'Unattributable';
52
+ if (task.event && BROWSER_TASK_NAMES_SET.has(task.event.name)) attributableURL = 'Browser';
53
+ else if (task.event && BROWSER_GC_TASK_NAMES_SET.has(task.event.name)) {
54
+ attributableURL = 'Browser GC';
55
+ } else attributableURL = 'Unattributable';
55
56
  }
56
57
 
57
58
  return attributableURL;
58
59
  }
59
60
 
60
61
  /**
61
- * @param {LH.Artifacts.TaskNode[]} tasks
62
+ * @param {Array<{attributableURLs: string[], selfTime: number, group: LH.Artifacts.TaskNode['group'], event?: {name: string}}>} tasks
62
63
  * @param {Array<LH.Artifacts.NetworkRequest>} networkRecords
63
64
  * @return {Map<string, Record<string, number>>}
64
65
  */
@@ -91,7 +91,7 @@ export class TraceProcessor {
91
91
  * @param {LH.TraceEvent[]} traceEvents
92
92
  * @param {(e: LH.TraceEvent) => boolean} filter
93
93
  */
94
- static filteredTraceSort(traceEvents: LH.TraceEvent[], filter: (e: LH.TraceEvent) => boolean): import("../..").TraceEvent[];
94
+ static filteredTraceSort(traceEvents: LH.TraceEvent[], filter: (e: LH.TraceEvent) => boolean): import("../../index.js").TraceEvent[];
95
95
  /**
96
96
  * There should *always* be at least one top level event, having 0 typically means something is
97
97
  * drastically wrong with the trace and we should just give up early and loudly.
@@ -283,12 +283,12 @@ export class TraceProcessor {
283
283
  }): {
284
284
  timings: TraceNavigationTimesForFrame;
285
285
  timestamps: TraceNavigationTimesForFrame;
286
- timeOriginEvt: import("../..").TraceEvent;
287
- firstPaintEvt: import("../..").TraceEvent | undefined;
288
- firstContentfulPaintEvt: import("../..").TraceEvent;
286
+ timeOriginEvt: import("../../index.js").TraceEvent;
287
+ firstPaintEvt: import("../../index.js").TraceEvent | undefined;
288
+ firstContentfulPaintEvt: import("../../index.js").TraceEvent;
289
289
  largestContentfulPaintEvt: LCPEvent | undefined;
290
- loadEvt: import("../..").TraceEvent | undefined;
291
- domContentLoadedEvt: import("../..").TraceEvent | undefined;
290
+ loadEvt: import("../../index.js").TraceEvent | undefined;
291
+ domContentLoadedEvt: import("../../index.js").TraceEvent | undefined;
292
292
  lcpInvalidated: boolean;
293
293
  lcpImageUrl: string | undefined;
294
294
  };
@@ -21,7 +21,7 @@
21
21
  /** @typedef {Omit<LH.TraceEvent, 'name'|'args'> & {name: 'largestContentfulPaint::Invalidate'|'largestContentfulPaint::Candidate', args: {data?: {size?: number, nodeId?: number, type?: string}, frame: string}}} LCPEvent */
22
22
  /** @typedef {Omit<LH.TraceEvent, 'name'|'args'> & {name: 'largestContentfulPaint::Candidate', args: {data: {size: number, nodeId?: number, type?: string}, frame: string}}} LCPCandidateEvent */
23
23
 
24
- import log from 'lighthouse-logger';
24
+ import log from '../lighthouse-logger.js';
25
25
 
26
26
  const ACCEPTABLE_NAVIGATION_URL_REGEX = /^(chrome|https?):/;
27
27
 
@@ -4,8 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import log from 'lighthouse-logger';
8
-
7
+ import log from '../lighthouse-logger.js';
9
8
  import {TraceProcessor} from '../tracehouse/trace-processor.js';
10
9
 
11
10
  /**
@@ -38,13 +38,13 @@ declare class UrlUtils {
38
38
  static rootDomainsMatch(urlA: string | URL, urlB: string | URL): boolean;
39
39
  /**
40
40
  * @param {string} url
41
- * @param {{numPathParts: number, preserveQuery: boolean, preserveHost: boolean}=} options
41
+ * @param {{numPathParts?: number, preserveQuery?: boolean, preserveHost?: boolean}=} options
42
42
  * @return {string}
43
43
  */
44
44
  static getURLDisplayName(url: string, options?: {
45
- numPathParts: number;
46
- preserveQuery: boolean;
47
- preserveHost: boolean;
45
+ numPathParts?: number;
46
+ preserveQuery?: boolean;
47
+ preserveHost?: boolean;
48
48
  } | undefined): string;
49
49
  /**
50
50
  * Limits data URIs to 100 characters, returns all other strings untouched.
@@ -140,7 +140,7 @@ class UrlUtils {
140
140
 
141
141
  /**
142
142
  * @param {string} url
143
- * @param {{numPathParts: number, preserveQuery: boolean, preserveHost: boolean}=} options
143
+ * @param {{numPathParts?: number, preserveQuery?: boolean, preserveHost?: boolean}=} options
144
144
  * @return {string}
145
145
  */
146
146
  static getURLDisplayName(url, options) {
package/core/runner.js CHANGED
@@ -8,8 +8,7 @@ import fs from 'fs';
8
8
  import path from 'path';
9
9
 
10
10
 
11
- import log from 'lighthouse-logger';
12
-
11
+ import log from './lib/lighthouse-logger.js';
13
12
  import {ReportScoring} from './scoring.js';
14
13
  import {Audit} from './audits/audit.js';
15
14
  import * as format from '../shared/localization/format.js';