@scrymore/scry-deployer 0.6.1 → 0.7.0-next.20260926193255

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/lib/coverage.js CHANGED
@@ -12,8 +12,90 @@ const chalk = require('chalk');
12
12
  * @property {boolean} [keepReport=false] If true, do not delete the output file after reading
13
13
  * @property {boolean} [screenshots=false] Enable passing-story screenshots in scry-sbcov
14
14
  * @property {string|null} [outputZipPath=null] Where to write metadata+screenshots ZIP
15
+ * @property {'root'|'viewport'} [captureMode] Screenshot framing forwarded as --capture-mode
16
+ * @property {number|string} [captureScale] Device scale factor (0 < n <= 4) forwarded as --capture-scale
17
+ * @property {string|{width:number,height:number}} [captureViewport] "WxH" or {width,height}, forwarded as --capture-viewport
18
+ * @property {number|string} [maxDropped] Forwarded as --max-dropped: sbcov exits 3 when more stories than this were dropped.
19
+ * Unset: with screenshots on, the deployer passes --max-dropped 0 (any dropped story ends the
20
+ * deploy red, after the rest are uploaded) when the installed scry-sbcov supports the flag.
15
21
  */
16
22
 
23
+ /**
24
+ * What a non-zero scry-sbcov exit means. The contract with scry-sbcov (#51):
25
+ * 2 = the capture config is broken, misspelt or unknown and no archive was
26
+ * written; 3 = more stories were dropped than --max-dropped allows, and the
27
+ * archive of the stories that did capture WAS written.
28
+ *
29
+ * @param {number|null} code
30
+ * @param {string|null} signal
31
+ * @returns {string}
32
+ */
33
+ function describeSbcovExit(code, signal) {
34
+ if (code === 2) return 'scry-sbcov rejected the capture config (exit 2)';
35
+ if (code === 3) return 'scry-sbcov dropped more stories than --max-dropped allows (exit 3)';
36
+ if (signal) return `scry-sbcov was killed by ${signal}`;
37
+ if (code === 127) return 'scry-sbcov could not be started (exit 127, command not found)';
38
+ if (code === null || code === undefined) return 'scry-sbcov could not be run';
39
+ return `scry-sbcov exited with code ${code}`;
40
+ }
41
+
42
+ const CAPTURE_MODES = ['root', 'viewport'];
43
+
44
+ /**
45
+ * Turn a project's capture settings into scry-sbcov flags.
46
+ *
47
+ * Only settings the project actually set are forwarded: an unset value is left
48
+ * to scry-sbcov, so its own defaults and any scry-sbcov.config.* in the project
49
+ * still apply. Every value is validated to a fixed shape (enum, bounded number,
50
+ * WxH integers) before it gets near a shell command; anything else throws.
51
+ *
52
+ * @param {{captureMode?:any, captureScale?:any, captureViewport?:any}} [settings]
53
+ * @returns {string[]}
54
+ */
55
+ function buildCaptureArgs(settings = {}) {
56
+ const { captureMode, captureScale, captureViewport } = settings || {};
57
+ const args = [];
58
+ const isSet = (v) => v !== undefined && v !== null && v !== '';
59
+
60
+ if (isSet(captureMode)) {
61
+ if (typeof captureMode !== 'string' || !CAPTURE_MODES.includes(captureMode)) {
62
+ throw new Error(`Invalid captureMode ${JSON.stringify(captureMode)}: expected "root" or "viewport"`);
63
+ }
64
+ args.push('--capture-mode', captureMode);
65
+ }
66
+
67
+ if (isSet(captureScale)) {
68
+ const text = String(captureScale).trim();
69
+ const n = Number(text);
70
+ if (!/^\d+(\.\d+)?$/.test(text) || !(n > 0) || n > 4) {
71
+ throw new Error(`Invalid captureScale ${JSON.stringify(captureScale)}: expected a number in (0, 4]`);
72
+ }
73
+ args.push('--capture-scale', String(n));
74
+ }
75
+
76
+ if (isSet(captureViewport)) {
77
+ let width;
78
+ let height;
79
+ if (typeof captureViewport === 'string') {
80
+ const m = /^\s*(\d{1,5})\s*[xX]\s*(\d{1,5})\s*$/.exec(captureViewport);
81
+ if (m) {
82
+ width = Number(m[1]);
83
+ height = Number(m[2]);
84
+ }
85
+ } else if (typeof captureViewport === 'object') {
86
+ width = captureViewport.width;
87
+ height = captureViewport.height;
88
+ }
89
+ const ok = (v) => Number.isInteger(v) && v >= 1 && v <= 10000;
90
+ if (!ok(width) || !ok(height)) {
91
+ throw new Error(`Invalid captureViewport ${JSON.stringify(captureViewport)}: expected "WIDTHxHEIGHT" or { width, height } in whole CSS px`);
92
+ }
93
+ args.push('--capture-viewport', `${width}x${height}`);
94
+ }
95
+
96
+ return args;
97
+ }
98
+
17
99
  /**
18
100
  * Run Storybook coverage analysis via `@scrymore/scry-sbcov`.
19
101
  *
@@ -23,11 +105,14 @@ const chalk = require('chalk');
23
105
  * - Reads and returns the parsed JSON report
24
106
  * - Deletes the temporary report file
25
107
  *
26
- * If the underlying tool fails and `failOnThreshold` is false, returns
27
- * `{ report: null, metadataZipPath: null }`.
108
+ * If the underlying tool exits non-zero it is no longer swallowed: the result
109
+ * carries `sbcovFailure: {exitCode, signal, reason}`, plus whatever report and
110
+ * archive sbcov did write (exit 3 writes both). The caller decides the exit
111
+ * code. With `failOnThreshold` a failure other than exit 3 is rethrown, as
112
+ * before.
28
113
  *
29
114
  * @param {RunCoverageOptions} options
30
- * @returns {Promise<{report:any|null, metadataZipPath:string|null}>}
115
+ * @returns {Promise<{report:any|null, metadataZipPath:string|null, sbcovFailure:null|{exitCode:number|null, signal:string|null, reason:string}, effectiveMaxDropped:number|null, maxDroppedUnsupported:boolean}>}
31
116
  */
