Fix telemetry reporting for integrations that return an array (#7429)

This commit is contained in:
Chris Swithinbank 2023-06-20 14:42:49 +02:00 committed by GitHub
parent 82b1964432
commit 89a4835202
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix telemetry reporting for integrations that return an array

View file

@ -83,7 +83,10 @@ export function eventCliSession(
) ?? []),
] as string[],
adapter: userConfig?.adapter?.name ?? null,
integrations: (userConfig?.integrations ?? []).filter(Boolean).map((i: any) => i?.name),
integrations: (userConfig?.integrations ?? [])
.filter(Boolean)
.flat()
.map((i: any) => i?.name),
trailingSlash: userConfig?.trailingSlash,
build: userConfig?.build
? {

View file

@ -385,6 +385,14 @@ describe('Events', () => {
expect(payload.config.integrations.length).to.equal(0);
});
it('finds names for integration arrays', () => {
const config = {
integrations: [{ name: 'foo' }, [{ name: 'bar' }, { name: 'baz' }]],
};
const [{ payload }] = events.eventCliSession({ cliCommand: 'dev' }, config);
expect(payload.config.integrations).to.deep.equal(['foo', 'bar', 'baz']);
});
it('includes cli flags in payload', () => {
const config = {};
const flags = {