diff --git a/.env.dist b/.env.dist index b8ee3f0e3..9f701730c 100644 --- a/.env.dist +++ b/.env.dist @@ -52,3 +52,7 @@ RABBITMQ_PORT= # MODULES FRONT_OFFICE_URI= BACK_OFFICE_URI= + +# MIXPANEL CONFIGURATION +MIXPANEL_TOKEN= +MIXPANEL_HOST= diff --git a/config/custom-environment-variables.js b/config/custom-environment-variables.js index dacdb425e..1533e242c 100644 --- a/config/custom-environment-variables.js +++ b/config/custom-environment-variables.js @@ -3,6 +3,7 @@ */ module.exports = { server: { + port: 'SERVER_PORT', url: 'SERVER_URL', allowedOrigins: 'SERVER_ALLOWED_ORIGINS', }, @@ -38,6 +39,7 @@ module.exports = { clientId: 'AUTH_CLIENT_ID', tenantId: 'AUTH_TENANT_ID', allowedIssuers: 'AUTH_ALLOWED_ISSUERS', + audience: 'AUTH_AUDIENCE', }, encryption: { key: 'ENCRYPTION_KEY', @@ -61,4 +63,8 @@ module.exports = { clientSecret: 'COMMON_SERVICES_CLIENT_SECRET', scope: 'COMMON_SERVICES_SCOPE', }, + mixpanel: { + token: 'MIXPANEL_TOKEN', + host: 'MIXPANEL_HOST', + }, }; diff --git a/package-lock.json b/package-lock.json index 298003627..1b276c5f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,6 +54,7 @@ "lodash": "^4.17.21", "migrate": "^1.8.0", "mime-types": "^2.1.33", + "mixpanel": "^0.18.0", "mongoose": "^7.4.3", "node-cache": "^5.1.2", "node-fetch": "^2.6.1", @@ -12830,6 +12831,29 @@ "node": ">= 6" } }, + "node_modules/mixpanel": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/mixpanel/-/mixpanel-0.18.0.tgz", + "integrity": "sha512-VyUoiLB/S/7abYYHGD5x0LijeuJCUabG8Hb+FvYU3Y99xHf1Qh+s4/pH9lt50fRitAHncWbU1FE01EknUfVVjQ==", + "dependencies": { + "https-proxy-agent": "5.0.0" + }, + "engines": { + "node": ">=10.0" + } + }, + "node_modules/mixpanel/node_modules/https-proxy-agent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", + "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/mkdirp": { "version": "0.5.6", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", diff --git a/package.json b/package.json index 051dd4d45..c2516a528 100644 --- a/package.json +++ b/package.json @@ -39,9 +39,9 @@ "@azure/storage-blob": "^12.5.0", "@casl/ability": "^6.5.0", "@casl/mongoose": "^7.2.1", + "@graphql-tools/schema": "^10.0.0", "@turf/helpers": "^6.5.0", "@turf/turf": "^6.5.0", - "@graphql-tools/schema": "^10.0.0", "@ucast/mongo2js": "^1.3.3", "amqplib": "^0.8.0", "axios": "^1.4.0", @@ -79,6 +79,7 @@ "lodash": "^4.17.21", "migrate": "^1.8.0", "mime-types": "^2.1.33", + "mixpanel": "^0.18.0", "mongoose": "^7.4.3", "node-cache": "^5.1.2", "node-fetch": "^2.6.1", diff --git a/src/index.ts b/src/index.ts index df915c662..3ae76d8f5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,7 @@ import subscriberSafe from './server/subscriberSafe'; import pullJobScheduler from './server/pullJobScheduler'; import customNotificationScheduler from './server/customNotificationScheduler'; import { startDatabase } from './server/database'; +import { initMixpanel } from './server/mixpanel'; import config from 'config'; import { logger } from './services/logger.service'; import { checkConfig } from '@utils/server/checkConfig.util'; @@ -22,6 +23,9 @@ declare global { } } +/** Init Mixpanel */ +initMixpanel(); + // Ensure that all mandatory keys exist checkConfig(); diff --git a/src/models/form.model.ts b/src/models/form.model.ts index 2cd04d72c..4bf6c3a9e 100644 --- a/src/models/form.model.ts +++ b/src/models/form.model.ts @@ -54,6 +54,7 @@ interface FormDocument extends Document { versions?: any[]; channel?: any; layouts?: any; + logEvents?: boolean; } /** Interface of form */ @@ -82,6 +83,7 @@ const schema = new Schema