Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Telemetry: Add precedingUpgrade data to dev/build events" #20105

Merged
merged 1 commit into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions code/lib/core-server/src/build-static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { dedent } from 'ts-dedent';
import global from 'global';

import { logger } from '@storybook/node-logger';
import { telemetry, getPrecedingUpgrade } from '@storybook/telemetry';
import { telemetry } from '@storybook/telemetry';
import type {
BuilderOptions,
CLIOptions,
Expand Down Expand Up @@ -173,14 +173,11 @@ export async function buildStaticStandalone(
effects.push(
initializedStoryIndexGenerator.then(async (generator) => {
const storyIndex = await generator?.getIndex();
const payload = {
precedingUpgrade: await getPrecedingUpgrade('build'),
};
if (storyIndex) {
Object.assign(payload, {
storyIndex: summarizeIndex(storyIndex),
});
}
const payload = storyIndex
? {
storyIndex: summarizeIndex(storyIndex),
}
: undefined;
await telemetry('build', payload, { configDir: options.configDir });
})
);
Expand Down
18 changes: 7 additions & 11 deletions code/lib/core-server/src/dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {

import { normalizeStories, logConfig } from '@storybook/core-common';

import { telemetry, getPrecedingUpgrade } from '@storybook/telemetry';
import { telemetry } from '@storybook/telemetry';
import { getMiddleware } from './utils/middleware';
import { getServerAddresses } from './utils/server-address';
import { getServer } from './utils/server-init';
Expand Down Expand Up @@ -156,16 +156,12 @@ async function doTelemetry(
initializedStoryIndexGenerator.then(async (generator) => {
const storyIndex = await generator?.getIndex();
const { versionCheck, versionUpdates } = options;
const payload = {
precedingUpgrade: await getPrecedingUpgrade('dev'),
};
if (storyIndex) {
Object.assign(payload, {
versionStatus: versionUpdates ? versionStatus(versionCheck) : 'disabled',
storyIndex: summarizeIndex(storyIndex),
});
}

const payload = storyIndex
? {
versionStatus: versionUpdates ? versionStatus(versionCheck) : 'disabled',
storyIndex: summarizeIndex(storyIndex),
}
: undefined;
telemetry('dev', payload, { configDir: options.configDir });
});
}
Expand Down
146 changes: 0 additions & 146 deletions code/lib/telemetry/src/event-cache.test.ts

This file was deleted.

39 changes: 0 additions & 39 deletions code/lib/telemetry/src/event-cache.ts

This file was deleted.

2 changes: 0 additions & 2 deletions code/lib/telemetry/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export * from './types';

export { getStorybookCoreVersion } from './package-json';

export { getPrecedingUpgrade } from './event-cache';

export const telemetry = async (
eventType: EventType,
payload: Payload = {},
Expand Down
11 changes: 3 additions & 8 deletions code/lib/telemetry/src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import retry from 'fetch-retry';
import { nanoid } from 'nanoid';
import type { Options, TelemetryData } from './types';
import { getAnonymousProjectId } from './anonymous-id';
import { set as saveToCache } from './event-cache';

const URL = process.env.STORYBOOK_TELEMETRY_URL || 'https://storybook.js.org/event-log';

Expand All @@ -25,17 +24,16 @@ export async function sendTelemetry(
// the server actually gets the request and stores it anyway.

// flatten the data before we send it
const { eventType, payload, metadata, ...rest } = data;
const { payload, metadata, ...rest } = data;
const context = options.stripMetadata
? {}
: {
anonymousId: getAnonymousProjectId(),
inCI: Boolean(process.env.CI),
};
const eventId = nanoid();
const body = { ...rest, eventType, eventId, sessionId, metadata, payload, context };
const body = { ...rest, eventId, sessionId, metadata, payload, context };
let request: Promise<any>;
let cache: Promise<any>;

try {
request = fetch(URL, {
Expand All @@ -51,18 +49,15 @@ export async function sendTelemetry(
: 1000),
});
tasks.push(request);
cache = saveToCache(eventType, body);
tasks.push(cache);

if (options.immediate) {
await Promise.all(tasks);
} else {
await request;
await cache;
}
} catch (err) {
//
} finally {
tasks = tasks.filter((task) => task !== request && task !== cache);
tasks = tasks.filter((task) => task !== request);
}
}