How to use the @sentry/node.getCurrentHub 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 sandorTuranszky / production-ready-expressjs-server / src / utils / errorMiddleware.js View on Github external
const exitProcess = () => {
  const sentryClient = Sentry.getCurrentHub().getClient();
  // eslint-disable-next-line promise/catch-or-return, promise/always-return, promise/no-promise-in-callback, no-process-exit
  if (sentryClient) sentryClient.close(2000).then(() => process.exit(1));
  else process.exit(1); // eslint-disable-line no-process-exit
};
github back4app / antframework / packages / ant-util-analytics / lib / Analytics.js View on Github external
async trackError(err) {
    if (!this.sentryInitialized) {
      return;
    }
    Sentry.captureException(err);
    // Returns a promise that will be resolved in 2000ms,
    // which is the timeout to resolve all pending communication
    // with Sentry servers.
    // @see https://docs.sentry.io/learn/draining
    const client = Sentry.getCurrentHub().getClient();
    return await client.close(2000);
  }
github ShabadOS / desktop / app / lib / analytics.js View on Github external
flush() {
    // Give 2 seconds to flush Sentry data
    const sentryClient = Sentry.getCurrentHub().getClient()
    return sentryClient ? sentryClient.close( 2000 ) : Promise.resolve()
  }
}
github miscord / miscord / src / error.ts View on Github external
async function cleanup (exitCode: string) {
    await Sentry.getCurrentHub().getClient()!!.close(2000)
    if (global.discord) await discord.client.destroy()
    console.error(exitCode)
  }
}
github algolia / npm-search / src / utils / sentry.js View on Github external
export function drain() {
  const client = Sentry.getCurrentHub().getClient();
  if (client) {
    return client.close(2000);
  }
  return Promise.resolve();
}
github getsentry / sentry / build-utils / sentry-apm.js View on Github external
(params, callback) => {
        spans.compile = Sentry.getCurrentHub().startSpan({
          op: 'compile',
        });
        callback();
      }
    );
github miscord / miscord / src / error / sentry.ts View on Github external
export function closeSentry () {
  return Sentry.getCurrentHub().getClient()!!.close(2000)
}