• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript core.getCurrentHub函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript hub.getCurrentHub函数代码示例发布时间:2022-05-28
下一篇:
TypeScript browser.init函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap