/
githubmirror
/
strapi
Обзор
Документация
Войти
/
githubmirror
/
strapi
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/plugins/i18n/server/src/services/metrics.ts
36 строк
1 KB
DMehaffy
fix: remove await from several telemetry calls to prevent blocking (#24743)
11 май 2026, 18:24
Не верифицирован
11 май 2026, 18:24
e875c44
Код
Авторство
О чём код?
import { reduce } from 'lodash/fp'; import { getService } from '../utils'; const sendDidInitializeEvent = async () => { const { isLocalizedContentType } = getService('content-types'); // 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. const numberOfContentTypes = reduce( (sum, contentType) => (isLocalizedContentType(contentType) ? sum + 1 : sum), 0 )(strapi.contentTypes as any); strapi.telemetry .send('didInitializeI18n', { groupProperties: { numberOfContentTypes } }) .catch(() => {}); }; const sendDidUpdateI18nLocalesEvent = async () => { const numberOfLocales = await getService('locales').count(); strapi.telemetry .send('didUpdateI18nLocales', { groupProperties: { numberOfLocales }, }) .catch(() => {}); }; const metrics = () => ({ sendDidInitializeEvent, sendDidUpdateI18nLocalesEvent, }); type MetricsService = typeof metrics; export default metrics; export type { MetricsService };