|
@@ -19,7 +19,12 @@ import {
|
|
|
} from 'src/errors';
|
|
|
import { throwErr, validateSMTPEmail, validateSMTPUrl } from 'src/utils';
|
|
|
import { ConfigService } from '@nestjs/config';
|
|
|
-import { ServiceStatus, getConfiguredSSOProviders, stopApp } from './helper';
|
|
|
+import {
|
|
|
+ ServiceStatus,
|
|
|
+ generateAnalyticsUserId,
|
|
|
+ getConfiguredSSOProviders,
|
|
|
+ stopApp,
|
|
|
+} from './helper';
|
|
|
import { EnableAndDisableSSOArgs, InfraConfigArgs } from './input-args';
|
|
|
import { AuthProvider } from 'src/auth/helper';
|
|
|
|
|
@@ -75,6 +80,14 @@ export class InfraConfigService implements OnModuleInit {
|
|
|
name: InfraConfigEnum.VITE_ALLOWED_AUTH_PROVIDERS,
|
|
|
value: getConfiguredSSOProviders(),
|
|
|
},
|
|
|
+ {
|
|
|
+ name: InfraConfigEnum.ALLOW_ANALYTICS_COLLECTION,
|
|
|
+ value: false.toString(),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: InfraConfigEnum.ANALYTICS_USER_ID,
|
|
|
+ value: generateAnalyticsUserId(),
|
|
|
+ },
|
|
|
{
|
|
|
name: InfraConfigEnum.IS_FIRST_TIME_INFRA_SETUP,
|
|
|
value: (await this.prisma.infraConfig.count()) === 0 ? 'true' : 'false',
|
|
@@ -231,6 +244,22 @@ export class InfraConfigService implements OnModuleInit {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Enable or Disable Analytics Collection
|
|
|
+ *
|
|
|
+ * @param status Status to enable or disable
|
|
|
+ * @returns Boolean of status of analytics collection
|
|
|
+ */
|
|
|
+ async toggleAnalyticsCollection(status: ServiceStatus) {
|
|
|
+ const isUpdated = await this.update(
|
|
|
+ InfraConfigEnum.ALLOW_ANALYTICS_COLLECTION,
|
|
|
+ status === ServiceStatus.ENABLE ? 'true' : 'false',
|
|
|
+ );
|
|
|
+
|
|
|
+ if (E.isLeft(isUpdated)) return E.left(isUpdated.left);
|
|
|
+ return E.right(isUpdated.right.value === 'true');
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Enable or Disable SSO for login/signup
|
|
|
* @param provider Auth Provider to enable or disable
|