Skip to content

Commit 93902d6

Browse files
committed
ref: Dedupe is now optional, Fix integration build
1 parent a4734da commit 93902d6

40 files changed

+317
-168
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ since we removed some methods from the public API and removed some classes from
4444
- [all] feat: Prefix all private methods with `_`
4545
- [all] build: Use terser instead of uglify
4646
- [opentracing] feat: Introduce `@sentry/opentracing` providing functions to attach opentracing data to Sentry Events
47+
- **breaking** [core] ref: `Dedupe` Integration is now optional, it is no longer enabled by default.
4748

4849
## 4.6.4
4950

dangerfile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ export default async () => {
4848

4949
schedule(async () => {
5050
const result = (await promisify(exec)('cd packages/browser; yarn size:check')).stdout;
51-
message(`@sentry/browser gzip'ed minified size: ${result.split('\n')[1]}`);
51+
message(`@sentry/browser bundle gzip'ed minified size: \n${result.split('\n')[2]}\n${result.split('\n')[3]}`);
5252
});
5353
};

packages/browser/src/sdk.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { BrowserClient, ReportDialogOptions } from './client';
44
import { Breadcrumbs, GlobalHandlers, LinkedErrors, TryCatch, UserAgent } from './integrations';
55

66
export const defaultIntegrations = [
7-
new CoreIntegrations.Dedupe(),
87
new CoreIntegrations.InboundFilters(),
98
new CoreIntegrations.FunctionToString(),
109
new TryCatch(),

packages/browser/test/index.test.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,6 @@ describe('SentryBrowser', () => {
128128
captureEvent({ message: 'event' });
129129
});
130130

131-
it('should dedupe an event', async () => {
132-
captureMessage('event222');
133-
captureMessage('event222');
134-
135-
await flush(2000);
136-
137-
expect(beforeSend.calledOnce).to.be.true;
138-
});
139-
140131
it('should not dedupe an event on bound client', async () => {
141132
const localBeforeSend = spy();
142133
getCurrentHub().bindClient(

packages/browser/test/integration/common.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ function initSDK() {
117117
Sentry.init({
118118
dsn: 'https://public@example.com/1',
119119
// debug: true,
120+
integrations: [new SentryIntegration.Dedupe()],
120121
attachStacktrace: true,
121122
transport: DummyTransport,
122123
ignoreErrors: ['ignoreErrorTest'],
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../integrations/build/dedupe.js

packages/browser/test/integration/dedupe.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/browser/test/integration/frame.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<title></title>
77
<script src="polyfills/es6-promise-4.2.5.auto.js"></script>
88
<script src="polyfills/whatwg-fetch-3.0.0.js"></script>
9+
<script src="dedupe.js"></script>
910
<script src="common.js"></script>
1011
<script src="../../build/bundle.js"></script>
1112
<script src="init.js"></script>

packages/browser/test/integration/loader-lazy-no.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<title></title>
77
<script src="polyfills/es6-promise-4.2.5.auto.js"></script>
88
<script src="polyfills/whatwg-fetch-3.0.0.js"></script>
9+
<script src="dedupe.js"></script>
910
<script src="common.js"></script>
1011
<script src="../../src/loader.js" data-lazy="no"></script>
1112
</head>

packages/browser/test/integration/loader-with-no-global-init-lazy-no.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<title></title>
66
<script src="polyfills/es6-promise-4.2.5.auto.js"></script>
77
<script src="polyfills/whatwg-fetch-3.0.0.js"></script>
8+
<script src="dedupe.js"></script>
89
<script src="common.js"></script>
910
<script src="../../src/loader.js" data-lazy="no"></script>
1011
</head>

packages/browser/test/integration/loader-with-no-global-init.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<title></title>
66
<script src="polyfills/es6-promise-4.2.5.auto.js"></script>
77
<script src="polyfills/whatwg-fetch-3.0.0.js"></script>
8+
<script src="dedupe.js"></script>
89
<script src="common.js"></script>
910
<script src="../../src/loader.js"></script>
1011
</head>

packages/browser/test/integration/loader.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<title></title>
77
<script src="polyfills/es6-promise-4.2.5.auto.js"></script>
88
<script src="polyfills/whatwg-fetch-3.0.0.js"></script>
9+
<script src="dedupe.js"></script>
910
<script src="common.js"></script>
1011
<script src="../../src/loader.js"></script>
1112
</head>

packages/browser/test/karma/integration-files.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ module.exports = [
1717
{ pattern: 'test/integration/init.js', included: false },
1818
{ pattern: 'build/bundle.js', included: false },
1919
{ pattern: 'build/bundle.js.map', included: false },
20+
{ pattern: 'test/integration/dedupe.js', included: false },
21+
{ pattern: 'test/integration/dedupe.js.map', included: false },
2022
'test/integration/test.js',
2123
];

packages/core/src/integration.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/hub';
12
import { Integration, Options } from '@sentry/types';
23
import { logger } from '@sentry/utils/logger';
34

@@ -50,7 +51,7 @@ export function setupIntegration(integration: Integration): void {
5051
if (installedIntegrations.indexOf(getIntegrationName(integration)) !== -1) {
5152
return;
5253
}
53-
integration.setupOnce();
54+
integration.setupOnce(addGlobalEventProcessor, getCurrentHub);
5455
installedIntegrations.push(getIntegrationName(integration));
5556
logger.log(`Integration installed: ${getIntegrationName(integration)}`);
5657
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
export { Dedupe } from './dedupe';
21
export { FunctionToString } from './functiontostring';
32
export { InboundFilters } from './inboundfilters';

packages/core/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"extends": "./tsconfig.build.json",
3-
"include": ["src/**/*.ts", "test/**/*.ts"],
3+
"include": ["src/**/*.ts", "test/**/*.ts", "../integrations/test/dedupe.test.ts"],
44
"exclude": ["dist"],
55
"compilerOptions": {
66
"rootDir": ".",

packages/hub/src/hub.ts

Lines changed: 20 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
Client,
55
Event,
66
EventHint,
7+
Hub as HubInterface,
78
Integration,
89
IntegrationClass,
910
Severity,
@@ -49,7 +50,7 @@ const MAX_BREADCRUMBS = 100;
4950
* Internal class used to make sure we always have the latest internal functions
5051
* working in case we have a version conflict.
5152
*/
52-
export class Hub {
53+
export class Hub implements HubInterface {
5354
/** Is a {@link Layer}[] containing the client and scope */
5455
private readonly _stack: Layer[] = [];
5556

@@ -82,35 +83,22 @@ export class Hub {
8283
}
8384

8485
/**
85-
* Checks if this hub's version is older than the given version.
86-
*
87-
* @param version A version number to compare to.
88-
* @return True if the given version is newer; otherwise false.
89-
*
90-
* @hidden
86+
* @inheritdoc
9187
*/
9288
public isOlderThan(version: number): boolean {
9389
return this._version < version;
9490
}
9591

9692
/**
97-
* This binds the given client to the current scope.
98-
* @param client An SDK client (client) instance.
93+
* @inheritdoc
9994
*/
10095
public bindClient(client?: Client): void {
10196
const top = this.getStackTop();
10297
top.client = client;
10398
}
10499

105100
/**
106-
* Create a new scope to store context information.
107-
*
108-
* The scope will be layered on top of the current one. It is isolated, i.e. all
109-
* breadcrumbs and context information added to this scope will be removed once
110-
* the scope ends. Be sure to always remove this scope with {@link this.popScope}
111-
* when the operation finishes or throws.
112-
*
113-
* @returns Scope, the new cloned scope
101+
* @inheritdoc
114102
*/
115103
public pushScope(): Scope {
116104
// We want to clone the content of prev scope
@@ -125,28 +113,14 @@ export class Hub {
125113
}
126114

127115
/**
128-
* Removes a previously pushed scope from the stack.
129-
*
130-
* This restores the state before the scope was pushed. All breadcrumbs and
131-
* context information added since the last call to {@link this.pushScope} are
132-
* discarded.
116+
* @inheritdoc
133117
*/
134118
public popScope(): boolean {
135119
return this.getStack().pop() !== undefined;
136120
}
137121

138122
/**
139-
* Creates a new scope with and executes the given operation within.
140-
* The scope is automatically removed once the operation
141-
* finishes or throws.
142-
*
143-
* This is essentially a convenience function for:
144-
*
145-
* pushScope();
146-
* callback();
147-
* popScope();
148-
*
149-
* @param callback that will be enclosed into push/popScope.
123+
* @inheritdoc
150124
*/
151125
public withScope(callback: (scope: Scope) => void): void {
152126
const scope = this.pushScope();
@@ -157,7 +131,9 @@ export class Hub {
157131
}
158132
}
159133

160-
/** Returns the client of the top stack. */
134+
/**
135+
* @inheritdoc
136+
*/
161137
public getClient(): Client | undefined {
162138
return this.getStackTop().client;
163139
}
@@ -178,11 +154,7 @@ export class Hub {
178154
}
179155

180156
/**
181-
* Captures an exception event and sends it to Sentry.
182-
*
183-
* @param exception An exception-like object.
184-
* @param hint May contain additional information about the original exception.
185-
* @returns The generated eventId.
157+
* @inheritdoc
186158
*/
187159
public captureException(exception: any, hint?: EventHint): string {
188160
const eventId = (this._lastEventId = uuid4());
@@ -194,12 +166,7 @@ export class Hub {
194166
}
195167

196168
/**
197-
* Captures a message event and sends it to Sentry.
198-
*
199-
* @param message The message to send to Sentry.
200-
* @param level Define the level of the message.
201-
* @param hint May contain additional information about the original exception.
202-
* @returns The generated eventId.
169+
* @inheritdoc
203170
*/
204171
public captureMessage(message: string, level?: Severity, hint?: EventHint): string {
205172
const eventId = (this._lastEventId = uuid4());
@@ -211,10 +178,7 @@ export class Hub {
211178
}
212179

213180
/**
214-
* Captures a manually created event and sends it to Sentry.
215-
*
216-
* @param event The event to send to Sentry.
217-
* @param hint May contain additional information about the original exception.
181+
* @inheritdoc
218182
*/
219183
public captureEvent(event: Event, hint?: EventHint): string {
220184
const eventId = (this._lastEventId = uuid4());
@@ -226,22 +190,14 @@ export class Hub {
226190
}
227191

228192
/**
229-
* This is the getter for lastEventId.
230-
*
231-
* @returns The last event id of a captured event.
193+
* @inheritdoc
232194
*/
233195
public lastEventId(): string | undefined {
234196
return this._lastEventId;
235197
}
236198

237199
/**
238-
* Records a new breadcrumb which will be attached to future events.
239-
*
240-
* Breadcrumbs will be added to subsequent events to provide more context on
241-
* user's actions prior to an error or crash.
242-
*
243-
* @param breadcrumb The breadcrumb to record.
244-
* @param hint May contain additional information about the original breadcrumb.
200+
* @inheritdoc
245201
*/
246202
public addBreadcrumb(breadcrumb: Breadcrumb, hint?: BreadcrumbHint): void {
247203
const top = this.getStackTop();
@@ -270,9 +226,7 @@ export class Hub {
270226
}
271227

272228
/**
273-
* Callback to set context information onto the scope.
274-
*
275-
* @param callback Callback function that receives Scope.
229+
* @inheritdoc
276230
*/
277231
public configureScope(callback: (scope: Scope) => void): void {
278232
const top = this.getStackTop();
@@ -283,9 +237,7 @@ export class Hub {
283237
}
284238

285239
/**
286-
* For the duraction of the callback, this hub will be set as the global current Hub.
287-
* This function is useful if you want to run your own client and hook into an already initialized one
288-
* e.g.: Reporting issues to your own sentry when running in your component while still using the users configuration.
240+
* @inheritdoc
289241
*/
290242
public run(callback: (hub: Hub) => void): void {
291243
const oldHub = makeMain(this);
@@ -296,7 +248,9 @@ export class Hub {
296248
}
297249
}
298250

299-
/** Returns the integration if installed on the current client. */
251+
/**
252+
* @inheritdoc
253+
*/
300254
public getIntegration<T extends Integration>(integration: IntegrationClass<T>): T | null {
301255
const client = this.getClient();
302256
if (!client) {

packages/hub/src/scope.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export class Scope implements ScopeInterface {
159159
/**
160160
* @inheritdoc
161161
*/
162-
public setLevel(level?: Severity): this {
162+
public setLevel(level: Severity): this {
163163
this._level = normalize(level);
164164
this._notifyScopeListeners();
165165
return this;

packages/integrations/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/integrations/.npmignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
*
2-
!*.js.map
3-
!*.d.ts
4-
!*.js
2+
!/dist/**/*
3+
!/build/**/*
54
!/esm/**/*
6-
jest.config.js

packages/integrations/package.json

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@sentry/core": "5.0.0-beta0",
17-
"@sentry/hub": "5.0.0-beta0",
1816
"@sentry/types": "5.0.0-beta0",
19-
"@sentry/utils": "5.0.0-beta0",
20-
"tslib": "^1.9.3"
17+
"@sentry/utils": "5.0.0-beta0"
2118
},
2219
"devDependencies": {
2320
"@types/angular": "^1.6.54",
@@ -27,12 +24,19 @@
2724
"prettier": "^1.16.4",
2825
"prettier-check": "^2.0.0",
2926
"rimraf": "^2.6.3",
27+
"rollup": "^1.4.0",
28+
"rollup-plugin-commonjs": "^9.2.1",
29+
"rollup-plugin-node-resolve": "^4.0.1",
30+
"rollup-plugin-terser": "^4.0.4",
31+
"rollup-plugin-typescript2": "^0.19.2",
3032
"tslint": "^5.12.1",
3133
"typescript": "^3.3.3"
3234
},
3335
"scripts": {
34-
"build": "tsc -p tsconfig.build.json",
36+
"build": "run-p build:es5 build:bundle",
37+
"build:es5": "tsc -p tsconfig.build.json",
3538
"build:watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
39+
"build:bundle": "rollup --config",
3640
"clean": "rimraf dist coverage *.js *.js.map *.d.ts",
3741
"lint": "run-s lint:prettier lint:tslint",
3842
"lint:prettier": "prettier-check \"{src,test}/**/*.ts\"",
@@ -49,9 +53,14 @@
4953
"transform": {
5054
"^.+\\.ts$": "ts-jest"
5155
},
52-
"moduleFileExtensions": ["js", "ts"],
56+
"moduleFileExtensions": [
57+
"js",
58+
"ts"
59+
],
5360
"testEnvironment": "node",
54-
"testMatch": ["**/*.test.ts"],
61+
"testMatch": [
62+
"**/*.test.ts"
63+
],
5564
"globals": {
5665
"ts-jest": {
5766
"tsConfig": "./tsconfig.json",

0 commit comments

Comments
 (0)