Skip to content

Commit

Permalink
Adds tel events for errors with cloud integrations api calls
Browse files Browse the repository at this point in the history
  • Loading branch information
axosoft-ramint committed Aug 15, 2024
1 parent e063b2f commit 0f54c79
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,23 @@ export type TelemetryEvents = {
'integration.connected.ids': string | undefined;
};

/** Sent when getting connected providers from the api fails*/
'cloudIntegrations/getConnections/failed': {
code: number | undefined;
};

/** Sent when getting a provider token from the api fails*/
'cloudIntegrations/getConnection/failed': {
code: number | undefined;
'integration.id': string | undefined;
};

/** Sent when refreshing a provider token from the api fails*/
'cloudIntegrations/refreshConnection/failed': {
code: number | undefined;
'integration.id': string | undefined;
};

/** Sent when a cloud-based hosting provider is connected */
'cloudIntegrations/hosting/connected': {
'hostingProvider.provider': IntegrationId;
Expand Down
23 changes: 21 additions & 2 deletions src/plus/integrations/authentication/cloudIntegrationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ export class CloudIntegrationService {
);
if (!providersRsp.ok) {
const error = (await providersRsp.json())?.error;
const errorMessage =
typeof error === 'string' ? error : (error?.message as string) ?? providersRsp.statusText;
if (error != null) {
Logger.error(`Failed to get connected providers from cloud: ${error.message}`);
Logger.error(`Failed to get connected providers from cloud: ${errorMessage}`);
}
if (this.container.telemetry.enabled) {
this.container.telemetry.sendEvent('cloudIntegrations/getConnections/failed', {
code: providersRsp.status,
});
}
return undefined;
}
Expand Down Expand Up @@ -54,8 +61,20 @@ export class CloudIntegrationService {
);
if (!tokenRsp.ok) {
const error = (await tokenRsp.json())?.error;
const errorMessage = typeof error === 'string' ? error : (error?.message as string) ?? tokenRsp.statusText;
if (error != null) {
Logger.error(`Failed to ${refresh ? 'refresh' : 'get'} ${id} token from cloud: ${error.message}`);
Logger.error(`Failed to ${refresh ? 'refresh' : 'get'} ${id} token from cloud: ${errorMessage}`);
}
if (this.container.telemetry.enabled) {
this.container.telemetry.sendEvent(
refreshToken
? 'cloudIntegrations/refreshConnection/failed'
: 'cloudIntegrations/getConnection/failed',
{
code: tokenRsp.status,
'integration.id': id,
},
);
}
return undefined;
}
Expand Down

0 comments on commit 0f54c79

Please sign in to comment.