32
117
  async function runCoverageAnalysis(options) {
33
118
  const {
@@ -39,12 +124,22 @@ async function runCoverageAnalysis(options) {
39
124
  keepReport = false,
40
125
  screenshots = false,
41
126
  outputZipPath = null,
127
+ captureMode,
128
+ captureScale,
129
+ captureViewport,
130
+ maxDropped,
42
131
  } = options || {};
43
132
 
44
133
  if (!storybookDir || typeof storybookDir !== 'string') {
45
134
  throw new Error('runCoverageAnalysis: options.storybookDir is required');
46
135
  }
47
136
 
137
+ // Validate before doing anything: a bad explicit setting should fail loudly,
138
+ // not be swallowed by the failOnThreshold=false path below.
139
+ const captureArgs = buildCaptureArgs({ captureMode, captureScale, captureViewport });
140
+ // Validated up front; the default (0) is decided below, once the command is known.
141
+ const userMaxDroppedArgs = buildMaxDroppedArgs(maxDropped);
142
+
48
143
  console.log(chalk.blue('Running Storybook coverage analysis...'));
49
144
 
50
145
  const outputPath = providedOutputPath
@@ -77,6 +172,7 @@ async function runCoverageAnalysis(options) {
77
172
  cliArgs.push('--output-zip', outputZipPath);
78
173
  }
79
174
  }
175
+ cliArgs.push(...captureArgs);
80
176
 
81
177
  // Allow local override for E2E testing before package publication.
82
178
  // Example:
@@ -95,6 +191,33 @@ async function runCoverageAnalysis(options) {
95
191
  }
96
192
  }
97
193
  const sbcovCommandPrefix = (process.env.SCRY_SBCOV_CMD || defaultSbcovCmd).trim();
