Skip to content

refactor(config): rename ANALYTICS_ENABLED to IS_ANALYTICS_ENABLED #11652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ jobs:
env:
NX_REJECT_UNKNOWN_LOCAL_CACHE: 0
NODE_ENV: test
ANALYTICS_ENABLED: true
IS_ANALYTICS_ENABLED: true
CLICKHOUSE_URL: "http://default:clickhousePassword@localhost:8123/twenty"
CLICKHOUSE_PASSWORD: clickhousePassword
steps:
Expand Down
36 changes: 35 additions & 1 deletion packages/twenty-front/src/generated-metadata/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ export enum CaptchaDriverType {

export type ClientConfig = {
__typename?: 'ClientConfig';
analyticsEnabled: Scalars['Boolean']['output'];
api: ApiConfig;
authProviders: AuthProviders;
billing: Billing;
Expand All @@ -308,6 +307,7 @@ export type ClientConfig = {
debugMode: Scalars['Boolean']['output'];
defaultSubdomain?: Maybe<Scalars['String']['output']>;
frontDomain: Scalars['String']['output'];
isAnalyticsEnabled: Scalars['Boolean']['output'];
isAttachmentPreviewEnabled: Scalars['Boolean']['output'];
isEmailVerificationRequired: Scalars['Boolean']['output'];
isGoogleCalendarEnabled: Scalars['Boolean']['output'];
Expand Down Expand Up @@ -517,6 +517,15 @@ export type CustomDomainValidRecords = {
records: Array<CustomDomainRecord>;
};

/** Database Event Action */
export enum DatabaseEventAction {
CREATED = 'CREATED',
DELETED = 'DELETED',
DESTROYED = 'DESTROYED',
RESTORED = 'RESTORED',
UPDATED = 'UPDATED'
}

export type DateFilter = {
eq?: InputMaybe<Scalars['Date']['input']>;
gt?: InputMaybe<Scalars['Date']['input']>;
Expand Down Expand Up @@ -1500,6 +1509,21 @@ export type ObjectStandardOverrides = {
translations?: Maybe<Scalars['JSON']['output']>;
};

export type OnDbEventDto = {
__typename?: 'OnDbEventDTO';
action: DatabaseEventAction;
eventDate: Scalars['DateTime']['output'];
objectNameSingular: Scalars['String']['output'];
record: Scalars['JSON']['output'];
updatedFields?: Maybe<Array<Scalars['String']['output']>>;
};

export type OnDbEventInput = {
action?: InputMaybe<DatabaseEventAction>;
objectNameSingular?: InputMaybe<Scalars['String']['input']>;
recordId?: InputMaybe<Scalars['String']['input']>;
};

/** Onboarding status */
export enum OnboardingStatus {
COMPLETED = 'COMPLETED',
Expand Down Expand Up @@ -2090,6 +2114,16 @@ export type SubmitFormStepInput = {
workflowRunId: Scalars['String']['input'];
};

export type Subscription = {
__typename?: 'Subscription';
onDbEvent: OnDbEventDto;
};


export type SubscriptionOnDbEventArgs = {
input: OnDbEventInput;
};

export enum SubscriptionInterval {
Day = 'Day',
Month = 'Month',
Expand Down
6 changes: 3 additions & 3 deletions packages/twenty-front/src/generated/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ export enum CaptchaDriverType {

export type ClientConfig = {
__typename?: 'ClientConfig';
analyticsEnabled: Scalars['Boolean'];
api: ApiConfig;
authProviders: AuthProviders;
billing: Billing;
Expand All @@ -300,6 +299,7 @@ export type ClientConfig = {
debugMode: Scalars['Boolean'];
defaultSubdomain?: Maybe<Scalars['String']>;
frontDomain: Scalars['String'];
isAnalyticsEnabled: Scalars['Boolean'];
isAttachmentPreviewEnabled: Scalars['Boolean'];
isEmailVerificationRequired: Scalars['Boolean'];
isGoogleCalendarEnabled: Scalars['Boolean'];
Expand Down Expand Up @@ -2660,7 +2660,7 @@ export type SwitchSubscriptionToYearlyIntervalMutation = { __typename?: 'Mutatio
export type GetClientConfigQueryVariables = Exact<{ [key: string]: never; }>;


export type GetClientConfigQuery = { __typename?: 'Query', clientConfig: { __typename?: 'ClientConfig', signInPrefilled: boolean, isMultiWorkspaceEnabled: boolean, isEmailVerificationRequired: boolean, defaultSubdomain?: string | null, frontDomain: string, debugMode: boolean, analyticsEnabled: boolean, isAttachmentPreviewEnabled: boolean, chromeExtensionId?: string | null, canManageFeatureFlags: boolean, isMicrosoftMessagingEnabled: boolean, isMicrosoftCalendarEnabled: boolean, isGoogleMessagingEnabled: boolean, isGoogleCalendarEnabled: boolean, billing: { __typename?: 'Billing', isBillingEnabled: boolean, billingUrl?: string | null, trialPeriods: Array<{ __typename?: 'BillingTrialPeriodDTO', duration: number, isCreditCardRequired: boolean }> }, authProviders: { __typename?: 'AuthProviders', google: boolean, password: boolean, microsoft: boolean, sso: Array<{ __typename?: 'SSOIdentityProvider', id: string, name: string, type: IdentityProviderType, status: SsoIdentityProviderStatus, issuer: string }> }, support: { __typename?: 'Support', supportDriver: string, supportFrontChatId?: string | null }, sentry: { __typename?: 'Sentry', dsn?: string | null, environment?: string | null, release?: string | null }, captcha: { __typename?: 'Captcha', provider?: CaptchaDriverType | null, siteKey?: string | null }, api: { __typename?: 'ApiConfig', mutationMaximumAffectedRecords: number }, publicFeatureFlags: Array<{ __typename?: 'PublicFeatureFlag', key: FeatureFlagKey, metadata: { __typename?: 'PublicFeatureFlagMetadata', label: string, description: string, imagePath: string } }> } };
export type GetClientConfigQuery = { __typename?: 'Query', clientConfig: { __typename?: 'ClientConfig', signInPrefilled: boolean, isMultiWorkspaceEnabled: boolean, isEmailVerificationRequired: boolean, defaultSubdomain?: string | null, frontDomain: string, debugMode: boolean, isAnalyticsEnabled: boolean, isAttachmentPreviewEnabled: boolean, chromeExtensionId?: string | null, canManageFeatureFlags: boolean, isMicrosoftMessagingEnabled: boolean, isMicrosoftCalendarEnabled: boolean, isGoogleMessagingEnabled: boolean, isGoogleCalendarEnabled: boolean, billing: { __typename?: 'Billing', isBillingEnabled: boolean, billingUrl?: string | null, trialPeriods: Array<{ __typename?: 'BillingTrialPeriodDTO', duration: number, isCreditCardRequired: boolean }> }, authProviders: { __typename?: 'AuthProviders', google: boolean, password: boolean, microsoft: boolean, sso: Array<{ __typename?: 'SSOIdentityProvider', id: string, name: string, type: IdentityProviderType, status: SsoIdentityProviderStatus, issuer: string }> }, support: { __typename?: 'Support', supportDriver: string, supportFrontChatId?: string | null }, sentry: { __typename?: 'Sentry', dsn?: string | null, environment?: string | null, release?: string | null }, captcha: { __typename?: 'Captcha', provider?: CaptchaDriverType | null, siteKey?: string | null }, api: { __typename?: 'ApiConfig', mutationMaximumAffectedRecords: number }, publicFeatureFlags: Array<{ __typename?: 'PublicFeatureFlag', key: FeatureFlagKey, metadata: { __typename?: 'PublicFeatureFlagMetadata', label: string, description: string, imagePath: string } }> } };

export type SearchQueryVariables = Exact<{
searchInput: Scalars['String'];
Expand Down Expand Up @@ -4466,7 +4466,7 @@ export const GetClientConfigDocument = gql`
defaultSubdomain
frontDomain
debugMode
analyticsEnabled
isAnalyticsEnabled
isAttachmentPreviewEnabled
support {
supportDriver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export const ActionButton = ({
/>
<StyledWrapper>
<AppTooltip
// eslint-disable-next-line
anchorSelect={`#action-menu-entry-${action.key}`}
content={label}
delay={TooltipDelay.longDelay}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ export const useRequestFreshCaptchaToken = () => {
});
break;
case CaptchaDriverType.Turnstile:
// TODO: fix workspace-no-hardcoded-colors rule
// eslint-disable-next-line @nx/workspace-no-hardcoded-colors
captchaWidget = window.turnstile.render('#captcha-widget', {
sitekey: captcha.siteKey,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const ClientConfigProviderEffect = () => {
sso: data?.clientConfig.authProviders.sso,
});
setIsDebugMode(data?.clientConfig.debugMode);
setIsAnalyticsEnabled(data?.clientConfig.analyticsEnabled);
setIsAnalyticsEnabled(data?.clientConfig.isAnalyticsEnabled);
setIsDeveloperDefaultSignInPrefilled(data?.clientConfig.signInPrefilled);
setIsMultiWorkspaceEnabled(data?.clientConfig.isMultiWorkspaceEnabled);
setIsEmailVerificationRequired(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const GET_CLIENT_CONFIG = gql`
defaultSubdomain
frontDomain
debugMode
analyticsEnabled
isAnalyticsEnabled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe let's rename the env variable only since this will create a breaking change during the next deploy :(

isAttachmentPreviewEnabled
support {
supportDriver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ export const ObjectOptionsDropdownMenuContent = () => {
</div>
{currentView?.key === 'INDEX' && (
<AppTooltip
// eslint-disable-next-line
anchorSelect={`#delete-view-menu-item`}
content={t`Not available on Default View`}
noArrow
Expand Down
2 changes: 1 addition & 1 deletion packages/twenty-front/src/testing/mock-data/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const mockedClientConfig: ClientConfig = {
defaultSubdomain: 'app',
chromeExtensionId: 'MOCKED_EXTENSION_ID',
debugMode: false,
analyticsEnabled: true,
isAnalyticsEnabled: true,
support: {
supportDriver: 'front',
supportFrontChatId: null,
Expand Down
2 changes: 1 addition & 1 deletion packages/twenty-server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ FRONTEND_URL=http://localhost:3001
# CLOUDFLARE_ZONE_ID=
# CLOUDFLARE_WEBHOOK_SECRET=
# IS_CONFIG_VARIABLES_IN_DB_ENABLED=false
# ANALYTICS_ENABLED=
# IS_ANALYTICS_ENABLED=
# CLICKHOUSE_URL=http://default:clickhousePassword@localhost:8123/twenty
1 change: 1 addition & 0 deletions packages/twenty-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"worker:prod": "node dist/src/queue-worker/queue-worker",
"database:init:prod": "npx ts-node ./scripts/setup-db.ts && yarn database:migrate:prod",
"database:migrate:prod": "npx -y typeorm migration:run -d dist/src/database/typeorm/metadata/metadata.datasource && npx -y typeorm migration:run -d dist/src/database/typeorm/core/core.datasource",
"clickhouse:migrate:prod": "npx ts-node ./src/database/clickhouse/migrations/run-migrations.ts",
"typeorm": "../../node_modules/typeorm/.bin/typeorm"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ CREATE TABLE IF NOT EXISTS events
`workspaceId` String DEFAULT '',
`properties` JSON
)
ENGINE = MergeTree
ORDER BY (event, workspaceId, timestamp);
ENGINE = MergeTree
ORDER BY (event, workspaceId, timestamp)
SETTINGS index_granularity = 8192
SETTINGS allow_experimental_json_type = 1;
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ CREATE TABLE IF NOT EXISTS pageview
`userId` String DEFAULT '',
`workspaceId` String DEFAULT ''
)
ENGINE = MergeTree
ORDER BY (name, workspaceId, userId, timestamp);
ENGINE = MergeTree
ORDER BY (name, workspaceId, userId, timestamp)
SETTINGS index_granularity = 8192
SETTINGS allow_experimental_json_type = 1;
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ async function ensureDatabaseExists() {
await client.command({
query: `CREATE DATABASE IF NOT EXISTS "${database}"`,
});
await client.command({
query: `SET enable_json_type = 1`,
});

await client.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class AnalyticsService {
private preventAnalyticsIfDisabled(
sendEventOrPageviewFunction: () => Promise<{ success: boolean }>,
) {
if (!this.twentyConfigService.get('ANALYTICS_ENABLED')) {
if (!this.twentyConfigService.get('IS_ANALYTICS_ENABLED')) {
return { success: true };
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('ClickhouseService', () => {
provide: TwentyConfigService,
useValue: {
get: jest.fn((key) => {
if (key === 'ANALYTICS_ENABLED') return true;
if (key === 'IS_ANALYTICS_ENABLED') return true;
if (key === 'CLICKHOUSE_URL') return 'http://localhost:8123';

return null;
Expand Down Expand Up @@ -83,7 +83,7 @@ describe('ClickhouseService', () => {
describe('constructor', () => {
it('should not initialize clickhouse client when analytics is disabled', async () => {
jest.spyOn(twentyConfigService, 'get').mockImplementation((key) => {
if (key === 'ANALYTICS_ENABLED') return false;
if (key === 'IS_ANALYTICS_ENABLED') return false;
});

const newModule: TestingModule = await Test.createTestingModule({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class ClickhouseService {
private readonly exceptionHandlerService: ExceptionHandlerService,
private readonly twentyConfigService: TwentyConfigService,
) {
if (twentyConfigService.get('ANALYTICS_ENABLED')) {
if (twentyConfigService.get('IS_ANALYTICS_ENABLED')) {
this.clickhouseClient = createClient({
url: twentyConfigService.get('CLICKHOUSE_URL'),
compression: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class ClientConfig {
debugMode: boolean;

@Field(() => Boolean)
analyticsEnabled: boolean;
isAnalyticsEnabled: boolean;

@Field(() => Support)
support: Support;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class ClientConfigResolver {
isAttachmentPreviewEnabled: this.twentyConfigService.get(
'IS_ATTACHMENT_PREVIEW_ENABLED',
),
analyticsEnabled: this.twentyConfigService.get('ANALYTICS_ENABLED'),
isAnalyticsEnabled: this.twentyConfigService.get('IS_ANALYTICS_ENABLED'),
canManageFeatureFlags:
this.twentyConfigService.get('NODE_ENV') ===
NodeEnvironment.development ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ export class ConfigVariables {
@CastToBoolean()
@IsOptional()
@IsBoolean()
ANALYTICS_ENABLED = false;
IS_ANALYTICS_ENABLED = false;

@ConfigVariablesMetadata({
group: ConfigVariablesGroup.AnalyticsConfig,
Expand All @@ -472,7 +472,7 @@ export class ConfigVariables {
require_tld: false,
allow_underscores: true,
})
@ValidateIf((env) => env.ANALYTICS_ENABLED === true)
@ValidateIf((env) => env.IS_ANALYTICS_ENABLED === true)
CLICKHOUSE_URL: string;

@ConfigVariablesMetadata({
Expand Down
Loading