[messaging]Add temporary capture to gmail refresh token exceptions (#4875)

## Context
This exception is currently caught since this is expected but it seems
to be rejected more than it should so we want to have more visibility on
it

## Test
<img width="562" alt="Screenshot 2024-04-08 at 11 32 28"
src="https://github.com/twentyhq/twenty/assets/1834158/43bb6de9-191a-42d4-911b-6e83c7d8aa18">
This commit is contained in:
Weiko
2024-04-08 13:23:31 +02:00
committed by GitHub
parent fbd7c34478
commit ab60b8be65
2 changed files with 8 additions and 1 deletions

View File

@ -144,7 +144,7 @@ export class ConnectedAccountRepository {
this.workspaceDataSourceService.getSchemaName(workspaceId);
await this.workspaceDataSourceService.executeRawQuery(
`UPDATE ${dataSourceSchema}."connectedAccount" SET "accessToken" = $1 WHERE "id" = $2`,
`UPDATE ${dataSourceSchema}."connectedAccount" SET "accessToken" = $1, "authFailedAt" = NULL WHERE "id" = $2`,
[accessToken, connectedAccountId],
workspaceId,
transactionManager,

View File

@ -3,6 +3,7 @@ import { Injectable } from '@nestjs/common';
import axios from 'axios';
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
import { ExceptionHandlerService } from 'src/engine/integrations/exception-handler/exception-handler.service';
import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repository/object-metadata-repository.decorator';
import { ConnectedAccountRepository } from 'src/modules/connected-account/repositories/connected-account.repository';
import { ConnectedAccountObjectMetadata } from 'src/modules/connected-account/standard-objects/connected-account.object-metadata';
@ -13,6 +14,7 @@ export class GoogleAPIRefreshAccessTokenService {
private readonly environmentService: EnvironmentService,
@InjectObjectMetadataRepository(ConnectedAccountObjectMetadata)
private readonly connectedAccountRepository: ConnectedAccountRepository,
private readonly exceptionHandlerService: ExceptionHandlerService,
) {}
async refreshAndSaveAccessToken(
@ -80,6 +82,11 @@ export class GoogleAPIRefreshAccessTokenService {
connectedAccountId,
workspaceId,
);
this.exceptionHandlerService.captureExceptions([error], {
user: {
workspaceId,
},
});
throw new Error(`Error refreshing access token: ${error.message}`);
}
}