本文整理匯總了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.`);
}