Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getService = () => {
// newrelic cannot be imported in a browser environment.
if (! process.env.BROWSER) {
// Attempt to create newrelic client using vip go package.
try {
const { newrelic, logger } = require('@automattic/vip-go'); // eslint-disable-line global-require
const client = newrelic({
logger: logger('irving:newrelic'),
});
// VIP Go's package can return nothing if newrelic is not instsalled or configured improperly.
if (! client) {
return defaultService;
}
return {
client,
start: () => {},
logError(err) {
client.noticeError(err);
},
logTransaction(method, status, category) {
client.setTransactionName(`${method} ${status} ${category}`);