Skip to content

Commit

Permalink
Merge branch 'release-8-0' into norbert/remove-storyshots
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Oct 18, 2023
2 parents 4eacfc2 + 0b3d271 commit 48fa779
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 52 deletions.
8 changes: 5 additions & 3 deletions code/builders/builder-manager/templates/template.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@
<% } %>

<script type="module">
import './sb-manager/runtime.js';
import './sb-manager/globals-runtime.js';
<% files.js.forEach(file => { %>
import '<%= file %>';
import '<%= file %>';
<% }); %>
import './sb-manager/runtime.js';
</script>

<link href="./sb-preview/runtime.js" rel="prefetch" as="script" />
Expand Down
3 changes: 2 additions & 1 deletion code/ui/manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@
"pre": "./scripts/generate-exports-file.ts",
"browserEntries": [
"./src/index.tsx",
"./src/runtime.ts"
"./src/runtime.ts",
"./src/globals-runtime.ts"
],
"nodeEntries": [
"./src/globals.ts"
Expand Down
28 changes: 28 additions & 0 deletions code/ui/manager/src/globals-runtime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { global } from '@storybook/global';

import { TELEMETRY_ERROR } from '@storybook/core-events';

import { values } from './globals/runtime';
import { Keys } from './globals/types';
import { prepareForTelemetry, shouldSkipError } from './utils/prepareForTelemetry';

// Apply all the globals
Object.keys(Keys).forEach((key: keyof typeof Keys) => {
global[Keys[key]] = values[key];
});

global.sendTelemetryError = (error) => {
if (!shouldSkipError(error)) {
const channel = global.__STORYBOOK_ADDONS_CHANNEL__;
channel.emit(TELEMETRY_ERROR, prepareForTelemetry(error));
}
};

// handle all uncaught errors at the root of the application and log to telemetry
global.addEventListener('error', (args) => {
const error = args.error || args;
global.sendTelemetryError(error);
});
global.addEventListener('unhandledrejection', ({ reason }) => {
global.sendTelemetryError(reason);
});
27 changes: 1 addition & 26 deletions code/ui/manager/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ import type { AddonStore } from '@storybook/manager-api';
import { addons } from '@storybook/manager-api';
import type { Addon_Types, Addon_Config } from '@storybook/types';
import { createBrowserChannel } from '@storybook/channels';
import { CHANNEL_CREATED, TELEMETRY_ERROR } from '@storybook/core-events';
import { CHANNEL_CREATED } from '@storybook/core-events';
import Provider from './provider';
import { renderStorybookUI } from './index';

import { values } from './globals/runtime';
import { Keys } from './globals/types';
import { prepareForTelemetry, shouldSkipError } from './utils/prepareForTelemetry';

const { FEATURES, CONFIG_TYPE } = global;

class ReactProvider extends Provider {
Expand Down Expand Up @@ -57,27 +53,6 @@ class ReactProvider extends Provider {
}
}

// Apply all the globals
Object.keys(Keys).forEach((key: keyof typeof Keys) => {
global[Keys[key]] = values[key];
});

global.sendTelemetryError = (error) => {
if (!shouldSkipError(error)) {
const channel = global.__STORYBOOK_ADDONS_CHANNEL__;
channel.emit(TELEMETRY_ERROR, prepareForTelemetry(error));
}
};

// handle all uncaught errors at the root of the application and log to telemetry
global.addEventListener('error', (args) => {
const error = args.error || args;
global.sendTelemetryError(error);
});
global.addEventListener('unhandledrejection', ({ reason }) => {
global.sendTelemetryError(reason);
});

const { document } = global;
const rootEl = document.getElementById('root');
renderStorybookUI(rootEl, new ReactProvider());
24 changes: 2 additions & 22 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2204,7 +2204,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.10.2, @babel/runtime@npm:^7.11.2, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.13.10, @babel/runtime@npm:^7.14.8, @babel/runtime@npm:^7.17.8, @babel/runtime@npm:^7.18.3, @babel/runtime@npm:^7.20.13, @babel/runtime@npm:^7.20.7, @babel/runtime@npm:^7.21.0, @babel/runtime@npm:^7.22.6, @babel/runtime@npm:^7.3.1, @babel/runtime@npm:^7.7.6, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.9.2":
"@babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.10.2, @babel/runtime@npm:^7.11.2, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.13.10, @babel/runtime@npm:^7.14.8, @babel/runtime@npm:^7.17.8, @babel/runtime@npm:^7.18.3, @babel/runtime@npm:^7.20.13, @babel/runtime@npm:^7.20.7, @babel/runtime@npm:^7.21.0, @babel/runtime@npm:^7.22.6, @babel/runtime@npm:^7.3.1, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.7.6, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.8.7, @babel/runtime@npm:^7.9.2":
version: 7.23.1
resolution: "@babel/runtime@npm:7.23.1"
dependencies:
Expand All @@ -2213,15 +2213,6 @@ __metadata:
languageName: node
linkType: hard

"@babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.8.7":
version: 7.22.15
resolution: "@babel/runtime@npm:7.22.15"
dependencies:
regenerator-runtime: ^0.14.0
checksum: 96b74adfd1db812d06ed56d9db12acecfc844d252b93994ce4901433957bd28affba725622a4dc9e7f76384c4cb6cadc3d620d07817c8be9156eaedba5eea059
languageName: node
linkType: hard

"@babel/runtime@npm:~7.5.4":
version: 7.5.5
resolution: "@babel/runtime@npm:7.5.5"
Expand Down Expand Up @@ -9015,18 +9006,7 @@ __metadata:
languageName: node
linkType: hard

"@types/react@npm:*, @types/react@npm:>=16":
version: 16.14.46
resolution: "@types/react@npm:16.14.46"
dependencies:
"@types/prop-types": "*"
"@types/scheduler": "*"
csstype: ^3.0.2
checksum: 815885cbae2c8653dddf8df4e6c2ce43ff8ff1d02c03f8356ce4b13aa7c8e6c72c588f04977c6f49fdd82419d46fdd895535d5e66726f0b0ea13c04065294995
languageName: node
linkType: hard

"@types/react@npm:^16, @types/react@npm:^16.14.34":
"@types/react@npm:*, @types/react@npm:>=16, @types/react@npm:^16, @types/react@npm:^16.14.34":
version: 16.14.48
resolution: "@types/react@npm:16.14.48"
dependencies:
Expand Down

0 comments on commit 48fa779

Please sign in to comment.