How to use the @sentry/node.withScope function in @sentry/node

To help you get started, we’ve selected a few @sentry/node examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SideProjectGuys / invite-manager-bot / src / framework / services / Commands.ts View on Github external
// Save the error for later so error handling doesn't count to command process time
			error = e;
		}

		const execTime = Date.now() - start;

		if (error) {
			this.client.stats.cmdErrors++;
			if (error.code) {
				const num = this.client.stats.cmdHttpErrors.get(error.code) || 0;
				this.client.stats.cmdHttpErrors.set(error.code, num + 1);
			}

			console.error(error);

			withScope(scope => {
				if (guild) {
					scope.setUser({ id: guild.id });
				}
				scope.setTag('command', cmd.name);
				scope.setExtra('channel', channel.id);
				scope.setExtra('message', message.content);
				captureException(error);
			});

			if (guild) {
				this.client.db.saveIncident(guild, {
					id: null,
					guildId: guild.id,
					error: error.message,
					details: {
						command: cmd.name,
github astroband / astrograph / src / graphql_server.ts View on Github external
function reportToSentry(error: GraphQLError): void {
  const errorCodesToIgnore = ["BAD_USER_INPUT", "GRAPHQL_VALIDATION_FAILED"];
  const errorCode = error.extensions ? error.extensions.code : null;

  if (errorCode && errorCodesToIgnore.includes(errorCode)) {
    return;
  }

  Sentry.withScope((scope) => {
    scope.setExtra("query", error.source);
    Sentry.captureException(error.originalError || error);
  });
}
github ShabadOS / desktop / app / lib / analytics.js View on Github external
sendException( error ) {
    Sentry.withScope( scope => {
      scope.setExtra( 'settings', settings.get() )
      scope.setExtra( 'system', {
        cpus: cpus(),
        freeMemory: freemem(),
        totalMemory: totalmem(),
        platform: platform(),
        networkInterfaces: networkInterfaces(),
      } )

      Sentry.captureException( error )
    } )
  }
github Christilut / node-modern-boilerplate / config / sentry.ts View on Github external
export function message(message: string, extra: object) {
  Sentry.withScope(scope => {
    for (const key in extra) {
      scope.setExtra(key, extra[key])
    }

    scope.setLevel(Sentry.Severity.Info)
    Sentry.captureMessage(message)
  })
}
github zmts / supra-api-nodejs / core / lib / SentryCatch.js View on Github external
captureException (error, meta = {}) {
    Sentry.withScope(scope => {
      scope.setUser({ ...meta })
      Sentry.captureException(error)
    })
  }
github VulcanJS / Vulcan / packages / vulcan-errors-sentry / lib / server / sentry-server.js View on Github external
function logToSentry({ error, details, currentUser }) {
  Sentry.withScope(scope => {
    if (currentUser) {
      scope.setUser(getUserObject(currentUser));
    }
    Object.keys(details).forEach(key => {
      scope.setExtra(key, details[key]);
    });
    Sentry.captureException(error);
  });
}
addLogFunction(logToSentry);
github Christilut / node-modern-boilerplate / config / sentry.ts View on Github external
export function exception(err: Error, extra: object) {
  Sentry.withScope(scope => {
    for (const key in extra) {
      scope.setExtra(key, extra[key])
    }

    scope.setLevel(Sentry.Severity.Error)
    Sentry.captureException(err)
  })
}
github zmts / supra-api-nodejs / core / lib / SentryCatch.js View on Github external
captureMessage (message, meta = {}) {
    Sentry.withScope(scope => {
      scope.setUser({ ...meta })
      Sentry.captureMessage(message, 'debug')
    })
  }
}
github algolia / npm-search / src / utils / sentry.js View on Github external
export function report(err, extra = {}) {
  log.error(err.message);
  if (!process.env.SENTRY_DSN) {
    log.error(err);
    return;
  }

  Sentry.withScope(scope => {
    scope.setExtras(extra);
    Sentry.captureException(err);
  });
}