How to use the @sentry/core.API function in @sentry/core

To help you get started, we’ve selected a few @sentry/core 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 getsentry / sentry-javascript / packages / browser / src / integrations / breadcrumbs.ts View on Github external
function(this: SentryWrappedXMLHttpRequest, ...args: any[]): void {
          const url = args[1];
          this.__sentry_xhr__ = {
            method: isString(args[0]) ? args[0].toUpperCase() : args[0],
            url: args[1],
          };

          const client = getCurrentHub().getClient();
          const dsn = client && client.getDsn();
          if (dsn) {
            const filterUrl = new API(dsn).getStoreEndpoint();
            // if Sentry key appears in URL, don't capture it as a request
            // but rather as our own 'sentry' type breadcrumb
            if (isString(url) && (filterUrl && url.indexOf(filterUrl) !== -1)) {
              this.__sentry_own_request__ = true;
            }
          }

          return originalOpen.apply(this, args);
        },
    );
github getsentry / sentry-javascript / packages / browser / src / integrations / instrumenthandlers.ts View on Github external
function fetchBreadcrumb(handlerData: { [key: string]: any }): void {
  // We only capture complete fetch requests
  if (!handlerData.requestComplete) {
    return;
  }

  const client = getCurrentHub().getClient();
  const dsn = client && client.getDsn();

  if (dsn) {
    const filterUrl = new API(dsn).getStoreEndpoint();
    // if Sentry key appears in URL, don't capture it as a request
    // but rather as our own 'sentry' type breadcrumb
    if (
      filterUrl &&
      handlerData.fetchData.url.indexOf(filterUrl) !== -1 &&
      handlerData.fetchData.method === 'POST' &&
      handlerData.args[1] &&
      handlerData.args[1].body
    ) {
      addSentryBreadcrumb(handlerData.args[1].body);
      return;
    }
  }

  if (handlerData.error) {
    getCurrentHub().addBreadcrumb(
github getsentry / sentry-javascript / packages / node / src / transports / base.ts View on Github external
public constructor(public options: TransportOptions) {
    this._api = new API(options.dsn);
  }
github getsentry / sentry-javascript / packages / browser / src / client.ts View on Github external
const dsn = options.dsn || this.getDsn();

    if (!options.eventId) {
      logger.error('Missing `eventId` option in showReportDialog call');
      return;
    }

    if (!dsn) {
      logger.error('Missing `Dsn` option in showReportDialog call');
      return;
    }

    const script = document.createElement('script');
    script.async = true;
    script.src = new API(dsn).getReportDialogEndpoint(options);

    if (options.onLoad) {
      script.onload = options.onLoad;
    }

    (document.head || document.body).appendChild(script);
  }
}
github getsentry / sentry-javascript / packages / browser / src / transports / base.ts View on Github external
public constructor(public options: TransportOptions) {
    this.url = new API(this.options.dsn).getStoreEndpointWithUrlEncodedAuth();
  }