Skip to content

Commit

Permalink
perf: move sentry to lazy loaded bundle by lazy invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi authored and shauke committed Feb 23, 2021
1 parent ac0b35a commit 983ae82
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/app/core/utils/default-error-handler.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { ErrorHandler, Injectable, Injector } from '@angular/core';
import * as Sentry from '@sentry/browser';

import { FeatureToggleService } from './feature-toggle/feature-toggle.service';

@Injectable()
export class DefaultErrorhandler implements ErrorHandler {
constructor(private injector: Injector) {}

handleError(error: Error): void {
async handleError(error: Error) {
if (this.injector.get(FeatureToggleService)?.enabled('sentry')) {
Sentry.captureException(error);
await import('@sentry/browser').then(sentry => {
sentry.captureException(error);
});
}
console.error(error);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createSelector } from '@ngrx/store';
import { User } from '@sentry/browser';
import { UUID } from 'angular2-uuid';

import { Customer } from 'ish-core/models/customer/customer.model';
import { User } from 'ish-core/models/user/user.model';
import { getLoggedInCustomer, getLoggedInUser } from 'ish-core/store/customer/user';
import { getSelectedProduct } from 'ish-core/store/shopping/products';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { User } from '@sentry/browser';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { AccountFacade } from 'ish-core/facades/account.facade';
import { Customer } from 'ish-core/models/customer/customer.model';
import { User } from 'ish-core/models/user/user.model';

@Component({
selector: 'ish-account-user-info',
Expand Down
5 changes: 5 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,11 @@
"filePattern": "^(?!.*/extensions/seo/.*$).*$",
"message": "Imports from @ngx-meta are only allowed in SEO extension."
},
{
"import": "User",
"from": "@sentry/browser",
"message": "You probably meant to import the ISH PWA user model."
},
{
"import": ".*ExportsModule",
"from": ".*.*",
Expand Down

0 comments on commit 983ae82

Please sign in to comment.