Skip to content

Commit e20cc10

Browse files
fix(sentry): remove discouraged configureScope (#417)
* 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>
1 parent a11ebc0 commit e20cc10

File tree

4 files changed

+30
-29
lines changed

4 files changed

+30
-29
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ Error contains details field with responseBody, responseHeaders, code (only when
227227
```
228228

229229
## Sentry Integration
230-
filestack-js now using [@sentry/minimal](https://www.npmjs.com/package/@sentry/minimal) package.
230+
231+
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).
231232

232233
## Versioning
233234

package-lock.json

Lines changed: 19 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"dependencies": {
4343
"@babel/runtime": "^7.8.4",
4444
"@filestack/loader": "^1.0.4",
45-
"@sentry/minimal": "^5.12.0",
45+
"@sentry/minimal": "^6.1.0",
4646
"abab": "^2.0.3",
4747
"debug": "^4.1.1",
4848
"eventemitter3": "^4.0.0",

src/lib/client.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,14 @@ export class Client extends EventEmitter {
110110
return Utils;
111111
}
112112

113-
constructor(apikey: string, options?: ClientOptions) {
113+
constructor(apikey: string, private options?: ClientOptions) {
114114
super();
115115

116116
/* istanbul ignore if */
117117
if (options && options.forwardErrors) {
118118
this.forwardErrors = options.forwardErrors;
119119
}
120120

121-
/* istanbul ignore next */
122-
Sentry.configureScope(scope => {
123-
scope.setTag('apikey', apikey);
124-
scope.setTag('sdk-version', Utils.getVersion());
125-
scope.setExtra('clientOptions', options);
126-
});
127-
128121
if (!apikey || typeof apikey !== 'string' || apikey.length === 0) {
129122
throw new Error('An apikey is required to initialize the Filestack client');
130123
}
@@ -310,7 +303,7 @@ export class Client extends EventEmitter {
310303
* @param uploadTags Optional tags visible in webhooks.
311304
* @param headers Optional headers to send
312305
*/
313-
storeURL(url: string, storeParams?: StoreParams, token?: any, security?: Security, uploadTags?: UploadTags, headers?: {[key: string]: string}): Promise<Object> {
306+
storeURL(url: string, storeParams?: StoreParams, token?: any, security?: Security, uploadTags?: UploadTags, headers?: { [key: string]: string }): Promise<Object> {
314307
return storeURL({
315308
session: this.session,
316309
url,
@@ -439,6 +432,9 @@ export class Client extends EventEmitter {
439432
upload.on('error', e => {
440433
if (this.forwardErrors) {
441434
Sentry.withScope(scope => {
435+
scope.setTag('filestack-apikey', this.session.apikey);
436+
scope.setTag('filestack-version', Utils.getVersion());
437+
scope.setExtra('filestack-options', this.options);
442438
scope.setExtras({ uploadOptions: options, storeOptions, details: e.details });
443439
e.message = `FS-${e.message}`;
444440

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

0 commit comments

Comments
 (0)