From 3144e7693dfde05c804b7e128a733aaf5e8267a3 Mon Sep 17 00:00:00 2001 From: Maxim Balaganskiy Date: Wed, 31 Jul 2019 16:18:19 +1000 Subject: [PATCH] feat(alert-service): log an error and display a message --- src/services/alert-service.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/services/alert-service.ts b/src/services/alert-service.ts index bcddc7f..3c30cec 100644 --- a/src/services/alert-service.ts +++ b/src/services/alert-service.ts @@ -3,11 +3,12 @@ import { ProgressHandle } from "./progress-handle"; import { IDisposable } from "../interfaces/i-disposable"; import { AlertModal } from "../elements/alert-modal/alert-modal"; import { I18NResource } from "../interfaces/i18n-resource"; +import { ApplicationInsights } from "@microsoft/applicationinsights-web"; @au.autoinject export class AlertService { constructor(private toast: au.MdToastService, private eventAggregator: au.EventAggregator, private templatingEngine: au.TemplatingEngine, - private i18n: au.I18N) { + private i18n: au.I18N, private appInsights: ApplicationInsights) { this.logger = au.getLogger("AlertService"); this.i18nResource = this.i18n.tr("aurelia-toolkit:alert", { returnObjects: true }) as any as I18NResource["alert"]; } @@ -52,6 +53,11 @@ export class AlertService { return this.alert(message, "error", "red"); } + criticalError(message: string, error: any): Promise { + this.appInsights.trackException(error); + return this.alert(message, "error", "red"); + } + confirmToast(message: string, timeout?: number) { this.toast.show(message as any, timeout || this.defaultTimeout); }