本文整理汇总了TypeScript中@sentry/hub.getCurrentHub函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getCurrentHub函数的具体用法?TypeScript getCurrentHub怎么用?TypeScript getCurrentHub使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getCurrentHub函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('Level', () => {
const client: any = new TestClient({});
const scope = getCurrentHub().pushScope();
getCurrentHub().bindClient(client);
scope.setLevel(Severity.Warning);
expect(global.__SENTRY__.hub._stack[1].scope._level).toEqual(Severity.Warning);
});
示例2: getCurrentHub
getCurrentHub().withScope(() => {
getCurrentHub().bindClient(new TestClient({}) as any);
_callOnClient('mySecretPublicMethod', 'test');
expect(s.mock.calls[0][0]).toBe('test');
s.mockRestore();
done();
});
示例3: getCurrentHub
/**
* This calls a function on the current hub.
* @param method function to call on hub.
* @param args to pass to function.
*/
function callOnHub<T>(method: string, ...args: any[]): T {
const hub = getCurrentHub();
if (hub && hub[method as keyof Hub]) {
// tslint:disable-next-line:no-unsafe-any
return (hub[method as keyof Hub] as any)(...args);
}
throw new Error(`No hub defined or ${method} was not found on the hub, please open a bug report.`);
}