Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: getsentry/sentry-javascript
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4.1.1
Choose a base ref
...
head repository: getsentry/sentry-javascript
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4.2.0
Choose a head ref
  • 9 commits
  • 74 files changed
  • 3 contributors

Commits on Oct 10, 2018

  1. Copy the full SHA
    6c93dc1 View commit details

Commits on Oct 12, 2018

  1. Copy the full SHA
    56e7648 View commit details

Commits on Oct 17, 2018

  1. Copy the full SHA
    f48596e View commit details
  2. Copy the full SHA
    81a3412 View commit details

Commits on Oct 18, 2018

  1. Copy the full SHA
    b7cf873 View commit details

Commits on Oct 22, 2018

  1. meta: 4.2.0 changelog

    HazAT committed Oct 22, 2018
    Copy the full SHA
    e9bcfb6 View commit details
  2. meta: Update pack script

    HazAT committed Oct 22, 2018
    Copy the full SHA
    d236b3f View commit details
  3. meta: Fix prerelease script

    HazAT committed Oct 22, 2018
    Copy the full SHA
    6a541b7 View commit details
  4. release: 4.2.0

    HazAT committed Oct 22, 2018
    Copy the full SHA
    4b4e172 View commit details
Showing with 2,528 additions and 2,079 deletions.
  1. +7 −1 CHANGELOG.md
  2. +1 −1 lerna.json
  3. +5 −4 packages/browser/package.json
  4. +4 −0 packages/browser/rollup.config.js
  5. +2 −1 packages/browser/src/backend.ts
  6. +88 −56 packages/browser/src/integrations/breadcrumbs.ts
  7. +12 −3 packages/browser/src/integrations/globalhandlers.ts
  8. +14 −3 packages/browser/src/integrations/linkederrors.ts
  9. +23 −15 packages/browser/src/integrations/pluggable/ember.ts
  10. +23 −17 packages/browser/src/integrations/pluggable/vue.ts
  11. +9 −2 packages/browser/src/integrations/reportingobserver.ts
  12. +6 −1 packages/browser/src/integrations/trycatch.ts
  13. +11 −5 packages/browser/src/integrations/useragent.ts
  14. +5 −2 packages/browser/src/sdk.ts
  15. +1 −1 packages/browser/src/version.ts
  16. +66 −37 packages/browser/test/index.test.ts
  17. +7 −0 packages/browser/test/integration/console-logs.js
  18. +7 −1 packages/browser/test/integration/init.js
  19. +1,212 −1,200 packages/browser/test/integration/test.js
  20. +0 −1 packages/browser/test/integration/throw-error.js
  21. +1 −0 packages/browser/test/karma/integration-files.js
  22. +5 −5 packages/core/package.json
  23. +1 −1 packages/core/src/basebackend.ts
  24. +33 −44 packages/core/src/baseclient.ts
  25. +1 −2 packages/core/src/index.ts
  26. +15 −8 packages/core/src/integrations/dedupe.ts
  27. +1 −1 packages/core/src/integrations/functiontostring.ts
  28. +25 −16 packages/core/src/integrations/inboundfilters.ts
  29. +98 −0 packages/core/src/integrations/index.ts
  30. +14 −9 packages/core/src/integrations/pluggable/debug.ts
  31. +13 −4 packages/core/src/integrations/pluggable/rewriteframes.ts
  32. +2 −2 packages/core/src/integrations/sdkinformation.ts
  33. +9 −7 packages/core/src/interfaces.ts
  34. +10 −4 packages/core/src/logger.ts
  35. +5 −33 packages/core/src/sdk.ts
  36. +46 −60 packages/core/test/lib/base.test.ts
  37. +38 −18 packages/core/test/lib/integrations/inboundfilters.test.ts
  38. +124 −0 packages/core/test/lib/integrations/index.test.ts
  39. +1 −1 packages/core/test/lib/integrations/rewriteframes.test.ts
  40. +41 −29 packages/core/test/lib/sdk.test.ts
  41. +24 −0 packages/core/test/mocks/integration.ts
  42. +3 −3 packages/hub/package.json
  43. +81 −29 packages/hub/src/hub.ts
  44. +2 −2 packages/hub/src/index.ts
  45. +3 −1 packages/hub/src/interfaces.ts
  46. +24 −6 packages/hub/src/scope.ts
  47. +1 −1 packages/hub/test/{lib → }/global.test.ts
  48. +4 −6 packages/hub/test/{lib → }/hub.test.ts
  49. +1 −1 packages/hub/test/{lib → }/scope.test.ts
  50. +3 −3 packages/minimal/package.json
  51. +5 −5 packages/node/package.json
  52. +1 −2 packages/node/src/backend.ts
  53. +3 −69 packages/node/src/handlers.ts
  54. +36 −29 packages/node/src/integrations/console.ts
  55. +28 −23 packages/node/src/integrations/http.ts
  56. +12 −4 packages/node/src/integrations/linkederrors.ts
  57. +79 −4 packages/node/src/integrations/onuncaughtexception.ts
  58. +33 −21 packages/node/src/integrations/onunhandledrejection.ts
  59. +12 −6 packages/node/src/integrations/pluggable/modules.ts
  60. +12 −5 packages/node/src/integrations/pluggable/transaction.ts
  61. +13 −3 packages/node/src/sdk.ts
  62. +1 −1 packages/node/src/version.ts
  63. +21 −21 packages/node/test/domain.test.ts
  64. +0 −1 packages/node/test/index.test.ts
  65. +2 −1 packages/node/test/onunhandledrejection.test.ts
  66. +1 −1 packages/types/package.json
  67. +20 −2 packages/types/src/index.ts
  68. +2 −2 packages/utils/package.json
  69. +59 −0 packages/utils/src/logger.ts
  70. +37 −1 packages/utils/src/misc.ts
  71. +1 −1 scripts/craft-pre-release.sh
  72. +4 −4 scripts/pack-and-upload.sh
  73. +5 −0 scripts/package-and-upload-to-zeus.js
  74. +9 −226 yarn.lock
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,13 @@

