@netlify/build-info
Version:
Build info utility
30 lines • 1.03 kB
JavaScript
import { readFile } from 'fs/promises';
import bugsnag from '@bugsnag/js';
import { NoopLogger } from './get-build-info.js';
const { default: Bugsnag } = bugsnag;
const pkgJSON = new URL('../../package.json', import.meta.url);
export async function initializeMetrics() {
try {
const { version, name } = JSON.parse(await readFile(pkgJSON, 'utf-8'));
const metadata = {
deploy_id: process.env.DEPLOY_ID,
build_id: process.env.BUILD_ID,
repository_url: process.env.REPOSITORY_URL,
};
Bugsnag.start({
apiKey: process.env.BUGSNAG_KEY_BUILD_INFO || '',
appType: name,
appVersion: version,
releaseStage: 'production',
enabledReleaseStages: ['production'],
metadata,
autoTrackSessions: false,
logger: new NoopLogger(),
});
return Bugsnag.startSession();
}
catch {
// noop this handles it gracefully
}
}
//# sourceMappingURL=metrics.js.map