diff --git a/code/lib/core-server/src/withTelemetry.ts b/code/lib/core-server/src/withTelemetry.ts index aca91f9335e..13954c4b64a 100644 --- a/code/lib/core-server/src/withTelemetry.ts +++ b/code/lib/core-server/src/withTelemetry.ts @@ -1,5 +1,5 @@ import prompts from 'prompts'; -import type { CLIOptions, LoadOptions, BuilderOptions, CoreConfig } from '@storybook/core-common'; +import type { CLIOptions, CoreConfig } from '@storybook/core-common'; import { loadAllPresets, cache } from '@storybook/core-common'; import { telemetry } from '@storybook/telemetry'; import type { EventType } from '@storybook/telemetry'; @@ -40,7 +40,7 @@ async function shouldSendError({ cliOptions, presetOptions }: TelemetryOptions) // If the user has chosen to enable/disable crash reports in main.js // or disabled telemetry, we can return that const core = await presets.apply('core'); - if (core.enableCrashReports !== undefined) return core.enableCrashReports; + if (core?.enableCrashReports !== undefined) return core.enableCrashReports; if (core?.disableTelemetry) return false; // Deal with typo, remove in future version (7.1?) diff --git a/code/lib/telemetry/src/index.ts b/code/lib/telemetry/src/index.ts index 8a9e97166f4..f49b77fb7a4 100644 --- a/code/lib/telemetry/src/index.ts +++ b/code/lib/telemetry/src/index.ts @@ -20,7 +20,7 @@ export const telemetry = async ( payload, }; try { - if (!options.stripMetadata) + if (!options?.stripMetadata) telemetryData.metadata = await getStorybookMetadata(options?.configDir); } catch (error: any) { telemetryData.payload.metadataErrorMessage = sanitizeError(error).message;