Skip to content

Commit

Permalink
fix(sentry): remove discouraged configureScope (#417)
Browse files Browse the repository at this point in the history
* fix(sentry): remove discouraged configureScope

* Prefix Sentry keys; bump sentry/minimal

Co-Authored-By: Thinh Vo <5215128+thinhvo0108@users.noreply.github.com>

Co-authored-by: Thinh Vo <5215128+thinhvo0108@users.noreply.github.com>
  • Loading branch information
namoscato and thinhvo0108 authored Feb 23, 2021
1 parent a11ebc0 commit e20cc10
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 29 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ Error contains details field with responseBody, responseHeaders, code (only when
```

## Sentry Integration
filestack-js now using [@sentry/minimal](https://www.npmjs.com/package/@sentry/minimal) package.

If you're using [Sentry](https://sentry.io/welcome/) to monitor your application, Filestack will automatically report upload errors to Sentry, and tag them with helpful diagnostic information via [`@sentry/minimal`](https://github.com/getsentry/sentry-javascript/tree/master/packages/minimal).

## Versioning

Expand Down
37 changes: 19 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"dependencies": {
"@babel/runtime": "^7.8.4",
"@filestack/loader": "^1.0.4",
"@sentry/minimal": "^5.12.0",
"@sentry/minimal": "^6.1.0",
"abab": "^2.0.3",
"debug": "^4.1.1",
"eventemitter3": "^4.0.0",
Expand Down
17 changes: 8 additions & 9 deletions src/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,14 @@ export class Client extends EventEmitter {
return Utils;
}

constructor(apikey: string, options?: ClientOptions) {
constructor(apikey: string, private options?: ClientOptions) {
super();

/* istanbul ignore if */
if (options && options.forwardErrors) {
this.forwardErrors = options.forwardErrors;
}

/* istanbul ignore next */
Sentry.configureScope(scope => {
scope.setTag('apikey', apikey);
scope.setTag('sdk-version', Utils.getVersion());
scope.setExtra('clientOptions', options);
});

if (!apikey || typeof apikey !== 'string' || apikey.length === 0) {
throw new Error('An apikey is required to initialize the Filestack client');
}
Expand Down Expand Up @@ -310,7 +303,7 @@ export class Client extends EventEmitter {
* @param uploadTags Optional tags visible in webhooks.
* @param headers Optional headers to send
*/
storeURL(url: string, storeParams?: StoreParams, token?: any, security?: Security, uploadTags?: UploadTags, headers?: {[key: string]: string}): Promise<Object> {
storeURL(url: string, storeParams?: StoreParams, token?: any, security?: Security, uploadTags?: UploadTags, headers?: { [key: string]: string }): Promise<Object> {
return storeURL({
session: this.session,
url,
Expand Down Expand Up @@ -439,6 +432,9 @@ export class Client extends EventEmitter {
upload.on('error', e => {
if (this.forwardErrors) {
Sentry.withScope(scope => {
scope.setTag('filestack-apikey', this.session.apikey);
scope.setTag('filestack-version', Utils.getVersion());
scope.setExtra('filestack-options', this.options);
scope.setExtras({ uploadOptions: options, storeOptions, details: e.details });
e.message = `FS-${e.message}`;

Expand Down Expand Up @@ -500,6 +496,9 @@ export class Client extends EventEmitter {
/* istanbul ignore next */
upload.on('error', e => {
Sentry.withScope(scope => {
scope.setTag('filestack-apikey', this.session.apikey);
scope.setTag('filestack-version', Utils.getVersion());
scope.setExtra('filestack-options', this.options);
scope.setExtras(e.details);
scope.setExtras({ uploadOptions: options, storeOptions });
Sentry.captureException(e);
Expand Down

0 comments on commit e20cc10

Please sign in to comment.