mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 02:16:03 +00:00
Track content types, dzs, and components per user
This commit is contained in:
parent
b5e75847ca
commit
c0c8570c36
@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const { map, get, values, isEqual, sumBy, sum } = require('lodash/fp');
|
||||
const execa = require('execa');
|
||||
const _ = require('lodash');
|
||||
const { exists } = require('fs-extra');
|
||||
@ -96,11 +98,23 @@ module.exports = {
|
||||
);
|
||||
const isHostedOnStrapiCloud = env('STRAPI_HOSTING', null) === 'strapi.cloud';
|
||||
|
||||
const numberOfContentTypes = _.size(strapi.contentTypes);
|
||||
const numberOfComponents = _.size(strapi.components);
|
||||
const numberOfDynamicZones = sum(
|
||||
map(
|
||||
(ct) => sumBy(isEqual('dynamiczone'), map(get('type'), values(get('attributes', ct)))),
|
||||
strapi.contentTypes
|
||||
)
|
||||
);
|
||||
|
||||
return {
|
||||
data: {
|
||||
useTypescriptOnServer,
|
||||
useTypescriptOnAdmin,
|
||||
isHostedOnStrapiCloud,
|
||||
numberOfContentTypes,
|
||||
numberOfComponents,
|
||||
numberOfDynamicZones,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const _ = require('lodash');
|
||||
const { map, get, values, isEqual, sumBy, sum } = require('lodash/fp');
|
||||
const isDocker = require('is-docker');
|
||||
const fetch = require('node-fetch');
|
||||
const ciEnv = require('ci-info');
|
||||
@ -42,6 +43,14 @@ module.exports = (strapi) => {
|
||||
const serverRootPath = strapi.dirs.app.root;
|
||||
const adminRootPath = path.join(strapi.dirs.app.root, 'src', 'admin');
|
||||
|
||||
const getNumberOfDynamicZones = () =>
|
||||
sum(
|
||||
map(
|
||||
(ct) => sumBy(isEqual('dynamiczone'), map(get('type'), values(get('attributes', ct)))),
|
||||
strapi.contentTypes
|
||||
)
|
||||
);
|
||||
|
||||
const anonymousMetadata = {
|
||||
environment: strapi.config.environment,
|
||||
os: os.type(),
|
||||
@ -56,6 +65,9 @@ module.exports = (strapi) => {
|
||||
useTypescriptOnServer: isUsingTypeScriptSync(serverRootPath),
|
||||
useTypescriptOnAdmin: isUsingTypeScriptSync(adminRootPath),
|
||||
isHostedOnStrapiCloud: env('STRAPI_HOSTING', null) === 'strapi.cloud',
|
||||
numberOfContentTypes: _.size(strapi.contentTypes),
|
||||
numberOfComponents: _.size(strapi.components),
|
||||
numberOfDynamicZones: getNumberOfDynamicZones(),
|
||||
};
|
||||
|
||||
addPackageJsonStrapiMetadata(anonymousMetadata, strapi);
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
const os = require('os');
|
||||
const _ = require('lodash');
|
||||
const { map, get, values, isEqual, sumBy, sum } = require('lodash/fp');
|
||||
const fetch = require('node-fetch');
|
||||
const sentry = require('@sentry/node');
|
||||
|
||||
@ -53,6 +54,14 @@ function captureStderr(name, error) {
|
||||
return captureError(name);
|
||||
}
|
||||
|
||||
const getNumberOfDynamicZones = () =>
|
||||
sum(
|
||||
map(
|
||||
(ct) => sumBy(isEqual('dynamiczone'), map(get('type'), values(get('attributes', ct)))),
|
||||
strapi.contentTypes
|
||||
)
|
||||
);
|
||||
|
||||
const getProperties = (scope, error) => ({
|
||||
error: typeof error === 'string' ? error : error && error.message,
|
||||
os: os.type(),
|
||||
@ -67,6 +76,9 @@ const getProperties = (scope, error) => ({
|
||||
useTypescriptOnAdmin: scope.useTypescript,
|
||||
isHostedOnStrapiCloud: process.env.STRAPI_HOSTING === 'strapi.cloud',
|
||||
noRun: (scope.runQuickstartApp !== true).toString(),
|
||||
numberOfContentTypes: _.size(strapi.contentTypes),
|
||||
numberOfComponents: _.size(strapi.components),
|
||||
numberOfDynamicZones: getNumberOfDynamicZones(),
|
||||
});
|
||||
|
||||
function trackEvent(event, body) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user