Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tap(null, (exception) => {
if (this.shouldReport(exception)) {
Sentry.withScope(scope => {
// TODO: When https://github.com/nestjs/nest/issues/1581 gets implemented switch to that
switch(this.options.context){
case 'Http': return this.captureHttpException(scope, http, exception);
case 'Ws': return this.captureWsException(scope, ws, exception);
case 'Rpc': return this.captureRpcException(scope, rpc, exception);
}
});
}
})
);
import { transform, TransformOptions } from './api/transform';
import { storeURL } from './api/store';
import { resolveHost, getVersion } from './utils';
import { Upload, InputFile, UploadOptions, StoreUploadOptions } from './api/upload';
import { preview, PreviewOptions } from './api/preview';
import { CloudClient } from './api/cloud';
import { StoreParams } from './filelink';
import {
picker,
PickerInstance,
PickerOptions,
} from './picker';
/* istanbul ignore next */
Sentry.addBreadcrumb({ category: 'sdk', message: 'filestack-js-sdk scope' });
export interface Session {
apikey: string;
urls: Hosts;
cname?: string;
policy?: string;
signature?: string;
}
export interface Security {
policy: string;
signature: string;
}
export interface ClientOptions {
[option: string]: any;
constructor(apikey: string, options?: ClientOptions) {
super();
/* istanbul ignore next */
Sentry.configureScope(scope => {
scope.setTag('apikey', apikey);
scope.setTag('sdk-version', 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');
}
const { urls } = config;
this.session = { apikey, urls };
if (options) {
const { cname, security } = options;
this.setSecurity(security);
this.setCname(cname);
upload.on('error', (e) => {
Sentry.withScope(scope => {
scope.setExtras(e.details);
scope.setExtras({ uploadOptions: options, storeOptions });
Sentry.captureException(e);
});
this.emit('upload.error', e);
});
private captureException(scope: Scope, exception): void {
if (this.options.level) scope.setLevel(this.options.level);
if (this.options.fingerprint) scope.setFingerprint(this.options.fingerprint);
if (this.options.extra) for (const key in this.options.extra) {
if(this.options.extra.hasOwnProperty(key)) scope.setExtra(key, this.options.extra[key]);
}
for (const tag in this.options.tags) {
scope.setTag(tag, this.options.tags[tag])
}
Sentry.captureException(exception);
}
Sentry.withScope(scope => {
scope.setExtras(e.details);
scope.setExtras({ uploadOptions: options, storeOptions });
Sentry.captureException(e);
});
public handler(event: PromiseRejectionEvent): void {
captureException(event.reason);
}
/**