@microsoft/applicationinsights-angularplugin-js 15.1.0 → 15.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/.eslintrc.json +74 -0
  2. package/NOTICE +17 -0
  3. package/PRIVACY +3 -0
  4. package/SECURITY.md +41 -0
  5. package/SUPPORT.md +14 -0
  6. package/karma.conf.js +43 -0
  7. package/ng-package.json +15 -0
  8. package/package.json +30 -47
  9. package/{lib/IErrorService.d.ts → src/lib/IErrorService.ts} +1 -0
  10. package/src/lib/applicationininsights-angularplugin-multiple-instace.spec.ts +245 -0
  11. package/src/lib/applicationinsights-angularplugin-error.service.spec.ts +113 -0
  12. package/src/lib/applicationinsights-angularplugin-error.service.ts +57 -0
  13. package/src/lib/applicationinsights-angularplugin-js.component.spec.ts +158 -0
  14. package/src/lib/applicationinsights-angularplugin-js.component.ts +203 -0
  15. package/src/lib/applicationinsights-angularplugin-js.module.ts +14 -0
  16. package/{public-api.d.ts → src/public-api.ts} +4 -0
  17. package/src/test.ts +13 -0
  18. package/tsconfig.lib.json +30 -0
  19. package/tsconfig.lib.prod.json +10 -0
  20. package/tsconfig.spec.json +17 -0
  21. package/esm2020/lib/IErrorService.mjs +0 -2
  22. package/esm2020/lib/applicationinsights-angularplugin-error.service.mjs +0 -52
  23. package/esm2020/lib/applicationinsights-angularplugin-js.component.mjs +0 -152
  24. package/esm2020/lib/applicationinsights-angularplugin-js.module.mjs +0 -23
  25. package/esm2020/microsoft-applicationinsights-angularplugin-js.mjs +0 -5
  26. package/esm2020/public-api.mjs +0 -8
  27. package/fesm2015/microsoft-applicationinsights-angularplugin-js.mjs +0 -231
  28. package/fesm2015/microsoft-applicationinsights-angularplugin-js.mjs.map +0 -1
  29. package/fesm2020/microsoft-applicationinsights-angularplugin-js.mjs +0 -230
  30. package/fesm2020/microsoft-applicationinsights-angularplugin-js.mjs.map +0 -1
  31. package/index.d.ts +0 -5
  32. package/lib/applicationinsights-angularplugin-error.service.d.ts +0 -16
  33. package/lib/applicationinsights-angularplugin-js.component.d.ts +0 -20
  34. package/lib/applicationinsights-angularplugin-js.module.d.ts +0 -7
  35. package/microsoft-applicationinsights-angularplugin-js-15.1.0.tgz +0 -0
