Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 2s
111 lines
3.7 KiB
TypeScript
111 lines
3.7 KiB
TypeScript
import { LivechatContacts, Statistics, Users } from '@rocket.chat/models';
|
|
import moment from 'moment';
|
|
|
|
import { LICENSE_VERSION } from './license';
|
|
import { Info } from '../../../app/utils/rocketchat.info';
|
|
import { settings } from '../../settings';
|
|
import { statistics } from '../statistics';
|
|
|
|
export type WorkspaceRegistrationData<T> = {
|
|
uniqueId: string;
|
|
deploymentFingerprintHash: string;
|
|
deploymentFingerprintVerified: boolean;
|
|
workspaceId: string;
|
|
address: string;
|
|
contactName: string;
|
|
contactEmail: T;
|
|
seats: number;
|
|
|
|
organizationType: string;
|
|
industry: string;
|
|
orgSize: string;
|
|
country: string;
|
|
language: string;
|
|
allowMarketing: string;
|
|
accountName: string;
|
|
agreePrivacyTerms: string;
|
|
website: string;
|
|
siteName: string;
|
|
workspaceType: unknown;
|
|
deploymentMethod: string;
|
|
deploymentPlatform: string;
|
|
version: string;
|
|
licenseVersion: number;
|
|
license?: string;
|
|
enterpriseReady: boolean;
|
|
setupComplete: boolean;
|
|
connectionDisable: boolean;
|
|
npsEnabled: string;
|
|
// TODO: Evaluate naming
|
|
MAC: number;
|
|
// activeContactsBillingMonth: number;
|
|
// activeContactsYesterday: number;
|
|
statsToken?: string;
|
|
};
|
|
|
|
export async function buildWorkspaceRegistrationData<T extends string | undefined>(contactEmail: T): Promise<WorkspaceRegistrationData<T>> {
|
|
const stats = (await Statistics.findLast()) || (await statistics.get());
|
|
|
|
const address = settings.get<string>('Site_Url');
|
|
const siteName = settings.get<string>('Site_Name');
|
|
const workspaceId = settings.get<string>('Cloud_Workspace_Id');
|
|
const allowMarketing = settings.get<string>('Allow_Marketing_Emails');
|
|
const accountName = settings.get<string>('Organization_Name');
|
|
const website = settings.get<string>('Website');
|
|
const npsEnabled = settings.get<string>('NPS_survey_enabled');
|
|
const agreePrivacyTerms = settings.get<string>('Cloud_Service_Agree_PrivacyTerms');
|
|
const setupWizardState = settings.get<string>('Show_Setup_Wizard');
|
|
const deploymentFingerprintHash = settings.get<string>('Deployment_FingerPrint_Hash');
|
|
const deploymentFingerprintVerified = settings.get<boolean>('Deployment_FingerPrint_Verified');
|
|
|
|
const firstUser = await Users.getOldest({ projection: { name: 1, emails: 1 } });
|
|
const contactName = firstUser?.name || '';
|
|
|
|
const country = settings.get<string>('Country');
|
|
const language = settings.get<string>('Language');
|
|
const organizationType = settings.get<string>('Organization_Type');
|
|
const industry = settings.get<string>('Industry');
|
|
const orgSize = settings.get<string>('Size');
|
|
const workspaceType = settings.get<string>('Server_Type');
|
|
|
|
const seats = await Users.getActiveLocalUserCount();
|
|
const MAC = await LivechatContacts.countContactsOnPeriod(moment.utc().format('YYYY-MM'));
|
|
|
|
const license = settings.get<string>('Enterprise_License');
|
|
|
|
return {
|
|
uniqueId: stats.uniqueId,
|
|
deploymentFingerprintHash,
|
|
deploymentFingerprintVerified,
|
|
workspaceId,
|
|
address,
|
|
contactName,
|
|
contactEmail,
|
|
seats,
|
|
allowMarketing,
|
|
accountName,
|
|
organizationType: String(organizationType),
|
|
industry: String(industry),
|
|
orgSize: String(orgSize),
|
|
country: String(country),
|
|
language: String(language),
|
|
agreePrivacyTerms,
|
|
website,
|
|
siteName,
|
|
workspaceType: String(workspaceType),
|
|
deploymentMethod: stats.deploy.method,
|
|
deploymentPlatform: stats.deploy.platform,
|
|
version: stats.version ?? Info.version,
|
|
licenseVersion: LICENSE_VERSION,
|
|
...(license && { license }),
|
|
enterpriseReady: true,
|
|
setupComplete: setupWizardState === 'completed',
|
|
connectionDisable: false,
|
|
npsEnabled,
|
|
MAC,
|
|
// activeContactsBillingMonth: stats.omnichannelContactsBySource.contactsCount,
|
|
// activeContactsYesterday: stats.uniqueContactsOfYesterday.contactsCount,
|
|
statsToken: stats.statsToken,
|
|
};
|
|
}
|