本文整理汇总了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);
}
示例2: afterEach
afterEach(() => {
jest.resetAllMocks();
jest.useRealTimers();
getGlobalObject<any>().__SENTRY__.globalEventProcessors = undefined;
});
示例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),
})),
);
}
}
示例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 };
示例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,
};