## Unreleased

- [tbd] tbd
## 4.2.0

- [browser] fix: Make `addBreadcrumb` sync internally, `beforeBreadcrumb` is now only sync
- [browser] fix: Remove internal `console` guard in `beforeBreadcrumb`
- [core] feat: Integrations now live on the `Client`. This means that when binding a new Client to the `Hub` the client
itself can decide which integration should run.
- [node] ref: Simplify Node global handlers code

## 4.1.1

2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"lerna": "3.4.0",
"version": "4.1.1",
"version": "4.2.0",
"packages": "packages/*",
"ignore": "raven-*",
"npmClient": "yarn",
9 changes: 5 additions & 4 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sentry/browser",
"version": "4.1.1",
"version": "4.2.0",
"description": "Offical Sentry SDK for browsers",
"repository": "git://github.com/getsentry/raven-js.git",
"homepage": "https://github.com/getsentry/raven-js/tree/master/packages/browser",
@@ -15,9 +15,9 @@
"access": "public"
},
"dependencies": {
"@sentry/core": "4.1.1",
"@sentry/types": "4.1.0",
"@sentry/utils": "4.1.1"
"@sentry/core": "4.2.0",
"@sentry/types": "4.2.0",
"@sentry/utils": "4.2.0"
},
"devDependencies": {
"@types/md5": "2.1.32",
@@ -42,6 +42,7 @@
"rollup-plugin-license": "^0.6.0",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-npm": "^2.0.0",
"rollup-plugin-shim": "^1.0.0",
"rollup-plugin-typescript2": "^0.13.0",
"rollup-plugin-uglify": "^3.0.0",
"sinon": "^5.0.3",
4 changes: 4 additions & 0 deletions packages/browser/rollup.config.js
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import uglify from 'rollup-plugin-uglify';
import resolve from 'rollup-plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import license from 'rollup-plugin-license';
import shim from 'rollup-plugin-shim';

const commitHash = require('child_process')
.execSync('git rev-parse --short HEAD', { encoding: 'utf-8' })
@@ -17,6 +18,9 @@ const bundleConfig = {
},
context: 'window',
plugins: [
shim({
domain: `export default {}`,
}),
typescript({
tsconfig: 'tsconfig.build.json',
tsconfigOverride: { compilerOptions: { declaration: false } },
3 changes: 2 additions & 1 deletion packages/browser/src/backend.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BaseBackend, logger, Options, SentryError } from '@sentry/core';
import { BaseBackend, Options, SentryError } from '@sentry/core';
import { SentryEvent, SentryEventHint, SentryResponse, Severity, Status } from '@sentry/types';
import { isDOMError, isDOMException, isError, isErrorEvent, isPlainObject } from '@sentry/utils/is';
import { logger } from '@sentry/utils/logger';
import { supportsBeacon, supportsFetch } from '@sentry/utils/supports';
import { eventFromPlainObject, eventFromStacktrace, prepareFramesForEvent } from './parsers';
import { computeStackTrace } from './tracekit';
144 changes: 88 additions & 56 deletions packages/browser/src/integrations/breadcrumbs.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { API, getCurrentHub, logger } from '@sentry/core';
import { Integration, Severity } from '@sentry/types';
import { API, getCurrentHub } from '@sentry/core';
import { Breadcrumb, Integration, SentryBreadcrumbHint, Severity } from '@sentry/types';
import { isFunction, isString } from '@sentry/utils/is';
import { logger } from '@sentry/utils/logger';
import { getEventDescription, getGlobalObject, parseUrl } from '@sentry/utils/misc';
import { deserialize, fill } from '@sentry/utils/object';
import { includes, safeJoin } from '@sentry/utils/string';
import { supportsBeacon, supportsHistory, supportsNativeFetch } from '@sentry/utils/supports';
import { BrowserOptions } from '../backend';
import { BrowserClient } from '../client';
import { breadcrumbEventHandler, keypressEventHandler, wrap } from './helpers';

const global = getGlobalObject() as Window;
@@ -21,28 +22,6 @@ export interface SentryWrappedXMLHttpRequest extends XMLHttpRequest {
};
}

/** JSDoc */
function addSentryBreadcrumb(serializedData: string): void {
// There's always something that can go wrong with deserialization...
try {
const event: { [key: string]: any } = deserialize(serializedData);

getCurrentHub().addBreadcrumb(
{
category: 'sentry',
event_id: event.event_id,
level: event.level || Severity.fromString('error'),
message: getEventDescription(event),
},
{
event,
},
);
} catch (_oO) {
logger.error('Error while adding sentry type breadcrumb');
}
}

/** JSDoc */
interface BreadcrumbIntegrations {
beacon?: boolean;
@@ -61,6 +40,11 @@ export class Breadcrumbs implements Integration {
*/
public name: string = 'Breadcrumbs';

/**
* @inheritDoc
*/
public static id: string = 'Breadcrumbs';

/** JSDoc */
private readonly options: BreadcrumbIntegrations;

@@ -81,7 +65,7 @@ export class Breadcrumbs implements Integration {
}

/** JSDoc */
private instrumentBeacon(options: { filterUrl?: string }): void {
private instrumentBeacon(): void {
if (!supportsBeacon()) {
return;
}
@@ -95,11 +79,16 @@ export class Breadcrumbs implements Integration {
// https://developer.mozilla.org/en-US/docs/Web/API/Beacon_API/Using_the_Beacon_API
const result = originalBeaconFunction.apply(this, args);

// if Sentry key appears in URL, don't capture it as a request
// but rather as our own 'sentry' type breadcrumb
if (options.filterUrl && includes(url, options.filterUrl)) {
addSentryBreadcrumb(data);
return result;
const client = getCurrentHub().getClient() as BrowserClient;
const dsn = client && client.getDsn();
if (dsn) {
const filterUrl = new API(dsn).getStoreEndpoint();
// if Sentry key appears in URL, don't capture it as a request
// but rather as our own 'sentry' type breadcrumb
if (filterUrl && includes(url, filterUrl)) {
addSentryBreadcrumb(data);
return result;
}
}

// What is wrong with you TypeScript...
@@ -113,7 +102,7 @@ export class Breadcrumbs implements Integration {
breadcrumbData.level = Severity.Error;
}

getCurrentHub().addBreadcrumb(breadcrumbData, {
Breadcrumbs.addBreadcrumb(breadcrumbData, {
input: args,
result,
});
@@ -156,14 +145,14 @@ export class Breadcrumbs implements Integration {
}
}

getCurrentHub().addBreadcrumb(breadcrumbData, {
Breadcrumbs.addBreadcrumb(breadcrumbData, {
input: args,
level,
});

// this fails for some browsers. :(
if (originalConsoleLevel) {
originalConsoleLevel.apply(global.console, args);
Function.prototype.apply.call(originalConsoleLevel, global.console, args);
}
};
});
@@ -182,7 +171,7 @@ export class Breadcrumbs implements Integration {
}

/** JSDoc */
private instrumentFetch(options: { filterUrl?: string }): void {
private instrumentFetch(): void {
if (!supportsNativeFetch()) {
return;
}
@@ -208,13 +197,18 @@ export class Breadcrumbs implements Integration {
method = args[1].method;
}

// if Sentry key appears in URL, don't capture it as a request
// but rather as our own 'sentry' type breadcrumb
if (options.filterUrl && includes(url, options.filterUrl)) {
if (method === 'POST' && args[1] && args[1].body) {
addSentryBreadcrumb(args[1].body);
const client = getCurrentHub().getClient() as BrowserClient;
const dsn = client && client.getDsn();
if (dsn) {
const filterUrl = new API(dsn).getStoreEndpoint();
// if Sentry key appears in URL, don't capture it as a request
// but rather as our own 'sentry' type breadcrumb
if (filterUrl && includes(url, filterUrl)) {
if (method === 'POST' && args[1] && args[1].body) {
addSentryBreadcrumb(args[1].body);
}
return originalFetch.apply(global, args);
}
return originalFetch.apply(global, args);
}

const fetchData: {
@@ -230,7 +224,7 @@ export class Breadcrumbs implements Integration {
.apply(global, args)
.then((response: Response) => {
fetchData.status_code = response.status;
getCurrentHub().addBreadcrumb(
Breadcrumbs.addBreadcrumb(
{
category: 'fetch',
data: fetchData,
@@ -244,7 +238,7 @@ export class Breadcrumbs implements Integration {
return response;
})
.catch((error: Error) => {
getCurrentHub().addBreadcrumb(
Breadcrumbs.addBreadcrumb(
{
category: 'fetch',
data: fetchData,
@@ -295,7 +289,7 @@ export class Breadcrumbs implements Integration {
from = parsedFrom.relative;
}

getCurrentHub().addBreadcrumb({
Breadcrumbs.addBreadcrumb({
category: 'navigation',
data: {
from,
@@ -334,7 +328,7 @@ export class Breadcrumbs implements Integration {
}

/** JSDoc */
private instrumentXHR(options: { filterUrl?: string }): void {
private instrumentXHR(): void {
if (!('XMLHttpRequest' in global)) {
return;
}
@@ -369,11 +363,18 @@ export class Breadcrumbs implements Integration {
method: args[0],
url: args[1],
};
// if Sentry key appears in URL, don't capture it as a request
// but rather as our own 'sentry' type breadcrumb
if (isString(url) && (options.filterUrl && includes(url, options.filterUrl))) {
this.__sentry_own_request__ = true;

const client = getCurrentHub().getClient() as BrowserClient;
const dsn = client && client.getDsn();
if (dsn) {
const filterUrl = new API(dsn).getStoreEndpoint();
// if Sentry key appears in URL, don't capture it as a request
// but rather as our own 'sentry' type breadcrumb
if (isString(url) && (filterUrl && includes(url, filterUrl))) {
this.__sentry_own_request__ = true;
}
}

return originalOpen.apply(this, args);
},
);
@@ -404,7 +405,7 @@ export class Breadcrumbs implements Integration {
} catch (e) {
/* do nothing */
}
getCurrentHub().addBreadcrumb(
Breadcrumbs.addBreadcrumb(
{
category: 'xhr',
data: xhr.__sentry_xhr__,
@@ -447,6 +448,18 @@ export class Breadcrumbs implements Integration {
},
);
}

/**
* Helper that checks if integration is enabled on the client.
* @param breadcrumb Breadcrumb
* @param hint SentryBreadcrumbHint
*/
public static addBreadcrumb(breadcrumb: Breadcrumb, hint?: SentryBreadcrumbHint): void {
if (getCurrentHub().getIntegration(Breadcrumbs)) {
getCurrentHub().addBreadcrumb(breadcrumb, hint);
}
}

/**
* Instrument browser built-ins w/ breadcrumb capturing
* - Console API
@@ -455,26 +468,45 @@ export class Breadcrumbs implements Integration {
* - Fetch API
* - History API
*/
public install(options: BrowserOptions = {}): void {
const filterUrl = options.dsn && new API(options.dsn).getStoreEndpoint();

public setupOnce(): void {
if (this.options.console) {
this.instrumentConsole();
}
if (this.options.dom) {
this.instrumentDOM();
}
if (this.options.xhr) {
this.instrumentXHR({ filterUrl });
this.instrumentXHR();
}
if (this.options.fetch) {
this.instrumentFetch({ filterUrl });
this.instrumentFetch();
}
if (this.options.beacon) {
this.instrumentBeacon({ filterUrl });
this.instrumentBeacon();
}
if (this.options.history) {
this.instrumentHistory();
}
}
}

/** JSDoc */
function addSentryBreadcrumb(serializedData: string): void {
// There's always something that can go wrong with deserialization...
try {
const event: { [key: string]: any } = deserialize(serializedData);
Breadcrumbs.addBreadcrumb(
{
category: 'sentry',
event_id: event.event_id,
level: event.level || Severity.fromString('error'),
message: getEventDescription(event),
},
{
event,
},
);
} catch (_oO) {
logger.error('Error while adding sentry type breadcrumb');
}
}
Loading