194
+
195
+ // --max-dropped. The user's value is forwarded as given. Unset, and capturing
196
+ // screenshots, the deployer asks for 0 — any story that fails to capture ends
197
+ // the deploy red after the rest are uploaded — because scry-sbcov itself only
198
+ // exits 3 when the flag is passed. A scry-sbcov too old to know the flag
199
+ // would reject it and capture nothing, so it is only sent when --help lists
200
+ // it; otherwise the result says so and the caller warns.
201
+ let effectiveMaxDropped = userMaxDroppedArgs.length ? Number(userMaxDroppedArgs[1]) : null;
202
+ let maxDroppedUnsupported = false;
203
+ if (userMaxDroppedArgs.length) {
204
+ // The user's value, but only to an sbcov that knows the flag: an older one
205
+ // rejects it, captures nothing, and the run would end red for the wrong
206
+ // reason. The caller warns that it could not be applied.
207
+ if (sbcovSupportsMaxDropped(sbcovCommandPrefix)) {
208
+ cliArgs.push(...userMaxDroppedArgs);
209
+ } else {
210
+ maxDroppedUnsupported = true;
211
+ }
212
+ } else if (screenshots) {
213
+ effectiveMaxDropped = 0;
214
+ if (sbcovSupportsMaxDropped(sbcovCommandPrefix)) {
215
+ cliArgs.push('--max-dropped', '0');
216
+ } else {
217
+ maxDroppedUnsupported = true;
218
+ }
219
+ }
220
+
98
221
  const npxCommand = `${sbcovCommandPrefix} ${cliArgs.map(shellEscape).join(' ')}`;
99
222
 
100
223
  // Debug logging to show the exact command being executed
@@ -122,19 +245,101 @@ async function runCoverageAnalysis(options) {
122
245
  cwd: projectRoot // Run from the project root, not scry-node directory
123
246
  });
124
247
 
125
- const raw = fs.readFileSync(outputPath, 'utf-8');
126
- const report = JSON.parse(raw);
127
- const metadataZipPath = (screenshots && outputZipPath && fs.existsSync(outputZipPath))
128
- ? outputZipPath
129
- : null;
248
+ const report = JSON.parse(fs.readFileSync(outputPath, 'utf-8'));
249
+ const metadataZipPath = existingZip(screenshots, outputZipPath);
130
250
 
131
251
  if (!keepReport && !providedOutputPath) safeUnlink(outputPath);
