2020-06-24 20:07:01 +01:00
|
|
|
let client;
|
|
|
|
const appInsightsKey = process.env.PORTAL_RUNNER_APP_INSIGHTS_KEY;
|
|
|
|
if (!appInsightsKey) {
|
|
|
|
console.warn(`PORTAL_RUNNER_APP_INSIGHTS_KEY env var not set. Runner telemetry will not be reported`);
|
|
|
|
} else {
|
|
|
|
const appInsights = require("applicationinsights");
|
|
|
|
appInsights.setup(process.env.PORTAL_RUNNER_APP_INSIGHTS_KEY).start();
|
|
|
|
client = appInsights.defaultClient;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports.trackEvent = (...args) => {
|
|
|
|
if (client) {
|
|
|
|
client.trackEvent(...args);
|
|
|
|
}
|
|
|
|
};
|
2020-06-26 00:59:44 +01:00
|
|
|
|
|
|
|
module.exports.trackException = exception => {
|
|
|
|
if (client) {
|
|
|
|
client.trackException({ exception });
|
|
|
|
}
|
|
|
|
};
|