Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
], safe.sure(cb, function () {
// Set up Raven
ctx.locals.ravenjs = new raven.Client('http://blah:blah@localhost/collect/sentry/'+self_id);
setTimeout(function () {
ctx.locals.ravenjs.captureError(new Error("Tinelic Sentry startup!"));
}, 1000);
require("newrelic").noticeError( new Error("Tinelic NewRelic startup!"));
cb(null,{api:{
getFeed:function (token, p, cb) {
if (ctx.locals.newrelic)
ctx.locals.newrelic.setTransactionName("/webapi/"+(token=="public"?"public":"token")+"/feed/"+p.feed);
feed = p.feed.split(".");
requirejs(["feed/"+feed[0]], function (m) {
m[feed[1]](token,p.params,cb);
},cb);
}
}});
}));
},cb);
}, function( error ){
if (error) {
// report getsentry error with newrelic ;)
newrelic.noticeError(error);
res.writeHead( 500, { 'x-sentry-error': error.toString() } );
res.status(500).end( error.toString() );
} else {
res.status(200).end( "ok" );
}
});
});
}, error => {
if (error) {
// report getsentry error with newrelic ;)
newrelic.noticeError(error);
res.writeHead(500, { 'x-sentry-error': error.toString() });
res.status(500).end(error.toString());
} else {
res.status(200).end('ok');
}
});
}
}, function (err) {
if (err) {
newrelic.noticeError(err);
console.log(data);
}
res.set('Content-Type', 'image/gif');
res.send(buf);
});
});
const callback = function (err, ...args2) {
if (err)
newrelic.noticeError(err);
cb.call(this, err, ...args2);
};
logger.forEach(function (entry) {
if ((entry.data) && (typeof entry.data.msec === 'number')) { params.request.duration = entry.data.msec }
})
if ((newrelic) && (request.response._error)) {
flattened = {}
underscore.keys(params).forEach(param => {
underscore.keys(params[param]).forEach(key => {
if ((param === 'error') && ((key === 'message') || (key === 'payload') || (key === 'stack'))) return
flattened[param + '.' + key] = params[param][key]
})
})
flattened.url = flattened['request.pathname']
delete flattened['request.pathname']
newrelic.noticeError(request.response._error, flattened)
}
debug('end', { sdebug: params })
})
return graphqlError => {
const error = graphqlError.originalError || graphqlError
if (error.statusCode === undefined || error.statusCode >= 500) {
newrelic.noticeError(error, query)
}
return { message: error.message }
}
}
}, err => {
if (err)
newrelic.noticeError(err);
transaction.end();
});
});