132
- return { report, metadataZipPath };
252
+ return { report, metadataZipPath, sbcovFailure: null, effectiveMaxDropped, maxDroppedUnsupported };
133
253
  } catch (error) {
254
+ const exitCode = typeof error.status === 'number' ? error.status : null;
255
+ const signal = error.signal || null;
256
+ // A throw with no exit status is not sbcov's verdict: the command never
257
+ // ran, or its report could not be read after a zero exit.
258
+ const reason = (exitCode === null && !signal)
259
+ ? `${describeSbcovExit(null, null)}: ${error.message}`
260
+ : describeSbcovExit(exitCode, signal);
261
+
262
+ // Exit 3 writes the report and the archive of the stories that captured;
263
+ // keep both so they can still be uploaded and indexed. Any other failure
264
+ // promises no complete archive, so a leftover one is removed, never sent.
265
+ const report = readReportIfPresent(outputPath);
266
+ let metadataZipPath = null;
267
+ if (exitCode === 3) {
268
+ metadataZipPath = existingZip(screenshots, outputZipPath);
269
+ } else if (outputZipPath) {
270
+ safeUnlink(outputZipPath);
271
+ }
272
+
134
273
  if (!keepReport && !providedOutputPath) safeUnlink(outputPath);
135
- if (failOnThreshold) throw error;
136
- return { report: null, metadataZipPath: null };
274
+ if (failOnThreshold && exitCode !== 3) throw error;
275
+
276
+ console.error(chalk.red(`Coverage: ${reason}`));
277
+ return {
278
+ report,
279
+ metadataZipPath,
280
+ sbcovFailure: { exitCode, signal, reason },
281
+ effectiveMaxDropped,
282
+ maxDroppedUnsupported,
283
+ };
284
+ }
285
+ }
286
+
287
+ function existingZip(screenshots, outputZipPath) {
288
+ return (screenshots && outputZipPath && fs.existsSync(outputZipPath)) ? outputZipPath : null;
289
+ }
290
+
291
+ function readReportIfPresent(outputPath) {
292
+ try {
293
+ if (!fs.existsSync(outputPath)) return null;
294
+ return JSON.parse(fs.readFileSync(outputPath, 'utf-8'));
295
+ } catch (_) {
296
+ // A half-written report is no report; the failure itself is already
297
+ // carried in sbcovFailure.
298
+ return null;
299
+ }
300
+ }
301
+
302
+ const maxDroppedSupport = new Map();
303
+
304
+ /**
305
+ * Whether this scry-sbcov command knows --max-dropped (0.5.2+), from its --help.
306
+ * Cached per command for the life of the process. Any failure to ask = no.
307
+ *
308
+ * @param {string} commandPrefix
309
+ * @returns {boolean}
310
+ */
311
+ function sbcovSupportsMaxDropped(commandPrefix) {
312
+ if (maxDroppedSupport.has(commandPrefix)) return maxDroppedSupport.get(commandPrefix);
313
+ let supported = false;
314
+ try {
315
+ const out = execSync(`${commandPrefix} --help`, {
316
+ encoding: 'utf-8',
317
+ stdio: ['ignore', 'pipe', 'pipe'],
318
+ timeout: 30000,
319
+ });
320
+ supported = /--max-dropped\b/.test(out);
321
+ } catch (_) {
322
+ // An sbcov whose --help fails is judged unable to take the flag; the
323
+ // caller prints that dropped stories cannot be checked.
324
+ supported = false;
325
+ }
326
+ maxDroppedSupport.set(commandPrefix, supported);
327
+ return supported;
328
+ }
329
+
330
+ /**
331
+ * --max-dropped for scry-sbcov: a whole number of stories, 0 or more.
332
+ *
333
+ * @param {any} maxDropped
334
+ * @returns {string[]}
335
+ */
336
+ function buildMaxDroppedArgs(maxDropped) {
337
+ if (maxDropped === undefined || maxDropped === null || maxDropped === '') return [];
338
+ const text = String(maxDropped).trim();
339
+ if (!/^\d{1,9}$/.test(text)) {
340
+ throw new Error(`Invalid maxDropped ${JSON.stringify(maxDropped)}: expected a whole number of stories, 0 or more`);
137
341
  }
342
+ return ['--max-dropped', String(Number(text))];
138
343
  }
139
344
 
