Skip to content

Commit 6687dd5

Browse files
committed
ref: Change the imports
1 parent bd38f37 commit 6687dd5

File tree

5 files changed

+57
-57
lines changed

5 files changed

+57
-57
lines changed

packages/browser/src/client.ts

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,12 @@
1-
import { API, BaseClient, Scope } from '@sentry/core';
2-
import { DsnLike, Event, EventHint } from '@sentry/types';
1+
import { BaseClient, Scope } from '@sentry/core';
2+
import { Event, EventHint } from '@sentry/types';
33
import { getGlobalObject, logger } from '@sentry/utils';
44

55
import { BrowserBackend, BrowserOptions } from './backend';
6+
import { injectReportDialog, ReportDialogOptions } from './helpers';
67
import { Breadcrumbs } from './integrations';
78
import { SDK_NAME, SDK_VERSION } from './version';
89

9-
/**
10-
* All properties the report dialog supports
11-
*/
12-
export interface ReportDialogOptions {
13-
[key: string]: any;
14-
eventId?: string;
15-
dsn?: DsnLike;
16-
user?: {
17-
email?: string;
18-
name?: string;
19-
};
20-
lang?: string;
21-
title?: string;
22-
subtitle?: string;
23-
subtitle2?: string;
24-
labelName?: string;
25-
labelEmail?: string;
26-
labelComments?: string;
27-
labelClose?: string;
28-
labelSubmit?: string;
29-
errorGeneric?: string;
30-
errorFormEntry?: string;
31-
successMessage?: string;
32-
/** Callback after reportDialog showed up */
33-
onLoad?(): void;
34-
}
35-
3610
/**
3711
* The Sentry Browser SDK Client.
3812
*
@@ -110,14 +84,6 @@ export class BrowserClient extends BaseClient<BrowserBackend, BrowserOptions> {
11084
return;
11185
}
11286

113-
const script = document.createElement('script');
114-
script.async = true;
115-
script.src = new API(dsn).getReportDialogEndpoint(options);
116-
117-
if (options.onLoad) {
118-
script.onload = options.onLoad;
119-
}
120-
121-
(document.head || document.body).appendChild(script);
87+
injectReportDialog(options);
12288
}
12389
}

packages/browser/src/exports.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export {
3838
} from '@sentry/core';
3939

4040
export { BrowserOptions } from './backend';
41-
export { BrowserClient, ReportDialogOptions } from './client';
41+
export { BrowserClient } from './client';
42+
export { ReportDialogOptions } from './helpers';
4243
export { defaultIntegrations, forceLoad, init, lastEventId, onLoad, showReportDialog, flush, close, wrap } from './sdk';
4344
export { SDK_NAME, SDK_VERSION } from './version';

packages/browser/src/helpers.ts

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { captureException, withScope } from '@sentry/core';
2-
import { Event as SentryEvent, Mechanism, Scope, WrappedFunction } from '@sentry/types';
1+
import { API, captureException, withScope } from '@sentry/core';
2+
import { DsnLike, Event as SentryEvent, Mechanism, Scope, WrappedFunction } from '@sentry/types';
33
import { addExceptionMechanism, addExceptionTypeValue } from '@sentry/utils';
44

55
let ignoreOnError: number = 0;
@@ -158,3 +158,46 @@ export function wrap(
158158

159159
return sentryWrapped;
160160
}
161+
162+
/**
163+
* All properties the report dialog supports
164+
*/
165+
export interface ReportDialogOptions {
166+
[key: string]: any;
167+
eventId?: string;
168+
dsn?: DsnLike;
169+
user?: {
170+
email?: string;
171+
name?: string;
172+
};
173+
lang?: string;
174+
title?: string;
175+
subtitle?: string;
176+
subtitle2?: string;
177+
labelName?: string;
178+
labelEmail?: string;
179+
labelComments?: string;
180+
labelClose?: string;
181+
labelSubmit?: string;
182+
errorGeneric?: string;
183+
errorFormEntry?: string;
184+
successMessage?: string;
185+
/** Callback after reportDialog showed up */
186+
onLoad?(): void;
187+
}
188+
189+
/**
190+
* Injects the Report Dialog script
191+
*/
192+
export function injectReportDialog(options: ReportDialogOptions = {}): void {
193+
const script = document.createElement('script');
194+
script.async = true;
195+
// tslint:disable-next-line: no-non-null-assertion
196+
script.src = new API(options.dsn!).getReportDialogEndpoint(options);
197+
198+
if (options.onLoad) {
199+
script.onload = options.onLoad;
200+
}
201+
202+
(document.head || document.body).appendChild(script);
203+
}

packages/browser/src/index.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ export * from './exports';
33
import { Integrations as CoreIntegrations } from '@sentry/core';
44
import { getGlobalObject } from '@sentry/utils';
55

6-
import { Breadcrumbs, GlobalHandlers, LinkedErrors, TryCatch, UserAgent } from './integrations';
7-
import { BaseTransport, FetchTransport, XHRTransport } from './transports';
6+
import * as BrowserIntegrations from './integrations';
7+
import * as Transports from './transports';
88

99
let windowIntegrations = {};
1010

@@ -19,17 +19,7 @@ if (_window.Sentry && _window.Sentry.Integrations) {
1919
const INTEGRATIONS = {
2020
...windowIntegrations,
2121
...CoreIntegrations,
22-
Breadcrumbs,
23-
GlobalHandlers,
24-
LinkedErrors,
25-
TryCatch,
26-
UserAgent,
22+
...BrowserIntegrations,
2723
};
2824

29-
const TRANSPORTS = {
30-
BaseTransport,
31-
FetchTransport,
32-
XHRTransport,
33-
};
34-
35-
export { INTEGRATIONS as Integrations, TRANSPORTS as Transports };
25+
export { INTEGRATIONS as Integrations, Transports };

packages/browser/src/sdk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { getCurrentHub, initAndBind, Integrations as CoreIntegrations } from '@s
22
import { getGlobalObject, SyncPromise } from '@sentry/utils';
33

44
import { BrowserOptions } from './backend';
5-
import { BrowserClient, ReportDialogOptions } from './client';
6-
import { wrap as internalWrap } from './helpers';
5+
import { BrowserClient } from './client';
6+
import { ReportDialogOptions, wrap as internalWrap } from './helpers';
77
import { Breadcrumbs, GlobalHandlers, LinkedErrors, TryCatch, UserAgent } from './integrations';
88

99
export const defaultIntegrations = [

0 commit comments

Comments
 (0)