Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'raygun' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
export async function initAsync(options_: IOptions = {}) : Promise
{
assert(logger == null, "double initialization");
logger = td.createLogger("raygun");
if (!options_.apiKey) {
options_.apiKey = td.serverSetting("RAYGUN_API_KEY", false);
}
if (options_.saveReport != null) {
pendingReports = [];
/* async */ saveReportLoopAsync(options_);
}
var opt = options_;
var raygunClient = new raygun.Client().init({ apiKey: opt.apiKey });
var util = require('util');
if(opt.version) raygunClient.setVersion(opt.version);
td.App.addTransport({
id: "raygun",
log : function(level, category, message, meta) {
// "crash" messages already reported below
if (level <= 3 && category != "crash") {
try { throw new Error(category + ": " + message); }
catch(err) { raygunClient.send(err, meta); }
}
},
logException : function(err, meta) {
logger.debug("sending crash: " + err.message);
var req = err.tdNodeRequest
if (pendingReports) {
var js = mkBugReport(err, "custom")
import { IncomingMessage } from 'http';
import { ApiError, ApiValidationError } from '../api.error';
import { gitInfo } from '../gitinfo';
import { logger } from '../logger';
import { config } from '../settings';
import { Context } from '../typings/context';
const appVersion = require('../../../../package.json').version;
// initialize raygun
let raygunClient: any = null;
/* istanbul ignore if: no crash reporters when testing */
if (config.vpdb.services.raygun.enabled) {
logger.info(null, '[koaErrorHandler] Setting up Raygun...');
const raygun = require('raygun');
raygunClient = new raygun.Client().init({ apiKey: config.vpdb.services.raygun.apiKey });
raygunClient.setVersion(appVersion.substr(1));
}
// initialize rollbar
let rollbar: any = null;
/* istanbul ignore if: no crash reporters when testing */
if (config.vpdb.services.rollbar.enabled) {
const Rollbar = require('rollbar');
rollbar = new Rollbar({
accessToken: config.vpdb.services.rollbar.apiKey,
captureUncaught: true,
captureUnhandledRejections: true,
environment: config.vpdb.services.rollbar.environment,
codeVersion: gitInfo.hasInfo() ? gitInfo.getLastCommit().SHA : appVersion,
captureEmail: true,
captureUsername: true,
// override standard promises
Promise = require('bluebird');
mongoose.Promise = Promise;
const settings = require('./src/modules/settings');
const serverDomain = domain.create();
let raygunClient = null;
// setup logger
require('./src/logging').init();
// setup raygun error handling
if (config && config.vpdb.services && config.vpdb.services.raygun && config.vpdb.services.raygun.enabled) {
const raygun = require('raygun');
const pkg = require('./package');
raygunClient = new raygun.Client().init({ apiKey: config.vpdb.services.raygun.apiKey });
raygunClient.setVersion(pkg.version);
logger.info('[logging] Raygun crash logging enabled with API key %s', config.vpdb.services.raygun.apiKey);
serverDomain.on('error', function(err){
logger.info('[logging] Sending error to Raygun...');
raygunClient.send(err, {}, function() {
process.exit(1);
});
});
}
// validate settings before continueing
if (!settings.validate()) {
logger.error('[app] Settings validation failed, aborting.');
process.exit(1);
}
async register(container: Container.IContainer, options) {
return new raygun.Client().init(options);
},
};
config: function(config) {
let key = apiKey;
if (config.apiKey) {
key = config.apiKey;
}
if (key && isProduction) {
RaygunClient = new Raygun.Client().init({ apiKey: key });
} else {
RaygunClient = {
send: function(error, extra, cb) {
cb();
}
};
}
}
};
const initClient = () => {
raygunClient = new raygun.Client().init({apiKey: config.RAYGUN_API_KEY});
raygunClient.onBeforeSend((payload: any) => {
delete payload.details.machineName;
return payload;
});
};
const ErrorHandler = function () {
if (config.get('raygunApiKey').length) {
this.client = new Raygun.Client().init({
apiKey: config.get('raygunApiKey')
})
}
}