@storybook/telemetry 7.0.0-alpha.3 → 7.0.0-alpha.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/get-monorepo-type.js +5 -2
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/storybook-metadata.js +25 -11
- package/dist/cjs/telemetry.js +1 -1
- package/dist/esm/get-monorepo-type.js +6 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/storybook-metadata.js +19 -10
- package/dist/esm/telemetry.js +1 -1
- package/dist/types/storybook-metadata.d.ts +2 -1
- package/dist/types/types.d.ts +1 -1
- package/package.json +10 -9
- package/LICENSE +0 -21
|
@@ -25,7 +25,8 @@ exports.monorepoConfigs = monorepoConfigs;
|
|
|
25
25
|
const getMonorepoType = () => {
|
|
26
26
|
const projectRootPath = (0, _coreCommon.getProjectRoot)();
|
|
27
27
|
if (!projectRootPath) return undefined;
|
|
28
|
-
const
|
|
28
|
+
const keys = Object.keys(monorepoConfigs);
|
|
29
|
+
const monorepoType = keys.find(monorepo => {
|
|
29
30
|
const configFile = _path.default.join(projectRootPath, monorepoConfigs[monorepo]);
|
|
30
31
|
|
|
31
32
|
return _fsExtra.default.existsSync(configFile);
|
|
@@ -35,7 +36,9 @@ const getMonorepoType = () => {
|
|
|
35
36
|
return monorepoType;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
if (!_fsExtra.default.existsSync(_path.default.join(projectRootPath, 'package.json')))
|
|
39
|
+
if (!_fsExtra.default.existsSync(_path.default.join(projectRootPath, 'package.json'))) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
39
42
|
|
|
40
43
|
const packageJson = _fsExtra.default.readJsonSync(_path.default.join(projectRootPath, 'package.json'));
|
|
41
44
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -30,7 +30,7 @@ var _notify = require("./notify");
|
|
|
30
30
|
|
|
31
31
|
var _sanitize = require("./sanitize");
|
|
32
32
|
|
|
33
|
-
const telemetry = async (eventType, payload = {}, options) => {
|
|
33
|
+
const telemetry = async (eventType, payload = {}, options = {}) => {
|
|
34
34
|
await (0, _notify.notify)();
|
|
35
35
|
const telemetryData = {
|
|
36
36
|
eventType,
|
|
@@ -38,7 +38,7 @@ const telemetry = async (eventType, payload = {}, options) => {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
try {
|
|
41
|
-
telemetryData.metadata = await (0, _storybookMetadata.getStorybookMetadata)(options.configDir);
|
|
41
|
+
telemetryData.metadata = await (0, _storybookMetadata.getStorybookMetadata)(options === null || options === void 0 ? void 0 : options.configDir);
|
|
42
42
|
} catch (error) {
|
|
43
43
|
if (!telemetryData.payload.error) telemetryData.payload.error = error;
|
|
44
44
|
} finally {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.metaFrameworks = exports.getStorybookMetadata = exports.computeStorybookMetadata = void 0;
|
|
6
|
+
exports.sanitizeAddonName = exports.metaFrameworks = exports.getStorybookMetadata = exports.computeStorybookMetadata = void 0;
|
|
7
7
|
|
|
8
8
|
var _readPkgUp = _interopRequireDefault(require("read-pkg-up"));
|
|
9
9
|
|
|
@@ -15,6 +15,8 @@ var _packageVersions = require("./package-versions");
|
|
|
15
15
|
|
|
16
16
|
var _getMonorepoType = require("./get-monorepo-type");
|
|
17
17
|
|
|
18
|
+
var _sanitize = require("./sanitize");
|
|
19
|
+
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
21
|
|
|
20
22
|
const metaFrameworks = {
|
|
@@ -39,10 +41,16 @@ const getFrameworkOptions = mainConfig => {
|
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
return undefined;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const sanitizeAddonName = name => {
|
|
47
|
+
return (0, _sanitize.cleanPaths)(name).replace(/\/dist\/.*/, '').replace(/\.[mc]?[tj]?s[x]?$/, '').replace(/\/register$/, '').replace(/\/manager$/, '').replace(/\/preset$/, '');
|
|
42
48
|
}; // Analyze a combination of information from main.js and package.json
|
|
43
49
|
// to provide telemetry over a Storybook project
|
|
44
50
|
|
|
45
51
|
|
|
52
|
+
exports.sanitizeAddonName = sanitizeAddonName;
|
|
53
|
+
|
|
46
54
|
const computeStorybookMetadata = async ({
|
|
47
55
|
packageJson,
|
|
48
56
|
mainConfig
|
|
@@ -123,17 +131,17 @@ const computeStorybookMetadata = async ({
|
|
|
123
131
|
|
|
124
132
|
if (mainConfig.addons) {
|
|
125
133
|
mainConfig.addons.forEach(addon => {
|
|
126
|
-
let
|
|
134
|
+
let addonName;
|
|
127
135
|
let options;
|
|
128
136
|
|
|
129
137
|
if (typeof addon === 'string') {
|
|
130
|
-
|
|
138
|
+
addonName = sanitizeAddonName(addon);
|
|
131
139
|
} else {
|
|
132
140
|
options = addon.options;
|
|
133
|
-
|
|
141
|
+
addonName = sanitizeAddonName(addon.name);
|
|
134
142
|
}
|
|
135
143
|
|
|
136
|
-
addons[
|
|
144
|
+
addons[addonName] = {
|
|
137
145
|
options,
|
|
138
146
|
version: undefined
|
|
139
147
|
};
|
|
@@ -164,7 +172,9 @@ const computeStorybookMetadata = async ({
|
|
|
164
172
|
storybookPackages[name].version = version;
|
|
165
173
|
});
|
|
166
174
|
const language = allDependencies.typescript ? 'typescript' : 'javascript';
|
|
167
|
-
const hasStorybookEslint = !!allDependencies['eslint-plugin-storybook'];
|
|
175
|
+
const hasStorybookEslint = !!allDependencies['eslint-plugin-storybook']; // FIXME: resolve framework/renderer split in 7.0
|
|
176
|
+
// OR should be getting this from mainConfig instead?
|
|
177
|
+
|
|
168
178
|
const storybookInfo = (0, _coreCommon.getStorybookInfo)(packageJson);
|
|
169
179
|
const storybookVersion = ((_storybookPackages$st = storybookPackages[storybookInfo.frameworkPackage]) === null || _storybookPackages$st === void 0 ? void 0 : _storybookPackages$st.version) || storybookInfo.version;
|
|
170
180
|
return Object.assign({}, metadata, {
|
|
@@ -184,15 +194,19 @@ exports.computeStorybookMetadata = computeStorybookMetadata;
|
|
|
184
194
|
let cachedMetadata;
|
|
185
195
|
|
|
186
196
|
const getStorybookMetadata = async _configDir => {
|
|
197
|
+
var _packageJson$scripts;
|
|
198
|
+
|
|
187
199
|
if (cachedMetadata) {
|
|
188
200
|
return cachedMetadata;
|
|
189
201
|
}
|
|
190
202
|
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
203
|
+
const {
|
|
204
|
+
packageJson = {}
|
|
205
|
+
} = _readPkgUp.default.sync({
|
|
206
|
+
cwd: process.cwd(),
|
|
207
|
+
normalize: false
|
|
208
|
+
}) || {};
|
|
209
|
+
const configDir = (_configDir || (0, _coreCommon.getStorybookConfiguration)((packageJson === null || packageJson === void 0 ? void 0 : (_packageJson$scripts = packageJson.scripts) === null || _packageJson$scripts === void 0 ? void 0 : _packageJson$scripts.storybook) || '', '-c', '--config-dir')) ?? '.storybook';
|
|
196
210
|
const mainConfig = (0, _coreCommon.loadMainConfig)({
|
|
197
211
|
configDir
|
|
198
212
|
});
|
package/dist/cjs/telemetry.js
CHANGED
|
@@ -64,7 +64,7 @@ async function sendTelemetry(data, options = {
|
|
|
64
64
|
},
|
|
65
65
|
retries: 3,
|
|
66
66
|
retryOn: [503, 504],
|
|
67
|
-
retryDelay: attempt => 2 ** attempt * options.retryDelay
|
|
67
|
+
retryDelay: attempt => 2 ** attempt * (typeof (options === null || options === void 0 ? void 0 : options.retryDelay) === 'number' && !Number.isNaN(options === null || options === void 0 ? void 0 : options.retryDelay) ? options.retryDelay : 1000)
|
|
68
68
|
});
|
|
69
69
|
tasks.push(request);
|
|
70
70
|
|
|
@@ -11,7 +11,8 @@ export const monorepoConfigs = {
|
|
|
11
11
|
export const getMonorepoType = () => {
|
|
12
12
|
const projectRootPath = getProjectRoot();
|
|
13
13
|
if (!projectRootPath) return undefined;
|
|
14
|
-
const
|
|
14
|
+
const keys = Object.keys(monorepoConfigs);
|
|
15
|
+
const monorepoType = keys.find(monorepo => {
|
|
15
16
|
const configFile = path.join(projectRootPath, monorepoConfigs[monorepo]);
|
|
16
17
|
return fs.existsSync(configFile);
|
|
17
18
|
});
|
|
@@ -20,7 +21,10 @@ export const getMonorepoType = () => {
|
|
|
20
21
|
return monorepoType;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
if (!fs.existsSync(path.join(projectRootPath, 'package.json')))
|
|
24
|
+
if (!fs.existsSync(path.join(projectRootPath, 'package.json'))) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
24
28
|
const packageJson = fs.readJsonSync(path.join(projectRootPath, 'package.json'));
|
|
25
29
|
|
|
26
30
|
if (packageJson?.workspaces) {
|
package/dist/esm/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { sendTelemetry } from './telemetry';
|
|
|
4
4
|
import { notify } from './notify';
|
|
5
5
|
import { sanitizeError } from './sanitize';
|
|
6
6
|
export * from './storybook-metadata';
|
|
7
|
-
export const telemetry = async (eventType, payload = {}, options) => {
|
|
7
|
+
export const telemetry = async (eventType, payload = {}, options = {}) => {
|
|
8
8
|
await notify();
|
|
9
9
|
const telemetryData = {
|
|
10
10
|
eventType,
|
|
@@ -12,7 +12,7 @@ export const telemetry = async (eventType, payload = {}, options) => {
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
try {
|
|
15
|
-
telemetryData.metadata = await getStorybookMetadata(options
|
|
15
|
+
telemetryData.metadata = await getStorybookMetadata(options?.configDir);
|
|
16
16
|
} catch (error) {
|
|
17
17
|
if (!telemetryData.payload.error) telemetryData.payload.error = error;
|
|
18
18
|
} finally {
|
|
@@ -3,6 +3,7 @@ import { detect, getNpmVersion } from 'detect-package-manager';
|
|
|
3
3
|
import { loadMainConfig, getStorybookInfo, getStorybookConfiguration, getProjectRoot } from '@storybook/core-common';
|
|
4
4
|
import { getActualPackageVersion, getActualPackageVersions } from './package-versions';
|
|
5
5
|
import { getMonorepoType } from './get-monorepo-type';
|
|
6
|
+
import { cleanPaths } from './sanitize';
|
|
6
7
|
export const metaFrameworks = {
|
|
7
8
|
next: 'Next',
|
|
8
9
|
'react-scripts': 'CRA',
|
|
@@ -23,10 +24,13 @@ const getFrameworkOptions = mainConfig => {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
return undefined;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const sanitizeAddonName = name => {
|
|
30
|
+
return cleanPaths(name).replace(/\/dist\/.*/, '').replace(/\.[mc]?[tj]?s[x]?$/, '').replace(/\/register$/, '').replace(/\/manager$/, '').replace(/\/preset$/, '');
|
|
26
31
|
}; // Analyze a combination of information from main.js and package.json
|
|
27
32
|
// to provide telemetry over a Storybook project
|
|
28
33
|
|
|
29
|
-
|
|
30
34
|
export const computeStorybookMetadata = async ({
|
|
31
35
|
packageJson,
|
|
32
36
|
mainConfig
|
|
@@ -105,17 +109,17 @@ export const computeStorybookMetadata = async ({
|
|
|
105
109
|
|
|
106
110
|
if (mainConfig.addons) {
|
|
107
111
|
mainConfig.addons.forEach(addon => {
|
|
108
|
-
let
|
|
112
|
+
let addonName;
|
|
109
113
|
let options;
|
|
110
114
|
|
|
111
115
|
if (typeof addon === 'string') {
|
|
112
|
-
|
|
116
|
+
addonName = sanitizeAddonName(addon);
|
|
113
117
|
} else {
|
|
114
118
|
options = addon.options;
|
|
115
|
-
|
|
119
|
+
addonName = sanitizeAddonName(addon.name);
|
|
116
120
|
}
|
|
117
121
|
|
|
118
|
-
addons[
|
|
122
|
+
addons[addonName] = {
|
|
119
123
|
options,
|
|
120
124
|
version: undefined
|
|
121
125
|
};
|
|
@@ -146,7 +150,9 @@ export const computeStorybookMetadata = async ({
|
|
|
146
150
|
storybookPackages[name].version = version;
|
|
147
151
|
});
|
|
148
152
|
const language = allDependencies.typescript ? 'typescript' : 'javascript';
|
|
149
|
-
const hasStorybookEslint = !!allDependencies['eslint-plugin-storybook'];
|
|
153
|
+
const hasStorybookEslint = !!allDependencies['eslint-plugin-storybook']; // FIXME: resolve framework/renderer split in 7.0
|
|
154
|
+
// OR should be getting this from mainConfig instead?
|
|
155
|
+
|
|
150
156
|
const storybookInfo = getStorybookInfo(packageJson);
|
|
151
157
|
const storybookVersion = storybookPackages[storybookInfo.frameworkPackage]?.version || storybookInfo.version;
|
|
152
158
|
return Object.assign({}, metadata, {
|
|
@@ -167,10 +173,13 @@ export const getStorybookMetadata = async _configDir => {
|
|
|
167
173
|
return cachedMetadata;
|
|
168
174
|
}
|
|
169
175
|
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
176
|
+
const {
|
|
177
|
+
packageJson = {}
|
|
178
|
+
} = readPkgUp.sync({
|
|
179
|
+
cwd: process.cwd(),
|
|
180
|
+
normalize: false
|
|
181
|
+
}) || {};
|
|
182
|
+
const configDir = (_configDir || getStorybookConfiguration(packageJson?.scripts?.storybook || '', '-c', '--config-dir')) ?? '.storybook';
|
|
174
183
|
const mainConfig = loadMainConfig({
|
|
175
184
|
configDir
|
|
176
185
|
});
|
package/dist/esm/telemetry.js
CHANGED
|
@@ -50,7 +50,7 @@ export async function sendTelemetry(data, options = {
|
|
|
50
50
|
},
|
|
51
51
|
retries: 3,
|
|
52
52
|
retryOn: [503, 504],
|
|
53
|
-
retryDelay: attempt => 2 ** attempt * options.retryDelay
|
|
53
|
+
retryDelay: attempt => 2 ** attempt * (typeof options?.retryDelay === 'number' && !Number.isNaN(options?.retryDelay) ? options.retryDelay : 1000)
|
|
54
54
|
});
|
|
55
55
|
tasks.push(request);
|
|
56
56
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { StorybookConfig, PackageJson } from '@storybook/core-common';
|
|
2
2
|
import type { StorybookMetadata } from './types';
|
|
3
3
|
export declare const metaFrameworks: Record<string, string>;
|
|
4
|
+
export declare const sanitizeAddonName: (name: string) => string;
|
|
4
5
|
export declare const computeStorybookMetadata: ({ packageJson, mainConfig, }: {
|
|
5
6
|
packageJson: PackageJson;
|
|
6
7
|
mainConfig: StorybookConfig & Record<string, any>;
|
|
7
8
|
}) => Promise<StorybookMetadata>;
|
|
8
|
-
export declare const getStorybookMetadata: (_configDir
|
|
9
|
+
export declare const getStorybookMetadata: (_configDir?: string | undefined) => Promise<StorybookMetadata>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { PM } from 'detect-package-manager';
|
|
|
3
3
|
import type { MonorepoType } from './get-monorepo-type';
|
|
4
4
|
export declare type EventType = 'start' | 'build' | 'upgrade' | 'init' | 'error-build' | 'error-dev' | 'error-metadata';
|
|
5
5
|
export interface Dependency {
|
|
6
|
-
version: string;
|
|
6
|
+
version: string | undefined;
|
|
7
7
|
}
|
|
8
8
|
export interface StorybookAddon extends Dependency {
|
|
9
9
|
options: any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/telemetry",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.33",
|
|
4
4
|
"description": "Telemetry logging for crash reports and usage statistics",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -30,24 +30,25 @@
|
|
|
30
30
|
"*.d.ts"
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
|
-
"
|
|
33
|
+
"check": "tsc --noEmit",
|
|
34
|
+
"prep": "node ../../../scripts/prepare.js"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@storybook/client-logger": "7.0.0-alpha.
|
|
37
|
-
"@storybook/core-common": "7.0.0-alpha.
|
|
37
|
+
"@storybook/client-logger": "7.0.0-alpha.33",
|
|
38
|
+
"@storybook/core-common": "7.0.0-alpha.33",
|
|
38
39
|
"chalk": "^4.1.0",
|
|
39
|
-
"core-js": "^3.8.2",
|
|
40
40
|
"detect-package-manager": "^2.0.1",
|
|
41
41
|
"fetch-retry": "^5.0.2",
|
|
42
42
|
"fs-extra": "^9.0.1",
|
|
43
|
-
"global": "^4.4.0",
|
|
44
43
|
"isomorphic-unfetch": "^3.1.0",
|
|
45
44
|
"nanoid": "^3.3.1",
|
|
46
|
-
"read-pkg-up": "^7.0.1"
|
|
47
|
-
|
|
45
|
+
"read-pkg-up": "^7.0.1"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"typescript": "~4.6.3"
|
|
48
49
|
},
|
|
49
50
|
"publishConfig": {
|
|
50
51
|
"access": "public"
|
|
51
52
|
},
|
|
52
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "5da5b0fabd04cc5cd5771e8242a960f05d03234a"
|
|
53
54
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2017 Kadira Inc. <hello@kadira.io>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|