140
345
  /**
@@ -305,6 +510,10 @@ function readGithubPullRequestBaseSha(eventPath) {
305
510
 
306
511
  module.exports = {
307
512
  runCoverageAnalysis,
513
+ buildCaptureArgs,
514
+ buildMaxDroppedArgs,
515
+ describeSbcovExit,
516
+ sbcovSupportsMaxDropped,
308
517
  loadCoverageReport,
309
518
  extractCoverageSummary,
310
519
  normalizeGitBaseRef,
@@ -0,0 +1,135 @@
1
+ const fs = require('fs');
2
+ const zlib = require('zlib');
3
+
4
+ /**
5
+ * Count the entries in an analysis archive's metadata.json.
6
+ *
7
+ * scry-sbcov writes an archive even when every story failed after the browser
8
+ * launched: its metadata.json is `[]`. Uploading that queues a build with
9
+ * nothing to index, and the processing service then marks it `completed`, so
10
+ * the deploy used to end green over an empty index (ISSUES.md #50). The
11
+ * deployer counts before it uploads.
12
+ *
13
+ * A small reader of the ZIP central directory, not a dependency: the archive
14
+ * is written by sbcov with `archiver` (stored or deflated entries, no ZIP64 at
15
+ * the sizes the upload service accepts).
16
+ *
17
+ * Never throws. When the archive cannot be read the result says why
18
+ * (`count: null`, `error`), and the caller must surface it.
19
+ *
20
+ * @param {string} zipPath
21
+ * @returns {{count: number|null, error: string|null}}
22
+ */
23
+ function countMetadataEntries(zipPath) {
24
+ let buf;
25
+ try {
26
+ buf = fs.readFileSync(zipPath);
27
+ } catch (err) {
28
+ return { count: null, error: `cannot read archive: ${err.message}` };
29
+ }
30
+
31
+ try {
32
+ const json = readZipEntry(buf, 'metadata.json');
33
+ if (json === null) return { count: 0, error: 'archive has no metadata.json' };
34
+ const parsed = JSON.parse(json.toString('utf8'));
35
+ if (!Array.isArray(parsed)) {
36
+ return { count: null, error: 'metadata.json is not a list' };
37
+ }
38
+ return { count: parsed.length, error: null };
39
+ } catch (err) {
40
+ return { count: null, error: err.message };
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Read scry-sbcov's `sbcov-manifest.json` from an analysis archive (0.5.2+):
46
+ * `{declared, captured, dropped:[{storyId, storyTitle, reason}], capture, sbcovVersion}`.
47
+ *
48
+ * Never throws. `manifest: null` with no error = an older sbcov that writes no
49
+ * manifest; with an error = present but unreadable, which the caller surfaces.
50
+ *
51
+ * @param {string} zipPath
52
+ * @returns {{manifest: null|{declared:number|null, captured:number|null, dropped:Array<{storyId?:string, storyTitle?:string, reason?:string}>, sbcovVersion?:string}, error: string|null}}
53
+ */
54
+ function readSbcovManifest(zipPath) {
55
+ try {
56
+ const raw = readZipEntry(fs.readFileSync(zipPath), 'sbcov-manifest.json');
57
+ if (raw === null) return { manifest: null, error: null };
58
+ const m = JSON.parse(raw.toString('utf8'));
59
+ if (!m || typeof m !== 'object' || !Array.isArray(m.dropped)) {
60
+ return { manifest: null, error: 'sbcov-manifest.json has no dropped list' };
61
+ }
62
+ const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : null);
63
+ return {
64
+ manifest: { declared: num(m.declared), captured: num(m.captured), dropped: m.dropped, sbcovVersion: m.sbcovVersion },
65
+ error: null,
66
+ };
67
+ } catch (err) {
68
+ return { manifest: null, error: `sbcov-manifest.json unreadable: ${err.message}` };
69
+ }
70
+ }
71
+
72
+ /**
73
+ * "timeout 40, render error 4" from a manifest's dropped list.
74
+ * @param {Array<{reason?:string}>} dropped
75
+ */
76
+ function droppedReasons(dropped) {
77
+ const counts = new Map();
78
+ for (const d of dropped) {
79
+ const r = String((d && d.reason) || 'unknown').replace(/[_-]+/g, ' ').slice(0, 40);
80
+ counts.set(r, (counts.get(r) || 0) + 1);
81
+ }
82
+ return [...counts.entries()].sort((a, b) => b[1] - a[1]).map(([r, n]) => `${r} ${n}`).join(', ');
83
+ }
84
+
85
+ /**
86
+ * Return one entry's bytes, or null when the archive has no entry by that name.
87
+ *
88
+ * @param {Buffer} buf
89
+ * @param {string} name
90
+ * @returns {Buffer|null}
91
+ */
92
+ function readZipEntry(buf, name) {
93
+ const EOCD_SIG = 0x06054b50;
94
+ const CEN_SIG = 0x02014b50;
95
+ const LOC_SIG = 0x04034b50;
96
+
97
+ // End of central directory: 22 bytes plus an optional comment of up to 64 KiB.
98
+ let eocd = -1;
99
+ for (let i = buf.length - 22; i >= Math.max(0, buf.length - 22 - 0xffff); i--) {
100
+ if (buf.readUInt32LE(i) === EOCD_SIG) { eocd = i; break; }
101
+ }
102
+ if (eocd < 0) throw new Error('not a zip archive (no end-of-central-directory record)');
103
+
104
+ const total = buf.readUInt16LE(eocd + 10);
105
+ let off = buf.readUInt32LE(eocd + 16);
106
+ if (total === 0xffff || off === 0xffffffff) throw new Error('ZIP64 archives are not supported');
107
+
108
+ for (let n = 0; n < total; n++) {
109
+ if (off + 46 > buf.length || buf.readUInt32LE(off) !== CEN_SIG) {
110
+ throw new Error('corrupt zip central directory');
111
+ }
112
+ const method = buf.readUInt16LE(off + 10);
113
+ const compSize = buf.readUInt32LE(off + 20);
114
+ const nameLen = buf.readUInt16LE(off + 28);
115
+ const extraLen = buf.readUInt16LE(off + 30);
116
+ const commentLen = buf.readUInt16LE(off + 32);
117
+ const localOff = buf.readUInt32LE(off + 42);
118
+ const entryName = buf.toString('utf8', off + 46, off + 46 + nameLen);
119
+ off += 46 + nameLen + extraLen + commentLen;
120
+
121
+ if (entryName !== name) continue;
122
+
123
+ if (localOff + 30 > buf.length || buf.readUInt32LE(localOff) !== LOC_SIG) {
124
+ throw new Error(`corrupt local header for ${name}`);
125
+ }
126
+ const start = localOff + 30 + buf.readUInt16LE(localOff + 26) + buf.readUInt16LE(localOff + 28);
127
+ const data = buf.subarray(start, start + compSize);
128
+ if (method === 0) return data;
129
+ if (method === 8) return zlib.inflateRawSync(data);
130
+ throw new Error(`unsupported compression method ${method} for ${name}`);
131
+ }
132
+ return null;
133
+ }
134
+
135
+ module.exports = { countMetadataEntries, readSbcovManifest, droppedReasons, readZipEntry };
package/lib/telemetry.js CHANGED
@@ -21,8 +21,6 @@ const Sentry = require('@sentry/node');
21
21
  * None of that is needed to know that an upload failed with EAI_AGAIN.
22
22
  */
23
23
 
24
- const { version: PACKAGE_VERSION } = require('../package.json');
25
-
26
24
  const DSN =
27
25
  'https://c66ce229a1db2289f145eebd02436d9c@o4507889391828992.ingest.us.sentry.io/4510699330732032';
28
26
 
@@ -43,58 +41,8 @@ const SECRET_PATTERNS = [
43
41
  [/scry_proj_[A-Za-z0-9_\-]+/g, 'scry_proj_<redacted>'],
44
42
  [/(X-Amz-Signature=)[^&\s]+/gi, '$1<redacted>'],
45
43
  [/(Bearer\s+)[A-Za-z0-9._\-]+/gi, '$1<redacted>'],
46
- // A credential flag echoed on a command line: --api-key X, --api-key=X,
47
- // -k X, --token X, --openai-api-key X, ...
48
- [/(--[\w-]*(?:api-key|apikey|token|secret|password)[\w-]*[=\s]+|(?:^|\s)-k[=\s]+)(?!<redacted>)[^\s"',]+/gi, '$1<redacted>'],
49
- // A credential field inside serialized JSON: "apiKey":"X", "token": "X".
50
- [/("[\w-]*(?:api[-_]?key|token|secret|password)[\w-]*"\s*:\s*)"[^"]*"/gi, '$1"<redacted>"'],
51
- // An env echo: SCRY_API_KEY=X, STORYBOOK_DEPLOYER_API_KEY=X, JINA_API_KEY=X.
52
- [/(\b[A-Z][A-Z0-9_]*(?:KEY|TOKEN|SECRET|PASSWORD)[A-Z0-9_]*=)(?!<redacted>)[^\s"',]+/g, '$1<redacted>'],
53
44
  ];
54
45
 
55
- /** Field names whose values are credentials, in any spelling yargs produces. */
56
- const SECRET_FIELD = /(^k$|api[-_]?key|token|secret|password)/i;
57
-
58
- /**
59
- * A copy of argv with every credential-named field masked, at any depth.
60
- *
61
- * For logging argv whole (the --verbose "Received arguments" line), which is
62
- * also a Sentry breadcrumb. Unlike sanitizeArgv this keeps every field, so it
63
- * must only be used for local diagnostics, never as event context.
64
- */
65
- function redactArgv(value, depth = 0) {
66
- if (depth > 5 || value === null || typeof value !== 'object') return value;
67
- if (Array.isArray(value)) return value.map((v) => redactArgv(v, depth + 1));
68
- const out = {};
69
- for (const [k, v] of Object.entries(value)) {
70
- out[k] = SECRET_FIELD.test(k) && v !== undefined && v !== null && v !== '' ? '<redacted>' : redactArgv(v, depth + 1);
71
- }
72
- return out;
73
- }
74
-
75
- /** Scrub every string in a JSON-like value (breadcrumb data), in place-safe copy. */
76
- function scrubDeep(value, depth = 0) {
77
- if (typeof value === 'string') return scrub(value);
78
- if (depth > 5 || value === null || typeof value !== 'object') return value;
79
- if (Array.isArray(value)) return value.map((v) => scrubDeep(v, depth + 1));
80
- const out = {};
81
- for (const [k, v] of Object.entries(value)) {
82
- out[k] = SECRET_FIELD.test(k) && typeof v === 'string' && v ? '<redacted>' : scrubDeep(v, depth + 1);
83
- }
84
- return out;
85
- }
86
-
87
- /**
88
- * Breadcrumbs are sent with every event and beforeSend does not see them as
89
- * separate items, so they get the same scrubbing on the way in.
90
- */
91
- function scrubBreadcrumb(breadcrumb) {
92
- if (!breadcrumb) return breadcrumb;
93
- if (breadcrumb.message) breadcrumb.message = scrub(breadcrumb.message);
94
- if (breadcrumb.data) breadcrumb.data = scrubDeep(breadcrumb.data);
95
- return breadcrumb;
96
- }
97
-
98
46
  function scrub(value) {
99
47
  if (typeof value !== 'string') return value;
100
48
  return SECRET_PATTERNS.reduce((acc, [pattern, replacement]) => acc.replace(pattern, replacement), value);
@@ -129,9 +77,6 @@ function initTelemetry() {
129
77
  Sentry.init({
130
78
  dsn: DSN,
131
79
  environment: process.env.NODE_ENV || 'production',
132
- // Which published deployer produced the event, so a fix can be matched to
133
- // the versions still in the wild.
134
- release: `@scrymore/scry-deployer@${PACKAGE_VERSION}`,
135
80
 
136
81
  // Errors only. Traces from a CLI describe the customer's build pipeline,
137
82
  // which is more than is needed to fix a crash.
@@ -141,18 +86,8 @@ function initTelemetry() {
141
86
  sendDefaultPii: false,
142
87
  serverName: false,
143
88
 
144
- // The logger turns every line (including debug) into a breadcrumb, and
145
- // Sentry's console integration does the same for console.*. None of that
146
- // passed through beforeSend's scrubbing before.
147
- beforeBreadcrumb(breadcrumb) {
148
- return scrubBreadcrumb(breadcrumb);
149
- },
150
-
151
89
  beforeSend(event) {
152
90
  if (event.message) event.message = scrub(event.message);
153
- // Belt and braces for breadcrumbs added before init or by integrations
154
- // that bypass beforeBreadcrumb.
155
- if (Array.isArray(event.breadcrumbs)) event.breadcrumbs = event.breadcrumbs.map(scrubBreadcrumb);
156
91
 
157
92
  for (const entry of event.exception?.values ?? []) {
158
93
  if (entry.value) entry.value = scrub(entry.value);
@@ -200,8 +135,6 @@ module.exports = {
200
135
  flushTelemetry,
201
136
  telemetryDisabled,
202
137
  sanitizeArgv,
203
- redactArgv,
204
138
  scrub,
205
- scrubBreadcrumb,
206
139
  SAFE_ARGV_FIELDS,
207
140
  };