Skip to content

Commit

Permalink
Add more verbose errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lramos15 committed Mar 15, 2022
1 parent 4dcbf11 commit da3acb7
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions src/node/telemetryReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,38 @@ const appInsightsClientFactory = async (key: string): Promise<BaseTelemetryClien
appInsightsClient.config.endpointUrl = "https://vortex.data.microsoft.com/collect/v1";
}
} catch (e: any) {
return Promise.reject(e);
return Promise.reject("Failed to initialize app insights!\n" + e.message);
}
// Sets the appinsights client into a standardized form
const telemetryClient: BaseTelemetryClient = {
logEvent: (eventName: string, data?: AppenderData) => {
appInsightsClient?.trackEvent({
name: eventName,
properties: data?.properties,
measurements: data?.measurements
});
try {
appInsightsClient?.trackEvent({
name: eventName,
properties: data?.properties,
measurements: data?.measurements
});
} catch (e: any) {
throw new Error("Failed to log event to app insights!\n" + e.message);
}
},
logException: (exception: Error, data?: AppenderData) => {
appInsightsClient?.trackException({
exception,
properties: data?.properties,
measurements: data?.measurements
});
try {
appInsightsClient?.trackException({
exception,
properties: data?.properties,
measurements: data?.measurements
});
} catch(e: any) {
throw new Error("Failed to log exception to app insights!\n" + e.message);
}
},
flush: async () => {
appInsightsClient?.flush();
try {
appInsightsClient?.flush();
} catch(e: any) {
throw new Error("Failed to flush app insights!\n" + e.message);
}
}
};
return telemetryClient;
Expand Down

0 comments on commit da3acb7

Please sign in to comment.