How to use the @sentry/utils.getGlobalObject function in @sentry/utils

To help you get started, we’ve selected a few @sentry/utils 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 / integrations / src / tracing.ts View on Github external
private _traceFetch(getCurrentHub: () => Hub): void {
    if (!supportsNativeFetch()) {
      return;
    }

    // tslint:disable: only-arrow-functions
    fill(getGlobalObject(), 'fetch', function(originalFetch: () => void): () => void {
      return function(...args: any[]): void {
        // @ts-ignore
        const self = getCurrentHub().getIntegration(Tracing);
        if (self && self._options.tracingOrigins) {
          const url = args[0] as string;
          const options = (args[1] = (args[1] as { [key: string]: any }) || {});

          let whiteListed = false;
          self._options.tracingOrigins.forEach((whiteListUrl: string | RegExp) => {
            if (!whiteListed) {
              whiteListed = isMatchingPattern(url, whiteListUrl);
            }
          });

          if (whiteListed) {
            if (options.headers) {
github getsentry / sentry-javascript / packages / browser / src / client.ts View on Github external
public showReportDialog(options: ReportDialogOptions = {}): void {
    // doesn't work without a document (React Native)
    const document = getGlobalObject().document;
    if (!document) {
      return;
    }

    if (!this._isEnabled()) {
      logger.error('Trying to call showReportDialog with Sentry Client is disabled');
      return;
    }

    const dsn = options.dsn || this.getDsn();

    if (!options.eventId) {
      logger.error('Missing `eventId` option in showReportDialog call');
      return;
    }
github getsentry / sentry-javascript / packages / integrations / src / ember.ts View on Github external
public constructor(options: { Ember?: any } = {}) {
    // tslint:disable-next-line: no-unsafe-any
    this._Ember = options.Ember || getGlobalObject().Ember;
  }
github getsentry / sentry-javascript / packages / integrations / src / tracing.ts View on Github external
private _traceXHR(getCurrentHub: () => Hub): void {
    if (!('XMLHttpRequest' in getGlobalObject())) {
      return;
    }

    const xhrproto = XMLHttpRequest.prototype;

    fill(
      xhrproto,
      'open',
      originalOpen =>
        function(this: XMLHttpRequest, ...args: any[]): void {
          // @ts-ignore
          const self = getCurrentHub().getIntegration(Tracing);
          if (self) {
            self._xhrUrl = args[1] as string;
          }
          // tslint:disable-next-line: no-unsafe-any
github getsentry / sentry-javascript / packages / hub / src / hub.ts View on Github external
export function getMainCarrier(): Carrier {
  const carrier = getGlobalObject();
  carrier.__SENTRY__ = carrier.__SENTRY__ || {
    extensions: {},
    hub: undefined,
  };
  return carrier;
}
github getsentry / sentry-javascript / packages / apm / src / integrations / transactionactivity.ts View on Github external
import { getGlobalObject } from '@sentry/utils';

/** JSDoc */
interface TransactionActivityOptions {
  idleTimeout: number;
  startTransactionOnLocationChange: boolean;
  tracesSampleRate: number;
}

/** JSDoc */
interface Activity {
  name: string;
  span?: Span;
}

const global = getGlobalObject();

/** JSDoc */
export class TransactionActivity implements Integration {
  /**
   * @inheritDoc
   */
  public name: string = TransactionActivity.id;

  /**
   * @inheritDoc
   */
  public static id: string = 'TransactionActivity';

  /**
   * Is Tracing enabled, this will be determined once per pageload.
   */
github getsentry / sentry-javascript / packages / apm / src / integrations / tracing.ts View on Github external
* on initalization.
   * 0 = 0% chance of instrumenting
   * 1 = 100% change of instrumenting
   *
   * Default: 1
   */
  tracesSampleRate: number;
}

/** JSDoc */
interface Activity {
  name: string;
  span?: Span;
}

const global = getGlobalObject();

/**
 * Tracing Integration
 */
export class Tracing implements Integration {
  /**
   * @inheritDoc
   */
  public name: string = Tracing.id;

  /**
   * @inheritDoc
   */
  public static id: string = 'Tracing';

  /**