@sentry/browser
Advanced tools
Comparing version 0.3.0 to 0.4.0-0
@@ -1,1 +0,1 @@ | ||
export { SentryBrowser, ISentryBrowserOptions } from './lib/SentryBrowser'; | ||
export { SentryBrowser, BrowserOptions as SentryBrowserOptions } from './lib/browser'; |
@@ -1,5 +0,197 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var SentryBrowser_1 = require("./lib/SentryBrowser"); | ||
exports.SentryBrowser = SentryBrowser_1.SentryBrowser; | ||
//# sourceMappingURL=index.js.map | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var RavenJS = require('raven-js'); | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
} | ||
function __generator(thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [0, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
} | ||
var Raven = RavenJS; | ||
var sendRavenEvent = Raven._sendProcessedPayload; | ||
var SentryBrowser = /** @class */ (function () { | ||
function SentryBrowser(client, options) { | ||
if (options === void 0) { options = {}; } | ||
this.client = client; | ||
this.options = options; | ||
this.capturing = false; | ||
} | ||
SentryBrowser.prototype.install = function () { | ||
Raven.config(this.client.dsn.toString(), this.options).install(); | ||
// Hook into Raven's breadcrumb mechanism. This allows us to intercept | ||
// both breadcrumbs created internally by Raven and pass them to the | ||
// Client first, before actually capturing them. | ||
Raven.setBreadcrumbCallback(this.interceptRavenBreadcrumb.bind(this)); | ||
// Hook into Raven's internal event sending mechanism. This allows us to | ||
// intercept events generated by Raven in the same way as events created | ||
// via `SentryBrowser.captureException`. In both cases, we call | ||
// `Client.send` with the intercepted event, so that the client can | ||
// override the sending mechanism. | ||
Raven._sendProcessedPayload = this.interceptRavenSend.bind(this); | ||
return Promise.resolve(true); | ||
}; | ||
SentryBrowser.prototype.getRaven = function () { | ||
return Raven; | ||
}; | ||
SentryBrowser.prototype.captureException = function (exception) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
// We are being called by the Client. We must not send the exception here, | ||
// which is why we capture and return it. The Client will then call `send`. | ||
return [2 /*return*/, this.capture(function () { return Raven.captureException(exception); })]; | ||
}); | ||
}); | ||
}; | ||
SentryBrowser.prototype.captureMessage = function (message) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
// We are being called by the Client. We must not send the message here, | ||
// which is why we capture and return it. The Client will then call `send`. | ||
return [2 /*return*/, this.capture(function () { return Raven.captureMessage(message); })]; | ||
}); | ||
}); | ||
}; | ||
SentryBrowser.prototype.captureBreadcrumb = function (breadcrumb) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
// We are being called by the Client. This means, the breadcrumb has been | ||
// processed already and we can pass it on to Raven. | ||
return [2 /*return*/, this.capture(function () { return Raven.captureBreadcrumb(breadcrumb); })]; | ||
}); | ||
}); | ||
}; | ||
SentryBrowser.prototype.send = function (event) { | ||
return new Promise(function (resolve, reject) { | ||
sendRavenEvent(event, function (error) { | ||
if (error) { | ||
reject(error); | ||
} | ||
else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
}; | ||
SentryBrowser.prototype.wrap = function (fn, options) { | ||
return Raven.wrap(options, fn); | ||
}; | ||
SentryBrowser.prototype.setOptions = function (options) { | ||
Object.assign(this.options, options); | ||
Object.assign(Raven._globalOptions, this.options); | ||
return Promise.resolve(); | ||
}; | ||
SentryBrowser.prototype.getContext = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, Promise.resolve(Raven.getContext())]; | ||
}); | ||
}); | ||
}; | ||
SentryBrowser.prototype.setContext = function (context) { | ||
if (context.extra) { | ||
Raven.setExtraContext(context.extra); | ||
} | ||
if (context.user) { | ||
Raven.setUserContext(context.user); | ||
} | ||
if (context.tags) { | ||
Raven.setTagsContext(context.tags); | ||
} | ||
return Promise.resolve(); | ||
}; | ||
SentryBrowser.prototype.interceptRavenSend = function (event) { | ||
if (this.capturing) { | ||
// This event was requested via `SentryBrowser.captureException` or | ||
// `SentryBrowser.captureMessage`. We capture it, which will return it to | ||
// the `Client`. The client will call its `send` method automatically. | ||
this.captured = event; | ||
} | ||
else { | ||
// This event was generated inside RavenJS in a wrapped function or | ||
// global exception hook. We have to manually pass it to `Client.send`. | ||
// The client will then run all callbacks and decide how to send this | ||
// event. | ||
this.client.send(event); | ||
} | ||
}; | ||
SentryBrowser.prototype.interceptRavenBreadcrumb = function (crumb) { | ||
if (this.capturing) { | ||
// This breadcrumb is being captured explicitly by the Client. We return | ||
// it so that Raven uses its internal mechanism to store it. | ||
this.captured = crumb; | ||
return crumb; | ||
} | ||
// The breadcrumb has been generated internally by Raven. We return `false` | ||
// to prevent Raven's default mechanism and pass it to the client instead. | ||
// The client can then run all callbacks and decide how to store the | ||
// breadcrumb. If SentryBrowser is in charge, the Client will call | ||
// `SentryBrowser.captureBreadcrumb` next, which will capture it (see | ||
// above). | ||
this.client.captureBreadcrumb(crumb); | ||
return false; | ||
}; | ||
SentryBrowser.prototype.capture = function (callback) { | ||
this.captured = undefined; | ||
this.capturing = true; | ||
callback(); | ||
var captured = this.captured; | ||
this.captured = undefined; | ||
this.capturing = false; | ||
if (captured === undefined) { | ||
throw new Error('Could not capture.'); | ||
} | ||
return captured; | ||
}; | ||
return SentryBrowser; | ||
}()); | ||
exports.SentryBrowser = SentryBrowser; |
{ | ||
"name": "@sentry/browser", | ||
"version": "0.3.0", | ||
"version": "0.4.0-0", | ||
"description": "Offical Sentry SDK for browsers", | ||
"author": "Sentry", | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"main": "dist/index.js", | ||
"typings": "dist/index.d.ts", | ||
"typescript": { | ||
"definition": "dist/index.d.ts" | ||
"types": "dist/index.d.ts", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@sentry/core": "^0.3.0", | ||
"raven-js": "^3.22.1" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^22.0.1", | ||
"@types/node": "^9.3.0", | ||
"@types/puppeteer": "^0.13.9", | ||
"jest": "^22.1.0", | ||
"npm-run-all": "^4.1.2", | ||
"prettier": "^1.10.2", | ||
"puppeteer": "^1.0.0", | ||
"rollup": "^0.54.0", | ||
"rollup-plugin-commonjs": "^8.2.6", | ||
"rollup-plugin-node-resolve": "^3.0.2", | ||
"rollup-plugin-uglify": "^2.0.1", | ||
"ts-jest": "^22.0.1", | ||
"ts-loader": "^3.2.0", | ||
"ts-node": "^4.1.0", | ||
"tslint": "^5.9.1", | ||
"tslint-config-prettier": "^1.6.0", | ||
"tslint-eslint-rules": "^4.1.1", | ||
"typescript": "^2.6.2", | ||
"vrsource-tslint-rules": "^5.8.0" | ||
"karma": "*", | ||
"prettier": "*", | ||
"rimraf": "*", | ||
"rollup": "*", | ||
"rollup-plugin-commonjs": "*", | ||
"rollup-plugin-node-resolve": "*", | ||
"rollup-plugin-typescript2": "*", | ||
"rollup-plugin-uglify": "*", | ||
"tslint": "*", | ||
"typescript": "*" | ||
}, | ||
"engines": { | ||
"node": ">=6.9.5", | ||
"npm": ">=3.10.7", | ||
"yarn": ">=1.0.2" | ||
"peerDependencies": { | ||
"@sentry/core": "^0.3.0" | ||
}, | ||
"scripts": { | ||
"build:bundle": "rollup --config", | ||
"build:browser:test": "rollup --config rollup.config.test.js", | ||
"build:typescript": "tsc -p tsconfig.json", | ||
"clean": "rm -rf ./dist", | ||
"dist": "npm-run-all clean build:typescript build:bundle build:browser:test", | ||
"test:browser": "jest --forceExit", | ||
"test:watch": "jest --watch --notify", | ||
"test": "npm-run-all dist test:browser", | ||
"size:check": "cat dist/build.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print $1,\"kB\";}'" | ||
}, | ||
"jest": { | ||
"transform": { | ||
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js" | ||
}, | ||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js", | ||
"jsx", | ||
"json" | ||
], | ||
"modulePathIgnorePatterns": [ | ||
"<rootDir>/dist/__mocks__" | ||
], | ||
"testPathIgnorePatterns": [ | ||
"/node_modules/", | ||
"rollup.*", | ||
"\\.d\\.(jsx?|tsx?)$", | ||
"\\.no-jest\\.(jsx?|tsx?)$", | ||
"/dist/" | ||
] | ||
}, | ||
"author": "Sentry", | ||
"license": "MIT" | ||
"build": "rollup --config", | ||
"clean": "rimraf dist coverage .rpt2_cache build", | ||
"lint": "tslint --config ../../tslint.json src/**/*", | ||
"format": "prettier --config ../../.prettierrc.json src/**/* --write", | ||
"test": "karma start karma.config.js", | ||
"test:watch": "karma start karma.config.js --auto-watch --no-single-run", | ||
"size:check": "cat build/bundle.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print $1,\"kB\";}'" | ||
} | ||
} |
@@ -20,8 +20,9 @@ <p align="center"> | ||
First you have to create the core and `use` a corresponding SDK. | ||
```javascript | ||
import * as Sentry from '@sentry/core'; | ||
import { Browser } from '@sentry/browser'; | ||
import { SentryBrowser } from '@sentry/Sentrybrowser'; | ||
Sentry.create('__DSN__') | ||
.use(Browser) | ||
.use(SentryBrowser) | ||
.install(); | ||
@@ -31,2 +32,3 @@ ``` | ||
After that you can call function on the global `sharedClient`: | ||
```javascript | ||
@@ -39,3 +41,4 @@ Sentry.getSharedClient().setTagsContext({ cordova: true }); | ||
If you don't want to use a global static instance of Sentry, you can create one on your own: | ||
If you don't want to use a global static instance of Sentry, you can create one | ||
on your own: | ||
@@ -61,2 +64,2 @@ ```javascript | ||
Notice, `install()` is a `Promise` but we internally wait until it is resolved, | ||
so it is save to call other function without waiting for it. | ||
so it is save to call other function without waiting for it. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
10
62
1
13653
5
1
212
- Removed@sentry/core@^0.3.0