@@ -0,0 +1,57 @@
1
+ import { Injectable } from "@angular/core";
2
+ import { IAppInsights } from "@microsoft/applicationinsights-common";
3
+ import { arrForEach, isFunction } from "@microsoft/applicationinsights-core-js";
4
+ import { IErrorService } from "./IErrorService";
5
+
6
+ @Injectable({
7
+ providedIn: "root"
8
+ })
9
+ export class ApplicationinsightsAngularpluginErrorService implements IErrorService {
10
+ public static instance: ApplicationinsightsAngularpluginErrorService = null;
11
+ private analyticsPlugin: IAppInsights;
12
+ private errorServices: IErrorService[] = [];
13
+
14
+ constructor() {
15
+ if (ApplicationinsightsAngularpluginErrorService.instance === null) {
16
+ ApplicationinsightsAngularpluginErrorService.instance = this;
17
+ }
18
+ }
19
+
20
+ public set plugin(analyticsPlugin: IAppInsights) {
21
+ this.analyticsPlugin = analyticsPlugin;
22
+ }
23
+
24
+ public clearErrorHandlers() {
25
+ this.errorServices = [];
26
+ }
27
+
28
+ public addErrorHandler(errorService: IErrorService): void {
29
+ if (errorService && isFunction(errorService.handleError)) {
30
+ this.errorServices.push(errorService);
31
+ }
32
+ }
33
+
34
+ public removeErrorHandler(errorService: IErrorService): void {
35
+ if (errorService && isFunction(errorService.handleError)) {
36
+ const idx = this.errorServices.indexOf(errorService);
37
+ if (idx !== -1) {
38
+ this.errorServices.splice(idx, 1);
39
+ }
40
+ }
41
+ }
42
+
43
+ handleError(error: any): void {
44
+ if (this.analyticsPlugin) {
45
+ this.analyticsPlugin.trackException({ exception: error });
46
+ }
47
+
48
+ if (this.errorServices && this.errorServices.length > 0) {
49
+ arrForEach(this.errorServices, errorService => {
50
+ if (isFunction(errorService.handleError)) {
51
+ errorService.handleError(error);
52
+ }
53
+ });
54
+ }
55
+ }
56
+ }
57
+
@@ -0,0 +1,158 @@
1
+ import { AppInsightsCore, IConfiguration, ITelemetryItem, IPlugin, IAppInsightsCore } from "@microsoft/applicationinsights-core-js";
2
+ import { IConfig, IPageViewTelemetry } from "@microsoft/applicationinsights-common";
3
+ import { AngularPlugin } from "./applicationinsights-angularplugin-js.component";
4
+ import { ComponentFixture, TestBed, fakeAsync, tick } from "@angular/core/testing";
5
+ import { Router } from "@angular/router";
6
+ import { ApplicationinsightsAngularpluginErrorService } from "./applicationinsights-angularplugin-error.service";
7
+ import { AnalyticsPlugin } from "@microsoft/applicationinsights-analytics-js";
8
+ import { RouterTestingModule } from "@angular/router/testing";
9
+ import { Component } from "@angular/core";
10
+
11
+ @Component({
12
+ template: "<p>Fake Home Component</p>"
13
+ })
14
+ class FakeHomeComponent {}
15
+ class FakeAboutComponent {}
16
+ describe("ReactAI", () => {
17
+
18
+ let fixture: ComponentFixture<AngularPlugin>;
19
+ let angularPlugin: AngularPlugin;
20
+ let analyticsPlugin: AnalyticsPlugin;
21
+ let core: AppInsightsCore;
22
+ let channel: ChannelPlugin;
23
+ let router: Router;
24
+
25
+ beforeEach(() => {
26
+ const spy = jasmine.createSpyObj("AnalyticsPlugin", ["trackPageView"]);
27
+ TestBed.configureTestingModule({
28
+ declarations: [AngularPlugin],
29
+ imports: [
30
+ RouterTestingModule.withRoutes([
31
+ { path: "home", component: FakeHomeComponent },
32
+ { path: "about", component: FakeAboutComponent },
33
+ { path: "test", component: FakeHomeComponent }
34
+ ])
35
+ ],
36
+ providers: [
37
+ { provide: AnalyticsPlugin, useValue: spy }
38
+ ]
39
+ });
40
+
41
+ TestBed.inject(ApplicationinsightsAngularpluginErrorService);
42
+ fixture = TestBed.createComponent(AngularPlugin);
43
+ angularPlugin = fixture.componentInstance;
44
+ router = TestBed.inject(Router);
45
+
46
+ // Get the spy on trackPageView from the spy object
47
+ // analyticsPluginSpy
48
+ TestBed.inject(AnalyticsPlugin) as jasmine.SpyObj<AnalyticsPlugin>;
49
+ fixture.detectChanges();
50
+
51
+ // Setup
52
+ analyticsPlugin = new AnalyticsPlugin();
53
+ core = new AppInsightsCore();
54
+ channel = new ChannelPlugin();
55
+
56
+ core.initialize({
57
+ instrumentationKey: "",
58
+ extensionConfig: {
59
+ [angularPlugin.identifier]: { }
60
+ }
61
+ } as IConfig & IConfiguration, [angularPlugin, analyticsPlugin, channel]);
62
+
63
+
64
+ });
65
+
66
+ afterEach(() => {
67
+ // Unload and remove any previous resources
68
+ core.unload(false);
69
+
70
+ // clean up
71
+ analyticsPlugin = undefined;
72
+ core = undefined;
73
+ channel = undefined;
74
+ ApplicationinsightsAngularpluginErrorService.instance = null; // reset the singleton instance to null for re-assignment
75
+
76
+ });
77
+
78
+ it("Dynamic Config Test: router could be added and removed", fakeAsync(()=> {
79
+ expect(angularPlugin["_getDbgPlgTargets"]().router).toEqual(undefined);
80
+ core.config.extensionConfig[angularPlugin.identifier].router = router;
81
+ tick(3000);
82
+ expect(angularPlugin["_getDbgPlgTargets"]().router).toEqual(router);
83
+ }));
84
+
85
+ it("Dynamic Config Test: trackPageView is updated when router changed", fakeAsync(()=> {
86
+ spyOn(angularPlugin, "trackPageView");
87
+ core.config.extensionConfig[angularPlugin.identifier].router = router;
88
+ tick(3000);
89
+ expect(angularPlugin["_getDbgPlgTargets"]().router).toEqual(router);
90
+
91
+ expect(angularPlugin.trackPageView).toHaveBeenCalledTimes(1);
92
+ let args = (angularPlugin.trackPageView as jasmine.Spy).calls.mostRecent().args;
93
+ let pageViewEvents: IPageViewTelemetry = args[0];
94
+ expect(pageViewEvents.uri).toEqual(router.url);
95
+ router.navigate(["about"]).then(() => {
96
+ expect(angularPlugin.trackPageView).toHaveBeenCalledTimes(1);
97
+ router.navigate(["test"]).then(() => {
98
+ expect(angularPlugin.trackPageView).toHaveBeenCalledTimes(2);
99
+ let funcArgs = (angularPlugin.trackPageView as jasmine.Spy).calls.mostRecent().args;
100
+ pageViewEvents = funcArgs[0];
101
+ expect(pageViewEvents.uri).toEqual("/test");
102
+ router.navigateByUrl("about").then(() => {
103
+ funcArgs = (angularPlugin.trackPageView as jasmine.Spy).calls.mostRecent().args;
104
+ pageViewEvents = funcArgs[0];
105
+ expect(pageViewEvents.uri).toEqual("/about");
106
+ });
107
+
108
+ });
109
+ });
110
+ }));
111
+ });
112
+
113
+ class ChannelPlugin implements IPlugin {
114
+ public isFlushInvoked = false;
115
+ public isTearDownInvoked = false;
116
+ public isResumeInvoked = false;
117
+ public isPauseInvoked = false;
118
+
119
+ public identifier = "Sender";
120
+
121
+ public priority: number = 1001;
122
+
123
+ constructor() {
124
+ this.processTelemetry = this._processTelemetry.bind(this);
125
+ }
126
+ public pause(): void {
127
+ this.isPauseInvoked = true;
128
+ }
129
+
130
+ public resume(): void {
131
+ this.isResumeInvoked = true;
132
+ }
133
+
134
+ public teardown(): void {
135
+ this.isTearDownInvoked = true;
136
+ }
137
+
138
+ flush(async?: boolean, callBack?: () => void): void {
139
+ this.isFlushInvoked = true;
140
+ if (callBack) {
141
+ callBack();
142
+ }
143
+ }
144
+
145
+ public processTelemetry(env: ITelemetryItem) { }
146
+
147
+ setNextPlugin(next: any) {
148
+ // no next setup
149
+ }
150
+
151
+ public initialize = (config: IConfiguration, core: IAppInsightsCore, plugin: IPlugin[]) => {
152
+ // Mocked - Do Nothing
153
+ };
154
+
155
+ private _processTelemetry(env: ITelemetryItem) {
156
+
157
+ }
158
+ }
@@ -0,0 +1,203 @@
1
+ import { Component, Injector} from "@angular/core";
2
+ import {
3
+ IConfig, IPageViewTelemetry, PropertiesPluginIdentifier, AnalyticsPluginIdentifier
4
+ } from "@microsoft/applicationinsights-common";
5
+ import {
6
+ IPlugin, IConfiguration, IAppInsightsCore, BaseTelemetryPlugin, arrForEach, ITelemetryItem, ITelemetryPluginChain,
7
+ IProcessTelemetryContext, getLocation, _throwInternal, eLoggingSeverity, _eInternalMessageId, IProcessTelemetryUnloadContext,
8
+ ITelemetryUnloadState, generateW3CId, onConfigChange, IConfigDefaults, isArray
9
+ } from "@microsoft/applicationinsights-core-js";
10
+ import dynamicProto from "@microsoft/dynamicproto-js";
11
+ import { NavigationEnd, Router } from "@angular/router";
12
+ import { ApplicationinsightsAngularpluginErrorService } from "./applicationinsights-angularplugin-error.service";
13
+ import { IErrorService } from "./IErrorService";
14
+ import { Subscription } from "rxjs";
15
+ import { AnalyticsPlugin } from "@microsoft/applicationinsights-analytics-js";
16
+ import {objDeepFreeze} from "@nevware21/ts-utils";
17
+ import { PropertiesPlugin } from "@microsoft/applicationinsights-properties-js";
18
+
19
+ interface IAngularExtensionConfig {
20
+ /**
21
+ * Angular router for enabling Application Insights PageView tracking.
22
+ */
23
+ router?: Router;
24
+
25
+ /**
26
+ * Custom error service for global error handling.
27
+ */
28
+ errorServices?: IErrorService[];
29
+ useInjector?: boolean;
30
+ }
31
+
32
+ let undefValue;
33
+
34
+ const defaultAngularExtensionConfig: IConfigDefaults<IAngularExtensionConfig> = objDeepFreeze({
35
+ router: { blkVal: true, v: undefValue},
36
+ errorServices: { blkVal: true, v: undefValue}
37
+ });
38
+
39
+ @Component({
40
+ selector: "lib-applicationinsights-angularplugin-js",
41
+ template: "",
42
+ styles: []
43
+ })
44
+ // eslint-disable-next-line @angular-eslint/component-class-suffix
45
+ export class AngularPlugin extends BaseTelemetryPlugin {
46
+ public priority = 186;
47
+ public identifier = "AngularPlugin";
48
+
49
+ constructor(private _injector?: Injector) { // _injector is optional to provide
50
+ super();
51
+ let _analyticsPlugin: AnalyticsPlugin;
52
+ let _propertiesPlugin: PropertiesPlugin;
53
+ let _angularCfg: IAngularExtensionConfig;
54
+ let _eventSubscription: Subscription;
55
+ let _isPageInitialLoad: boolean;
56
+ let _prevRouter: Router;
57
+ let _errorServiceInstance: ApplicationinsightsAngularpluginErrorService;
58
+
59
+ dynamicProto(AngularPlugin, this, (_self, _base) => {
60
+
61
+ const _initDefaults = () => {
62
+ _analyticsPlugin = null;
63
+ _propertiesPlugin = null;
64
+ _angularCfg = null;
65
+ _eventSubscription = null;
66
+ _isPageInitialLoad = true;
67
+ _prevRouter = undefValue;
68
+ };
69
+
70
+ _initDefaults();
71
+
72
+ _self.initialize = (config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[],
73
+ pluginChain?: ITelemetryPluginChain) => {
74
+ super.initialize(config, core, extensions, pluginChain);
75
+
76
+ _self._addHook(onConfigChange(config, (details) => {
77
+ let ctx = _self._getTelCtx();
78
+ _angularCfg = ctx.getExtCfg<IAngularExtensionConfig>(_self.identifier, defaultAngularExtensionConfig);
79
+ _propertiesPlugin = core.getPlugin<PropertiesPlugin>(PropertiesPluginIdentifier)?.plugin as PropertiesPlugin;
80
+ _analyticsPlugin = core.getPlugin<AnalyticsPlugin>(AnalyticsPluginIdentifier)?.plugin as AnalyticsPlugin;
81
+
82
+ if (_angularCfg.useInjector && _injector){
83
+ _errorServiceInstance = this._injector.get(ApplicationinsightsAngularpluginErrorService);
84
+ }
85
+ _errorServiceInstance = _errorServiceInstance ? _errorServiceInstance
86
+ : ApplicationinsightsAngularpluginErrorService.instance;
87
+
88
+ // two instance of errorService
89
+
90
+ if (_analyticsPlugin) {
91
+ if (_errorServiceInstance !== null) {
92
+ _errorServiceInstance.plugin = _analyticsPlugin;
93
+ if (_angularCfg.errorServices && isArray(_angularCfg.errorServices)) {
94
+ _errorServiceInstance.clearErrorHandlers();
95
+ arrForEach(_angularCfg.errorServices, (errorService: IErrorService) => {
96
+ _errorServiceInstance.addErrorHandler(errorService);
97
+ });
98
+ }
99
+ }
100
+ }
101
+
102
+ if (_angularCfg.router !== _prevRouter) {
103
+ // router is changed, or has not been initialized yet
104
+
105
+ // unsubscribe previous router events
106
+ if (_eventSubscription) {
107
+ _eventSubscription.unsubscribe();
108
+ }
109
+
110
+ if (_angularCfg.router){
111
+ // only track page view if it is the initial page load for this plugin
112
+ if (_isPageInitialLoad){
113
+ const pageViewTelemetry: IPageViewTelemetry = {
114
+ uri: _angularCfg.router.url
115
+ };
116
+ _self.trackPageView(pageViewTelemetry);
117
+ }
118
+
119
+ // subscribe to new router events
120
+ _eventSubscription = _angularCfg.router.events.subscribe(event => {
121
+ if (_self.isInitialized()) {
122
+ if (event instanceof NavigationEnd) {
123
+ // for page initial load, do not call trackPageView twice
124
+ if (_isPageInitialLoad) {
125
+ _isPageInitialLoad = false;
126
+ return;
127
+ }
128
+ const pvt: IPageViewTelemetry = {
129
+ uri: _angularCfg.router.url,
130
+ properties: { duration: 0 } // SPA route change loading durations are undefined, so send 0
131
+ };
132
+ _self.trackPageView(pvt);
133
+ }
134
+ }
135
+ });
136
+ }
137
+ _prevRouter = _angularCfg.router;
138
+ }
139
+ }));
140
+
141
+ // for test purpose only
142
+ _self["_getDbgPlgTargets"] = () => _angularCfg;
143
+ _self["_getErrorService"] = () => _errorServiceInstance;
144
+ };
145
+
146
+ _self.trackPageView = (pageView: IPageViewTelemetry) => {
147
+ if (_analyticsPlugin) {
148
+ const location = getLocation();
149
+ if (_propertiesPlugin && _propertiesPlugin.context && _propertiesPlugin.context.telemetryTrace) {
150
+ _propertiesPlugin.context.telemetryTrace.traceID = generateW3CId();
151
+ _propertiesPlugin.context.telemetryTrace.name = location && location.pathname || "_unknown_";
152
+ }
153
+ _analyticsPlugin.trackPageView(pageView);
154
+ } else {
155
+ _throwInternal(_self.diagLog(),
156
+ // eslint-disable-next-line max-len
157
+ eLoggingSeverity.CRITICAL, _eInternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, Angular plugin telemetry will not be sent: ");
158
+ }
159
+ };
160
+
161
+
162
+ _self._doTeardown = (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState,
163
+ asyncCallback?: () => void): void | boolean => {
164
+ if (_analyticsPlugin && _errorServiceInstance !== null) {
165
+ _errorServiceInstance.plugin = null;
166
+ if (_angularCfg) {
167
+ if (_angularCfg.errorServices && Array.isArray(_angularCfg.errorServices)) {
168
+ _errorServiceInstance.clearErrorHandlers();
169
+
170
+ }
171
+ }
172
+ }
173
+
174
+ if (_eventSubscription) {
175
+ _eventSubscription.unsubscribe();
176
+ _eventSubscription = null;
177
+ }
178
+ _initDefaults();
179
+ };
180
+ });
181
+
182
+ }
183
+ /**
184
+ * Add Part A fields to the event
185
+ *
186
+ * @param event The event that needs to be processed
187
+ */
188
+ processTelemetry(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext) {
189
+ this.processNext(event, itemCtx);
190
+ }
191
+
192
+
193
+ initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain) {
194
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
195
+ }
196
+
197
+ trackPageView(pageView: IPageViewTelemetry) {
198
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
199
+ }
200
+
201
+
202
+
203
+ }
@@ -0,0 +1,14 @@
1
+ import { NgModule } from "@angular/core";
2
+ import { AngularPlugin } from "./applicationinsights-angularplugin-js.component";
3
+ import { ApplicationinsightsAngularpluginErrorService } from "./applicationinsights-angularplugin-error.service";
4
+
5
+ @NgModule({
6
+ declarations: [AngularPlugin],
7
+ imports: [
8
+ ],
9
+ exports: [AngularPlugin],
10
+ providers: [
11
+ ApplicationinsightsAngularpluginErrorService
12
+ ]
13
+ })
14
+ export class ApplicationinsightsAngularpluginJsModule { }
@@ -1,3 +1,7 @@
1
+ /*
2
+ * Public API Surface of applicationinsights-angularplugin-js
3
+ */
4
+
1
5
  export * from "./lib/applicationinsights-angularplugin-js.component";
