From a768b28765f06a78a4d8ccfab7793e5758306f30 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Tue, 7 Feb 2023 22:45:12 +0800 Subject: [PATCH] Telemetry: Hash error messages --- code/lib/core-server/src/withTelemetry.ts | 9 +++++++-- code/lib/telemetry/src/index.ts | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/code/lib/core-server/src/withTelemetry.ts b/code/lib/core-server/src/withTelemetry.ts index 39ad33e7cf14..8efcf050b8f9 100644 --- a/code/lib/core-server/src/withTelemetry.ts +++ b/code/lib/core-server/src/withTelemetry.ts @@ -1,7 +1,7 @@ import prompts from 'prompts'; import type { CLIOptions, CoreConfig } from '@storybook/types'; import { loadAllPresets, cache } from '@storybook/core-common'; -import { telemetry, getPrecedingUpgrade } from '@storybook/telemetry'; +import { telemetry, getPrecedingUpgrade, oneWayHash } from '@storybook/telemetry'; import type { EventType } from '@storybook/telemetry'; type TelemetryOptions = { @@ -76,7 +76,12 @@ export async function withTelemetry( await telemetry( 'error', - { eventType, precedingUpgrade, error: errorLevel === 'full' ? error : undefined }, + { + eventType, + precedingUpgrade, + error: errorLevel === 'full' ? error : undefined, + errorHash: oneWayHash(error.message), + }, { immediate: true, configDir: options.cliOptions.configDir || options.presetOptions?.configDir, diff --git a/code/lib/telemetry/src/index.ts b/code/lib/telemetry/src/index.ts index a1da9bc69531..ab82cad7c2e0 100644 --- a/code/lib/telemetry/src/index.ts +++ b/code/lib/telemetry/src/index.ts @@ -5,6 +5,8 @@ import { sendTelemetry } from './telemetry'; import { notify } from './notify'; import { sanitizeError } from './sanitize'; +export { oneWayHash } from './one-way-hash'; + export * from './storybook-metadata'; export * from './types';