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

Telemetry: Replace isomorphic-unfetch with node-fetch in telemetry #21497

Merged
merged 2 commits into from
Mar 9, 2023
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
3 changes: 2 additions & 1 deletion code/lib/telemetry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@
"dependencies": {
"@storybook/client-logger": "7.0.0-beta.64",
"@storybook/core-common": "7.0.0-beta.64",
"@types/node-fetch": "^2.5.7",
"chalk": "^4.1.0",
"detect-package-manager": "^2.0.1",
"fetch-retry": "^5.0.2",
"fs-extra": "^11.1.0",
"isomorphic-unfetch": "^3.1.0",
"nanoid": "^3.3.1",
"node-fetch": "^2.6.7",
"read-pkg-up": "^7.0.1"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions code/lib/telemetry/src/telemetry.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/// <reference types="@types/jest" />;

import fetch from 'isomorphic-unfetch';
import fetch from 'node-fetch';

import { sendTelemetry } from './telemetry';

jest.mock('isomorphic-unfetch');
jest.mock('node-fetch');

const fetchMock = fetch as jest.Mock;
const fetchMock = fetch as any as jest.Mock;

beforeEach(() => {
fetchMock.mockResolvedValue({ status: 200 });
Expand Down
4 changes: 2 additions & 2 deletions code/lib/telemetry/src/telemetry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import originalFetch from 'isomorphic-unfetch';
import originalFetch from 'node-fetch';
import retry from 'fetch-retry';
import { nanoid } from 'nanoid';
import type { Options, TelemetryData } from './types';
Expand All @@ -7,7 +7,7 @@ import { set as saveToCache } from './event-cache';

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

const fetch = retry(originalFetch);
const fetch = retry(originalFetch as any);

let tasks: Promise<any>[] = [];

Expand Down
3 changes: 2 additions & 1 deletion code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7106,12 +7106,13 @@ __metadata:
dependencies:
"@storybook/client-logger": 7.0.0-beta.64
"@storybook/core-common": 7.0.0-beta.64
"@types/node-fetch": ^2.5.7
chalk: ^4.1.0
detect-package-manager: ^2.0.1
fetch-retry: ^5.0.2
fs-extra: ^11.1.0
isomorphic-unfetch: ^3.1.0
nanoid: ^3.3.1
node-fetch: ^2.6.7
read-pkg-up: ^7.0.1
typescript: ~4.9.3
languageName: unknown
Expand Down