本文整理汇总了TypeScript中@sentry/utils.getGlobalObject函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getGlobalObject函数的具体用法?TypeScript getGlobalObject怎么用?TypeScript getGlobalObject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getGlobalObject函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: showReportDialog
/**
* Show a report dialog to the user to send feedback to a specific event.
*
* @param options Set individual options for the dialog
*/
public showReportDialog(options: ReportDialogOptions = {}): void {
// doesn't work without a document (React Native)
const document = getGlobalObject<Window>().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;
}
if (!dsn) {
logger.error('Missing `Dsn` option in showReportDialog call');
return;
}
const script = document.createElement('script');
script.async = true;
script.src = new API(dsn).getReportDialogEndpoint(options);
if (options.onLoad) {
script.onload = options.onLoad;
}
(document.head || document.body).appendChild(script);
}
开发者ID:getsentry,项目名称:raven-js,代码行数:39,代码来源:client.ts
示例2: afterEach
afterEach(() => {
jest.resetAllMocks();
jest.useRealTimers();
getGlobalObject<any>().__SENTRY__.globalEventProcessors = undefined;
});
开发者ID:getsentry,项目名称:raven-js,代码行数:5,代码来源:scope.test.ts
示例3: sendEvent
import { Event, Response, Status } from '@sentry/types';
import { getGlobalObject, supportsReferrerPolicy } from '@sentry/utils';
import { BaseTransport } from './base';
const global = getGlobalObject<Window>();
/** `fetch` based transport */
export class FetchTransport extends BaseTransport {
/**
* @inheritDoc
*/
public sendEvent(event: Event): Promise<Response> {
const defaultOptions: RequestInit = {
body: JSON.stringify(event),
method: 'POST',
// Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default
// https://caniuse.com/#feat=referrer-policy
// It doesn't. And it throw exception instead of ignoring this parameter...
// REF: https://github.com/getsentry/raven-js/issues/1233
referrerPolicy: (supportsReferrerPolicy() ? 'origin' : '') as ReferrerPolicy,
};
return this._buffer.add(
global.fetch(this.url, defaultOptions).then(response => ({
status: Status.fromHttpCode(response.status),
})),
);
}
}
开发者ID:getsentry,项目名称:raven-js,代码行数:30,代码来源:fetch.ts
示例4:
} from '@sentry/core';
export { BrowserOptions } from './backend';
export { BrowserClient, ReportDialogOptions } from './client';
export { defaultIntegrations, forceLoad, init, lastEventId, onLoad, showReportDialog, flush, close, wrap } from './sdk';
export { SDK_NAME, SDK_VERSION } from './version';
import { Integrations as CoreIntegrations } from '@sentry/core';
import { getGlobalObject } from '@sentry/utils';
import * as BrowserIntegrations from './integrations';
import * as Transports from './transports';
let windowIntegrations = {};
// This block is needed to add compatibility with the integrations packages when used with a CDN
// tslint:disable: no-unsafe-any
const _window = getGlobalObject<Window>() as any;
if (_window.Sentry && _window.Sentry.Integrations) {
windowIntegrations = _window.Sentry.Integrations;
}
// tslint:enable: no-unsafe-any
const INTEGRATIONS = {
...windowIntegrations,
...CoreIntegrations,
...BrowserIntegrations,
};
export { INTEGRATIONS as Integrations, Transports };
开发者ID:getsentry,项目名称:raven-js,代码行数:30,代码来源:index.ts
示例5:
/**
* TraceKit - Cross brower stack traces
*
* This was originally forked from github.com/occ/TraceKit, but has since been
* largely modified and is now maintained as part of Sentry JS SDK.
*
* NOTE: Last merge with upstream repository
* Jul 11,2018 - #f03357c
*
* https://github.com/csnover/TraceKit
* @license MIT
* @namespace TraceKit
*/
var window = getGlobalObject<Window>();
interface TraceKit {
_report: any;
_collectWindowErrors: any;
_computeStackTrace: any;
_linesOfContext: any;
}
var TraceKit: TraceKit = {
_report: false,
_collectWindowErrors: false,
_computeStackTrace: false,
_linesOfContext: false,
};
开发者ID:getsentry,项目名称:raven-js,代码行数:29,代码来源:tracekit.ts
注:本文中的@sentry/utils.getGlobalObject函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论