當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript core.getCurrentHub函數代碼示例

本文整理匯總了TypeScript中@sentry/core.getCurrentHub函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getCurrentHub函數的具體用法?TypeScript getCurrentHub怎麽用?TypeScript getCurrentHub使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了getCurrentHub函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: showReportDialog

export function showReportDialog(options: ReportDialogOptions = {}): void {
  if (!options.eventId) {
    options.eventId = getCurrentHub().lastEventId();
  }
  const client = getCurrentHub().getClient<BrowserClient>();
  if (client) {
    client.showReportDialog(options);
  }
}
開發者ID:getsentry,項目名稱:raven-js,代碼行數:9,代碼來源:sdk.ts

示例2: close

export async function close(timeout?: number): Promise<boolean> {
  const client = getCurrentHub().getClient<NodeClient>();
  if (client) {
    return client.close(timeout);
  }
  return Promise.reject(false);
}
開發者ID:getsentry,項目名稱:raven-js,代碼行數:7,代碼來源:sdk.ts

示例3: flush

export function flush(timeout?: number): Promise<boolean> {
  const client = getCurrentHub().getClient<BrowserClient>();
  if (client) {
    return client.flush(timeout);
  }
  return Promise.reject(false);
}
開發者ID:getsentry,項目名稱:raven-js,代碼行數:7,代碼來源:sdk.ts

示例4: _htmlTreeAsString

    const captureBreadcrumb = () => {
      // try/catch both:
      // - accessing event.target (see getsentry/raven-js#838, #768)
      // - `htmlTreeAsString` because it's complex, and just accessing the DOM incorrectly
      //   can throw an exception in some circumstances.
      let target;
      try {
        target = event.target ? _htmlTreeAsString(event.target as Node) : _htmlTreeAsString((event as unknown) as Node);
      } catch (e) {
        target = '<unknown>';
      }

      if (target.length === 0) {
        return;
      }

      getCurrentHub().addBreadcrumb(
        {
          category: `ui.${eventName}`, // e.g. ui.click, ui.input
          message: target,
        },
        {
          event,
          name: eventName,
        },
      );
    };
開發者ID:getsentry,項目名稱:raven-js,代碼行數:27,代碼來源:helpers.ts

示例5: getCurrentHub

 d2.run(() => {
   const hub = getCurrentHub();
   hub.getStack().push({ client: 'local' });
   expect(hub.getStack()[1]).toEqual({ client: 'local' });
   setTimeout(() => {
     d2done = true;
     if (d1done) {
       done();
     }
   });
 });
開發者ID:getsentry,項目名稱:raven-js,代碼行數:11,代碼來源:domain.test.ts

示例6: test

 test('domain hub scope inheritance', () => {
   const globalHub = getCurrentHub();
   globalHub.configureScope(scope => {
     scope.setExtra('a', 'b');
     scope.setTag('a', 'b');
     scope.addBreadcrumb({ message: 'a' });
   });
   const d = domain.create();
   d.run(() => {
     const hub = getCurrentHub();
     expect(globalHub).toEqual(hub);
   });
 });
開發者ID:getsentry,項目名稱:raven-js,代碼行數:13,代碼來源:domain.test.ts

示例7: eventFromException

  /**
   * @inheritDoc
   */
  public eventFromException(exception: any, hint?: EventHint): SyncPromise<Event> {
    let ex: any = exception;
    const mechanism: Mechanism = {
      handled: true,
      type: 'generic',
    };

    if (!isError(exception)) {
      if (isPlainObject(exception)) {
        // This will allow us to group events based on top-level keys
        // which is much better than creating new group when any key/value change
        const keys = Object.keys(exception as {}).sort();
        const message = `Non-Error exception captured with keys: ${keysToEventMessage(keys)}`;

        getCurrentHub().configureScope(scope => {
          scope.setExtra('__serialized__', normalizeToSize(exception as {}));
        });

        ex = (hint && hint.syntheticException) || new Error(message);
        (ex as Error).message = message;
      } else {
        // This handles when someone does: `throw "something awesome";`
        // We use synthesized Error here so we can extract a (rough) stack trace.
        ex = (hint && hint.syntheticException) || new Error(exception as string);
      }
      mechanism.synthetic = true;
    }

    return new SyncPromise<Event>((resolve, reject) =>
      parseError(ex as Error, this._options)
        .then(event => {
          addExceptionTypeValue(event, undefined, undefined, mechanism);
          resolve({
            ...event,
            event_id: hint && hint.event_id,
          });
        })
        .catch(reject),
    );
  }
開發者ID:getsentry,項目名稱:raven-js,代碼行數:43,代碼來源:backend.ts

示例8: defaultOnFatalError

export function defaultOnFatalError(error: Error): void {
  console.error(error && error.stack ? error.stack : error);
  const client = getCurrentHub().getClient<NodeClient>();

  if (client === undefined) {
    logger.warn('No NodeClient was defined, we are exiting the process now.');
    global.process.exit(1);
    return;
  }

  const options = client.getOptions();
  const timeout =
    (options && options.shutdownTimeout && options.shutdownTimeout > 0 && options.shutdownTimeout) ||
    DEFAULT_SHUTDOWN_TIMEOUT;
  forget(
    client.close(timeout).then((result: boolean) => {
      if (!result) {
        logger.warn('We reached the timeout for emptying the request buffer, still exiting now!');
      }
      global.process.exit(1);
    }),
  );
}
開發者ID:getsentry,項目名稱:raven-js,代碼行數:23,代碼來源:handlers.ts

示例9: init

export function init(options: NodeOptions = {}): void {
  if (options.defaultIntegrations === undefined) {
    options.defaultIntegrations = defaultIntegrations;
  }

  if (options.dsn === undefined && process.env.SENTRY_DSN) {
    options.dsn = process.env.SENTRY_DSN;
  }

  if (options.release === undefined && process.env.SENTRY_RELEASE) {
    options.release = process.env.SENTRY_RELEASE;
  }

  if (options.environment === undefined && process.env.SENTRY_ENVIRONMENT) {
    options.environment = process.env.SENTRY_ENVIRONMENT;
  }

  if (domain.active) {
    setHubOnCarrier(getMainCarrier(), getCurrentHub());
  }

  initAndBind(NodeClient, options);
}
開發者ID:getsentry,項目名稱:raven-js,代碼行數:23,代碼來源:sdk.ts


注:本文中的@sentry/core.getCurrentHub函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。