From b0630fff701d947b6b207d4cc5dfd126459cab90 Mon Sep 17 00:00:00 2001 From: Pierre Lehnen <55164754+pierre-lehnen-rc@users.noreply.github.com> Date: Fri, 12 Apr 2024 18:13:58 -0300 Subject: [PATCH] chore: remove references to EE code in the stats collector (#32052) --- .../statistics/server/lib/getEEStatistics.ts} | 27 +++++-------------- .../app/statistics/server/lib/statistics.ts | 2 +- packages/core-typings/src/IStats.ts | 5 ++++ 3 files changed, 12 insertions(+), 22 deletions(-) rename apps/meteor/{ee/app/license/server/getStatistics.ts => app/statistics/server/lib/getEEStatistics.ts} (80%) diff --git a/apps/meteor/ee/app/license/server/getStatistics.ts b/apps/meteor/app/statistics/server/lib/getEEStatistics.ts similarity index 80% rename from apps/meteor/ee/app/license/server/getStatistics.ts rename to apps/meteor/app/statistics/server/lib/getEEStatistics.ts index e8ff402ea1c..ffb5a939c2f 100644 --- a/apps/meteor/ee/app/license/server/getStatistics.ts +++ b/apps/meteor/app/statistics/server/lib/getEEStatistics.ts @@ -1,29 +1,15 @@ import { log } from 'console'; import { Analytics } from '@rocket.chat/core-services'; +import type { IStats } from '@rocket.chat/core-typings'; import { License } from '@rocket.chat/license'; import { CannedResponse, OmnichannelServiceLevelAgreements, LivechatRooms, LivechatTag, LivechatUnit, Users } from '@rocket.chat/models'; -type ENTERPRISE_STATISTICS = GenericStats & Partial; - -type GenericStats = { - modules: string[]; - tags: string[]; - seatRequests: number; -}; - -type EEOnlyStats = { - livechatTags: number; - cannedResponses: number; - priorities: number; - slas: number; - businessUnits: number; - omnichannelPdfTranscriptRequested: number; - omnichannelPdfTranscriptSucceeded: number; - omnichannelRoomsWithSlas: number; - omnichannelRoomsWithPriorities: number; - livechatMonitors: number; -}; +type ENTERPRISE_STATISTICS = IStats['enterprise']; + +type GenericStats = Pick; + +type EEOnlyStats = Omit; export async function getStatistics(): Promise { const genericStats: GenericStats = { @@ -42,7 +28,6 @@ export async function getStatistics(): Promise { return statistics; } -// These models are only available on EE license so don't import them inside CE license as it will break the build async function getEEStatistics(): Promise { if (!License.hasModule('livechat-enterprise')) { return; diff --git a/apps/meteor/app/statistics/server/lib/statistics.ts b/apps/meteor/app/statistics/server/lib/statistics.ts index 8887f4ce36f..a6cc5e3cc26 100644 --- a/apps/meteor/app/statistics/server/lib/statistics.ts +++ b/apps/meteor/app/statistics/server/lib/statistics.ts @@ -29,7 +29,6 @@ import { import { MongoInternals } from 'meteor/mongo'; import moment from 'moment'; -import { getStatistics as getEnterpriseStatistics } from '../../../../ee/app/license/server/getStatistics'; import { readSecondaryPreferred } from '../../../../server/database/readSecondaryPreferred'; import { isRunningMs } from '../../../../server/lib/isRunningMs'; import { getControl } from '../../../../server/lib/migrations'; @@ -40,6 +39,7 @@ import { settings } from '../../../settings/server'; import { Info } from '../../../utils/rocketchat.info'; import { getMongoInfo } from '../../../utils/server/functions/getMongoInfo'; import { getAppsStatistics } from './getAppsStatistics'; +import { getStatistics as getEnterpriseStatistics } from './getEEStatistics'; import { getImporterStatistics } from './getImporterStatistics'; import { getServicesStatistics } from './getServicesStatistics'; diff --git a/packages/core-typings/src/IStats.ts b/packages/core-typings/src/IStats.ts index 6bfa761c24c..d2cc0110d72 100644 --- a/packages/core-typings/src/IStats.ts +++ b/packages/core-typings/src/IStats.ts @@ -159,6 +159,11 @@ export interface IStats { priorities?: number; slas?: number; businessUnits?: number; + omnichannelPdfTranscriptRequested?: number; + omnichannelPdfTranscriptSucceeded?: number; + omnichannelRoomsWithSlas?: number; + omnichannelRoomsWithPriorities?: number; + livechatMonitors?: number; }; createdAt: Date | string; totalOTR: number;