2
6
  export * from "./lib/applicationinsights-angularplugin-js.module";
3
7
  export * from "./lib/applicationinsights-angularplugin-error.service";
package/src/test.ts ADDED
@@ -0,0 +1,13 @@
1
+ // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2
+
3
+ import "zone.js";
4
+ import "zone.js/testing";
5
+ import { getTestBed } from "@angular/core/testing";
6
+ import { BrowserDynamicTestingModule, platformBrowserDynamicTesting} from "@angular/platform-browser-dynamic/testing";
7
+
8
+ // First, initialize the Angular testing environment.
9
+ getTestBed().initTestEnvironment(
10
+ BrowserDynamicTestingModule,
11
+ platformBrowserDynamicTesting(), {
12
+ teardown: { destroyAfterEach: false }
13
+ });
@@ -0,0 +1,30 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "../../tsconfig.json",
4
+ "compilerOptions": {
5
+ "outDir": "../../out-tsc/lib",
6
+ "target": "es2015",
7
+ "declaration": true,
8
+ "sourceMap": true,
9
+ "declarationMap": true,
10
+ "inlineSources": true,
11
+ "types": [],
12
+ "lib": [
13
+ "dom",
14
+ "es2018"
15
+ ]
16
+ },
17
+ "angularCompilerOptions": {
18
+ "skipTemplateCodegen": true,
19
+ "strictMetadataEmit": true,
20
+ "enableResourceInlining": true,
21
+ "fullTemplateTypeCheck": true,
22
+ "strictInjectionParameters": true,
23
+ "flatModuleId": "AUTOGENERATED",
24
+ "flatModuleOutFile": "AUTOGENERATED"
25
+ },
26
+ "exclude": [
27
+ "src/test.ts",
28
+ "**/*.spec.ts"
29
+ ]
30
+ }
@@ -0,0 +1,10 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "./tsconfig.lib.json",
4
+ "compilerOptions": {
5
+ "declarationMap": false
6
+ },
7
+ "angularCompilerOptions": {
8
+ "compilationMode": "partial"
9
+ }
10
+ }
@@ -0,0 +1,17 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "../../tsconfig.json",
4
+ "compilerOptions": {
5
+ "outDir": "../../out-tsc/spec",
6
+ "types": [
7
+ "jasmine"
8
+ ]
9
+ },
10
+ "files": [
11
+ "src/test.ts"
12
+ ],
13
+ "include": [
14
+ "**/*.spec.ts",
15
+ "**/*.d.ts"
16
+ ]
17
+ }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUVycm9yU2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL2FwcGxpY2F0aW9uaW5zaWdodHMtYW5ndWxhcnBsdWdpbi1qcy9zcmMvbGliL0lFcnJvclNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IEVycm9ySGFuZGxlciB9IGZyb20gXCJAYW5ndWxhci9jb3JlXCI7XHJcblxyXG5leHBvcnQgaW50ZXJmYWNlIElFcnJvclNlcnZpY2UgZXh0ZW5kcyBFcnJvckhhbmRsZXIge1xyXG4gICAgaGFuZGxlRXJyb3IoZXJyb3I6IGFueSk6IHZvaWQ7XHJcbn1cclxuIl19
@@ -1,52 +0,0 @@
1
- import { Injectable } from "@angular/core";
2
- import { arrForEach, isFunction } from "@microsoft/applicationinsights-core-js";
3
- import * as i0 from "@angular/core";
4
- export class ApplicationinsightsAngularpluginErrorService {
5
- constructor() {
6
- this.errorServices = [];
7
- if (ApplicationinsightsAngularpluginErrorService.instance === null) {
8
- ApplicationinsightsAngularpluginErrorService.instance = this;
9
- }
10
- }
11
- set plugin(analyticsPlugin) {
12
- this.analyticsPlugin = analyticsPlugin;
13
- }
14
- clearErrorHandlers() {
15
- this.errorServices = [];
16
- }
17
- addErrorHandler(errorService) {
18
- if (errorService && isFunction(errorService.handleError)) {
19
- this.errorServices.push(errorService);
20
- }
21
- }
22
- removeErrorHandler(errorService) {
23
- if (errorService && isFunction(errorService.handleError)) {
24
- const idx = this.errorServices.indexOf(errorService);
25
- if (idx !== -1) {
26
- this.errorServices.splice(idx, 1);
27
- }
28
- }
29
- }
30
- handleError(error) {
31
- if (this.analyticsPlugin) {
32
- this.analyticsPlugin.trackException({ exception: error });
33
- }
34
- if (this.errorServices && this.errorServices.length > 0) {
35
- arrForEach(this.errorServices, errorService => {
36
- if (isFunction(errorService.handleError)) {
37
- errorService.handleError(error);
38
- }
39
- });
40
- }
41
- }
42
- }
43
- ApplicationinsightsAngularpluginErrorService.instance = null;
44
- ApplicationinsightsAngularpluginErrorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ApplicationinsightsAngularpluginErrorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
45
- ApplicationinsightsAngularpluginErrorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ApplicationinsightsAngularpluginErrorService, providedIn: "root" });
46
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ApplicationinsightsAngularpluginErrorService, decorators: [{
47
- type: Injectable,
48
- args: [{
49
- providedIn: "root"
50
- }]
51
- }], ctorParameters: function () { return []; } });
52
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwbGljYXRpb25pbnNpZ2h0cy1hbmd1bGFycGx1Z2luLWVycm9yLnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9hcHBsaWNhdGlvbmluc2lnaHRzLWFuZ3VsYXJwbHVnaW4tanMvc3JjL2xpYi9hcHBsaWNhdGlvbmluc2lnaHRzLWFuZ3VsYXJwbHVnaW4tZXJyb3Iuc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBRTNDLE9BQU8sRUFBRSxVQUFVLEVBQUUsVUFBVSxFQUFFLE1BQU0sd0NBQXdDLENBQUM7O0FBTWhGLE1BQU0sT0FBTyw0Q0FBNEM7SUFLckQ7UUFGUSxrQkFBYSxHQUFvQixFQUFFLENBQUM7UUFHeEMsSUFBSSw0Q0FBNEMsQ0FBQyxRQUFRLEtBQUssSUFBSSxFQUFFO1lBQ2hFLDRDQUE0QyxDQUFDLFFBQVEsR0FBRyxJQUFJ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lcnZpY2UuaGFuZGxlRXJyb3IpKSB7XHJcbiAgICAgICAgICAgIGNvbnN0IGlkeCA9IHRoaXMuZXJyb3JTZXJ2aWNlcy5pbmRleE9mKGVycm9yU2VydmljZSk7XHJcbiAgICAgICAgICAgIGlmIChpZHggIT09IC0xKSB7XHJcbiAgICAgICAgICAgICAgICB0aGlzLmVycm9yU2VydmljZXMuc3BsaWNlKGlkeCwgMSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgaGFuZGxlRXJyb3IoZXJyb3I6IGFueSk6IHZvaWQge1xyXG4gICAgICAgIGlmICh0aGlzLmFuYWx5dGljc1BsdWdpbikge1xyXG4gICAgICAgICAgICB0aGlzLmFuYWx5dGljc1BsdWdpbi50cmFja0V4Y2VwdGlvbih7IGV4Y2VwdGlvbjogZXJyb3IgfSk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBpZiAodGhpcy5lcnJvclNlcnZpY2VzICYmIHRoaXMuZXJyb3JTZXJ2aWNlcy5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgIGFyckZvckVhY2godGhpcy5lcnJvclNlcnZpY2VzLCBlcnJvclNlcnZpY2UgPT4ge1xyXG4gICAgICAgICAgICAgICAgaWYgKGlzRnVuY3Rpb24oZXJyb3JTZXJ2aWNlLmhhbmRsZUVycm9yKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGVycm9yU2VydmljZS5oYW5kbGVFcnJvcihlcnJvcik7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxufVxyXG5cclxuIl19