2021-04-21 15:32:30 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const { reduce } = require('lodash/fp');
|
|
|
|
const { getService } = require('../utils');
|
|
|
|
|
|
|
|
const sendDidInitializeEvent = async () => {
|
|
|
|
const { isLocalizedContentType } = getService('content-types');
|
|
|
|
|
|
|
|
const numberOfContentTypes = reduce(
|
|
|
|
(sum, contentType) => (isLocalizedContentType(contentType) ? sum + 1 : sum),
|
|
|
|
0
|
|
|
|
)(strapi.contentTypes);
|
|
|
|
|
2022-09-02 14:43:51 +03:00
|
|
|
// This event is anonymous
|
|
|
|
await strapi.telemetry.send('didInitializeI18n', { groupProperties: { numberOfContentTypes } });
|
2021-04-21 15:32:30 +02:00
|
|
|
};
|
|
|
|
|
2022-09-02 14:43:51 +03:00
|
|
|
const sendDidUpdateI18nLocalesEvent = async (adminUser) => {
|
2021-04-21 15:32:30 +02:00
|
|
|
const numberOfLocales = await getService('locales').count();
|
|
|
|
|
2022-09-02 14:43:51 +03:00
|
|
|
await strapi.telemetry.send('didUpdateI18nLocales', {
|
|
|
|
adminUser,
|
|
|
|
groupProperties: { numberOfLocales },
|
|
|
|
});
|
2021-04-21 15:32:30 +02:00
|
|
|
};
|
|
|
|
|
2021-06-08 10:39:45 +02:00
|
|
|
module.exports = () => ({
|
2021-04-21 15:32:30 +02:00
|
|
|
sendDidInitializeEvent,
|
|
|
|
sendDidUpdateI18nLocalesEvent,
|
2021-06-08 10:39:45 +02:00
|
|
|
});
|