The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Land app chargeCredits in a dedicated APP_OPERATION category (#29241)
martmull7526c1a81838
diff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql b/packages/twenty-client-sdk/src/metadata/generated/schema.graphqlindex 8bd8d5d366a..05baccbe148 100644--- a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql+++ b/packages/twenty-client-sdk/src/metadata/generated/schema.graphql@@ -623,6 +623,7 @@ type ApplicationMonitoringActivityBucket {type ApplicationMonitoringCreditBucket {bucketStart: DateTime!creditsUsed: Float!+ operationLabel: StringoperationType: String!}@@ -1859,6 +1860,7 @@ input CreateWebhookInput {type CreditUsedItem {creditsUsed: Float!+ icon: Stringlabel: Stringoperation: UsageOperationTyperesource: UsageResourceType@@ -5686,6 +5688,7 @@ enum UsageOperationType {AI_WORKFLOW_WEB_SEARCHALLAPI_REQUEST+ APP_OPERATIONCALL_RECORDINGCODE_EXECUTIONEMAIL_SENDdiff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.ts b/packages/twenty-client-sdk/src/metadata/generated/schema.tsindex 98a76b25b1b..9a4db6a1eb5 100644--- a/packages/twenty-client-sdk/src/metadata/generated/schema.ts+++ b/packages/twenty-client-sdk/src/metadata/generated/schema.ts@@ -529,6 +529,7 @@ export interface ApplicationMonitoringActivityBucket {export interface ApplicationMonitoringCreditBucket {bucketStart: Scalars['DateTime']creditsUsed: Scalars['Float']+ operationLabel?: Scalars['String']operationType: Scalars['String']__typename: 'ApplicationMonitoringCreditBucket'}@@ -1327,6 +1328,7 @@ export interface CreateEmailGroupChannelOutput {export interface CreditUsedItem {creditsUsed: Scalars['Float']+ icon?: Scalars['String']label?: Scalars['String']operation?: UsageOperationTyperesource?: UsageResourceType@@ -3678,7 +3680,7 @@ export interface UsageLimitOperationDefinition {__typename: 'UsageLimitOperationDefinition'}-export type UsageOperationType = 'AI_CHAT_TOKEN' | 'AI_WORKFLOW_TOKEN' | 'AI_WORKFLOW_WEB_SEARCH' | 'ALL' | 'API_REQUEST' | 'CALL_RECORDING' | 'CODE_EXECUTION' | 'EMAIL_SEND' | 'MESSAGE_CAMPAIGN_SEND' | 'RECORD_WRITE' | 'STORAGE_FILE' | 'SUBSCRIPTION' | 'WEBHOOK_CALL' | 'WEB_SEARCH' | 'WORKFLOW_EXECUTION'+export type UsageOperationType = 'AI_CHAT_TOKEN' | 'AI_WORKFLOW_TOKEN' | 'AI_WORKFLOW_WEB_SEARCH' | 'ALL' | 'API_REQUEST' | 'APP_OPERATION' | 'CALL_RECORDING' | 'CODE_EXECUTION' | 'EMAIL_SEND' | 'MESSAGE_CAMPAIGN_SEND' | 'RECORD_WRITE' | 'STORAGE_FILE' | 'SUBSCRIPTION' | 'WEBHOOK_CALL' | 'WEB_SEARCH' | 'WORKFLOW_EXECUTION'export interface UsageQuotaDefinition {allowedOperations: UsageLimitOperationDefinition[]@@ -4782,6 +4784,7 @@ export interface ApplicationMonitoringActivityBucketGenqlSelection{export interface ApplicationMonitoringCreditBucketGenqlSelection{bucketStart?: boolean | numbercreditsUsed?: boolean | number+ operationLabel?: boolean | numberoperationType?: boolean | number__typename?: boolean | number__scalar?: boolean | number@@ -5714,6 +5717,7 @@ export interface CreateWebhookInput {description?: (Scalars['String'] | null),idexport interface CreditUsedItemGenqlSelection{creditsUsed?: boolean | number+ icon?: boolean | numberlabel?: boolean | numberoperation?: boolean | numberresource?: boolean | number@@ -12750,6 +12754,7 @@ export const enumUsageOperationType = {AI_WORKFLOW_WEB_SEARCH: 'AI_WORKFLOW_WEB_SEARCH' as const,ALL: 'ALL' as const,API_REQUEST: 'API_REQUEST' as const,+ APP_OPERATION: 'APP_OPERATION' as const,CALL_RECORDING: 'CALL_RECORDING' as const,CODE_EXECUTION: 'CODE_EXECUTION' as const,EMAIL_SEND: 'EMAIL_SEND' as const,diff --git a/packages/twenty-client-sdk/src/metadata/generated/types.ts b/packages/twenty-client-sdk/src/metadata/generated/types.tsindex c7a94e11ac3..25f1b924241 100644--- a/packages/twenty-client-sdk/src/metadata/generated/types.ts+++ b/packages/twenty-client-sdk/src/metadata/generated/types.ts@@ -1399,6 +1399,9 @@ export default {"creditsUsed": [6],+ "operationLabel": [+ 1+ ],"operationType": [1],@@ -4194,6 +4197,9 @@ export default {"creditsUsed": [6],+ "icon": [+ 1+ ],"label": [1],diff --git a/packages/twenty-docs/developers/extend/apps/logic/credits.mdx b/packages/twenty-docs/developers/extend/apps/logic/credits.mdxindex 00b264ca4c3..d91eb652505 100644--- a/packages/twenty-docs/developers/extend/apps/logic/credits.mdx+++ b/packages/twenty-docs/developers/extend/apps/logic/credits.mdx@@ -82,24 +82,28 @@ How they are raised:## Billable operations-An operation is what your app charges for as it works. Each entry maps an operation name you choose onto the billing category the platform meters, plus the label shown to workspace admins in **Settings > Usage**.+An operation is what your app charges for as it works. Each entry names an operation you choose and the label shown to workspace admins in **Settings > Usage** and to you in your app's monitoring **Credits used** chart. It can optionally map onto one of the platform's billing categories.```ts src/application-config.tsbilling: {operations: {+ enrichPerson: {+ label: 'Person enrichment',+ icon: 'IconUserSearch',+ },recordMeeting: {operationType: 'CALL_RECORDING',label: 'Meeting recording',},- summarizeMeeting: {- operationType: 'AI_CHAT_TOKEN',- label: 'Meeting summary',- },},},```-`operationType` must be one of the platform's billing categories: `AI_CHAT_TOKEN`, `AI_WORKFLOW_TOKEN`, `WORKFLOW_EXECUTION`, `CODE_EXECUTION`, `WEB_SEARCH`, `CALL_RECORDING`, `EMAIL_SEND`. It decides how the spend is metered and which counting unit applies (tokens, invocations, minutes) — it is not what admins read. The `label` is.+`icon` is optional: a Twenty icon name (e.g. `IconUserSearch`) shown next to the label in your app's credits breakdown on its settings page.++`operationType` is optional and defaults to `APP_OPERATION`, the dedicated category for app charges. Set it only when the spend really is one of the platform's categories: `AI_CHAT_TOKEN`, `AI_WORKFLOW_TOKEN`, `WORKFLOW_EXECUTION`, `CODE_EXECUTION`, `WEB_SEARCH`, `CALL_RECORDING`, `EMAIL_SEND`, `APP_OPERATION`. It decides how the spend is metered and which counting unit applies (tokens, invocations, minutes) — it is not what admins read. The `label` is.++`CODE_EXECUTION` is where the platform meters your functions' own runs, so charges filed there are mixed with them; prefer the default.The build rejects an unknown `operationType`, an empty `label`, and a name used by both a recurring charge and an operation.@@ -123,8 +127,8 @@ Notes:- Declaring operations is what lets Usage split your app's spend by what it charged for. An app that declares nothing is still reported, as a single slice under its display name.- Charging an operation your manifest does not declare is rejected. Add it to `billing.operations` and sync.-- Several operations may share one `operationType`. Two enrichment operations both metered as `CODE_EXECUTION` still show as two labelled slices.-- Without `operation`, name the billing category directly with `operationType`, optionally with a free-form `resourceContext`. The two forms are mutually exclusive: `operation` carries the label, `operationType` does not.+- Several operations may share one `operationType`. Two enrichment operations both metered as `APP_OPERATION` still show as two labelled slices.+- Without `operation`, the charge lands in `APP_OPERATION`, or in the category you name with `operationType`, optionally with a free-form `resourceContext`. The two forms are mutually exclusive: `operation` carries the label, `operationType` does not.- Charging never fails your function. A billing error is logged and swallowed, and the call no-ops outside the logic function runtime so local runs and tests do not crash.## Checking before you spenddiff --git a/packages/twenty-front/src/generated-admin/graphql.ts b/packages/twenty-front/src/generated-admin/graphql.tsindex 1c2328a4e7f..2a5d2cf4433 100644--- a/packages/twenty-front/src/generated-admin/graphql.ts+++ b/packages/twenty-front/src/generated-admin/graphql.ts@@ -137,7 +137,7 @@ export type FindAdminApplicationRegistrationMonitoringQueryVariables = Exact<{}>;-export type FindAdminApplicationRegistrationMonitoringQuery = { findAdminApplicationRegistrationMonitoring: { __typename: 'AdminApplicationMonitoring', periodStart: string, periodEnd: string, bucketSizeInSeconds: number, lookbackInHours: number, runCount: number, failedRunCount: number, lifecycleFailureCount: number, rateLimitEventCount: number, creditsUsed: number | null, activeWorkspaceCount: number, activity: Array<{ __typename: 'ApplicationMonitoringActivityBucket', bucketStart: string, errorCount: number, rateLimitedRequestCount: number, rateLimitedJobCount: number }>, lifecycle: Array<{ __typename: 'ApplicationMonitoringLifecycleBucket', bucketStart: string, installCount: number, upgradeCount: number, uninstallCount: number, failedCount: number }>, creditUsage: Array<{ __typename: 'ApplicationMonitoringCreditBucket', bucketStart: string, operationType: string, creditsUsed: number }> | null, issues: Array<{ __typename: 'ApplicationMonitoringIssue', level: string, source: string, errorCode: string, logicFunctionName: string, versions: Array<string>, eventCount: number, affectedInstallCount: number, lastSeenAt: string }>, versions: Array<{ __typename: 'ApplicationMonitoringVersion', version: string, runCount: number, failedRunCount: number, activeInstallCount: number }>, functions: Array<{ __typename: 'ApplicationMonitoringFunction', logicFunctionName: string, runCount: number, failedRunCount: number, p95DurationMs: number }>, workspaces: Array<{ __typename: 'ApplicationMonitoringWorkspace', workspaceId: string, workspaceName: string | null, workspaceLogoUrl: string | null, applicationVersion: string, runCount: number, failedRunCount: number, rateLimitEventCount: number, lastEventAt: string }> } };+export type FindAdminApplicationRegistrationMonitoringQuery = { findAdminApplicationRegistrationMonitoring: { __typename: 'AdminApplicationMonitoring', periodStart: string, periodEnd: string, bucketSizeInSeconds: number, lookbackInHours: number, runCount: number, failedRunCount: number, lifecycleFailureCount: number, rateLimitEventCount: number, creditsUsed: number | null, activeWorkspaceCount: number, activity: Array<{ __typename: 'ApplicationMonitoringActivityBucket', bucketStart: string, errorCount: number, rateLimitedRequestCount: number, rateLimitedJobCount: number }>, lifecycle: Array<{ __typename: 'ApplicationMonitoringLifecycleBucket', bucketStart: string, installCount: number, upgradeCount: number, uninstallCount: number, failedCount: number }>, creditUsage: Array<{ __typename: 'ApplicationMonitoringCreditBucket', bucketStart: string, operationType: string, operationLabel: string | null, creditsUsed: number }> | null, issues: Array<{ __typename: 'ApplicationMonitoringIssue', level: string, source: string, errorCode: string, logicFunctionName: string, versions: Array<string>, eventCount: number, affectedInstallCount: number, lastSeenAt: string }>, versions: Array<{ __typename: 'ApplicationMonitoringVersion', version: string, runCount: number, failedRunCount: number, activeInstallCount: number }>, functions: Array<{ __typename: 'ApplicationMonitoringFunction', logicFunctionName: string, runCount: number, failedRunCount: number, p95DurationMs: number }>, workspaces: Array<{ __typename: 'ApplicationMonitoringWorkspace', workspaceId: string, workspaceName: string | null, workspaceLogoUrl: string | null, applicationVersion: string, runCount: number, failedRunCount: number, rateLimitEventCount: number, lastEventAt: string }> } };export type FindAdminApplicationRegistrationStatsQueryVariables = Exact<{id: string;@@ -146,7 +146,7 @@ export type FindAdminApplicationRegistrationStatsQueryVariables = Exact<{}>;-export type FindAdminApplicationRegistrationStatsQuery = { findAdminApplicationRegistrationStats: { __typename: 'ApplicationRegistrationStats', activeInstalls: number, autoUpdateEnabled: number, totalCreditsUsed: number | null, suspendedInstalls: number, mostInstalledVersion: string | null, creditsUsedBreakdown: Array<{ __typename: 'CreditUsedItem', label: string | null, operation: Types.UsageOperationType | null, creditsUsed: number }> | null, versionDistribution: Array<{ __typename: 'VersionDistributionEntry', version: string, count: number }> } };+export type FindAdminApplicationRegistrationStatsQuery = { findAdminApplicationRegistrationStats: { __typename: 'ApplicationRegistrationStats', activeInstalls: number, autoUpdateEnabled: number, totalCreditsUsed: number | null, suspendedInstalls: number, mostInstalledVersion: string | null, creditsUsedBreakdown: Array<{ __typename: 'CreditUsedItem', label: string | null, icon: string | null, operation: Types.UsageOperationType | null, creditsUsed: number }> | null, versionDistribution: Array<{ __typename: 'VersionDistributionEntry', version: string, count: number }> } };export type FindAdminApplicationRegistrationVariablesQueryVariables = Exact<{applicationRegistrationId: string;@@ -481,8 +481,8 @@ export const UpdateAdminApplicationRegistrationDocument = {"kind":"Document","deexport const UpdateAdminApplicationRegistrationVariableDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateAdminApplicationRegistrationVariable"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateApplicationRegistrationVariableInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateAdminApplicationRegistrationVariable"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"isSecret"}},{"kind":"Field","name":{"kind":"Name","value":"isRequired"}},{"kind":"Field","name":{"kind":"Name","value":"isFilled"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<UpdateAdminApplicationRegistrationVariableMutation, UpdateAdminApplicationRegistrationVariableMutationVariables>;export const FindAdminApplicationRegistrationClaimsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindAdminApplicationRegistrationClaims"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"applicationRegistrationId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findAdminApplicationRegistrationClaims"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"applicationRegistrationId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"applicationRegistrationId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspaceId"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceDisplayName"}}]}}]}}]} as unknown as DocumentNode<FindAdminApplicationRegistrationClaimsQuery, FindAdminApplicationRegistrationClaimsQueryVariables>;export const FindAdminApplicationRegistrationInstalledWorkspacesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindAdminApplicationRegistrationInstalledWorkspaces"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"FindApplicationRegistrationInstalledWorkspacesInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findAdminApplicationRegistrationInstalledWorkspaces"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"totalCount"}},{"kind":"Field","name":{"kind":"Name","value":"hasMore"}},{"kind":"Field","name":{"kind":"Name","value":"workspaces"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"logo"}},{"kind":"Field","name":{"kind":"Name","value":"version"}}]}}]}}]}}]} as unknown as DocumentNode<FindAdminApplicationRegistrationInstalledWorkspacesQuery, FindAdminApplicationRegistrationInstalledWorkspacesQueryVariables>;-export const FindAdminApplicationRegistrationMonitoringDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindAdminApplicationRegistrationMonitoring"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"periodStart"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"periodEnd"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findAdminApplicationRegistrationMonitoring"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}},{"kind":"Argument","name":{"kind":"Name","value":"workspaceId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}}},{"kind":"Argument","name":{"kind":"Name","value":"periodStart"},"value":{"kind":"Variable","name":{"kind":"Name","value":"periodStart"}}},{"kind":"Argument","name":{"kind":"Name","value":"periodEnd"},"value":{"kind":"Variable","name":{"kind":"Name","value":"periodEnd"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"periodStart"}},{"kind":"Field","name":{"kind":"Name","value":"periodEnd"}},{"kind":"Field","name":{"kind":"Name","value":"bucketSizeInSeconds"}},{"kind":"Field","name":{"kind":"Name","value":"lookbackInHours"}},{"kind":"Field","name":{"kind":"Name","value":"runCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedRunCount"}},{"kind":"Field","name":{"kind":"Name","value":"lifecycleFailureCount"}},{"kind":"Field","name":{"kind":"Name","value":"rateLimitEventCount"}},{"kind":"Field","name":{"kind":"Name","value":"creditsUsed"}},{"kind":"Field","name":{"kind":"Name","value":"activity"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"bucketStart"}},{"kind":"Field","name":{"kind":"Name","value":"errorCount"}},{"kind":"Field","name":{"kind":"Name","value":"rateLimitedRequestCount"}},{"kind":"Field","name":{"kind":"Name","value":"rateLimitedJobCount"}}]}},{"kind":"Field","name":{"kind":"Name","value":"lifecycle"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"bucketStart"}},{"kind":"Field","name":{"kind":"Name","value":"installCount"}},{"kind":"Field","name":{"kind":"Name","value":"upgradeCount"}},{"kind":"Field","name":{"kind":"Name","value":"uninstallCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedCount"}}]}},{"kind":"Field","name":{"kind":"Name","value":"creditUsage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"bucketStart"}},{"kind":"Field","name":{"kind":"Name","value":"operationType"}},{"kind":"Field","name":{"kind":"Name","value":"creditsUsed"}}]}},{"kind":"Field","name":{"kind":"Name","value":"issues"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"level"}},{"kind":"Field","name":{"kind":"Name","value":"source"}},{"kind":"Field","name":{"kind":"Name","value":"errorCode"}},{"kind":"Field","name":{"kind":"Name","value":"logicFunctionName"}},{"kind":"Field","name":{"kind":"Name","value":"versions"}},{"kind":"Field","name":{"kind":"Name","value":"eventCount"}},{"kind":"Field","name":{"kind":"Name","value":"affectedInstallCount"}},{"kind":"Field","name":{"kind":"Name","value":"lastSeenAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"versions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"version"}},{"kind":"Field","name":{"kind":"Name","value":"runCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedRunCount"}},{"kind":"Field","name":{"kind":"Name","value":"activeInstallCount"}}]}},{"kind":"Field","name":{"kind":"Name","value":"functions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"logicFunctionName"}},{"kind":"Field","name":{"kind":"Name","value":"runCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedRunCount"}},{"kind":"Field","name":{"kind":"Name","value":"p95DurationMs"}}]}},{"kind":"Field","name":{"kind":"Name","value":"activeWorkspaceCount"}},{"kind":"Field","name":{"kind":"Name","value":"workspaces"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspaceId"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceName"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceLogoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"applicationVersion"}},{"kind":"Field","name":{"kind":"Name","value":"runCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedRunCount"}},{"kind":"Field","name":{"kind":"Name","value":"rateLimitEventCount"}},{"kind":"Field","name":{"kind":"Name","value":"lastEventAt"}}]}}]}}]}}]} as unknown as DocumentNode<FindAdminApplicationRegistrationMonitoringQuery, FindAdminApplicationRegistrationMonitoringQueryVariables>;-export const FindAdminApplicationRegistrationStatsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindAdminApplicationRegistrationStats"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"periodStart"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"periodEnd"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findAdminApplicationRegistrationStats"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}},{"kind":"Argument","name":{"kind":"Name","value":"periodStart"},"value":{"kind":"Variable","name":{"kind":"Name","value":"periodStart"}}},{"kind":"Argument","name":{"kind":"Name","value":"periodEnd"},"value":{"kind":"Variable","name":{"kind":"Name","value":"periodEnd"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"activeInstalls"}},{"kind":"Field","name":{"kind":"Name","value":"autoUpdateEnabled"}},{"kind":"Field","name":{"kind":"Name","value":"totalCreditsUsed"}},{"kind":"Field","name":{"kind":"Name","value":"creditsUsedBreakdown"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"operation"}},{"kind":"Field","name":{"kind":"Name","value":"creditsUsed"}}]}},{"kind":"Field","name":{"kind":"Name","value":"suspendedInstalls"}},{"kind":"Field","name":{"kind":"Name","value":"mostInstalledVersion"}},{"kind":"Field","name":{"kind":"Name","value":"versionDistribution"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"version"}},{"kind":"Field","name":{"kind":"Name","value":"count"}}]}}]}}]}}]} as unknown as DocumentNode<FindAdminApplicationRegistrationStatsQuery, FindAdminApplicationRegistrationStatsQueryVariables>;+export const FindAdminApplicationRegistrationMonitoringDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindAdminApplicationRegistrationMonitoring"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"periodStart"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"periodEnd"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findAdminApplicationRegistrationMonitoring"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}},{"kind":"Argument","name":{"kind":"Name","value":"workspaceId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}}},{"kind":"Argument","name":{"kind":"Name","value":"periodStart"},"value":{"kind":"Variable","name":{"kind":"Name","value":"periodStart"}}},{"kind":"Argument","name":{"kind":"Name","value":"periodEnd"},"value":{"kind":"Variable","name":{"kind":"Name","value":"periodEnd"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"periodStart"}},{"kind":"Field","name":{"kind":"Name","value":"periodEnd"}},{"kind":"Field","name":{"kind":"Name","value":"bucketSizeInSeconds"}},{"kind":"Field","name":{"kind":"Name","value":"lookbackInHours"}},{"kind":"Field","name":{"kind":"Name","value":"runCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedRunCount"}},{"kind":"Field","name":{"kind":"Name","value":"lifecycleFailureCount"}},{"kind":"Field","name":{"kind":"Name","value":"rateLimitEventCount"}},{"kind":"Field","name":{"kind":"Name","value":"creditsUsed"}},{"kind":"Field","name":{"kind":"Name","value":"activity"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"bucketStart"}},{"kind":"Field","name":{"kind":"Name","value":"errorCount"}},{"kind":"Field","name":{"kind":"Name","value":"rateLimitedRequestCount"}},{"kind":"Field","name":{"kind":"Name","value":"rateLimitedJobCount"}}]}},{"kind":"Field","name":{"kind":"Name","value":"lifecycle"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"bucketStart"}},{"kind":"Field","name":{"kind":"Name","value":"installCount"}},{"kind":"Field","name":{"kind":"Name","value":"upgradeCount"}},{"kind":"Field","name":{"kind":"Name","value":"uninstallCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedCount"}}]}},{"kind":"Field","name":{"kind":"Name","value":"creditUsage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"bucketStart"}},{"kind":"Field","name":{"kind":"Name","value":"operationType"}},{"kind":"Field","name":{"kind":"Name","value":"operationLabel"}},{"kind":"Field","name":{"kind":"Name","value":"creditsUsed"}}]}},{"kind":"Field","name":{"kind":"Name","value":"issues"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"level"}},{"kind":"Field","name":{"kind":"Name","value":"source"}},{"kind":"Field","name":{"kind":"Name","value":"errorCode"}},{"kind":"Field","name":{"kind":"Name","value":"logicFunctionName"}},{"kind":"Field","name":{"kind":"Name","value":"versions"}},{"kind":"Field","name":{"kind":"Name","value":"eventCount"}},{"kind":"Field","name":{"kind":"Name","value":"affectedInstallCount"}},{"kind":"Field","name":{"kind":"Name","value":"lastSeenAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"versions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"version"}},{"kind":"Field","name":{"kind":"Name","value":"runCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedRunCount"}},{"kind":"Field","name":{"kind":"Name","value":"activeInstallCount"}}]}},{"kind":"Field","name":{"kind":"Name","value":"functions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"logicFunctionName"}},{"kind":"Field","name":{"kind":"Name","value":"runCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedRunCount"}},{"kind":"Field","name":{"kind":"Name","value":"p95DurationMs"}}]}},{"kind":"Field","name":{"kind":"Name","value":"activeWorkspaceCount"}},{"kind":"Field","name":{"kind":"Name","value":"workspaces"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspaceId"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceName"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceLogoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"applicationVersion"}},{"kind":"Field","name":{"kind":"Name","value":"runCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedRunCount"}},{"kind":"Field","name":{"kind":"Name","value":"rateLimitEventCount"}},{"kind":"Field","name":{"kind":"Name","value":"lastEventAt"}}]}}]}}]}}]} as unknown as DocumentNode<FindAdminApplicationRegistrationMonitoringQuery, FindAdminApplicationRegistrationMonitoringQueryVariables>;+export const FindAdminApplicationRegistrationStatsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindAdminApplicationRegistrationStats"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"periodStart"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"periodEnd"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findAdminApplicationRegistrationStats"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}},{"kind":"Argument","name":{"kind":"Name","value":"periodStart"},"value":{"kind":"Variable","name":{"kind":"Name","value":"periodStart"}}},{"kind":"Argument","name":{"kind":"Name","value":"periodEnd"},"value":{"kind":"Variable","name":{"kind":"Name","value":"periodEnd"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"activeInstalls"}},{"kind":"Field","name":{"kind":"Name","value":"autoUpdateEnabled"}},{"kind":"Field","name":{"kind":"Name","value":"totalCreditsUsed"}},{"kind":"Field","name":{"kind":"Name","value":"creditsUsedBreakdown"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"operation"}},{"kind":"Field","name":{"kind":"Name","value":"creditsUsed"}}]}},{"kind":"Field","name":{"kind":"Name","value":"suspendedInstalls"}},{"kind":"Field","name":{"kind":"Name","value":"mostInstalledVersion"}},{"kind":"Field","name":{"kind":"Name","value":"versionDistribution"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"version"}},{"kind":"Field","name":{"kind":"Name","value":"count"}}]}}]}}]}}]} as unknown as DocumentNode<FindAdminApplicationRegistrationStatsQuery, FindAdminApplicationRegistrationStatsQueryVariables>;export const FindAdminApplicationRegistrationVariablesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindAdminApplicationRegistrationVariables"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"applicationRegistrationId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findAdminApplicationRegistrationVariables"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"applicationRegistrationId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"applicationRegistrationId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"value"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"isSecret"}},{"kind":"Field","name":{"kind":"Name","value":"isRequired"}},{"kind":"Field","name":{"kind":"Name","value":"isDeprecated"}},{"kind":"Field","name":{"kind":"Name","value":"isFilled"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"options"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<FindAdminApplicationRegistrationVariablesQuery, FindAdminApplicationRegistrationVariablesQueryVariables>;export const FindAllApplicationRegistrationsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindAllApplicationRegistrations"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"limit"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"offset"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"searchTerm"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"isPreInstalledOnly"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Boolean"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"sourceTypes"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ApplicationRegistrationSourceType"}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"isListed"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Boolean"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"isConfigured"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Boolean"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findAllApplicationRegistrations"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"limit"},"value":{"kind":"Variable","name":{"kind":"Name","value":"limit"}}},{"kind":"Argument","name":{"kind":"Name","value":"offset"},"value":{"kind":"Variable","name":{"kind":"Name","value":"offset"}}},{"kind":"Argument","name":{"kind":"Name","value":"searchTerm"},"value":{"kind":"Variable","name":{"kind":"Name","value":"searchTerm"}}},{"kind":"Argument","name":{"kind":"Name","value":"isPreInstalledOnly"},"value":{"kind":"Variable","name":{"kind":"Name","value":"isPreInstalledOnly"}}},{"kind":"Argument","name":{"kind":"Name","value":"sourceTypes"},"value":{"kind":"Variable","name":{"kind":"Name","value":"sourceTypes"}}},{"kind":"Argument","name":{"kind":"Name","value":"isListed"},"value":{"kind":"Variable","name":{"kind":"Name","value":"isListed"}}},{"kind":"Argument","name":{"kind":"Name","value":"isConfigured"},"value":{"kind":"Variable","name":{"kind":"Name","value":"isConfigured"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"registrations"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ApplicationRegistrationFragment"}},{"kind":"Field","name":{"kind":"Name","value":"author"}},{"kind":"Field","name":{"kind":"Name","value":"installCount"}}]}},{"kind":"Field","name":{"kind":"Name","value":"totalCount"}},{"kind":"Field","name":{"kind":"Name","value":"hasMore"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ApplicationRegistrationFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ApplicationRegistration"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"universalIdentifier"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"logoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"galleryImagesUrls"}},{"kind":"Field","name":{"kind":"Name","value":"oAuthClientId"}},{"kind":"Field","name":{"kind":"Name","value":"oAuthRedirectUris"}},{"kind":"Field","name":{"kind":"Name","value":"oAuthScopes"}},{"kind":"Field","name":{"kind":"Name","value":"sourceType"}},{"kind":"Field","name":{"kind":"Name","value":"sourcePackage"}},{"kind":"Field","name":{"kind":"Name","value":"latestAvailableVersion"}},{"kind":"Field","name":{"kind":"Name","value":"isListed"}},{"kind":"Field","name":{"kind":"Name","value":"isPreInstalled"}},{"kind":"Field","name":{"kind":"Name","value":"isConfigured"}},{"kind":"Field","name":{"kind":"Name","value":"ownerWorkspaceId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode<FindAllApplicationRegistrationsQuery, FindAllApplicationRegistrationsQueryVariables>;export const CreateDatabaseConfigVariableDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateDatabaseConfigVariable"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"key"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"value"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"JSON"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createDatabaseConfigVariable"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"key"},"value":{"kind":"Variable","name":{"kind":"Name","value":"key"}}},{"kind":"Argument","name":{"kind":"Name","value":"value"},"value":{"kind":"Variable","name":{"kind":"Name","value":"value"}}}]}]}}]} as unknown as DocumentNode<CreateDatabaseConfigVariableMutation, CreateDatabaseConfigVariableMutationVariables>;diff --git a/packages/twenty-front/src/generated-admin/schema.ts b/packages/twenty-front/src/generated-admin/schema.tsindex 9d69f70e743..91e90a078fb 100644--- a/packages/twenty-front/src/generated-admin/schema.ts+++ b/packages/twenty-front/src/generated-admin/schema.ts@@ -299,6 +299,7 @@ export type ApplicationMonitoringCreditBucket = {__typename?: 'ApplicationMonitoringCreditBucket';bucketStart: Scalars['DateTime']['output'];creditsUsed: Scalars['Float']['output'];+ operationLabel?: Maybe<Scalars['String']['output']>;operationType: Scalars['String']['output'];};@@ -510,6 +511,7 @@ export type CreateUsageLimitInput = {export type CreditUsedItem = {__typename?: 'CreditUsedItem';creditsUsed: Scalars['Float']['output'];+ icon?: Maybe<Scalars['String']['output']>;label?: Maybe<Scalars['String']['output']>;operation?: Maybe<UsageOperationType>;resource?: Maybe<UsageResourceType>;@@ -1176,6 +1178,7 @@ export enum UsageOperationType {AI_WORKFLOW_WEB_SEARCH = 'AI_WORKFLOW_WEB_SEARCH',ALL = 'ALL',API_REQUEST = 'API_REQUEST',+ APP_OPERATION = 'APP_OPERATION',CALL_RECORDING = 'CALL_RECORDING',CODE_EXECUTION = 'CODE_EXECUTION',EMAIL_SEND = 'EMAIL_SEND',diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.tsindex 2b5e6deb1e0..314e9558749 100644--- a/packages/twenty-front/src/generated-metadata/graphql.ts+++ b/packages/twenty-front/src/generated-metadata/graphql.ts@@ -1795,7 +1795,7 @@ export type FindApplicationRegistrationMonitoringQueryVariables = Exact<{}>;-export type FindApplicationRegistrationMonitoringQuery = { findApplicationRegistrationMonitoring: { __typename: 'ApplicationMonitoring', periodStart: string, periodEnd: string, bucketSizeInSeconds: number, lookbackInHours: number, runCount: number, failedRunCount: number, lifecycleFailureCount: number, rateLimitEventCount: number, creditsUsed: number | null, activity: Array<{ __typename: 'ApplicationMonitoringActivityBucket', bucketStart: string, errorCount: number, rateLimitedRequestCount: number, rateLimitedJobCount: number }>, lifecycle: Array<{ __typename: 'ApplicationMonitoringLifecycleBucket', bucketStart: string, installCount: number, upgradeCount: number, uninstallCount: number, failedCount: number }>, creditUsage: Array<{ __typename: 'ApplicationMonitoringCreditBucket', bucketStart: string, operationType: string, creditsUsed: number }> | null, issues: Array<{ __typename: 'ApplicationMonitoringIssue', level: string, source: string, errorCode: string, logicFunctionName: string, versions: Array<string>, eventCount: number, affectedInstallCount: number, lastSeenAt: string }>, versions: Array<{ __typename: 'ApplicationMonitoringVersion', version: string, runCount: number, failedRunCount: number, activeInstallCount: number }>, functions: Array<{ __typename: 'ApplicationMonitoringFunction', logicFunctionName: string, runCount: number, failedRunCount: number, p95DurationMs: number }> } };+export type FindApplicationRegistrationMonitoringQuery = { findApplicationRegistrationMonitoring: { __typename: 'ApplicationMonitoring', periodStart: string, periodEnd: string, bucketSizeInSeconds: number, lookbackInHours: number, runCount: number, failedRunCount: number, lifecycleFailureCount: number, rateLimitEventCount: number, creditsUsed: number | null, activity: Array<{ __typename: 'ApplicationMonitoringActivityBucket', bucketStart: string, errorCount: number, rateLimitedRequestCount: number, rateLimitedJobCount: number }>, lifecycle: Array<{ __typename: 'ApplicationMonitoringLifecycleBucket', bucketStart: string, installCount: number, upgradeCount: number, uninstallCount: number, failedCount: number }>, creditUsage: Array<{ __typename: 'ApplicationMonitoringCreditBucket', bucketStart: string, operationType: string, operationLabel: string | null, creditsUsed: number }> | null, issues: Array<{ __typename: 'ApplicationMonitoringIssue', level: string, source: string, errorCode: string, logicFunctionName: string, versions: Array<string>, eventCount: number, affectedInstallCount: number, lastSeenAt: string }>, versions: Array<{ __typename: 'ApplicationMonitoringVersion', version: string, runCount: number, failedRunCount: number, activeInstallCount: number }>, functions: Array<{ __typename: 'ApplicationMonitoringFunction', logicFunctionName: string, runCount: number, failedRunCount: number, p95DurationMs: number }> } };export type FindApplicationRegistrationStatsQueryVariables = Exact<{id: string;@@ -1804,7 +1804,7 @@ export type FindApplicationRegistrationStatsQueryVariables = Exact<{}>;-export type FindApplicationRegistrationStatsQuery = { findApplicationRegistrationStats: { __typename: 'ApplicationRegistrationStats', activeInstalls: number, autoUpdateEnabled: number, totalCreditsUsed: number | null, suspendedInstalls: number, mostInstalledVersion: string | null, creditsUsedBreakdown: Array<{ __typename: 'CreditUsedItem', label: string | null, operation: Types.UsageOperationType | null, creditsUsed: number }> | null, versionDistribution: Array<{ __typename: 'VersionDistributionEntry', version: string, count: number }> } };+export type FindApplicationRegistrationStatsQuery = { findApplicationRegistrationStats: { __typename: 'ApplicationRegistrationStats', activeInstalls: number, autoUpdateEnabled: number, totalCreditsUsed: number | null, suspendedInstalls: number, mostInstalledVersion: string | null, creditsUsedBreakdown: Array<{ __typename: 'CreditUsedItem', label: string | null, icon: string | null, operation: Types.UsageOperationType | null, creditsUsed: number }> | null, versionDistribution: Array<{ __typename: 'VersionDistributionEntry', version: string, count: number }> } };export type FindApplicationRegistrationInstallCountQueryVariables = Exact<{id: string;@@ -3095,8 +3095,8 @@ export const TransferApplicationRegistrationOwnershipDocument = {"kind":"Documenexport const UpdateApplicationRegistrationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateApplicationRegistration"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateApplicationRegistrationInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateApplicationRegistration"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ApplicationRegistrationFragment"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ApplicationRegistrationFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ApplicationRegistration"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"universalIdentifier"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"logoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"galleryImagesUrls"}},{"kind":"Field","name":{"kind":"Name","value":"oAuthClientId"}},{"kind":"Field","name":{"kind":"Name","value":"oAuthRedirectUris"}},{"kind":"Field","name":{"kind":"Name","value":"oAuthScopes"}},{"kind":"Field","name":{"kind":"Name","value":"sourceType"}},{"kind":"Field","name":{"kind":"Name","value":"sourcePackage"}},{"kind":"Field","name":{"kind":"Name","value":"latestAvailableVersion"}},{"kind":"Field","name":{"kind":"Name","value":"isListed"}},{"kind":"Field","name":{"kind":"Name","value":"isPreInstalled"}},{"kind":"Field","name":{"kind":"Name","value":"isConfigured"}},{"kind":"Field","name":{"kind":"Name","value":"ownerWorkspaceId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode<UpdateApplicationRegistrationMutation, UpdateApplicationRegistrationMutationVariables>;export const UpdateApplicationRegistrationVariableDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateApplicationRegistrationVariable"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateApplicationRegistrationVariableInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateApplicationRegistrationVariable"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"isSecret"}},{"kind":"Field","name":{"kind":"Name","value":"isRequired"}},{"kind":"Field","name":{"kind":"Name","value":"isFilled"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<UpdateApplicationRegistrationVariableMutation, UpdateApplicationRegistrationVariableMutationVariables>;export const ApplicationRegistrationTarballUrlDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"ApplicationRegistrationTarballUrl"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"applicationRegistrationTarballUrl"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}]}]}}]} as unknown as DocumentNode<ApplicationRegistrationTarballUrlQuery, ApplicationRegistrationTarballUrlQueryVariables>;-export const FindApplicationRegistrationMonitoringDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindApplicationRegistrationMonitoring"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"periodStart"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"periodEnd"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findApplicationRegistrationMonitoring"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}},{"kind":"Argument","name":{"kind":"Name","value":"periodStart"},"value":{"kind":"Variable","name":{"kind":"Name","value":"periodStart"}}},{"kind":"Argument","name":{"kind":"Name","value":"periodEnd"},"value":{"kind":"Variable","name":{"kind":"Name","value":"periodEnd"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"periodStart"}},{"kind":"Field","name":{"kind":"Name","value":"periodEnd"}},{"kind":"Field","name":{"kind":"Name","value":"bucketSizeInSeconds"}},{"kind":"Field","name":{"kind":"Name","value":"lookbackInHours"}},{"kind":"Field","name":{"kind":"Name","value":"runCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedRunCount"}},{"kind":"Field","name":{"kind":"Name","value":"lifecycleFailureCount"}},{"kind":"Field","name":{"kind":"Name","value":"rateLimitEventCount"}},{"kind":"Field","name":{"kind":"Name","value":"creditsUsed"}},{"kind":"Field","name":{"kind":"Name","value":"activity"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"bucketStart"}},{"kind":"Field","name":{"kind":"Name","value":"errorCount"}},{"kind":"Field","name":{"kind":"Name","value":"rateLimitedRequestCount"}},{"kind":"Field","name":{"kind":"Name","value":"rateLimitedJobCount"}}]}},{"kind":"Field","name":{"kind":"Name","value":"lifecycle"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"bucketStart"}},{"kind":"Field","name":{"kind":"Name","value":"installCount"}},{"kind":"Field","name":{"kind":"Name","value":"upgradeCount"}},{"kind":"Field","name":{"kind":"Name","value":"uninstallCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedCount"}}]}},{"kind":"Field","name":{"kind":"Name","value":"creditUsage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"bucketStart"}},{"kind":"Field","name":{"kind":"Name","value":"operationType"}},{"kind":"Field","name":{"kind":"Name","value":"creditsUsed"}}]}},{"kind":"Field","name":{"kind":"Name","value":"issues"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"level"}},{"kind":"Field","name":{"kind":"Name","value":"source"}},{"kind":"Field","name":{"kind":"Name","value":"errorCode"}},{"kind":"Field","name":{"kind":"Name","value":"logicFunctionName"}},{"kind":"Field","name":{"kind":"Name","value":"versions"}},{"kind":"Field","name":{"kind":"Name","value":"eventCount"}},{"kind":"Field","name":{"kind":"Name","value":"affectedInstallCount"}},{"kind":"Field","name":{"kind":"Name","value":"lastSeenAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"versions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"version"}},{"kind":"Field","name":{"kind":"Name","value":"runCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedRunCount"}},{"kind":"Field","name":{"kind":"Name","value":"activeInstallCount"}}]}},{"kind":"Field","name":{"kind":"Name","value":"functions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"logicFunctionName"}},{"kind":"Field","name":{"kind":"Name","value":"runCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedRunCount"}},{"kind":"Field","name":{"kind":"Name","value":"p95DurationMs"}}]}}]}}]}}]} as unknown as DocumentNode<FindApplicationRegistrationMonitoringQuery, FindApplicationRegistrationMonitoringQueryVariables>;-export const FindApplicationRegistrationStatsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindApplicationRegistrationStats"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"periodStart"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"periodEnd"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findApplicationRegistrationStats"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}},{"kind":"Argument","name":{"kind":"Name","value":"periodStart"},"value":{"kind":"Variable","name":{"kind":"Name","value":"periodStart"}}},{"kind":"Argument","name":{"kind":"Name","value":"periodEnd"},"value":{"kind":"Variable","name":{"kind":"Name","value":"periodEnd"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"activeInstalls"}},{"kind":"Field","name":{"kind":"Name","value":"autoUpdateEnabled"}},{"kind":"Field","name":{"kind":"Name","value":"totalCreditsUsed"}},{"kind":"Field","name":{"kind":"Name","value":"creditsUsedBreakdown"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"operation"}},{"kind":"Field","name":{"kind":"Name","value":"creditsUsed"}}]}},{"kind":"Field","name":{"kind":"Name","value":"suspendedInstalls"}},{"kind":"Field","name":{"kind":"Name","value":"mostInstalledVersion"}},{"kind":"Field","name":{"kind":"Name","value":"versionDistribution"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"version"}},{"kind":"Field","name":{"kind":"Name","value":"count"}}]}}]}}]}}]} as unknown as DocumentNode<FindApplicationRegistrationStatsQuery, FindApplicationRegistrationStatsQueryVariables>;+export const FindApplicationRegistrationMonitoringDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindApplicationRegistrationMonitoring"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"periodStart"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"periodEnd"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findApplicationRegistrationMonitoring"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}},{"kind":"Argument","name":{"kind":"Name","value":"periodStart"},"value":{"kind":"Variable","name":{"kind":"Name","value":"periodStart"}}},{"kind":"Argument","name":{"kind":"Name","value":"periodEnd"},"value":{"kind":"Variable","name":{"kind":"Name","value":"periodEnd"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"periodStart"}},{"kind":"Field","name":{"kind":"Name","value":"periodEnd"}},{"kind":"Field","name":{"kind":"Name","value":"bucketSizeInSeconds"}},{"kind":"Field","name":{"kind":"Name","value":"lookbackInHours"}},{"kind":"Field","name":{"kind":"Name","value":"runCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedRunCount"}},{"kind":"Field","name":{"kind":"Name","value":"lifecycleFailureCount"}},{"kind":"Field","name":{"kind":"Name","value":"rateLimitEventCount"}},{"kind":"Field","name":{"kind":"Name","value":"creditsUsed"}},{"kind":"Field","name":{"kind":"Name","value":"activity"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"bucketStart"}},{"kind":"Field","name":{"kind":"Name","value":"errorCount"}},{"kind":"Field","name":{"kind":"Name","value":"rateLimitedRequestCount"}},{"kind":"Field","name":{"kind":"Name","value":"rateLimitedJobCount"}}]}},{"kind":"Field","name":{"kind":"Name","value":"lifecycle"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"bucketStart"}},{"kind":"Field","name":{"kind":"Name","value":"installCount"}},{"kind":"Field","name":{"kind":"Name","value":"upgradeCount"}},{"kind":"Field","name":{"kind":"Name","value":"uninstallCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedCount"}}]}},{"kind":"Field","name":{"kind":"Name","value":"creditUsage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"bucketStart"}},{"kind":"Field","name":{"kind":"Name","value":"operationType"}},{"kind":"Field","name":{"kind":"Name","value":"operationLabel"}},{"kind":"Field","name":{"kind":"Name","value":"creditsUsed"}}]}},{"kind":"Field","name":{"kind":"Name","value":"issues"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"level"}},{"kind":"Field","name":{"kind":"Name","value":"source"}},{"kind":"Field","name":{"kind":"Name","value":"errorCode"}},{"kind":"Field","name":{"kind":"Name","value":"logicFunctionName"}},{"kind":"Field","name":{"kind":"Name","value":"versions"}},{"kind":"Field","name":{"kind":"Name","value":"eventCount"}},{"kind":"Field","name":{"kind":"Name","value":"affectedInstallCount"}},{"kind":"Field","name":{"kind":"Name","value":"lastSeenAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"versions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"version"}},{"kind":"Field","name":{"kind":"Name","value":"runCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedRunCount"}},{"kind":"Field","name":{"kind":"Name","value":"activeInstallCount"}}]}},{"kind":"Field","name":{"kind":"Name","value":"functions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"logicFunctionName"}},{"kind":"Field","name":{"kind":"Name","value":"runCount"}},{"kind":"Field","name":{"kind":"Name","value":"failedRunCount"}},{"kind":"Field","name":{"kind":"Name","value":"p95DurationMs"}}]}}]}}]}}]} as unknown as DocumentNode<FindApplicationRegistrationMonitoringQuery, FindApplicationRegistrationMonitoringQueryVariables>;+export const FindApplicationRegistrationStatsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindApplicationRegistrationStats"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"periodStart"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"periodEnd"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findApplicationRegistrationStats"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}},{"kind":"Argument","name":{"kind":"Name","value":"periodStart"},"value":{"kind":"Variable","name":{"kind":"Name","value":"periodStart"}}},{"kind":"Argument","name":{"kind":"Name","value":"periodEnd"},"value":{"kind":"Variable","name":{"kind":"Name","value":"periodEnd"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"activeInstalls"}},{"kind":"Field","name":{"kind":"Name","value":"autoUpdateEnabled"}},{"kind":"Field","name":{"kind":"Name","value":"totalCreditsUsed"}},{"kind":"Field","name":{"kind":"Name","value":"creditsUsedBreakdown"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"operation"}},{"kind":"Field","name":{"kind":"Name","value":"creditsUsed"}}]}},{"kind":"Field","name":{"kind":"Name","value":"suspendedInstalls"}},{"kind":"Field","name":{"kind":"Name","value":"mostInstalledVersion"}},{"kind":"Field","name":{"kind":"Name","value":"versionDistribution"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"version"}},{"kind":"Field","name":{"kind":"Name","value":"count"}}]}}]}}]}}]} as unknown as DocumentNode<FindApplicationRegistrationStatsQuery, FindApplicationRegistrationStatsQueryVariables>;export const FindApplicationRegistrationInstallCountDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindApplicationRegistrationInstallCount"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findApplicationRegistrationStats"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"activeInstalls"}}]}}]}}]} as unknown as DocumentNode<FindApplicationRegistrationInstallCountQuery, FindApplicationRegistrationInstallCountQueryVariables>;export const FindApplicationRegistrationVariablesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindApplicationRegistrationVariables"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"applicationRegistrationId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findApplicationRegistrationVariables"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"applicationRegistrationId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"applicationRegistrationId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"value"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"isSecret"}},{"kind":"Field","name":{"kind":"Name","value":"isRequired"}},{"kind":"Field","name":{"kind":"Name","value":"isDeprecated"}},{"kind":"Field","name":{"kind":"Name","value":"isFilled"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"options"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<FindApplicationRegistrationVariablesQuery, FindApplicationRegistrationVariablesQueryVariables>;export const FindClaimableApplicationRegistrationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindClaimableApplicationRegistration"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"sourcePackage"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findClaimableApplicationRegistration"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"sourcePackage"},"value":{"kind":"Variable","name":{"kind":"Name","value":"sourcePackage"}}},{"kind":"Argument","name":{"kind":"Name","value":"universalIdentifier"},"value":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"universalIdentifier"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"sourcePackage"}},{"kind":"Field","name":{"kind":"Name","value":"logoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"author"}},{"kind":"Field","name":{"kind":"Name","value":"isOwned"}}]}}]}}]} as unknown as DocumentNode<FindClaimableApplicationRegistrationQuery, FindClaimableApplicationRegistrationQueryVariables>;diff --git a/packages/twenty-front/src/generated-metadata/schema.ts b/packages/twenty-front/src/generated-metadata/schema.tsindex 04e0d6b0ada..09ac70a8925 100644--- a/packages/twenty-front/src/generated-metadata/schema.ts+++ b/packages/twenty-front/src/generated-metadata/schema.ts@@ -685,6 +685,7 @@ export type ApplicationMonitoringCreditBucket = {__typename?: 'ApplicationMonitoringCreditBucket';bucketStart: Scalars['DateTime']['output'];creditsUsed: Scalars['Float']['output'];+ operationLabel?: Maybe<Scalars['String']['output']>;operationType: Scalars['String']['output'];};@@ -1979,6 +1980,7 @@ export type CreateWebhookInput = {export type CreditUsedItem = {__typename?: 'CreditUsedItem';creditsUsed: Scalars['Float']['output'];+ icon?: Maybe<Scalars['String']['output']>;label?: Maybe<Scalars['String']['output']>;operation?: Maybe<UsageOperationType>;resource?: Maybe<UsageResourceType>;@@ -7955,6 +7957,7 @@ export enum UsageOperationType {AI_WORKFLOW_WEB_SEARCH = 'AI_WORKFLOW_WEB_SEARCH',ALL = 'ALL',API_REQUEST = 'API_REQUEST',+ APP_OPERATION = 'APP_OPERATION',CALL_RECORDING = 'CALL_RECORDING',CODE_EXECUTION = 'CODE_EXECUTION',EMAIL_SEND = 'EMAIL_SEND',diff --git a/packages/twenty-front/src/modules/settings/admin-panel/apps/graphql/queries/findAdminApplicationRegistrationMonitoring.ts b/packages/twenty-front/src/modules/settings/admin-panel/apps/graphql/queries/findAdminApplicationRegistrationMonitoring.tsindex ab76c98d121..0272c46a866 100644--- a/packages/twenty-front/src/modules/settings/admin-panel/apps/graphql/queries/findAdminApplicationRegistrationMonitoring.ts+++ b/packages/twenty-front/src/modules/settings/admin-panel/apps/graphql/queries/findAdminApplicationRegistrationMonitoring.ts@@ -38,6 +38,7 @@ export const FIND_ADMIN_APPLICATION_REGISTRATION_MONITORING = gql`creditUsage {bucketStartoperationType+ operationLabelcreditsUsed}issues {diff --git a/packages/twenty-front/src/modules/settings/admin-panel/apps/graphql/queries/findAdminApplicationRegistrationStats.ts b/packages/twenty-front/src/modules/settings/admin-panel/apps/graphql/queries/findAdminApplicationRegistrationStats.tsindex ee6693c76ba..dc81b51fc23 100644--- a/packages/twenty-front/src/modules/settings/admin-panel/apps/graphql/queries/findAdminApplicationRegistrationStats.ts+++ b/packages/twenty-front/src/modules/settings/admin-panel/apps/graphql/queries/findAdminApplicationRegistrationStats.ts@@ -16,6 +16,7 @@ export const FIND_ADMIN_APPLICATION_REGISTRATION_STATS = gql`totalCreditsUsedcreditsUsedBreakdown {label+ iconoperationcreditsUsed}diff --git a/packages/twenty-front/src/modules/settings/application-monitoring/components/ApplicationMonitoringCreditsSection.tsx b/packages/twenty-front/src/modules/settings/application-monitoring/components/ApplicationMonitoringCreditsSection.tsxindex 3f4294a0ec9..15e86fe2591 100644--- a/packages/twenty-front/src/modules/settings/application-monitoring/components/ApplicationMonitoringCreditsSection.tsx+++ b/packages/twenty-front/src/modules/settings/application-monitoring/components/ApplicationMonitoringCreditsSection.tsx@@ -65,15 +65,17 @@ export const ApplicationMonitoringCreditsSection = ({<ApplicationMonitoringLineChartdata={creditChartData.data}series={creditChartData.series.map(- ({ key, operationType }, index) => {+ ({ key, operationType, operationLabel }, index) => {const operationTypeLabel =getUsageOperationTypeLabel(operationType);return {key,- label: isDefined(operationTypeLabel)- ? i18n._(operationTypeLabel)- : operationType,+ label:+ operationLabel ??+ (isDefined(operationTypeLabel)+ ? i18n._(operationTypeLabel)+ : operationType),color:APPLICATION_MONITORING_CREDIT_SERIES_COLORS[index % APPLICATION_MONITORING_CREDIT_SERIES_COLORS.lengthdiff --git a/packages/twenty-front/src/modules/settings/application-monitoring/components/__stories__/ApplicationMonitoring.stories.tsx b/packages/twenty-front/src/modules/settings/application-monitoring/components/__stories__/ApplicationMonitoring.stories.tsxindex 3856bfc3365..1193798d9e0 100644--- a/packages/twenty-front/src/modules/settings/application-monitoring/components/__stories__/ApplicationMonitoring.stories.tsx+++ b/packages/twenty-front/src/modules/settings/application-monitoring/components/__stories__/ApplicationMonitoring.stories.tsx@@ -72,18 +72,20 @@ const MONITORING: ApplicationMonitoringData = {],creditUsage: ([- ['2026-10-13', UsageOperationType.CODE_EXECUTION, 21],- ['2026-10-14', UsageOperationType.CODE_EXECUTION, 24.5],- ['2026-10-16', UsageOperationType.CODE_EXECUTION, 30],- ['2026-10-17', UsageOperationType.CODE_EXECUTION, 12],- ['2026-10-17', UsageOperationType.AI_WORKFLOW_TOKEN, 50],- ['2026-10-18', UsageOperationType.CODE_EXECUTION, 7],- ['2026-10-18', UsageOperationType.AI_WORKFLOW_TOKEN, 40],+ ['2026-10-13', UsageOperationType.CODE_EXECUTION, 21, null],+ ['2026-10-14', UsageOperationType.CODE_EXECUTION, 24.5, null],+ ['2026-10-16', UsageOperationType.CODE_EXECUTION, 30, null],+ ['2026-10-17', UsageOperationType.CODE_EXECUTION, 12, null],+ ['2026-10-17', UsageOperationType.AI_WORKFLOW_TOKEN, 50, null],+ ['2026-10-18', UsageOperationType.CODE_EXECUTION, 7, null],+ ['2026-10-18', UsageOperationType.AI_WORKFLOW_TOKEN, 40, null],+ ['2026-10-18', UsageOperationType.APP_OPERATION, 15, 'SMS sent'],] as const- ).map(([day, operationType, creditsUsed]) => ({+ ).map(([day, operationType, creditsUsed, operationLabel]) => ({__typename: 'ApplicationMonitoringCreditBucket' as const,bucketStart: `${day}T00:00:00.000Z`,operationType,+ operationLabel,creditsUsed,})),issues: [diff --git a/packages/twenty-front/src/modules/settings/application-monitoring/utils/__tests__/buildApplicationMonitoringCreditChartData.test.ts b/packages/twenty-front/src/modules/settings/application-monitoring/utils/__tests__/buildApplicationMonitoringCreditChartData.test.tsindex e8711b9b122..a26b6485d71 100644--- a/packages/twenty-front/src/modules/settings/application-monitoring/utils/__tests__/buildApplicationMonitoringCreditChartData.test.ts+++ b/packages/twenty-front/src/modules/settings/application-monitoring/utils/__tests__/buildApplicationMonitoringCreditChartData.test.ts@@ -1,7 +1,7 @@import { buildApplicationMonitoringCreditChartData } from '@/settings/application-monitoring/utils/buildApplicationMonitoringCreditChartData';describe('buildApplicationMonitoringCreditChartData', () => {- it('should split credits by operation type, declared ones included, largest total first, and fill the buckets without usage', () => {+ it('should split credits by declared operation label, else by operation type, largest total first, and fill the buckets without usage', () => {expect(buildApplicationMonitoringCreditChartData({periodStart: '2026-10-16T08:00:00.000Z',@@ -11,18 +11,21 @@ describe('buildApplicationMonitoringCreditChartData', () => {{bucketStart: '2026-10-17T00:00:00.000Z',operationType: 'CODE_EXECUTION',+ operationLabel: null,creditsUsed: 2.5,__typename: 'ApplicationMonitoringCreditBucket',},{bucketStart: '2026-10-17T00:00:00.000Z',- operationType: 'sendSms',+ operationType: 'APP_OPERATION',+ operationLabel: 'SMS sent',creditsUsed: 4,__typename: 'ApplicationMonitoringCreditBucket',},{bucketStart: '2026-10-18T00:00:00.000Z',operationType: 'CODE_EXECUTION',+ operationLabel: null,creditsUsed: 1,__typename: 'ApplicationMonitoringCreditBucket',},@@ -30,28 +33,36 @@ describe('buildApplicationMonitoringCreditChartData', () => {}),).toEqual({series: [- { key: 'operation:sendSms', operationType: 'sendSms' },- { key: 'operation:CODE_EXECUTION', operationType: 'CODE_EXECUTION' },+ {+ key: 'label:SMS sent',+ operationType: 'APP_OPERATION',+ operationLabel: 'SMS sent',+ },+ {+ key: 'operation:CODE_EXECUTION',+ operationType: 'CODE_EXECUTION',+ operationLabel: null,+ },],data: [{bucketStart: '2026-10-16T00:00:00.000Z',- 'operation:sendSms': 0,+ 'label:SMS sent': 0,'operation:CODE_EXECUTION': 0,},{bucketStart: '2026-10-17T00:00:00.000Z',- 'operation:sendSms': 4,+ 'label:SMS sent': 4,'operation:CODE_EXECUTION': 2.5,},{bucketStart: '2026-10-18T00:00:00.000Z',- 'operation:sendSms': 0,+ 'label:SMS sent': 0,'operation:CODE_EXECUTION': 1,},{bucketStart: '2026-10-19T00:00:00.000Z',- 'operation:sendSms': 0,+ 'label:SMS sent': 0,'operation:CODE_EXECUTION': 0,},],diff --git a/packages/twenty-front/src/modules/settings/application-monitoring/utils/buildApplicationMonitoringCreditChartData.ts b/packages/twenty-front/src/modules/settings/application-monitoring/utils/buildApplicationMonitoringCreditChartData.tsindex 2909b4e1460..3db1f649b41 100644--- a/packages/twenty-front/src/modules/settings/application-monitoring/utils/buildApplicationMonitoringCreditChartData.ts+++ b/packages/twenty-front/src/modules/settings/application-monitoring/utils/buildApplicationMonitoringCreditChartData.ts@@ -1,9 +1,19 @@+import { isDefined } from 'twenty-shared/utils';+import { type ApplicationMonitoringChartDatum } from '@/settings/application-monitoring/types/ApplicationMonitoringChartDatum';import { type ApplicationMonitoringData } from '@/settings/application-monitoring/types/ApplicationMonitoringData';import { listApplicationMonitoringBucketStarts } from '@/settings/application-monitoring/utils/listApplicationMonitoringBucketStarts';-// Prefixed so an app-declared operation can never collide with bucketStart-type ApplicationMonitoringCreditSeriesKey = `operation:${string}`;+// Prefixed so neither collides with bucketStart, nor a declared label with an operation type+type ApplicationMonitoringCreditSeriesKey =+ | `operation:${string}`+ | `label:${string}`;++type ApplicationMonitoringCreditSeries = {+ key: ApplicationMonitoringCreditSeriesKey;+ operationType: string;+ operationLabel: string | null;+};export const buildApplicationMonitoringCreditChartData = (monitoring: Pick<@@ -13,32 +23,48 @@ export const buildApplicationMonitoringCreditChartData = (creditUsage: NonNullable<ApplicationMonitoringData['creditUsage']>;},): {- series: {- key: ApplicationMonitoringCreditSeriesKey;- operationType: string;- }[];+ series: ApplicationMonitoringCreditSeries[];data: ApplicationMonitoringChartDatum<ApplicationMonitoringCreditSeriesKey>[];} => {- const totalByOperationType = new Map<string, number>();- const creditsUsedByBucketStartAndOperationType = new Map<string, number>();+ const seriesByKey = new Map<+ ApplicationMonitoringCreditSeriesKey,+ ApplicationMonitoringCreditSeries & { total: number }+ >();+ const creditsUsedByBucketStartAndSeriesKey = new Map<string, number>();for (const bucket of monitoring.creditUsage) {- totalByOperationType.set(- bucket.operationType,- (totalByOperationType.get(bucket.operationType) ?? 0) ++ const operationLabel = bucket.operationLabel ?? null;+ const key: ApplicationMonitoringCreditSeriesKey = isDefined(operationLabel)+ ? `label:${operationLabel}`+ : `operation:${bucket.operationType}`;+ const series = seriesByKey.get(key);++ if (isDefined(series)) {+ series.total += bucket.creditsUsed;+ } else {+ seriesByKey.set(key, {+ key,+ operationType: bucket.operationType,+ operationLabel,+ total: bucket.creditsUsed,+ });+ }++ const bucketKey = `${new Date(bucket.bucketStart).toISOString()}|${key}`;++ creditsUsedByBucketStartAndSeriesKey.set(+ bucketKey,+ (creditsUsedByBucketStartAndSeriesKey.get(bucketKey) ?? 0) +bucket.creditsUsed,);- creditsUsedByBucketStartAndOperationType.set(- `${new Date(bucket.bucketStart).toISOString()}|${bucket.operationType}`,- bucket.creditsUsed,- );}- const series = [...totalByOperationType.entries()]- .sort(([, firstTotal], [, secondTotal]) => secondTotal - firstTotal)- .map(([operationType]) => ({- key: `operation:${operationType}` as const,+ const series = [...seriesByKey.values()]+ .sort((firstSeries, secondSeries) => secondSeries.total - firstSeries.total)+ .map(({ key, operationType, operationLabel }) => ({+ key,operationType,+ operationLabel,}));return {@@ -48,10 +74,10 @@ export const buildApplicationMonitoringCreditChartData = (({bucketStart,...Object.fromEntries(- series.map(({ key, operationType }) => [+ series.map(({ key }) => [key,- creditsUsedByBucketStartAndOperationType.get(- `${bucketStart}|${operationType}`,+ creditsUsedByBucketStartAndSeriesKey.get(+ `${bucketStart}|${key}`,) ?? 0,]),),diff --git a/packages/twenty-front/src/modules/settings/application-registrations/graphql/queries/findApplicationRegistrationMonitoring.ts b/packages/twenty-front/src/modules/settings/application-registrations/graphql/queries/findApplicationRegistrationMonitoring.tsindex 38b7571b2f0..e1e5c010cf0 100644--- a/packages/twenty-front/src/modules/settings/application-registrations/graphql/queries/findApplicationRegistrationMonitoring.ts+++ b/packages/twenty-front/src/modules/settings/application-registrations/graphql/queries/findApplicationRegistrationMonitoring.ts@@ -36,6 +36,7 @@ export const FIND_APPLICATION_REGISTRATION_MONITORING = gql`creditUsage {bucketStartoperationType+ operationLabelcreditsUsed}issues {diff --git a/packages/twenty-front/src/modules/settings/application-registrations/graphql/queries/findApplicationRegistrationStats.ts b/packages/twenty-front/src/modules/settings/application-registrations/graphql/queries/findApplicationRegistrationStats.tsindex fe3b7645f2a..8b5fc08c79b 100644--- a/packages/twenty-front/src/modules/settings/application-registrations/graphql/queries/findApplicationRegistrationStats.ts+++ b/packages/twenty-front/src/modules/settings/application-registrations/graphql/queries/findApplicationRegistrationStats.ts@@ -16,6 +16,7 @@ export const FIND_APPLICATION_REGISTRATION_STATS = gql`totalCreditsUsedcreditsUsedBreakdown {label+ iconoperationcreditsUsed}diff --git a/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitOperationTypeIcons.ts b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitOperationTypeIcons.tsindex 45e2d62ebe0..88226f839e7 100644--- a/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitOperationTypeIcons.ts+++ b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitOperationTypeIcons.ts@@ -1,6 +1,7 @@import {IconAddressBook,IconApi,+ IconApps,IconCode,type IconComponent,IconFiles,@@ -32,6 +33,7 @@ export const USAGE_LIMIT_OPERATION_TYPE_ICONS: Record<[UsageOperationType.CALL_RECORDING]: IconPhone,[UsageOperationType.EMAIL_SEND]: IconMail,[UsageOperationType.MESSAGE_CAMPAIGN_SEND]: IconSend,+ [UsageOperationType.APP_OPERATION]: IconApps,[UsageOperationType.API_REQUEST]: IconApi,[UsageOperationType.WEBHOOK_CALL]: IconWebhook,[UsageOperationType.STORAGE_FILE]: IconFiles,diff --git a/packages/twenty-front/src/modules/settings/components/SettingsStatsGrid.tsx b/packages/twenty-front/src/modules/settings/components/SettingsStatsGrid.tsxindex 241a4239e4b..c7b35cb4879 100644--- a/packages/twenty-front/src/modules/settings/components/SettingsStatsGrid.tsx+++ b/packages/twenty-front/src/modules/settings/components/SettingsStatsGrid.tsx@@ -7,6 +7,7 @@ export type SettingsStatRow = {Icon: IconComponent;label: string;value: ReactNode;+ hasSeparatorAfter?: boolean;};type SettingsStatsGridProps = {@@ -43,6 +44,11 @@ const StyledRow = styled.div`height: ${themeCssVariables.spacing[6]};`;+const StyledRowSeparator = styled.div`+ background: ${themeCssVariables.border.color.light};+ height: 1px;+`;+const StyledLabel = styled.div`color: ${themeCssVariables.font.color.tertiary};flex: 1 1 0;@@ -78,13 +84,11 @@ export const SettingsStatsGrid = ({ columns }: SettingsStatsGridProps) => (<Fragment key={index}>{index > 0 && <StyledDivider />}<StyledColumn>- {column.map((stat) => (- <StatRow- key={stat.label}- Icon={stat.Icon}- label={stat.label}- value={stat.value}- />+ {column.map((stat, rowIndex) => (+ <Fragment key={`${rowIndex}-${stat.label}`}>+ <StatRow Icon={stat.Icon} label={stat.label} value={stat.value} />+ {stat.hasSeparatorAfter && <StyledRowSeparator />}+ </Fragment>))}</StyledColumn></Fragment>diff --git a/packages/twenty-front/src/modules/settings/usage/constants/UsageOperationTypeLabels.ts b/packages/twenty-front/src/modules/settings/usage/constants/UsageOperationTypeLabels.tsindex 9ee35dae622..b0c7e68d6ee 100644--- a/packages/twenty-front/src/modules/settings/usage/constants/UsageOperationTypeLabels.ts+++ b/packages/twenty-front/src/modules/settings/usage/constants/UsageOperationTypeLabels.ts@@ -17,6 +17,7 @@ export const USAGE_OPERATION_TYPE_LABELS: Record<[UsageOperationType.CALL_RECORDING]: msg`Call Recording`,[UsageOperationType.EMAIL_SEND]: msg`Email Send`,[UsageOperationType.MESSAGE_CAMPAIGN_SEND]: msg`Campaign Email Send`,+ [UsageOperationType.APP_OPERATION]: msg`App Operation`,[UsageOperationType.API_REQUEST]: msg`API Request`,[UsageOperationType.WEBHOOK_CALL]: msg`Webhook Call`,[UsageOperationType.STORAGE_FILE]: msg`File Storage`,diff --git a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationInstallStats.tsx b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationInstallStats.tsxindex 2ea99b206fb..ccfb4c85f95 100644--- a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationInstallStats.tsx+++ b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationInstallStats.tsx@@ -19,7 +19,9 @@ import {IconCoins,IconPlayerPause,IconRefresh,+ type IconComponent,IconVersions,+ useIcons,} from 'twenty-ui/icon';import { Tooltip } from 'twenty-ui/primitives/surfaces';import { OverflowingTextWithTooltip } from 'twenty-ui/primitives/typography';@@ -34,6 +36,7 @@ export const SettingsApplicationRegistrationInstallStats = ({isAdminView?: boolean;}) => {const { t, i18n } = useLingui();+ const { getIcon } = useIcons();const apolloAdminClient = useApolloAdminClient();const billing = useAtomStateValue(billingState);const isBillingEnabled = billing?.isBillingEnabled ?? false;@@ -107,10 +110,34 @@ export const SettingsApplicationRegistrationInstallStats = ({}): '—';+ const creditsUsedBreakdown = stats?.creditsUsedBreakdown ?? [];++ const getCreditsUsedBreakdownIcon = ({+ icon,+ operation,+ }: {+ icon?: string | null;+ operation?: string | null;+ }): IconComponent => {+ if (isDefined(icon)) {+ return getIcon(icon);+ }++ if (+ isDefined(operation) &&+ isKeyOfRecord(USAGE_LIMIT_OPERATION_TYPE_ICONS, operation)+ ) {+ return USAGE_LIMIT_OPERATION_TYPE_ICONS[operation];+ }++ return IconCoins;+ };+const creditsUsedStats: SettingsStatRow[] = [{Icon: IconCoins,label: t`Credits used this month`,+ hasSeparatorAfter: creditsUsedBreakdown.length > 0,value: (<Tooltipcontent={t`Usage attributed to this application in its current installing workspaces since the start of the month (UTC). Updated every ten minutes.`}@@ -119,25 +146,21 @@ export const SettingsApplicationRegistrationInstallStats = ({</Tooltip>),},- ...(stats?.creditsUsedBreakdown ?? []).map(- ({ label, operation, creditsUsed }) => {- const operationLabel = isDefined(operation)- ? getUsageOperationTypeLabel(operation)- : undefined;-- return {- Icon:- isDefined(operation) &&- isKeyOfRecord(USAGE_LIMIT_OPERATION_TYPE_ICONS, operation)- ? USAGE_LIMIT_OPERATION_TYPE_ICONS[operation]- : IconCoins,- label: isDefined(operationLabel)- ? i18n._(operationLabel)- : (label ?? operation ?? '—'),- value: formatCredits(creditsUsed),- };- },- ),+ ...creditsUsedBreakdown.map(({ label, icon, operation, creditsUsed }) => {+ const operationLabel = isDefined(operation)+ ? getUsageOperationTypeLabel(operation)+ : undefined;++ return {+ Icon: getCreditsUsedBreakdownIcon({ icon, operation }),+ label:+ label ??+ (isDefined(operationLabel) ? i18n._(operationLabel) : undefined) ??+ operation ??+ '—',+ value: formatCredits(creditsUsed),+ };+ }),];return (diff --git a/packages/twenty-front/src/pages/settings/applications/components/__tests__/SettingsApplicationRegistrationInstallStats.test.tsx b/packages/twenty-front/src/pages/settings/applications/components/__tests__/SettingsApplicationRegistrationInstallStats.test.tsxindex 675c3a051ac..a60d26864e1 100644--- a/packages/twenty-front/src/pages/settings/applications/components/__tests__/SettingsApplicationRegistrationInstallStats.test.tsx+++ b/packages/twenty-front/src/pages/settings/applications/components/__tests__/SettingsApplicationRegistrationInstallStats.test.tsx@@ -29,10 +29,16 @@ const STATS: ApplicationRegistrationStats = {creditsUsedBreakdown: [{label: null,+ icon: null,operation: UsageOperationType.CODE_EXECUTION,creditsUsed: 1171.704,},- { label: 'HISTORICAL_OPERATION', operation: null, creditsUsed: 1.262302 },+ {+ label: 'HISTORICAL_OPERATION',+ icon: null,+ operation: null,+ creditsUsed: 1.262302,+ },],};@@ -108,6 +114,25 @@ describe('Application registration statistics', () => {},);+ it('shows the label an app declared for its billing operation', async () => {+ renderStats({+ stats: {+ ...STATS,+ creditsUsedBreakdown: [+ {+ label: 'Person enrichment',+ icon: 'IconUserSearch',+ operation: UsageOperationType.APP_OPERATION,+ creditsUsed: 3,+ },+ ],+ },+ });++ expect(await screen.findByText('Person enrichment')).toBeVisible();+ expect(screen.queryByText('App Operation')).not.toBeInTheDocument();+ });+it.each([null, 0])('distinguishes unavailable usage from zero: %s',async (totalCreditsUsed) => {diff --git a/packages/twenty-sdk/src/sdk/billing/charge-credits.ts b/packages/twenty-sdk/src/sdk/billing/charge-credits.tsindex f0de3fc2b32..b1e8945579c 100644--- a/packages/twenty-sdk/src/sdk/billing/charge-credits.ts+++ b/packages/twenty-sdk/src/sdk/billing/charge-credits.ts@@ -18,8 +18,8 @@ export type ChargeCreditsParams = {resourceContext?: never;}| {- // For applications that declare no billable operations: names the platform billing category directly- operationType: UsageOperationTypeValue;+ // Platform billing category; omitted, the charge lands in the dedicated APP_OPERATION category+ operationType?: UsageOperationTypeValue;operation?: never;resourceContext?: string;}diff --git a/packages/twenty-sdk/src/sdk/define/application/__tests__/define-app.spec.ts b/packages/twenty-sdk/src/sdk/define/application/__tests__/define-app.spec.tsindex 2b61ad08529..9f4e28f6ed8 100644--- a/packages/twenty-sdk/src/sdk/define/application/__tests__/define-app.spec.ts+++ b/packages/twenty-sdk/src/sdk/define/application/__tests__/define-app.spec.ts@@ -298,6 +298,39 @@ describe('defineApplication', () => {);});+ it('should accept a billable operation with only a label and an icon', () => {+ const result = defineApplication({+ universalIdentifier: 'a9faf5f8-cf7e-4f24-9d37-fd523c30febe',+ displayName: 'My App',+ description: 'My app description',+ billing: {+ operations: {+ enrichPerson: { label: 'Person enrichment', icon: 'IconUserSearch' },+ },+ },+ });++ expect(result.success).toBe(true);+ });++ it('should return error when a billable operation has an empty icon', () => {+ const result = defineApplication({+ universalIdentifier: 'a9faf5f8-cf7e-4f24-9d37-fd523c30febe',+ displayName: 'My App',+ description: 'My app description',+ billing: {+ operations: {+ enrichPerson: { label: 'Person enrichment', icon: '' },+ },+ },+ });++ expect(result.success).toBe(false);+ expect(result.errors).toContain(+ 'Billable operation "enrichPerson" must have a non empty icon when set',+ );+ });+it('should accept a flat and a per member recurring charge', () => {const result = defineApplication({universalIdentifier: 'a9faf5f8-cf7e-4f24-9d37-fd523c30febe',diff --git a/packages/twenty-sdk/src/sdk/define/application/define-application.ts b/packages/twenty-sdk/src/sdk/define/application/define-application.tsindex 52f41bf67f6..4e879e0c40e 100644--- a/packages/twenty-sdk/src/sdk/define/application/define-application.ts+++ b/packages/twenty-sdk/src/sdk/define/application/define-application.ts@@ -73,7 +73,10 @@ export const defineApplication: DefineEntity<ApplicationConfig> = (config) => {continue;}- if (!isUsageOperationTypeValue(billableOperation.operationType)) {+ if (+ isDefined(billableOperation.operationType) &&+ !isUsageOperationTypeValue(billableOperation.operationType)+ ) {errors.push(`Billable operation "${operationName}" must map to a known operationType (${USAGE_OPERATION_TYPES.join(', ',@@ -86,6 +89,15 @@ export const defineApplication: DefineEntity<ApplicationConfig> = (config) => {`Billable operation "${operationName}" must have a non empty label`,);}++ if (+ isDefined(billableOperation.icon) &&+ !isNonEmptyString(billableOperation.icon)+ ) {+ errors.push(+ `Billable operation "${operationName}" must have a non empty icon when set`,+ );+ }}for (const [chargeName, recurringCharge] of Object.entries(diff --git a/packages/twenty-server/src/engine/core-modules/application/application-monitoring/application-monitoring.service.ts b/packages/twenty-server/src/engine/core-modules/application/application-monitoring/application-monitoring.service.tsindex 143d632b817..6d0f33170bc 100644--- a/packages/twenty-server/src/engine/core-modules/application/application-monitoring/application-monitoring.service.ts+++ b/packages/twenty-server/src/engine/core-modules/application/application-monitoring/application-monitoring.service.ts@@ -12,6 +12,7 @@ import { type ApplicationMonitoringDTO } from 'src/engine/core-modules/applicatiimport {type ApplicationMonitoringActiveWorkspaceCountRow,type ApplicationMonitoringActivityRow,+ type ApplicationMonitoringCreditUsage,type ApplicationMonitoringFunctionRow,type ApplicationMonitoringIssueRow,type ApplicationMonitoringLifecycleRow,@@ -30,6 +31,7 @@ import { ApplicationRegistrationService } from 'src/engine/core-modules/applicatimport { EventLogRetentionService } from 'src/engine/core-modules/event-logs/retention/services/event-log-retention.service';import { FileUrlService } from 'src/engine/core-modules/file/file-url/file-url.service';import { UsageAnalyticsService } from 'src/engine/core-modules/usage/services/usage-analytics.service';+import { listDeclaredBillingChargeNames } from 'src/engine/core-modules/usage/utils/list-declared-billing-charge-names.util';import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';type ApplicationMonitoringQueryParams = {@@ -218,26 +220,30 @@ export class ApplicationMonitoringService {'applicationRegistrationId' | 'workspaceId'>;period: ApplicationMonitoringPeriod;- }): Promise<- | {- bucketStart: Date;- operationType: string;- creditsUsedMicro: number;- }[]- | null- > {+ }): Promise<ApplicationMonitoringCreditUsage | null> {try {- const installations =- await this.applicationRegistrationService.findInstallations({+ const [installations, billing] = await Promise.all([+ this.applicationRegistrationService.findInstallations({applicationRegistrationId: params.applicationRegistrationId,workspaceId: isNonEmptyString(params.workspaceId)? params.workspaceId: undefined,- });+ }),+ this.applicationRegistrationService.findBilling(+ params.applicationRegistrationId,+ ),+ ]);- return await this.usageAnalyticsService.getCreditsUsedTimeSeriesForInstallations(- { installations, ...period },- );+ const rows =+ await this.usageAnalyticsService.getCreditsUsedTimeSeriesForInstallations(+ {+ installations,+ declaredOperations: listDeclaredBillingChargeNames({ billing }),+ ...period,+ },+ );++ return { rows, billing };} catch (error) {this.logger.warn(`Failed to load credits used for registration ${params.applicationRegistrationId}`,diff --git a/packages/twenty-server/src/engine/core-modules/application/application-monitoring/dtos/application-monitoring.dto.ts b/packages/twenty-server/src/engine/core-modules/application/application-monitoring/dtos/application-monitoring.dto.tsindex 35d5c006dae..daa0c1b53be 100644--- a/packages/twenty-server/src/engine/core-modules/application/application-monitoring/dtos/application-monitoring.dto.ts+++ b/packages/twenty-server/src/engine/core-modules/application/application-monitoring/dtos/application-monitoring.dto.ts@@ -42,6 +42,9 @@ export class ApplicationMonitoringCreditBucketDTO {@Field(() => String)operationType: string;+ @Field(() => String, { nullable: true })+ operationLabel: string | null;+@Field(() => Float)creditsUsed: number;}diff --git a/packages/twenty-server/src/engine/core-modules/application/application-monitoring/types/application-monitoring-rows.type.ts b/packages/twenty-server/src/engine/core-modules/application/application-monitoring/types/application-monitoring-rows.type.tsindex 6cb2ae50450..39f2828337a 100644--- a/packages/twenty-server/src/engine/core-modules/application/application-monitoring/types/application-monitoring-rows.type.ts+++ b/packages/twenty-server/src/engine/core-modules/application/application-monitoring/types/application-monitoring-rows.type.ts@@ -1,3 +1,7 @@+import { type ApplicationBilling } from 'twenty-shared/application';++import { type CreditsUsedTimeSeriesRow } from 'src/engine/core-modules/usage/types/credits-used-time-series-row.type';+type ClickHouseCount = number | string;export type ApplicationMonitoringTotalsRow = {@@ -68,3 +72,8 @@ export type ApplicationMonitoringWorkspaceRow = {rateLimitEventCount: ClickHouseCount;lastEventAt: string;};++export type ApplicationMonitoringCreditUsage = {+ rows: CreditsUsedTimeSeriesRow[];+ billing: ApplicationBilling | null;+};diff --git a/packages/twenty-server/src/engine/core-modules/application/application-monitoring/utils/__tests__/map-application-monitoring-rows.util.spec.ts b/packages/twenty-server/src/engine/core-modules/application/application-monitoring/utils/__tests__/map-application-monitoring-rows.util.spec.tsindex 331f0b9b059..6fa72c0970a 100644--- a/packages/twenty-server/src/engine/core-modules/application/application-monitoring/utils/__tests__/map-application-monitoring-rows.util.spec.ts+++ b/packages/twenty-server/src/engine/core-modules/application/application-monitoring/utils/__tests__/map-application-monitoring-rows.util.spec.ts@@ -23,7 +23,7 @@ describe('mapApplicationMonitoringRows', () => {period: PERIOD,lookbackInHours: 2160,rows: EMPTY_ROWS,- creditUsage: [],+ creditUsage: { rows: [], billing: null },}),).toEqual({...PERIOD,@@ -85,7 +85,7 @@ describe('mapApplicationMonitoringRows', () => {},],},- creditUsage: [],+ creditUsage: { rows: [], billing: null },});expect(monitoring).toMatchObject({@@ -119,23 +119,29 @@ describe('mapApplicationMonitoringRows', () => {period: PERIOD,lookbackInHours: 2160,rows: EMPTY_ROWS,- creditUsage: [- {- bucketStart: new Date('2026-10-17T00:00:00.000Z'),- operationType: UsageOperationType.CODE_EXECUTION,- creditsUsedMicro: 10_000,- },- {- bucketStart: new Date('2026-10-18T00:00:00.000Z'),- operationType: UsageOperationType.CODE_EXECUTION,- creditsUsedMicro: 10_000,- },- {- bucketStart: new Date('2026-10-18T00:00:00.000Z'),- operationType: 'sendSms',- creditsUsedMicro: 120_000,- },- ],+ creditUsage: {+ rows: [+ {+ bucketStart: new Date('2026-10-17T00:00:00.000Z'),+ operationType: UsageOperationType.CODE_EXECUTION,+ operation: '',+ creditsUsedMicro: 10_000,+ },+ {+ bucketStart: new Date('2026-10-18T00:00:00.000Z'),+ operationType: UsageOperationType.CODE_EXECUTION,+ operation: '',+ creditsUsedMicro: 10_000,+ },+ {+ bucketStart: new Date('2026-10-18T00:00:00.000Z'),+ operationType: UsageOperationType.APP_OPERATION,+ operation: '',+ creditsUsedMicro: 120_000,+ },+ ],+ billing: null,+ },}),).toMatchObject({creditsUsed: 0.14,@@ -143,18 +149,88 @@ describe('mapApplicationMonitoringRows', () => {{bucketStart: new Date('2026-10-17T00:00:00.000Z'),operationType: UsageOperationType.CODE_EXECUTION,+ operationLabel: null,creditsUsed: 0.01,},{bucketStart: new Date('2026-10-18T00:00:00.000Z'),operationType: UsageOperationType.CODE_EXECUTION,+ operationLabel: null,creditsUsed: 0.01,},{bucketStart: new Date('2026-10-18T00:00:00.000Z'),- operationType: 'sendSms',+ operationType: UsageOperationType.APP_OPERATION,+ operationLabel: null,+ creditsUsed: 0.12,+ },+ ],+ });+ });++ it('labels credits by the declared billing charge and merges undeclared contexts', () => {+ expect(+ mapApplicationMonitoringRows({+ period: PERIOD,+ lookbackInHours: 2160,+ rows: EMPTY_ROWS,+ creditUsage: {+ rows: [+ {+ bucketStart: new Date('2026-10-18T00:00:00.000Z'),+ operationType: UsageOperationType.APP_OPERATION,+ operation: 'sendSms',+ creditsUsedMicro: 120_000,+ },+ {+ bucketStart: new Date('2026-10-18T00:00:00.000Z'),+ operationType: UsageOperationType.APP_OPERATION,+ operation: 'workflow-run-1',+ creditsUsedMicro: 20_000,+ },+ {+ bucketStart: new Date('2026-10-18T00:00:00.000Z'),+ operationType: UsageOperationType.APP_OPERATION,+ operation: 'constructor',+ creditsUsedMicro: 10_000,+ },+ {+ bucketStart: new Date('2026-10-18T00:00:00.000Z'),+ operationType: UsageOperationType.SUBSCRIPTION,+ operation: 'platformFee',+ creditsUsedMicro: 1_000_000,+ },+ ],+ billing: {+ operations: { sendSms: { label: 'SMS sent' } },+ recurring: {+ platformFee: {+ period: 'MONTH',+ amountMicroCredits: 1_000_000,+ label: 'Platform fee',+ },+ },+ },+ },+ }),+ ).toMatchObject({+ creditsUsed: 1.15,+ creditUsage: [+ {+ operationType: UsageOperationType.APP_OPERATION,+ operationLabel: 'SMS sent',creditsUsed: 0.12,},+ {+ operationType: UsageOperationType.APP_OPERATION,+ operationLabel: null,+ creditsUsed: 0.03,+ },+ {+ operationType: UsageOperationType.SUBSCRIPTION,+ operationLabel: 'Platform fee',+ creditsUsed: 1,+ },],});});diff --git a/packages/twenty-server/src/engine/core-modules/application/application-monitoring/utils/map-application-monitoring-rows.util.ts b/packages/twenty-server/src/engine/core-modules/application/application-monitoring/utils/map-application-monitoring-rows.util.tsindex db55a574d60..9f6763d0c59 100644--- a/packages/twenty-server/src/engine/core-modules/application/application-monitoring/utils/map-application-monitoring-rows.util.ts+++ b/packages/twenty-server/src/engine/core-modules/application/application-monitoring/utils/map-application-monitoring-rows.util.ts@@ -3,13 +3,54 @@ import { isDefined } from 'twenty-shared/utils';import { parseClickHouseDateTime } from 'src/database/clickhouse/utils/parse-clickhouse-date-time.util';import { type ApplicationMonitoringDTO } from 'src/engine/core-modules/application/application-monitoring/dtos/application-monitoring.dto';-import { type ApplicationMonitoringRows } from 'src/engine/core-modules/application/application-monitoring/types/application-monitoring-rows.type';+import {+ type ApplicationMonitoringCreditUsage,+ type ApplicationMonitoringRows,+} from 'src/engine/core-modules/application/application-monitoring/types/application-monitoring-rows.type';import { type ApplicationMonitoringPeriod } from 'src/engine/core-modules/application/application-monitoring/utils/resolve-application-monitoring-period.util';+import { findDeclaredBillingCharge } from 'src/engine/core-modules/usage/utils/find-declared-billing-charge.util';import { toDisplayCredits } from 'src/engine/core-modules/usage/utils/to-display-credits.util';const toNumber = (value: number | string | undefined): number =>Number(value ?? 0);+// Resolved against the latest manifest, so an operation renamed or dropped since falls back to its operationType+const groupCreditUsageByOperationLabel = ({+ rows,+ billing,+}: ApplicationMonitoringCreditUsage) => {+ const bucketsByKey = new Map<+ string,+ {+ bucketStart: Date;+ operationType: string;+ operationLabel: string | null;+ creditsUsedMicro: number;+ }+ >();++ for (const row of rows) {+ const operationLabel =+ findDeclaredBillingCharge({ billing, chargeName: row.operation })+ ?.label ?? null;+ const key = `${row.bucketStart.toISOString()}|${row.operationType}|${operationLabel ?? ''}`;+ const bucket = bucketsByKey.get(key);++ if (isDefined(bucket)) {+ bucket.creditsUsedMicro += row.creditsUsedMicro;+ } else {+ bucketsByKey.set(key, {+ bucketStart: row.bucketStart,+ operationType: row.operationType,+ operationLabel,+ creditsUsedMicro: row.creditsUsedMicro,+ });+ }+ }++ return [...bucketsByKey.values()];+};+export const mapApplicationMonitoringRows = ({period,lookbackInHours,@@ -19,15 +60,12 @@ export const mapApplicationMonitoringRows = ({period: ApplicationMonitoringPeriod;lookbackInHours: number;rows: ApplicationMonitoringRows;- creditUsage:- | {- bucketStart: Date;- operationType: string;- creditsUsedMicro: number;- }[]- | null;+ creditUsage: ApplicationMonitoringCreditUsage | null;}): ApplicationMonitoringDTO => {const [totals] = rows.totals;+ const creditUsageBuckets = isDefined(creditUsage)+ ? groupCreditUsageByOperationLabel(creditUsage)+ : null;return {...period,@@ -36,9 +74,9 @@ export const mapApplicationMonitoringRows = ({failedRunCount: toNumber(totals?.failedRunCount),lifecycleFailureCount: toNumber(totals?.lifecycleFailureCount),rateLimitEventCount: toNumber(totals?.rateLimitEventCount),- creditsUsed: isDefined(creditUsage)+ creditsUsed: isDefined(creditUsageBuckets)? toDisplayCredits(- creditUsage.reduce(+ creditUsageBuckets.reduce((total, bucket) => total + bucket.creditsUsedMicro,0,),@@ -58,9 +96,10 @@ export const mapApplicationMonitoringRows = ({failedCount: toNumber(row.failedCount),})),creditUsage:- creditUsage?.map((bucket) => ({+ creditUsageBuckets?.map((bucket) => ({bucketStart: bucket.bucketStart,operationType: bucket.operationType,+ operationLabel: bucket.operationLabel,creditsUsed: toDisplayCredits(bucket.creditsUsedMicro),})) ?? null,issues: rows.issues.map((row) => ({diff --git a/packages/twenty-server/src/engine/core-modules/application/application-registration/application-registration.service.ts b/packages/twenty-server/src/engine/core-modules/application/application-registration/application-registration.service.tsindex d751c067179..cce3cd30fed 100644--- a/packages/twenty-server/src/engine/core-modules/application/application-registration/application-registration.service.ts+++ b/packages/twenty-server/src/engine/core-modules/application/application-registration/application-registration.service.ts@@ -8,6 +8,7 @@ import { isNonEmptyString } from '@sniptt/guards';import * as bcrypt from 'bcrypt';import isEqual from 'lodash.isequal';import {+ type ApplicationBilling,TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER,type Manifest,} from 'twenty-shared/application';@@ -1299,12 +1300,13 @@ export class ApplicationRegistrationService {periodEnd: Date;}): Promise<CreditUsedItemDTO[] | null> {try {- const installations = await this.findInstallations({- applicationRegistrationId,- });+ const [installations, billing] = await Promise.all([+ this.findInstallations({ applicationRegistrationId }),+ this.findBilling(applicationRegistrationId),+ ]);return await this.usageAnalyticsService.getCreditsUsedBreakdownForInstallations(- { installations, periodStart, periodEnd },+ { installations, billing, periodStart, periodEnd },);} catch (error) {this.logger.warn(@@ -1347,6 +1349,21 @@ export class ApplicationRegistrationService {.getRawMany<ApplicationInstallation>();}+ // Reads only the jsonb path: the full manifest can be large+ async findBilling(+ applicationRegistrationId: string,+ ): Promise<ApplicationBilling | null> {+ const row = await this.applicationRegistrationRepository+ .createQueryBuilder('registration')+ .select("registration.manifest -> 'application' -> 'billing'", 'billing')+ .where('registration.id = :applicationRegistrationId', {+ applicationRegistrationId,+ })+ .getRawOne<{ billing: ApplicationBilling | null }>();++ return row?.billing ?? null;+ }+// Admin panel only, which views apps across all workspaces, so ownership is not enforcedasync getInstalledWorkspacesGlobal(applicationRegistrationId: string,diff --git a/packages/twenty-server/src/engine/core-modules/billing/app-billing/__tests__/app-billing.service.spec.ts b/packages/twenty-server/src/engine/core-modules/billing/app-billing/__tests__/app-billing.service.spec.tsnew file mode 100644index 00000000000..f64be7385b5--- /dev/null+++ b/packages/twenty-server/src/engine/core-modules/billing/app-billing/__tests__/app-billing.service.spec.ts@@ -0,0 +1,126 @@+import { plainToInstance } from 'class-transformer';+import { validate } from 'class-validator';++import { AppBillingService } from 'src/engine/core-modules/billing/app-billing/app-billing.service';+import { ChargeDto } from 'src/engine/core-modules/billing/app-billing/dtos/charge.dto';+import { UsageOperationType } from 'src/engine/core-modules/usage/enums/usage-operation-type.enum';+import { UsageUnit } from 'src/engine/core-modules/usage/enums/usage-unit.enum';++const WORKSPACE_ID = '20202020-0000-4000-8000-000000000001';+const APPLICATION_ID = '20202020-0000-4000-8000-000000000002';++const buildService = (billingOperations: Record<string, unknown> = {}) => {+ const charge = jest.fn();++ const service = new AppBillingService(+ { charge } as never,+ {+ getOrRecompute: async () => ({+ flatApplicationMaps: {+ byId: {+ [APPLICATION_ID]: {+ id: APPLICATION_ID,+ deletedAt: null,+ billing: { operations: billingOperations },+ },+ },+ },+ }),+ } as never,+ {} as never,+ );++ return { service, charge };+};++const emitCharge = ({+ service,+ charge,+}: {+ service: AppBillingService;+ charge: Partial<ChargeDto>;+}) =>+ service.emitChargeEvent({+ workspaceId: WORKSPACE_ID,+ applicationId: APPLICATION_ID,+ userWorkspaceId: null,+ charge: { creditsUsedMicro: 1_000, quantity: 1, ...charge } as ChargeDto,+ });++const getRecordedEvent = (charge: jest.Mock) =>+ charge.mock.calls[0][0].events[0];++describe('AppBillingService.emitChargeEvent', () => {+ it('should record a charge naming no category under APP_OPERATION', async () => {+ const { service, charge } = buildService();++ await emitCharge({ service, charge: {} });++ expect(getRecordedEvent(charge)).toMatchObject({+ operationType: UsageOperationType.APP_OPERATION,+ unit: UsageUnit.INVOCATION,+ resourceContext: null,+ });+ });++ it('should record a declared operation with only a label under APP_OPERATION', async () => {+ const { service, charge } = buildService({+ enrichPerson: { label: 'Person enrichment' },+ });++ await emitCharge({ service, charge: { operation: 'enrichPerson' } });++ expect(getRecordedEvent(charge)).toMatchObject({+ operationType: UsageOperationType.APP_OPERATION,+ unit: UsageUnit.INVOCATION,+ resourceContext: 'enrichPerson',+ });+ });++ it('should keep the category a declared operation names', async () => {+ const { service, charge } = buildService({+ recordMeeting: { operationType: 'CALL_RECORDING', label: 'Recording' },+ });++ await emitCharge({ service, charge: { operation: 'recordMeeting' } });++ expect(getRecordedEvent(charge)).toMatchObject({+ operationType: UsageOperationType.CALL_RECORDING,+ unit: UsageUnit.MINUTE,+ });+ });++ it('should reject a declared operation with a platform-only category', async () => {+ const { service, charge } = buildService({+ sneaky: { operationType: 'SUBSCRIPTION', label: 'Sneaky' },+ });++ await expect(+ emitCharge({ service, charge: { operation: 'sneaky' } }),+ ).rejects.toThrow('declares an unknown operationType');+ expect(charge).not.toHaveBeenCalled();+ });+});++describe('ChargeDto', () => {+ const validateCharge = (body: Record<string, unknown>) =>+ validate(+ plainToInstance(ChargeDto, {+ creditsUsedMicro: 1_000,+ quantity: 1,+ ...body,+ }),+ { whitelist: true, forbidNonWhitelisted: true },+ );++ it('should accept a charge naming no category', async () => {+ expect(await validateCharge({})).toHaveLength(0);+ });++ it.each(['SUBSCRIPTION', 'API_REQUEST', 'UNKNOWN'])(+ 'should reject the operationType %s',+ async (operationType) => {+ expect(await validateCharge({ operationType })).not.toHaveLength(0);+ },+ );+});diff --git a/packages/twenty-server/src/engine/core-modules/billing/app-billing/app-billing.service.ts b/packages/twenty-server/src/engine/core-modules/billing/app-billing/app-billing.service.tsindex 09868a01d8b..c6e1b03b86c 100644--- a/packages/twenty-server/src/engine/core-modules/billing/app-billing/app-billing.service.ts+++ b/packages/twenty-server/src/engine/core-modules/billing/app-billing/app-billing.service.ts@@ -4,6 +4,7 @@ import { BadRequestException, Injectable, Logger } from '@nestjs/common';import { InjectRepository } from '@nestjs/typeorm';import {+ DEFAULT_APP_USAGE_OPERATION_TYPE,isUsageOperationTypeValue,type UsageOperationTypeValue,} from 'twenty-shared/application';@@ -35,6 +36,7 @@ const USAGE_UNIT_BY_OPERATION_TYPE: Record<[UsageOperationType.WEB_SEARCH]: UsageUnit.INVOCATION,[UsageOperationType.CALL_RECORDING]: UsageUnit.MINUTE,[UsageOperationType.EMAIL_SEND]: UsageUnit.INVOCATION,+ [UsageOperationType.APP_OPERATION]: UsageUnit.INVOCATION,};// workspaceId and applicationId come from the token, never the body, so an app can't charge another workspace or pose as another app@@ -103,13 +105,9 @@ export class AppBillingService {charge: ChargeDto;}): Promise<AppChargeableOperationType> {if (!isDefined(charge.operation)) {- if (!isDefined(charge.operationType)) {- throw new BadRequestException(- 'A charge must name either an operation or an operationType.',- );- }-- return UsageOperationType[charge.operationType];+ return UsageOperationType[+ charge.operationType ?? DEFAULT_APP_USAGE_OPERATION_TYPE+ ];}const { flatApplicationMaps } =@@ -137,16 +135,19 @@ export class AppBillingService {);}+ const declaredOperationType =+ billableOperation.operationType ?? DEFAULT_APP_USAGE_OPERATION_TYPE;+// jsonb is untrusted: an unknown value would record a row with no category or unit,// and a platform-only value like SUBSCRIPTION would bypass ChargeDto's @IsIn- if (!isUsageOperationTypeValue(billableOperation.operationType)) {+ if (!isUsageOperationTypeValue(declaredOperationType)) {throw new BadRequestException(`Billable operation "${charge.operation}" declares an unknown operationType.`,);}// Indexing by the manifest literal makes a drifted USAGE_OPERATION_TYPES value fail to compile- return UsageOperationType[billableOperation.operationType];+ return UsageOperationType[declaredOperationType];}// Scoped to the token's workspace so an app cannot attribute spend outside itdiff --git a/packages/twenty-server/src/engine/core-modules/billing/app-billing/dtos/charge.dto.ts b/packages/twenty-server/src/engine/core-modules/billing/app-billing/dtos/charge.dto.tsindex 5234501f809..f78ae5e61ef 100644--- a/packages/twenty-server/src/engine/core-modules/billing/app-billing/dtos/charge.dto.ts+++ b/packages/twenty-server/src/engine/core-modules/billing/app-billing/dtos/charge.dto.ts@@ -8,14 +8,12 @@ import {IsUUID,Max,Min,- ValidateIf,} from 'class-validator';import {USAGE_OPERATION_TYPES,type UsageOperationTypeValue,} from 'twenty-shared/application';-import { isDefined } from 'twenty-shared/utils';// $1000 in micro-credits, so a compromised or buggy app can't drain credits in one requestconst MAX_CREDITS_USED_MICRO_PER_CHARGE = 1_000_000_000;@@ -37,8 +35,8 @@ export class ChargeDto {@IsString()operation?: string;- // For apps declaring no operations; restricted so platform-raised categories cannot be charged- @ValidateIf((charge: ChargeDto) => !isDefined(charge.operation))+ // Restricted so platform-raised categories cannot be charged; omitted, the charge lands in APP_OPERATION+ @IsOptional()@IsIn(USAGE_OPERATION_TYPES)operationType?: UsageOperationTypeValue;diff --git a/packages/twenty-server/src/engine/core-modules/usage/dtos/credit-used-item.dto.ts b/packages/twenty-server/src/engine/core-modules/usage/dtos/credit-used-item.dto.tsindex c376734235d..f34d510ba1d 100644--- a/packages/twenty-server/src/engine/core-modules/usage/dtos/credit-used-item.dto.ts+++ b/packages/twenty-server/src/engine/core-modules/usage/dtos/credit-used-item.dto.ts@@ -16,6 +16,9 @@ export class CreditUsedItemDTO {@Field(() => String, { nullable: true })label?: string;+ @Field(() => String, { nullable: true })+ icon?: string;+@Field(() => Float)creditsUsed: number;}diff --git a/packages/twenty-server/src/engine/core-modules/usage/enums/usage-operation-type.enum.ts b/packages/twenty-server/src/engine/core-modules/usage/enums/usage-operation-type.enum.tsindex 208a6c3dc78..e43530ff306 100644--- a/packages/twenty-server/src/engine/core-modules/usage/enums/usage-operation-type.enum.ts+++ b/packages/twenty-server/src/engine/core-modules/usage/enums/usage-operation-type.enum.ts@@ -13,6 +13,8 @@ export enum UsageOperationType {CALL_RECORDING = 'CALL_RECORDING',EMAIL_SEND = 'EMAIL_SEND',MESSAGE_CAMPAIGN_SEND = 'MESSAGE_CAMPAIGN_SEND',+ // Charged by apps through chargeCredits when they name no platform category+ APP_OPERATION = 'APP_OPERATION',// Out of twenty-shared's USAGE_OPERATION_TYPES: the API rate limit reads it, so an app billing under it would spend the request budget.API_REQUEST = 'API_REQUEST',WEBHOOK_CALL = 'WEBHOOK_CALL',diff --git a/packages/twenty-server/src/engine/core-modules/usage/services/usage-analytics.service.ts b/packages/twenty-server/src/engine/core-modules/usage/services/usage-analytics.service.tsindex 4d52f3cf5a8..5a63b093ddc 100644--- a/packages/twenty-server/src/engine/core-modules/usage/services/usage-analytics.service.ts+++ b/packages/twenty-server/src/engine/core-modules/usage/services/usage-analytics.service.ts@@ -4,6 +4,7 @@ import { isNonEmptyString } from '@sniptt/guards';import { Injectable } from '@nestjs/common';+import { type ApplicationBilling } from 'twenty-shared/application';import { isNonEmptyArray } from 'twenty-shared/utils';import { ClickHouseService } from 'src/database/clickhouse/clickhouse.service';@@ -18,6 +19,9 @@ import { type UsageConsumptionRow } from 'src/engine/core-modules/usage/types/usimport { type UsageConsumptionTotals } from 'src/engine/core-modules/usage/types/usage-consumption-totals.type';import { type UsagePeriodAnchor } from 'src/engine/core-modules/usage/types/usage-period-anchor.type';import { type CreditsUsed } from 'src/engine/core-modules/usage/types/credits-used.type';+import { type CreditsUsedTimeSeriesRow } from 'src/engine/core-modules/usage/types/credits-used-time-series-row.type';+import { findDeclaredBillingCharge } from 'src/engine/core-modules/usage/utils/find-declared-billing-charge.util';+import { listDeclaredBillingChargeNames } from 'src/engine/core-modules/usage/utils/list-declared-billing-charge-names.util';import { buildInstallationFilterParams } from 'src/engine/core-modules/usage/utils/build-installation-filter-params.util';import { buildRecurringChargeKey } from 'src/engine/core-modules/usage/utils/build-recurring-charge-key.util';import { buildUsagePeriodClause } from 'src/engine/core-modules/usage/utils/build-usage-period-clause.util';@@ -109,10 +113,12 @@ export class UsageAnalyticsService {async getCreditsUsedBreakdownForInstallations({installations,+ billing,periodStart,periodEnd,}: {installations: { applicationId: string; workspaceId: string }[];+ billing: Pick<ApplicationBilling, 'recurring' | 'operations'> | null;periodStart: Date;periodEnd: Date;}): Promise<CreditUsedItemDTO[]> {@@ -121,61 +127,77 @@ export class UsageAnalyticsService {}const rows = await this.clickHouseService.selectOrThrow<{- resourceType: string;- operationType: string;+ operation: string;+ latestResourceType: string;+ latestOperationType: string;creditsUsedMicro: string | number;}>(- `SELECT resourceType, operationType, sum(creditsUsedMicro) AS creditsUsedMicro+ // One row per declared operation, else per operation type: a resource or category split renders as duplicates+ `SELECT if(resourceType = 'APP' AND has({declaredOperations:Array(String)}, resourceContext), resourceContext, '') AS operation,+ argMax(resourceType, timestamp) AS latestResourceType,+ argMax(operationType, timestamp) AS latestOperationType,+ sum(creditsUsedMicro) AS creditsUsedMicroFROM usageEventWHERE workspaceId IN {workspaceIds:Array(String)}AND applicationId IN {applicationIds:Array(String)}AND timestamp >= {periodStart:DateTime64(3, 'UTC')}AND timestamp < {periodEnd:DateTime64(3, 'UTC')}- GROUP BY resourceType, operationType+ GROUP BY operation, if(operation = '', operationType, '')HAVING creditsUsedMicro != 0ORDER BY creditsUsedMicro DESCSETTINGS max_execution_time = 10, use_query_cache = true,query_cache_ttl = 600, query_cache_min_query_duration = 0`,{...buildInstallationFilterParams(installations),+ declaredOperations: listDeclaredBillingChargeNames({ billing }),periodStart: formatDateTimeForClickHouse(periodStart),periodEnd: formatDateTimeForClickHouse(periodEnd),},);- return rows.map(({ resourceType, operationType, creditsUsedMicro }) => {- const isKnownOperation = USAGE_OPERATION_TYPES.has(operationType);-- return {- resource: USAGE_RESOURCE_TYPES.has(resourceType)- ? (resourceType as UsageResourceType)- : null,- operation: isKnownOperation- ? (operationType as UsageOperationType)- : null,- label: isKnownOperation ? undefined : operationType,- creditsUsed: toDisplayCredits(Number(creditsUsedMicro)),- };- });+ return rows.map(+ ({+ operation,+ latestResourceType: resourceType,+ latestOperationType: operationType,+ creditsUsedMicro,+ }) => {+ const isKnownOperation = USAGE_OPERATION_TYPES.has(operationType);+ const declaredCharge = findDeclaredBillingCharge({+ billing,+ chargeName: operation,+ });++ return {+ resource: USAGE_RESOURCE_TYPES.has(resourceType)+ ? (resourceType as UsageResourceType)+ : null,+ operation: isKnownOperation+ ? (operationType as UsageOperationType)+ : null,+ label:+ declaredCharge?.label ??+ (isKnownOperation ? undefined : operationType),+ icon: declaredCharge?.icon,+ creditsUsed: toDisplayCredits(Number(creditsUsedMicro)),+ };+ },+ );}async getCreditsUsedTimeSeriesForInstallations({installations,+ declaredOperations,periodStart,periodEnd,bucketSizeInSeconds,}: {installations: { applicationId: string; workspaceId: string }[];+ declaredOperations: string[];periodStart: Date;periodEnd: Date;bucketSizeInSeconds: number;- }): Promise<- {- bucketStart: Date;- operationType: string;- creditsUsedMicro: number;- }[]- > {+ }): Promise<CreditsUsedTimeSeriesRow[]> {if (!isNonEmptyArray(installations)) {return [];}@@ -183,34 +205,42 @@ export class UsageAnalyticsService {const rows = await this.clickHouseService.selectOrThrow<{bucketStart: string;operationType: string;+ operation: string;creditsUsedMicro: string | number;}>(+ // Only app-raised rows carry a declared operation name in resourceContext; any other+ // context is free-form and collapsed here so it cannot fan out into one row per charge`SELECTtoStartOfInterval(timestamp, toIntervalSecond({bucketSizeInSeconds:UInt32})) AS bucketStart,operationType,+ if(resourceType = 'APP' AND has({declaredOperations:Array(String)}, resourceContext), resourceContext, '') AS operation,sum(creditsUsedMicro) AS creditsUsedMicroFROM usageEventWHERE workspaceId IN {workspaceIds:Array(String)}AND applicationId IN {applicationIds:Array(String)}AND timestamp >= {periodStart:DateTime64(3, 'UTC')}AND timestamp < {periodEnd:DateTime64(3, 'UTC')}- GROUP BY bucketStart, operationType+ GROUP BY bucketStart, operationType, operationHAVING creditsUsedMicro != 0- ORDER BY bucketStart, operationType+ ORDER BY bucketStart, operationType, operationSETTINGS max_execution_time = 10`,{...buildInstallationFilterParams(installations),+ declaredOperations,periodStart: formatDateTimeForClickHouse(periodStart),periodEnd: formatDateTimeForClickHouse(periodEnd),bucketSizeInSeconds,},);- return rows.map(({ bucketStart, operationType, creditsUsedMicro }) => ({- bucketStart: parseClickHouseDateTime(bucketStart),- operationType,- creditsUsedMicro: Number(creditsUsedMicro),- }));+ return rows.map(+ ({ bucketStart, operationType, operation, creditsUsedMicro }) => ({+ bucketStart: parseClickHouseDateTime(bucketStart),+ operationType,+ operation,+ creditsUsedMicro: Number(creditsUsedMicro),+ }),+ );}async getConsumptionRowsForAllScopes({diff --git a/packages/twenty-server/src/engine/core-modules/usage/types/credits-used-time-series-row.type.ts b/packages/twenty-server/src/engine/core-modules/usage/types/credits-used-time-series-row.type.tsnew file mode 100644index 00000000000..d63f88b2c36--- /dev/null+++ b/packages/twenty-server/src/engine/core-modules/usage/types/credits-used-time-series-row.type.ts@@ -0,0 +1,6 @@+export type CreditsUsedTimeSeriesRow = {+ bucketStart: Date;+ operationType: string;+ operation: string;+ creditsUsedMicro: number;+};diff --git a/packages/twenty-server/src/engine/core-modules/usage/usage.resolver.ts b/packages/twenty-server/src/engine/core-modules/usage/usage.resolver.tsindex 828368dc8ca..b109e113ff8 100644--- a/packages/twenty-server/src/engine/core-modules/usage/usage.resolver.ts+++ b/packages/twenty-server/src/engine/core-modules/usage/usage.resolver.ts@@ -18,6 +18,7 @@ import {type UsageBreakdownItem,} from 'src/engine/core-modules/usage/services/usage-analytics.service';import { consolidateUsageByApplication } from 'src/engine/core-modules/usage/utils/consolidate-usage-by-application.util';+import { listDeclaredBillingChargeNames } from 'src/engine/core-modules/usage/utils/list-declared-billing-charge-names.util';import { fromUsageBreakdownItemToUsageBreakdownItemDTO } from 'src/engine/core-modules/usage/utils/from-usage-breakdown-item-to-usage-breakdown-item-dto.util';import { toDisplayCredits } from 'src/engine/core-modules/usage/utils/to-display-credits.util';import { UserWorkspaceEntity } from 'src/engine/core-modules/user-workspace/user-workspace.entity';@@ -82,10 +83,7 @@ export class UsageResolver {Object.entries(flatApplicationMaps.byId).map(([applicationId, application]) => [applicationId,- [- ...Object.keys(application?.billing?.recurring ?? {}),- ...Object.keys(application?.billing?.operations ?? {}),- ],+ listDeclaredBillingChargeNames({ billing: application?.billing }),],),);diff --git a/packages/twenty-server/src/engine/core-modules/usage/utils/__tests__/find-declared-billing-charge.util.spec.ts b/packages/twenty-server/src/engine/core-modules/usage/utils/__tests__/find-declared-billing-charge.util.spec.tsnew file mode 100644index 00000000000..49c5cdc9539--- /dev/null+++ b/packages/twenty-server/src/engine/core-modules/usage/utils/__tests__/find-declared-billing-charge.util.spec.ts@@ -0,0 +1,55 @@+import { findDeclaredBillingCharge } from 'src/engine/core-modules/usage/utils/find-declared-billing-charge.util';++const BILLING = {+ recurring: {+ platformFee: {+ period: 'MONTH' as const,+ amountMicroCredits: 1_000_000,+ label: 'Platform fee',+ },+ },+ operations: {+ enrichPerson: { label: 'Person enrichment', icon: 'IconUserSearch' },+ },+};++describe('findDeclaredBillingCharge', () => {+ it('should resolve a declared operation with its icon', () => {+ expect(+ findDeclaredBillingCharge({+ billing: BILLING,+ chargeName: 'enrichPerson',+ }),+ ).toEqual({ label: 'Person enrichment', icon: 'IconUserSearch' });+ });++ it('should resolve a declared recurring charge', () => {+ expect(+ findDeclaredBillingCharge({+ billing: BILLING,+ chargeName: 'platformFee',+ })?.label,+ ).toBe('Platform fee');+ });++ it('should return undefined for an undeclared or inherited name', () => {+ expect(+ findDeclaredBillingCharge({+ billing: BILLING,+ chargeName: 'run-42',+ }),+ ).toBeUndefined();+ expect(+ findDeclaredBillingCharge({+ billing: BILLING,+ chargeName: 'constructor',+ }),+ ).toBeUndefined();+ });++ it('should return undefined without billing', () => {+ expect(+ findDeclaredBillingCharge({ billing: null, chargeName: 'any' }),+ ).toBeUndefined();+ });+});diff --git a/packages/twenty-server/src/engine/core-modules/usage/utils/__tests__/list-declared-billing-charge-names.util.spec.ts b/packages/twenty-server/src/engine/core-modules/usage/utils/__tests__/list-declared-billing-charge-names.util.spec.tsnew file mode 100644index 00000000000..f4b3dfa9be1--- /dev/null+++ b/packages/twenty-server/src/engine/core-modules/usage/utils/__tests__/list-declared-billing-charge-names.util.spec.ts@@ -0,0 +1,24 @@+import { listDeclaredBillingChargeNames } from 'src/engine/core-modules/usage/utils/list-declared-billing-charge-names.util';++describe('listDeclaredBillingChargeNames', () => {+ it('should list recurring charges and operations', () => {+ expect(+ listDeclaredBillingChargeNames({+ billing: {+ recurring: {+ platformFee: {+ period: 'MONTH',+ amountMicroCredits: 1_000_000,+ label: 'Platform fee',+ },+ },+ operations: { enrichPerson: { label: 'Person enrichment' } },+ },+ }),+ ).toEqual(['platformFee', 'enrichPerson']);+ });++ it('should return an empty list without billing', () => {+ expect(listDeclaredBillingChargeNames({ billing: undefined })).toEqual([]);+ });+});diff --git a/packages/twenty-server/src/engine/core-modules/usage/utils/consolidate-usage-by-application.util.ts b/packages/twenty-server/src/engine/core-modules/usage/utils/consolidate-usage-by-application.util.tsindex 56bceb782ff..a845b356760 100644--- a/packages/twenty-server/src/engine/core-modules/usage/utils/consolidate-usage-by-application.util.ts+++ b/packages/twenty-server/src/engine/core-modules/usage/utils/consolidate-usage-by-application.util.ts@@ -5,6 +5,7 @@ import {type UsageApplicationBreakdownItem,type UsageBreakdownItem,} from 'src/engine/core-modules/usage/services/usage-analytics.service';+import { findDeclaredBillingCharge } from 'src/engine/core-modules/usage/utils/find-declared-billing-charge.util';type ConsolidateUsageByApplicationParams = {items: UsageApplicationBreakdownItem[];@@ -21,16 +22,15 @@ export const consolidateUsageByApplication = ({for (const item of items) {const application = flatApplicationMaps.byId[item.applicationId];- // Undefined until the upgrade that adds the column has run.- const declaredCharges = {- ...(application?.billing?.recurring ?? {}),- ...(application?.billing?.operations ?? {}),- };- const declaredCharge = declaredCharges[item.operation];+ // Billing is undefined until the upgrade that adds the column has run.+ const declaredChargeLabel = findDeclaredBillingCharge({+ billing: application?.billing,+ chargeName: item.operation,+ })?.label;const applicationName = application?.name ?? item.applicationId;- const key = isDefined(declaredCharge)- ? `${applicationName} · ${declaredCharge.label}`+ const key = isDefined(declaredChargeLabel)+ ? `${applicationName} · ${declaredChargeLabel}`: applicationName;const consolidatedItem = itemsByKey.get(key);diff --git a/packages/twenty-server/src/engine/core-modules/usage/utils/find-declared-billing-charge.util.ts b/packages/twenty-server/src/engine/core-modules/usage/utils/find-declared-billing-charge.util.tsnew file mode 100644index 00000000000..34c96bb39b9--- /dev/null+++ b/packages/twenty-server/src/engine/core-modules/usage/utils/find-declared-billing-charge.util.ts@@ -0,0 +1,24 @@+import { type ApplicationBilling } from 'twenty-shared/application';++// Own-property only: a charge named `constructor` must not resolve to an inherited value+export const findDeclaredBillingCharge = ({+ billing,+ chargeName,+}: {+ billing:+ | Pick<ApplicationBilling, 'recurring' | 'operations'>+ | null+ | undefined;+ chargeName: string;+}): { label: string; icon?: string } | undefined => {+ const declaredCharges: Partial<+ Record<string, { label: string; icon?: string }>+ > = {+ ...(billing?.recurring ?? {}),+ ...(billing?.operations ?? {}),+ };++ return Object.prototype.hasOwnProperty.call(declaredCharges, chargeName)+ ? declaredCharges[chargeName]+ : undefined;+};diff --git a/packages/twenty-server/src/engine/core-modules/usage/utils/list-declared-billing-charge-names.util.ts b/packages/twenty-server/src/engine/core-modules/usage/utils/list-declared-billing-charge-names.util.tsnew file mode 100644index 00000000000..5c0daafc63d--- /dev/null+++ b/packages/twenty-server/src/engine/core-modules/usage/utils/list-declared-billing-charge-names.util.ts@@ -0,0 +1,13 @@+import { type ApplicationBilling } from 'twenty-shared/application';++export const listDeclaredBillingChargeNames = ({+ billing,+}: {+ billing:+ | Pick<ApplicationBilling, 'recurring' | 'operations'>+ | null+ | undefined;+}): string[] => [+ ...Object.keys(billing?.recurring ?? {}),+ ...Object.keys(billing?.operations ?? {}),+];diff --git a/packages/twenty-shared/src/application/billableOperationsType.ts b/packages/twenty-shared/src/application/billableOperationsType.tsindex ce6672d1f2d..5b0f52e3233 100644--- a/packages/twenty-shared/src/application/billableOperationsType.ts+++ b/packages/twenty-shared/src/application/billableOperationsType.ts@@ -1,8 +1,11 @@import { type UsageOperationTypeValue } from '@/application/usageOperationTypesType';export type BillableOperationManifest = {- operationType: UsageOperationTypeValue;+ // Defaults to APP_OPERATION; `label` names the operation in the app's credit monitoring either way+ operationType?: UsageOperationTypeValue;label: string;+ // A Twenty icon name (e.g. `IconUserSearch`) shown next to the label in the app's credits breakdown+ icon?: string;};// Keyed by the operation name the application charges against.diff --git a/packages/twenty-shared/src/application/index.ts b/packages/twenty-shared/src/application/index.tsindex a69f12d9f18..0f7f3734ac8 100644--- a/packages/twenty-shared/src/application/index.ts+++ b/packages/twenty-shared/src/application/index.ts@@ -276,6 +276,7 @@ export type { UninstallLogicFunctionApplicationManifest } from './uninstallLogicexport type { UsageOperationTypeValue } from './usageOperationTypesType';export {USAGE_OPERATION_TYPES,+ DEFAULT_APP_USAGE_OPERATION_TYPE,isUsageOperationTypeValue,} from './usageOperationTypesType';export {diff --git a/packages/twenty-shared/src/application/usageOperationTypesType.ts b/packages/twenty-shared/src/application/usageOperationTypesType.tsindex 483f35bf444..6f6b07f9589 100644--- a/packages/twenty-shared/src/application/usageOperationTypesType.ts+++ b/packages/twenty-shared/src/application/usageOperationTypesType.ts@@ -8,8 +8,11 @@ export const USAGE_OPERATION_TYPES = ['WEB_SEARCH','CALL_RECORDING','EMAIL_SEND',+ 'APP_OPERATION',] as const;+export const DEFAULT_APP_USAGE_OPERATION_TYPE = 'APP_OPERATION';+export type UsageOperationTypeValue = (typeof USAGE_OPERATION_TYPES)[number];export const isUsageOperationTypeValue = (