Skip to content

Commit e2993ba

Browse files
authored
Merge branch 'master' into apm
2 parents e550a66 + 5d670a7 commit e2993ba

File tree

22 files changed

+224
-53
lines changed

22 files changed

+224
-53
lines changed

CHANGELOG.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,20 @@
22

33
## Unreleased
44

5-
- [browser]: feat: Try to read `window.SENTRY_RELEASE` to set release by default
6-
- [utils]: fix(utils): Add polyfill for Object.setPrototypeOf
5+
- None
6+
7+
## 5.5.0
8+
9+
- [core] fix: Store processing state for each `flush` call separately (#2143)
10+
- [scope] feat: Generate hint if not provided in the Hub calls (#2142)
11+
- [browser] feat: Read `window.SENTRY_RELEASE` to set release by default (#2132)
12+
- [browser] fix: Don't call `fn.handleEvent.bind` if `fn.handleEvent` does not exist (#2138)
13+
- [browser] fix: Correctly handle events that utilize `handleEvent` object (#2149)
14+
- [node] feat: Provide optional `shouldHandleError` option for node `errorHandler` (#2146)
15+
- [node] fix: Remove unsafe `any` from `NodeOptions` type (#2111)
16+
- [node] fix: Merge `transportOptions` correctly (#2151)
17+
- [utils] fix: Add polyfill for `Object.setPrototypeOf` (#2127)
18+
- [integrations] feat: `SessionDuration` integration (#2150)
719

820
## 5.4.3
921

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"lerna": "3.4.0",
3-
"version": "5.4.3",
3+
"version": "5.5.0",
44
"packages": "packages/*",
55
"ignore": "raven-*",
66
"npmClient": "yarn",

packages/browser/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/browser",
3-
"version": "5.4.3",
3+
"version": "5.5.0",
44
"description": "Official Sentry SDK for browsers",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/browser",
@@ -16,9 +16,9 @@
1616
"access": "public"
1717
},
1818
"dependencies": {
19-
"@sentry/core": "5.4.3",
20-
"@sentry/types": "5.4.2",
21-
"@sentry/utils": "5.4.2",
19+
"@sentry/core": "5.5.0",
20+
"@sentry/types": "5.5.0",
21+
"@sentry/utils": "5.5.0",
2222
"tslib": "^1.9.3"
2323
},
2424
"devDependencies": {

packages/browser/src/backend.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ export class BrowserBackend extends BaseBackend<BrowserOptions> {
4949
return super._setupTransport();
5050
}
5151

52-
const transportOptions = this._options.transportOptions
53-
? this._options.transportOptions
54-
: { dsn: this._options.dsn };
52+
const transportOptions = {
53+
...this._options.transportOptions,
54+
dsn: this._options.dsn,
55+
};
5556

5657
if (this._options.transport) {
5758
return new this._options.transport(transportOptions);

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ export class Breadcrumbs implements Integration {
157157
});
158158
}
159159
if (eventName === 'keypress') {
160-
fill(fn, 'handleEvent', keypressEventHandler());
160+
fill(fn, 'handleEvent', function(innerOriginal: () => void): (caughtEvent: Event) => void {
161+
return function(this: any, event: Event): (event: Event) => void {
162+
keypressEventHandler()(event);
163+
return innerOriginal.call(this, event);
164+
};
165+
});
161166
}
162167
} else {
163168
if (eventName === 'click') {

packages/browser/src/integrations/trycatch.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export class TryCatch implements Integration {
7070
options?: boolean | AddEventListenerOptions,
7171
): (eventName: string, fn: EventListenerObject, capture?: boolean, secure?: boolean) => void {
7272
try {
73+
// tslint:disable-next-line:no-unbound-method strict-type-predicates
7374
if (typeof fn.handleEvent === 'function') {
7475
fn.handleEvent = wrap(fn.handleEvent.bind(fn), {
7576
mechanism: {

packages/browser/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export const SDK_NAME = 'sentry.javascript.browser';
2-
export const SDK_VERSION = '5.4.3';
2+
export const SDK_VERSION = '5.5.0';

packages/browser/test/integration/test.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,84 @@ for (var idx in frames) {
16731673
);
16741674
});
16751675

1676+
it('should record click events that were handled using an object with handleEvent property and call original callback', function(done) {
1677+
var iframe = this.iframe;
1678+
1679+
iframeExecute(
1680+
iframe,
1681+
done,
1682+
function() {
1683+
var frame = this;
1684+
frame.handleEventCalled = false;
1685+
1686+
var input = document.getElementsByTagName('input')[0];
1687+
input.addEventListener('click', {
1688+
handleEvent() {
1689+
frame.handleEventCalled = true;
1690+
},
1691+
});
1692+
input.dispatchEvent(new MouseEvent('click'));
1693+
1694+
Sentry.captureMessage('test');
1695+
},
1696+
function(sentryData) {
1697+
if (IS_LOADER) {
1698+
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
1699+
assert.lengthOf(sentryData, 1);
1700+
return done();
1701+
}
1702+
var breadcrumbs = iframe.contentWindow.sentryBreadcrumbs;
1703+
1704+
assert.equal(breadcrumbs.length, 1);
1705+
assert.equal(breadcrumbs[0].category, 'ui.click');
1706+
assert.equal(breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]');
1707+
1708+
assert.equal(iframe.contentWindow.handleEventCalled, true);
1709+
1710+
done();
1711+
}
1712+
);
1713+
});
1714+
1715+
it('should record keypress events that were handled using an object with handleEvent property and call original callback', function(done) {
1716+
var iframe = this.iframe;
1717+
1718+
iframeExecute(
1719+
iframe,
1720+
done,
1721+
function() {
1722+
var frame = this;
1723+
frame.handleEventCalled = false;
1724+
1725+
var input = document.getElementsByTagName('input')[0];
1726+
input.addEventListener('keypress', {
1727+
handleEvent() {
1728+
frame.handleEventCalled = true;
1729+
},
1730+
});
1731+
input.dispatchEvent(new KeyboardEvent('keypress'));
1732+
1733+
Sentry.captureMessage('test');
1734+
},
1735+
function(sentryData) {
1736+
if (IS_LOADER) {
1737+
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
1738+
assert.lengthOf(sentryData, 1);
1739+
return done();
1740+
}
1741+
var breadcrumbs = iframe.contentWindow.sentryBreadcrumbs;
1742+
1743+
assert.equal(breadcrumbs.length, 1);
1744+
assert.equal(breadcrumbs[0].category, 'ui.input');
1745+
assert.equal(breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]');
1746+
1747+
assert.equal(iframe.contentWindow.handleEventCalled, true);
1748+
1749+
done();
1750+
}
1751+
);
1752+
});
1753+
16761754
it(
16771755
_alt('should record history.[pushState|replaceState] changes as navigation breadcrumbs', IS_LOADER),
16781756
function(done) {

packages/core/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/core",
3-
"version": "5.4.3",
3+
"version": "5.5.0",
44
"description": "Base implementation for all Sentry JavaScript SDKs",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/core",
@@ -16,10 +16,10 @@
1616
"access": "public"
1717
},
1818
"dependencies": {
19-
"@sentry/hub": "5.4.3",
20-
"@sentry/minimal": "5.4.3",
21-
"@sentry/types": "5.4.2",
22-
"@sentry/utils": "5.4.2",
19+
"@sentry/hub": "5.5.0",
20+
"@sentry/minimal": "5.5.0",
21+
"@sentry/types": "5.5.0",
22+
"@sentry/utils": "5.5.0",
2323
"tslib": "^1.9.3"
2424
},
2525
"devDependencies": {

packages/hub/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/hub",
3-
"version": "5.4.3",
3+
"version": "5.5.0",
44
"description": "Sentry hub which handles global state managment.",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/hub",
@@ -16,8 +16,8 @@
1616
"access": "public"
1717
},
1818
"dependencies": {
19-
"@sentry/types": "5.4.2",
20-
"@sentry/utils": "5.4.2",
19+
"@sentry/types": "5.5.0",
20+
"@sentry/utils": "5.5.0",
2121
"tslib": "^1.9.3"
2222
},
2323
"devDependencies": {

packages/integrations/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/integrations",
3-
"version": "5.4.2",
3+
"version": "5.5.0",
44
"description": "Pluggable integrations that can be used to enchance JS SDKs",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/integrations",
@@ -16,8 +16,8 @@
1616
"module": "esm/index.js",
1717
"types": "dist/index.d.ts",
1818
"dependencies": {
19-
"@sentry/types": "5.4.2",
20-
"@sentry/utils": "5.4.2",
19+
"@sentry/types": "5.5.0",
20+
"@sentry/utils": "5.5.0",
2121
"tslib": "^1.9.3"
2222
},
2323
"devDependencies": {

packages/integrations/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export { Ember } from './ember';
66
export { ExtraErrorData } from './extraerrordata';
77
export { ReportingObserver } from './reportingobserver';
88
export { RewriteFrames } from './rewriteframes';
9+
export { SessionTiming } from './sessiontiming';
910
export { Tracing } from './tracing';
1011
export { Transaction } from './transaction';
1112
export { Vue } from './vue';
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { Event, EventProcessor, Hub, Integration } from '@sentry/types';
2+
3+
/** This function adds duration since Sentry was initialized till the time event was sent */
4+
export class SessionTiming implements Integration {
5+
/**
6+
* @inheritDoc
7+
*/
8+
public name: string = SessionTiming.id;
9+
/**
10+
* @inheritDoc
11+
*/
12+
public static id: string = 'SessionTiming';
13+
14+
/** Exact time Client was initialized expressed in milliseconds since Unix Epoch. */
15+
protected readonly _startTime: number = Date.now();
16+
17+
/**
18+
* @inheritDoc
19+
*/
20+
public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {
21+
addGlobalEventProcessor(event => {
22+
const self = getCurrentHub().getIntegration(SessionTiming);
23+
if (self) {
24+
return self.process(event);
25+
}
26+
return event;
27+
});
28+
}
29+
30+
/**
31+
* @inheritDoc
32+
*/
33+
public process(event: Event): Event {
34+
const now = Date.now();
35+
36+
return {
37+
...event,
38+
extra: {
39+
...event.extra,
40+
['session:start']: this._startTime,
41+
['session:duration']: now - this._startTime,
42+
['session:end']: now,
43+
},
44+
};
45+
}
46+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { SessionTiming } from '../src/sessiontiming';
2+
3+
const sessionTiming: SessionTiming = new SessionTiming();
4+
5+
describe('SessionTiming', () => {
6+
it('should work as expected', () => {
7+
const event = sessionTiming.process({
8+
extra: {
9+
some: 'value',
10+
},
11+
});
12+
13+
expect(typeof event.extra!['session:start']).toBe('number');
14+
expect(typeof event.extra!['session:duration']).toBe('number');
15+
expect(typeof event.extra!['session:end']).toBe('number');
16+
expect(event.extra!.some).toEqual('value');
17+
});
18+
});

packages/minimal/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/minimal",
3-
"version": "5.4.3",
3+
"version": "5.5.0",
44
"description": "Sentry minimal library that can be used in other packages",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/minimal",
@@ -16,8 +16,8 @@
1616
"access": "public"
1717
},
1818
"dependencies": {
19-
"@sentry/hub": "5.4.3",
20-
"@sentry/types": "5.4.2",
19+
"@sentry/hub": "5.5.0",
20+
"@sentry/types": "5.5.0",
2121
"tslib": "^1.9.3"
2222
},
2323
"devDependencies": {

packages/node/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/node",
3-
"version": "5.4.3",
3+
"version": "5.5.0",
44
"description": "Offical Sentry SDK for Node.js",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/node",
@@ -16,10 +16,10 @@
1616
"access": "public"
1717
},
1818
"dependencies": {
19-
"@sentry/core": "5.4.3",
20-
"@sentry/hub": "5.4.3",
21-
"@sentry/types": "5.4.2",
22-
"@sentry/utils": "5.4.2",
19+
"@sentry/core": "5.5.0",
20+
"@sentry/hub": "5.5.0",
21+
"@sentry/types": "5.5.0",
22+
"@sentry/utils": "5.5.0",
2323
"cookie": "0.3.1",
2424
"https-proxy-agent": "2.2.1",
2525
"lru_map": "0.3.3",

packages/node/src/backend.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BaseBackend, Dsn, getCurrentHub } from '@sentry/core';
2-
import { Event, EventHint, Mechanism, Options, Severity, Transport } from '@sentry/types';
2+
import { Event, EventHint, Mechanism, Options, Severity, Transport, TransportOptions } from '@sentry/types';
33
import {
44
addExceptionTypeValue,
55
isError,
@@ -17,8 +17,6 @@ import { HTTPSTransport, HTTPTransport } from './transports';
1717
* @see NodeClient for more information.
1818
*/
1919
export interface NodeOptions extends Options {
20-
[key: string]: any;
21-
2220
/** Callback that is executed when a fatal global error occurs. */
2321
onFatalError?(error: Error): void;
2422

@@ -57,14 +55,13 @@ export class NodeBackend extends BaseBackend<NodeOptions> {
5755

5856
const dsn = new Dsn(this._options.dsn);
5957

60-
const transportOptions = this._options.transportOptions || { dsn };
61-
const clientOptions = ['httpProxy', 'httpsProxy', 'caCerts'];
62-
63-
for (const option of clientOptions) {
64-
if (this._options[option] || transportOptions[option]) {
65-
transportOptions[option] = transportOptions[option] || this._options[option];
66-
}
67-
}
58+
const transportOptions: TransportOptions = {
59+
...this._options.transportOptions,
60+
...(this._options.httpProxy && { httpProxy: this._options.httpProxy }),
61+
...(this._options.httpsProxy && { httpsProxy: this._options.httpsProxy }),
62+
...(this._options.caCerts && { caCerts: this._options.caCerts }),
63+
dsn: this._options.dsn,
64+
};
6865

6966
if (this._options.transport) {
7067
return new this._options.transport(transportOptions);

0 commit comments

Comments
 (0)