Skip to content

Commit 5cd5ded

Browse files
shilmanstorybook-bot
authored andcommitted
Merge pull request #24000 from storybookjs/shilman/filter-addons-telemetry
Telemetry: Filter addon options to protect sensitive info (cherry picked from commit 7b4f37f)
1 parent 1ad29ee commit 5cd5ded

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

code/lib/telemetry/src/storybook-metadata.test.ts

+27
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,33 @@ describe('storybook-metadata', () => {
349349
expect(res.refCount).toEqual(2);
350350
});
351351

352+
test('only reports addon options for addon-essentials', async () => {
353+
const res = await computeStorybookMetadata({
354+
packageJson: packageJsonMock,
355+
mainConfig: {
356+
...mainJsMock,
357+
addons: [
358+
{ name: '@storybook/addon-essentials', options: { controls: false } },
359+
{ name: 'addon-foo', options: { foo: 'bar' } },
360+
],
361+
},
362+
});
363+
expect(res.addons).toMatchInlineSnapshot(`
364+
Object {
365+
"@storybook/addon-essentials": Object {
366+
"options": Object {
367+
"controls": false,
368+
},
369+
"version": "x.x.x",
370+
},
371+
"addon-foo": Object {
372+
"options": undefined,
373+
"version": "x.x.x",
374+
},
375+
}
376+
`);
377+
});
378+
352379
test.each(Object.entries(metaFrameworks))(
353380
'should detect the supported metaframework: %s',
354381
async (metaFramework, name) => {

code/lib/telemetry/src/storybook-metadata.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ export const computeStorybookMetadata = async ({
114114
if (typeof addon === 'string') {
115115
addonName = sanitizeAddonName(addon);
116116
} else {
117-
options = addon.options;
117+
if (addon.name.includes('addon-essentials')) {
118+
options = addon.options;
119+
}
118120
addonName = sanitizeAddonName(addon.name);
119121
}
120122

0 commit comments

Comments
 (0)