Skip to content

Commit 2249c2e

Browse files
authored
feat: Expose withScope (#1536)
* feat: Expose push/pop/withScope in minimal, Add level to scope * feat: Remove minimal and hub dep from browser * feat: Remove reexport of push and pop in minimal * fix: Remove node 5/7/9
1 parent 22e7b9e commit 2249c2e

File tree

24 files changed

+226
-133
lines changed

24 files changed

+226
-133
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ lerna-debug.log
2424
.Trashes
2525

2626
.rpt2_cache
27+
28+
docs

.travis.yml

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,60 +15,45 @@ cache:
1515

1616
matrix:
1717
include:
18-
- name: "@sentry/packages - lint"
19-
node_js: "8"
18+
- name: '@sentry/packages - lint'
19+
node_js: '8'
2020
script: .travis/lint.sh
21-
- name: "@sentry/packages - build and test [node v6]"
22-
node_js: "6"
21+
- name: '@sentry/packages - build and test [node v6]'
22+
node_js: '6'
2323
script: .travis/test.sh
24-
- name: "@sentry/packages - build and test [node v7]"
25-
node_js: "7"
24+
- name: '@sentry/packages - build and test [node v8]'
25+
node_js: '8'
2626
script: .travis/test.sh
27-
- name: "@sentry/packages - build and test [node v8]"
28-
node_js: "8"
27+
- name: '@sentry/packages - build and test [node v10]'
28+
node_js: '10'
2929
script: .travis/test.sh
30-
- name: "@sentry/packages - build and test [node v9]"
31-
node_js: "9"
32-
script: .travis/test.sh
33-
- name: "@sentry/packages - build and test [node v10]"
34-
node_js: "10"
35-
script: .travis/test.sh
36-
- name: "@sentry/browser - integration tests"
37-
node_js: "8"
30+
- name: '@sentry/browser - integration tests'
31+
node_js: '8'
3832
addons:
3933
chrome: stable
4034
firefox: latest
4135
sauce_connect: true
4236
script: .travis/integration.sh
43-
- name: "raven-js - unit and integration tests"
44-
node_js: "8"
37+
- name: 'raven-js - unit and integration tests'
38+
node_js: '8'
4539
addons:
4640
chrome: stable
4741
firefox: latest
4842
script: .travis/raven-js.sh
49-
- name: "raven-js - saucelabs tests"
50-
node_js: "8"
43+
- name: 'raven-js - saucelabs tests'
44+
node_js: '8'
5145
addons:
5246
sauce_connect: true
5347
script: .travis/raven-js-saucelabs.sh
54-
- name: "raven-node [node v4]"
55-
node_js: "4"
56-
script: .travis/raven-node.sh
57-
- name: "raven-node [node v5]"
58-
node_js: "5"
59-
script: .travis/raven-node.sh
60-
- name: "raven-node [node v6]"
61-
node_js: "6"
62-
script: .travis/raven-node.sh
63-
- name: "raven-node [node v7]"
64-
node_js: "7"
48+
- name: 'raven-node [node v4]'
49+
node_js: '4'
6550
script: .travis/raven-node.sh
66-
- name: "raven-node [node v8]"
67-
node_js: "8"
51+
- name: 'raven-node [node v6]'
52+
node_js: '6'
6853
script: .travis/raven-node.sh
69-
- name: "raven-node [node v9]"
70-
node_js: "9"
54+
- name: 'raven-node [node v8]'
55+
node_js: '8'
7156
script: .travis/raven-node.sh
72-
- name: "raven-node [node v10]"
73-
node_js: "10"
57+
- name: 'raven-node [node v10]'
58+
node_js: '10'
7459
script: .travis/raven-node.sh

packages/browser/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
},
1717
"dependencies": {
1818
"@sentry/core": "4.0.0-rc.2",
19-
"@sentry/hub": "4.0.0-rc.2",
20-
"@sentry/minimal": "4.0.0-rc.2",
2119
"@sentry/types": "4.0.0-rc.2",
2220
"@sentry/utils": "4.0.0-rc.2",
2321
"md5": "2.2.1"

packages/browser/src/index.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,18 @@ export {
1313
User,
1414
} from '@sentry/types';
1515

16-
export { addBreadcrumb, captureMessage, captureException, captureEvent, configureScope } from '@sentry/minimal';
17-
18-
export { getHubFromCarrier, getCurrentHub, Hub, Scope } from '@sentry/hub';
16+
export {
17+
addBreadcrumb,
18+
captureException,
19+
captureEvent,
20+
captureMessage,
21+
configureScope,
22+
withScope,
23+
getHubFromCarrier,
24+
getCurrentHub,
25+
Hub,
26+
Scope,
27+
} from '@sentry/core';
1928

2029
export { BrowserBackend, BrowserOptions } from './backend';
2130
export { BrowserClient } from './client';

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { API, logger } from '@sentry/core';
2-
import { getCurrentHub } from '@sentry/hub';
1+
import { API, getCurrentHub, logger } from '@sentry/core';
32
import { Integration, Severity } from '@sentry/types';
43
import { isFunction, isString } from '@sentry/utils/is';
54
import { getGlobalObject, parseUrl } from '@sentry/utils/misc';

packages/browser/src/integrations/dedupe.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { logger } from '@sentry/core';
2-
import { getCurrentHub, Scope } from '@sentry/hub';
1+
import { configureScope, logger } from '@sentry/core';
32
import { Integration, SentryEvent, SentryException, StackFrame } from '@sentry/types';
43

54
/** Deduplication filter */
@@ -18,7 +17,7 @@ export class Dedupe implements Integration {
1817
* @inheritDoc
1918
*/
2019
public install(): void {
21-
getCurrentHub().configureScope((scope: Scope) => {
20+
configureScope(scope => {
2221
scope.addEventProcessor(async (currentEvent: SentryEvent) => {
2322
// Juuust in case something goes wrong
2423
try {

packages/browser/src/integrations/globalhandlers.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { logger } from '@sentry/core';
2-
import { getCurrentHub } from '@sentry/hub';
1+
import { getCurrentHub, logger } from '@sentry/core';
32
import { Integration, SentryEvent } from '@sentry/types';
43
import { eventFromStacktrace } from '../parsers';
54
import {

packages/browser/src/integrations/helpers.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getCurrentHub, Scope } from '@sentry/hub';
1+
import { getCurrentHub, withScope } from '@sentry/core';
22
import { Mechanism, SentryEvent, SentryWrappedFunction } from '@sentry/types';
33
import { isFunction } from '@sentry/utils/is';
44
import { htmlTreeAsString } from '@sentry/utils/misc';
@@ -65,18 +65,16 @@ export function wrap(
6565
} catch (ex) {
6666
ignoreNextOnError();
6767

68-
getCurrentHub().withScope(async () => {
69-
getCurrentHub().configureScope((scope: Scope) => {
70-
scope.addEventProcessor(async (event: SentryEvent) => {
71-
const processedEvent = { ...event };
68+
withScope(async scope => {
69+
scope.addEventProcessor(async (event: SentryEvent) => {
70+
const processedEvent = { ...event };
7271

73-
if (options.mechanism) {
74-
processedEvent.exception = processedEvent.exception || {};
75-
processedEvent.exception.mechanism = options.mechanism;
76-
}
72+
if (options.mechanism) {
73+
processedEvent.exception = processedEvent.exception || {};
74+
processedEvent.exception.mechanism = options.mechanism;
75+
}
7776

78-
return processedEvent;
79-
});
77+
return processedEvent;
8078
});
8179

8280
getCurrentHub().captureException(ex, { originalException: ex });

packages/browser/src/integrations/inboundfilters.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { logger } from '@sentry/core';
2-
import { getCurrentHub, Scope } from '@sentry/hub';
1+
import { configureScope, logger } from '@sentry/core';
32
import { Integration, SentryEvent } from '@sentry/types';
43
import { isRegExp } from '@sentry/utils/is';
54
import { BrowserOptions } from '../backend';
@@ -27,7 +26,7 @@ export class InboundFilters implements Integration {
2726
public install(options: BrowserOptions = {}): void {
2827
this.configureOptions(options);
2928

30-
getCurrentHub().configureScope((scope: Scope) => {
29+
configureScope(scope => {
3130
scope.addEventProcessor(async (event: SentryEvent) => {
3231
if (this.shouldDropEvent(event)) {
3332
return null;

packages/browser/src/integrations/linkederrors.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getCurrentHub } from '@sentry/hub';
1+
import { configureScope } from '@sentry/core';
22
import { Integration, SentryEvent, SentryEventHint, SentryException } from '@sentry/types';
33
import { exceptionFromStacktrace } from '../parsers';
44
import { computeStackTrace } from '../tracekit';
@@ -42,9 +42,7 @@ export class LinkedErrors implements Integration {
4242
* @inheritDoc
4343
*/
4444
public install(): void {
45-
getCurrentHub().configureScope(scope => {
46-
scope.addEventProcessor(this.handler.bind(this));
47-
});
45+
configureScope(scope => scope.addEventProcessor(this.handler.bind(this)));
4846
}
4947

5048
/**

0 commit comments

Comments
 (0)