From 09850c827fa2c23a708d9f4c0fa9e9fa3fbd3d16 Mon Sep 17 00:00:00 2001 From: Weiko Date: Wed, 7 May 2025 17:11:00 +0200 Subject: [PATCH] Fix codegen and missing track mutation (#11928) Track mutation was recently renamed TrackAnalytics which broke apollo.factory.test.ts specs due to signature mismatch. This also broke other surfaces depending on this such as codegen. I've also ran codegen since it was a bit outdated --- .../src/generated-metadata/graphql.ts | 64 ++++++++++++++++--- .../twenty-front/src/generated/graphql.tsx | 60 +++-------------- .../services/__tests__/apollo.factory.test.ts | 14 +++- 3 files changed, 78 insertions(+), 60 deletions(-) diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.ts index c459d1460..03f96f97e 100644 --- a/packages/twenty-front/src/generated-metadata/graphql.ts +++ b/packages/twenty-front/src/generated-metadata/graphql.ts @@ -309,6 +309,7 @@ export type ClientConfig = { defaultSubdomain?: Maybe; frontDomain: Scalars['String']['output']; isAttachmentPreviewEnabled: Scalars['Boolean']['output']; + isConfigVariablesInDbEnabled: Scalars['Boolean']['output']; isEmailVerificationRequired: Scalars['Boolean']['output']; isGoogleCalendarEnabled: Scalars['Boolean']['output']; isGoogleMessagingEnabled: Scalars['Boolean']['output']; @@ -326,14 +327,32 @@ export type ComputeStepOutputSchemaInput = { step: Scalars['JSON']['input']; }; +export enum ConfigSource { + DATABASE = 'DATABASE', + DEFAULT = 'DEFAULT', + ENVIRONMENT = 'ENVIRONMENT' +} + export type ConfigVariable = { __typename?: 'ConfigVariable'; description: Scalars['String']['output']; + isEnvOnly: Scalars['Boolean']['output']; isSensitive: Scalars['Boolean']['output']; name: Scalars['String']['output']; - value: Scalars['String']['output']; + options?: Maybe; + source: ConfigSource; + type: ConfigVariableType; + value?: Maybe; }; +export enum ConfigVariableType { + ARRAY = 'ARRAY', + BOOLEAN = 'BOOLEAN', + ENUM = 'ENUM', + NUMBER = 'NUMBER', + STRING = 'STRING' +} + export enum ConfigVariablesGroup { AnalyticsConfig = 'AnalyticsConfig', BillingConfig = 'BillingConfig', @@ -941,8 +960,10 @@ export type Mutation = { checkoutSession: BillingSessionOutput; computeStepOutputSchema: Scalars['JSON']['output']; createApprovedAccessDomain: ApprovedAccessDomain; + createDatabaseConfigVariable: Scalars['Boolean']['output']; createDraftFromWorkflowVersion: WorkflowVersion; createOIDCIdentityProvider: SetupSsoOutput; + createObjectEvent: Analytics; createOneAppToken: AppToken; createOneField: Field; createOneObject: Object; @@ -955,6 +976,7 @@ export type Mutation = { deactivateWorkflowVersion: Scalars['Boolean']['output']; deleteApprovedAccessDomain: Scalars['Boolean']['output']; deleteCurrentWorkspace: Workspace; + deleteDatabaseConfigVariable: Scalars['Boolean']['output']; deleteOneField: Field; deleteOneObject: Object; deleteOneRelation: RelationMetadata; @@ -991,9 +1013,9 @@ export type Mutation = { switchToYearlyInterval: BillingUpdateOutput; syncRemoteTable: RemoteTable; syncRemoteTableSchemaChanges: RemoteTable; - track: Analytics; trackAnalytics: Analytics; unsyncRemoteTable: RemoteTable; + updateDatabaseConfigVariable: Scalars['Boolean']['output']; updateLabPublicFeatureFlag: FeatureFlagDto; updateOneField: Field; updateOneObject: Object; @@ -1052,6 +1074,12 @@ export type MutationCreateApprovedAccessDomainArgs = { }; +export type MutationCreateDatabaseConfigVariableArgs = { + key: Scalars['String']['input']; + value: Scalars['JSON']['input']; +}; + + export type MutationCreateDraftFromWorkflowVersionArgs = { input: CreateDraftFromWorkflowVersionInput; }; @@ -1062,6 +1090,14 @@ export type MutationCreateOidcIdentityProviderArgs = { }; +export type MutationCreateObjectEventArgs = { + event: Scalars['String']['input']; + objectMetadataId: Scalars['String']['input']; + properties?: InputMaybe; + recordId: Scalars['String']['input']; +}; + + export type MutationCreateOneAppTokenArgs = { input: CreateOneAppTokenInput; }; @@ -1117,6 +1153,11 @@ export type MutationDeleteApprovedAccessDomainArgs = { }; +export type MutationDeleteDatabaseConfigVariableArgs = { + key: Scalars['String']['input']; +}; + + export type MutationDeleteOneFieldArgs = { input: DeleteOneFieldInput; }; @@ -1269,12 +1310,6 @@ export type MutationSyncRemoteTableSchemaChangesArgs = { }; -export type MutationTrackArgs = { - action: Scalars['String']['input']; - payload: Scalars['JSON']['input']; -}; - - export type MutationTrackAnalyticsArgs = { event?: InputMaybe; name?: InputMaybe; @@ -1288,6 +1323,12 @@ export type MutationUnsyncRemoteTableArgs = { }; +export type MutationUpdateDatabaseConfigVariableArgs = { + key: Scalars['String']['input']; + value: Scalars['JSON']['input']; +}; + + export type MutationUpdateLabPublicFeatureFlagArgs = { input: UpdateLabPublicFeatureFlagInput; }; @@ -1619,6 +1660,7 @@ export type Query = { getApprovedAccessDomains: Array; getAvailablePackages: Scalars['JSON']['output']; getConfigVariablesGrouped: ConfigVariablesOutput; + getDatabaseConfigVariable: ConfigVariable; getIndicatorHealthStatus: AdminPanelHealthServiceData; getMeteredProductsUsage: Array; getPostgresCredentials?: Maybe; @@ -1701,6 +1743,11 @@ export type QueryGetAvailablePackagesArgs = { }; +export type QueryGetDatabaseConfigVariableArgs = { + key: Scalars['String']['input']; +}; + + export type QueryGetIndicatorHealthStatusArgs = { indicatorId: HealthIndicatorId; }; @@ -2494,6 +2541,7 @@ export type WorkflowAction = { __typename?: 'WorkflowAction'; id: Scalars['UUID']['output']; name: Scalars['String']['output']; + nextStepIds?: Maybe>; settings: Scalars['JSON']['output']; type: Scalars['String']['output']; valid: Scalars['Boolean']['output']; diff --git a/packages/twenty-front/src/generated/graphql.tsx b/packages/twenty-front/src/generated/graphql.tsx index b25e00e97..2f1c8176f 100644 --- a/packages/twenty-front/src/generated/graphql.tsx +++ b/packages/twenty-front/src/generated/graphql.tsx @@ -1,5 +1,5 @@ -import * as Apollo from '@apollo/client'; import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; export type Maybe = T | null; export type InputMaybe = Maybe; export type Exact = { [K in keyof T]: T[K] }; @@ -887,6 +887,7 @@ export type Mutation = { createDatabaseConfigVariable: Scalars['Boolean']; createDraftFromWorkflowVersion: WorkflowVersion; createOIDCIdentityProvider: SetupSsoOutput; + createObjectEvent: Analytics; createOneAppToken: AppToken; createOneField: Field; createOneObject: Object; @@ -930,7 +931,6 @@ export type Mutation = { skipSyncEmailOnboardingStep: OnboardingStepSuccess; submitFormStep: Scalars['Boolean']; switchToYearlyInterval: BillingUpdateOutput; - track: Analytics; trackAnalytics: Analytics; updateDatabaseConfigVariable: Scalars['Boolean']; updateLabPublicFeatureFlag: FeatureFlagDto; @@ -1006,6 +1006,14 @@ export type MutationCreateOidcIdentityProviderArgs = { }; +export type MutationCreateObjectEventArgs = { + event: Scalars['String']; + objectMetadataId: Scalars['String']; + properties?: InputMaybe; + recordId: Scalars['String']; +}; + + export type MutationCreateOneFieldArgs = { input: CreateOneFieldMetadataInput; }; @@ -1178,12 +1186,6 @@ export type MutationSubmitFormStepArgs = { }; -export type MutationTrackArgs = { - action: Scalars['String']; - payload: Scalars['JSON']; -}; - - export type MutationTrackAnalyticsArgs = { event?: InputMaybe; name?: InputMaybe; @@ -2508,14 +2510,6 @@ export type TrackAnalyticsMutationVariables = Exact<{ export type TrackAnalyticsMutation = { __typename?: 'Mutation', trackAnalytics: { __typename?: 'Analytics', success: boolean } }; -export type TrackMutationVariables = Exact<{ - action: Scalars['String']; - payload: Scalars['JSON']; -}>; - - -export type TrackMutation = { __typename?: 'Mutation', track: { __typename?: 'Analytics', success: boolean } }; - export type UploadFileMutationVariables = Exact<{ file: Scalars['Upload']; fileFolder?: InputMaybe; @@ -3511,40 +3505,6 @@ export function useTrackAnalyticsMutation(baseOptions?: Apollo.MutationHookOptio export type TrackAnalyticsMutationHookResult = ReturnType; export type TrackAnalyticsMutationResult = Apollo.MutationResult; export type TrackAnalyticsMutationOptions = Apollo.BaseMutationOptions; -export const TrackDocument = gql` - mutation Track($action: String!, $payload: JSON!) { - track(action: $action, payload: $payload) { - success - } -} - `; -export type TrackMutationFn = Apollo.MutationFunction; - -/** - * __useTrackMutation__ - * - * To run a mutation, you first call `useTrackMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useTrackMutation` returns a tuple that includes: - * - A mutate function that you can call at any time to execute the mutation - * - An object with fields that represent the current status of the mutation's execution - * - * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; - * - * @example - * const [trackMutation, { data, loading, error }] = useTrackMutation({ - * variables: { - * action: // value for 'action' - * payload: // value for 'payload' - * }, - * }); - */ -export function useTrackMutation(baseOptions?: Apollo.MutationHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(TrackDocument, options); - } -export type TrackMutationHookResult = ReturnType; -export type TrackMutationResult = Apollo.MutationResult; -export type TrackMutationOptions = Apollo.BaseMutationOptions; export const UploadFileDocument = gql` mutation uploadFile($file: Upload!, $fileFolder: FileFolder) { uploadFile(file: $file, fileFolder: $fileFolder) diff --git a/packages/twenty-front/src/modules/apollo/services/__tests__/apollo.factory.test.ts b/packages/twenty-front/src/modules/apollo/services/__tests__/apollo.factory.test.ts index 60d49ac58..c5933ffbd 100644 --- a/packages/twenty-front/src/modules/apollo/services/__tests__/apollo.factory.test.ts +++ b/packages/twenty-front/src/modules/apollo/services/__tests__/apollo.factory.test.ts @@ -48,8 +48,18 @@ const makeRequest = async () => { await client.mutate({ mutation: gql` - mutation Track($action: String!, $payload: JSON!) { - track(action: $action, payload: $payload) { + mutation TrackAnalytics( + $type: AnalyticsType! + $event: String + $name: String + $properties: JSON + ) { + trackAnalytics( + type: $type + event: $event + name: $name + properties: $properties + ) { success } }