Move properties to single event

This commit is contained in:
Christian Capeans 2023-04-13 13:02:05 +02:00
parent cc95a75987
commit ae7ddd8df1
3 changed files with 20 additions and 4 deletions

View File

@ -43,6 +43,7 @@ const apisRegistry = require('./core/registries/apis');
const bootstrap = require('./core/bootstrap');
const loaders = require('./core/loaders');
const { destroyOnSignal } = require('./utils/signals');
const getNumberOfDynamicZones = require('./services/utils/dynamic-zones');
const sanitizersRegistry = require('./core/registries/sanitizers');
const convertCustomFieldType = require('./utils/convert-custom-field-type');
@ -249,6 +250,9 @@ class Strapi {
groupProperties: {
database: strapi.config.get('database.connection.client'),
plugins: Object.keys(strapi.plugins),
numberOfAllContentTypes: _.size(this.contentTypes), // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.
numberOfComponents: _.size(this.components),
numberOfDynamicZones: getNumberOfDynamicZones(),
// TODO: to add back
// providers: this.config.installedProviders,
},

View File

@ -17,7 +17,7 @@ const defaultQueryOpts = {
headers: { 'Content-Type': 'application/json' },
};
const ANALYTICS_URI = 'https://analytics.strapi.io';
const ANALYTICS_URI = 'http://localhost:4000';
/**
* Add properties from the package.json strapi key in the metadata
@ -71,7 +71,9 @@ module.exports = (strapi) => {
addPackageJsonStrapiMetadata(anonymousGroupProperties, strapi);
return async (event, payload = {}, opts = {}) => {
console.log('event', event, payload);
const userId = generateAdminUserHash(strapi);
console.log('anonymousGroupProperties', anonymousGroupProperties);
const reqParams = {
method: 'POST',
@ -84,9 +86,6 @@ module.exports = (strapi) => {
groupProperties: {
...anonymousGroupProperties,
projectType: strapi.EE ? 'Enterprise' : 'Community',
numberOfAllContentTypes: _.size(strapi.contentTypes), // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.
numberOfComponents: _.size(strapi.components),
numberOfDynamicZones: getNumberOfDynamicZones(),
...payload.groupProperties,
},
}),

View File

@ -0,0 +1,13 @@
'use strict';
const { map, values, sumBy, pipe, flatMap, propEq } = require('lodash/fp');
const getNumberOfDynamicZones = () => {
return pipe(
map('attributes'),
flatMap(values),
sumBy(propEq('type', 'dynamiczone'))
)(strapi.contentTypes);
};
module.exports = getNumberOfDynamicZones;