Skip to content

Commit 20605e8

Browse files
shilmandannyhw
andauthored
Build: Add dev/build telemetry (#794)
* Prototype dev/build telemetry (untested) * fix: add event to withStorybookConfig also --------- Co-authored-by: Daniel Williams <[email protected]>
1 parent 95d67d4 commit 20605e8

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

packages/react-native/src/metro/withStorybook.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as path from 'path';
22
import { generate } from '../../scripts/generate';
33
import { WebSocketServer, WebSocket, Data } from 'ws';
44
import type { MetroConfig } from 'metro-config';
5+
import { optionalEnvToBoolean } from 'storybook/internal/common';
6+
import { telemetry } from 'storybook/internal/telemetry';
57

68
/**
79
* Options for configuring WebSockets used for syncing storybook instances or sending events to storybook.
@@ -106,6 +108,14 @@ function withStorybook(
106108
liteMode = false,
107109
} = options;
108110

111+
const disableTelemetry = optionalEnvToBoolean(process.env.STORYBOOK_DISABLE_TELEMETRY);
112+
113+
if (!disableTelemetry && enabled) {
114+
const event = process.env.NODE_ENV === 'production' ? 'build' : 'dev';
115+
116+
telemetry(event, {}).catch((e) => {});
117+
}
118+
109119
if (!enabled) {
110120
if (onDisabledRemoveStorybook) {
111121
return {

packages/react-native/src/metro/withStorybookConfig.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as path from 'path';
22
import { generate } from '../../scripts/generate';
33
import { WebSocketServer, WebSocket, Data } from 'ws';
44
import type { MetroConfig } from 'metro-config';
5+
import { optionalEnvToBoolean } from 'storybook/internal/common';
6+
import { telemetry } from 'storybook/internal/telemetry';
57

68
/**
79
* Options for configuring WebSockets used for syncing storybook instances or sending events to storybook.
@@ -143,6 +145,14 @@ export function withStorybookConfig(
143145
liteMode = false,
144146
} = options;
145147

148+
const disableTelemetry = optionalEnvToBoolean(process.env.STORYBOOK_DISABLE_TELEMETRY);
149+
150+
if (!disableTelemetry && !removeStorybook) {
151+
const event = process.env.NODE_ENV === 'production' ? 'build' : 'dev';
152+
153+
telemetry(event, {}).catch((e) => {});
154+
}
155+
146156
if (removeStorybook) {
147157
return {
148158
...config,

0 commit comments

Comments
 (0)