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