@microsoft/applicationinsights-angularplugin-js 2.6.2 → 2.8.0
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.
- package/README.md +120 -13
- package/esm2020/lib/IErrorService.mjs +2 -0
- package/esm2020/lib/applicationinsights-angularplugin-error.service.mjs +39 -0
- package/esm2020/lib/applicationinsights-angularplugin-js.component.mjs +93 -0
- package/esm2020/lib/applicationinsights-angularplugin-js.module.mjs +23 -0
- package/{esm2015/microsoft-applicationinsights-angularplugin-js.js → esm2020/microsoft-applicationinsights-angularplugin-js.mjs} +0 -0
- package/{esm2015/public-api.js → esm2020/public-api.mjs} +2 -1
- package/fesm2015/microsoft-applicationinsights-angularplugin-js.mjs +158 -0
- package/fesm2015/microsoft-applicationinsights-angularplugin-js.mjs.map +1 -0
- package/fesm2020/microsoft-applicationinsights-angularplugin-js.mjs +158 -0
- package/fesm2020/microsoft-applicationinsights-angularplugin-js.mjs.map +1 -0
- package/lib/IErrorService.d.ts +4 -0
- package/lib/applicationinsights-angularplugin-error.service.d.ts +8 -3
- package/lib/applicationinsights-angularplugin-js.component.d.ts +4 -0
- package/lib/applicationinsights-angularplugin-js.module.d.ts +5 -0
- package/microsoft-applicationinsights-angularplugin-js-2.8.0.tgz +0 -0
- package/microsoft-applicationinsights-angularplugin-js.d.ts +1 -0
- package/package.json +24 -12
- package/public-api.d.ts +1 -0
- package/bundles/microsoft-applicationinsights-angularplugin-js.umd.js +0 -455
- package/bundles/microsoft-applicationinsights-angularplugin-js.umd.js.map +0 -1
- package/bundles/microsoft-applicationinsights-angularplugin-js.umd.min.js +0 -16
- package/bundles/microsoft-applicationinsights-angularplugin-js.umd.min.js.map +0 -1
- package/esm2015/lib/applicationinsights-angularplugin-error.service.js +0 -26
- package/esm2015/lib/applicationinsights-angularplugin-js.component.js +0 -79
- package/esm2015/lib/applicationinsights-angularplugin-js.module.js +0 -16
- package/fesm2015/microsoft-applicationinsights-angularplugin-js.js +0 -126
- package/fesm2015/microsoft-applicationinsights-angularplugin-js.js.map +0 -1
- package/microsoft-applicationinsights-angularplugin-js-2.6.2.tgz +0 -0
- package/microsoft-applicationinsights-angularplugin-js.metadata.json +0 -1
package/README.md
CHANGED
|
@@ -1,24 +1,131 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Microsoft Application Insights JavaScript SDK - Angular Plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/microsoft/applicationinsights-angularplugin-js/actions/workflows/angular.yml)
|
|
4
|
+
[]()
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Angular Plugin for the Application Insights Javascript SDK, enables the following:
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
> Note: Don't forget to add `--project applicationinsights-angularplugin-js` or else it will be added to the default project in your `angular.json` file.
|
|
8
|
+
> ***Note:*** Angular plugin is NOT es3 compatible
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
- Tracking of router changes
|
|
11
|
+
- Tracking uncaught exceptions
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
Angular Plugin for the Application Insights Javascript SDK
|
|
13
14
|
|
|
14
|
-
##
|
|
15
|
+
## Getting Started
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
Install npm package:
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
```bash
|
|
20
|
+
npm install @microsoft/applicationinsights-angularplugin-js
|
|
21
|
+
```
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
## Basic Usage
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
Set up an instance of Application Insights in the entry component in your app:
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
```js
|
|
28
|
+
import { Component } from '@angular/core';
|
|
29
|
+
import { ApplicationInsights } from '@microsoft/applicationinsights-web';
|
|
30
|
+
import { AngularPlugin } from '@microsoft/applicationinsights-angularplugin-js';
|
|
31
|
+
import { Router } from '@angular/router';
|
|
32
|
+
|
|
33
|
+
@Component({
|
|
34
|
+
selector: 'app-root',
|
|
35
|
+
templateUrl: './app.component.html',
|
|
36
|
+
styleUrls: ['./app.component.css']
|
|
37
|
+
})
|
|
38
|
+
export class AppComponent {
|
|
39
|
+
constructor(
|
|
40
|
+
private router: Router
|
|
41
|
+
){
|
|
42
|
+
var angularPlugin = new AngularPlugin();
|
|
43
|
+
const appInsights = new ApplicationInsights({ config: {
|
|
44
|
+
instrumentationKey: 'YOUR_INSTRUMENTATION_KEY_GOES_HERE',
|
|
45
|
+
extensions: [angularPlugin],
|
|
46
|
+
extensionConfig: {
|
|
47
|
+
[angularPlugin.identifier]: { router: this.router }
|
|
48
|
+
}
|
|
49
|
+
} });
|
|
50
|
+
appInsights.loadAppInsights();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
To track uncaught exceptions, setup ApplicationinsightsAngularpluginErrorService in `app.module.ts`:
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
import { ApplicationinsightsAngularpluginErrorService } from '@microsoft/applicationinsights-angularplugin-js';
|
|
59
|
+
|
|
60
|
+
@NgModule({
|
|
61
|
+
...
|
|
62
|
+
providers: [
|
|
63
|
+
{
|
|
64
|
+
provide: ErrorHandler,
|
|
65
|
+
useClass: ApplicationinsightsAngularpluginErrorService
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
...
|
|
69
|
+
})
|
|
70
|
+
export class AppModule { }
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
To chain more custom error handlers, create custom error handlers that implement IErrorService:
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
import { IErrorService } from '@microsoft/applicationinsights-angularplugin-js';
|
|
77
|
+
|
|
78
|
+
export class CustomErrorHandler implements IErrorService {
|
|
79
|
+
handleError(error: any) {
|
|
80
|
+
...
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
And pass errorServices array through extensionConfig:
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
extensionConfig: {
|
|
89
|
+
[angularPlugin.identifier]: {
|
|
90
|
+
router: this.router,
|
|
91
|
+
errorServices: [new CustomErrorHandler()]
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Contributing
|
|
97
|
+
|
|
98
|
+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
|
99
|
+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
|
100
|
+
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
|
|
101
|
+
|
|
102
|
+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
|
|
103
|
+
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
|
|
104
|
+
provided by the bot. You will only need to do this once across all repos using our CLA.
|
|
105
|
+
|
|
106
|
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
107
|
+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
|
108
|
+
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
109
|
+
|
|
110
|
+
## Trademarks
|
|
111
|
+
|
|
112
|
+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
|
|
113
|
+
trademarks or logos is subject to and must follow
|
|
114
|
+
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
|
|
115
|
+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
116
|
+
Any use of third-party trademarks or logos are subject to those third-party's policies.
|
|
117
|
+
|
|
118
|
+
### Note
|
|
119
|
+
|
|
120
|
+
Angular plugin is using newer version of typescript, make sure to build and test before you create a pull request.
|
|
121
|
+
Navigate to the root folder of Angular plugin, under /applicationinsights-angularplugin-js:
|
|
122
|
+
|
|
123
|
+
```js
|
|
124
|
+
npm install
|
|
125
|
+
npm run build
|
|
126
|
+
npm run test
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSUVycm9yU2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL2FwcGxpY2F0aW9uaW5zaWdodHMtYW5ndWxhcnBsdWdpbi1qcy9zcmMvbGliL0lFcnJvclNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IEVycm9ySGFuZGxlciB9IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xyXG5cclxuZXhwb3J0IGludGVyZmFjZSBJRXJyb3JTZXJ2aWNlIGV4dGVuZHMgRXJyb3JIYW5kbGVyIHtcclxuICAgIGhhbmRsZUVycm9yKGVycm9yOiBhbnkpOiB2b2lkO1xyXG59XHJcbiJdfQ==
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { arrForEach } 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
|
+
addErrorHandler(errorService) {
|
|
15
|
+
this.errorServices.push(errorService);
|
|
16
|
+
}
|
|
17
|
+
handleError(error) {
|
|
18
|
+
if (this.analyticsPlugin) {
|
|
19
|
+
this.analyticsPlugin.trackException({ exception: error });
|
|
20
|
+
}
|
|
21
|
+
if (this.errorServices && this.errorServices.length > 0) {
|
|
22
|
+
arrForEach(this.errorServices, errorService => {
|
|
23
|
+
if (errorService.handleError && typeof errorService.handleError === 'function') {
|
|
24
|
+
errorService.handleError(error);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
ApplicationinsightsAngularpluginErrorService.instance = null;
|
|
31
|
+
ApplicationinsightsAngularpluginErrorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: ApplicationinsightsAngularpluginErrorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
32
|
+
ApplicationinsightsAngularpluginErrorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: ApplicationinsightsAngularpluginErrorService, providedIn: 'root' });
|
|
33
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: ApplicationinsightsAngularpluginErrorService, decorators: [{
|
|
34
|
+
type: Injectable,
|
|
35
|
+
args: [{
|
|
36
|
+
providedIn: 'root'
|
|
37
|
+
}]
|
|
38
|
+
}], ctorParameters: function () { return []; } });
|
|
39
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwbGljYXRpb25pbnNpZ2h0cy1hbmd1bGFycGx1Z2luLWVycm9yLnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9hcHBsaWNhdGlvbmluc2lnaHRzLWFuZ3VsYXJwbHVnaW4tanMvc3JjL2xpYi9hcHBsaWNhdGlvbmluc2lnaHRzLWFuZ3VsYXJwbHVnaW4tZXJyb3Iuc2VydmljZS50cyJdL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93 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { PropertiesPluginIdentifier, Util } from '@microsoft/applicationinsights-common';
|
|
3
|
+
import { BaseTelemetryPlugin, arrForEach, _InternalMessageId, LoggingSeverity, getLocation } from '@microsoft/applicationinsights-core-js';
|
|
4
|
+
import { NavigationEnd } from '@angular/router';
|
|
5
|
+
import { ApplicationinsightsAngularpluginErrorService } from './applicationinsights-angularplugin-error.service';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
// eslint-disable-next-line @angular-eslint/component-class-suffix
|
|
8
|
+
export class AngularPlugin extends BaseTelemetryPlugin {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.priority = 186;
|
|
12
|
+
this.identifier = 'AngularPlugin';
|
|
13
|
+
}
|
|
14
|
+
initialize(config, core, extensions, pluginChain) {
|
|
15
|
+
super.initialize(config, core, extensions, pluginChain);
|
|
16
|
+
const self = this;
|
|
17
|
+
const ctx = self._getTelCtx();
|
|
18
|
+
const extConfig = ctx.getExtCfg(self.identifier, { router: null, errorServices: null });
|
|
19
|
+
arrForEach(extensions, ext => {
|
|
20
|
+
const identifier = ext.identifier;
|
|
21
|
+
if (identifier === 'ApplicationInsightsAnalytics') {
|
|
22
|
+
self.analyticsPlugin = ext;
|
|
23
|
+
if (ApplicationinsightsAngularpluginErrorService.instance !== null) {
|
|
24
|
+
ApplicationinsightsAngularpluginErrorService.instance.plugin = self.analyticsPlugin;
|
|
25
|
+
if (extConfig.errorServices && Array.isArray(extConfig.errorServices)) {
|
|
26
|
+
arrForEach(extConfig.errorServices, (errorService) => {
|
|
27
|
+
ApplicationinsightsAngularpluginErrorService.instance.addErrorHandler(errorService);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (identifier === PropertiesPluginIdentifier) {
|
|
33
|
+
self.propertiesPlugin = ext;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
if (extConfig.router) {
|
|
37
|
+
let isPageInitialLoad = true;
|
|
38
|
+
const pageViewTelemetry = {
|
|
39
|
+
uri: extConfig.router.url
|
|
40
|
+
};
|
|
41
|
+
self.trackPageView(pageViewTelemetry);
|
|
42
|
+
extConfig.router.events.subscribe(event => {
|
|
43
|
+
if (event instanceof NavigationEnd) {
|
|
44
|
+
// for page initial load, do not call trackPageView twice
|
|
45
|
+
if (isPageInitialLoad) {
|
|
46
|
+
isPageInitialLoad = false;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const pvt = {
|
|
50
|
+
uri: extConfig.router.url,
|
|
51
|
+
properties: { duration: 0 } // SPA route change loading durations are undefined, so send 0
|
|
52
|
+
};
|
|
53
|
+
self.trackPageView(pvt);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Add Part A fields to the event
|
|
60
|
+
*
|
|
61
|
+
* @param event The event that needs to be processed
|
|
62
|
+
*/
|
|
63
|
+
processTelemetry(event, itemCtx) {
|
|
64
|
+
this.processNext(event, itemCtx);
|
|
65
|
+
}
|
|
66
|
+
trackPageView(pageView) {
|
|
67
|
+
const self = this;
|
|
68
|
+
if (self.analyticsPlugin) {
|
|
69
|
+
const location = getLocation();
|
|
70
|
+
if (self.propertiesPlugin && self.propertiesPlugin.context && self.propertiesPlugin.context.telemetryTrace) {
|
|
71
|
+
self.propertiesPlugin.context.telemetryTrace.traceID = Util.generateW3CId();
|
|
72
|
+
self.propertiesPlugin.context.telemetryTrace.name = location && location.pathname || '_unknown_';
|
|
73
|
+
}
|
|
74
|
+
self.analyticsPlugin.trackPageView(pageView);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
self.diagLog().throwInternal(
|
|
78
|
+
// eslint-disable-next-line max-len
|
|
79
|
+
LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, 'Analytics plugin is not available, Angular plugin telemetry will not be sent: ');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
AngularPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AngularPlugin, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
84
|
+
AngularPlugin.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.3", type: AngularPlugin, selector: "lib-applicationinsights-angularplugin-js", usesInheritance: true, ngImport: i0, template: ``, isInline: true });
|
|
85
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AngularPlugin, decorators: [{
|
|
86
|
+
type: Component,
|
|
87
|
+
args: [{
|
|
88
|
+
selector: 'lib-applicationinsights-angularplugin-js',
|
|
89
|
+
template: ``,
|
|
90
|
+
styles: []
|
|
91
|
+
}]
|
|
92
|
+
}] });
|
|
93
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwbGljYXRpb25pbnNpZ2h0cy1hbmd1bGFycGx1Z2luLWpzLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL2FwcGxpY2F0aW9uaW5zaWdodHMtYW5ndWxhcnBsdWdpbi1qcy9zcmMvbGliL2FwcGxpY2F0aW9uaW5zaWdodHMtYW5ndWxhcnBsdWdpbi1qcy5jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUMxQyxPQUFPLEVBQ3dDLDBCQUEwQixFQUFFLElBQUksRUFDOUUsTUFBTSx1Q0FBdUMsQ0FBQztBQUMvQyxPQUFPLEVBRWUsbUJBQW1CLEVBQUUsVUFBVSxFQUN2QixrQkFBa0IsRUFBRSxlQUFlLEVBQUUsV0FBV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AgICAgICAgaWYgKEFwcGxpY2F0aW9uaW5zaWdodHNBbmd1bGFycGx1Z2luRXJyb3JTZXJ2aWNlLmluc3RhbmNlICE9PSBudWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgQXBwbGljYXRpb25pbnNpZ2h0c0FuZ3VsYXJwbHVnaW5FcnJvclNlcnZpY2UuaW5zdGFuY2UucGx1Z2luID0gc2VsZi5hbmFseXRpY3NQbHVnaW47XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGV4dENvbmZpZy5lcnJvclNlcnZpY2VzICYmIEFycmF5LmlzQXJyYXkoZXh0Q29uZmlnLmVycm9yU2VydmljZXMpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGFyckZvckVhY2goZXh0Q29uZmlnLmVycm9yU2VydmljZXMsIChlcnJvclNlcnZpY2U6IElFcnJvclNlcnZpY2UpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFwcGxpY2F0aW9uaW5zaWdodHNBbmd1bGFycGx1Z2luRXJyb3JTZXJ2aWNlLmluc3RhbmNlLmFkZEVycm9ySGFuZGxlcihlcnJvclNlcnZpY2UpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKGlkZW50aWZpZXIgPT09IFByb3BlcnRpZXNQbHVnaW5JZGVudGlmaWVyKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLnByb3BlcnRpZXNQbHVnaW4gPSAoZXh0IGFzIGFueSkgYXMgcHJvcGVydGllcy5Qcm9wZXJ0aWVzUGx1Z2luO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSk7XHJcblxyXG4gICAgICAgIGlmIChleHRDb25maWcucm91dGVyKSB7XHJcbiAgICAgICAgICAgIGxldCBpc1BhZ2VJbml0aWFsTG9hZCA9IHRydWU7XHJcbiAgICAgICAgICAgIGNvbnN0IHBhZ2VWaWV3VGVsZW1ldHJ5OiBJUGFnZVZpZXdUZWxlbWV0cnkgPSB7XHJcbiAgICAgICAgICAgICAgICB1cmk6IGV4dENvbmZpZy5yb3V0ZXIudXJsXHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgIHNlbGYudHJhY2tQYWdlVmlldyhwYWdlVmlld1RlbGVtZXRyeSk7XHJcbiAgICAgICAgICAgIGV4dENvbmZpZy5yb3V0ZXIuZXZlbnRzLnN1YnNjcmliZShldmVudCA9PiB7XHJcbiAgICAgICAgICAgICAgICBpZiAoZXZlbnQgaW5zdGFuY2VvZiBOYXZpZ2F0aW9uRW5kKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgLy8gZm9yIHBhZ2UgaW5pdGlhbCBsb2FkLCBkbyBub3QgY2FsbCB0cmFja1BhZ2VWaWV3IHR3aWNlXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlzUGFnZUluaXRpYWxMb2FkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlzUGFnZUluaXRpYWxMb2FkID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgcHZ0OiBJUGFnZVZpZXdUZWxlbWV0cnkgPSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHVyaTogZXh0Q29uZmlnLnJvdXRlci51cmwsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHByb3BlcnRpZXM6IHsgZHVyYXRpb246IDAgfSAvLyBTUEEgcm91dGUgY2hhbmdlIGxvYWRpbmcgZHVyYXRpb25zIGFyZSB1bmRlZmluZWQsIHNvIHNlbmQgMFxyXG4gICAgICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi50cmFja1BhZ2VWaWV3KHB2dCk7XHJcbiAgICAgICAgIC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8ICdfdW5rbm93bl8nO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHNlbGYuYW5hbHl0aWNzUGx1Z2luLnRyYWNrUGFnZVZpZXcocGFnZVZpZXcpO1xyXG4gICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgIHNlbGYuZGlhZ0xvZygpLnRocm93SW50ZXJuYWwoXHJcbiAgICAgICAgICAgICAgICAvLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgbWF4LWxlblxyXG4gICAgICAgICAgICAgICAgTG9nZ2luZ1NldmVyaXR5LkNSSVRJQ0FMLCBfSW50ZXJuYWxNZXNzYWdlSWQuVGVsZW1ldHJ5SW5pdGlhbGl6ZXJGYWlsZWQsICdBbmFseXRpY3MgcGx1Z2luIGlzIG5vdCBhdmFpbGFibGUsIEFuZ3VsYXIgcGx1Z2luIHRlbGVtZXRyeSB3aWxsIG5vdCBiZSBzZW50OiAnKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcbn1cclxuIl19
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { AngularPlugin } from './applicationinsights-angularplugin-js.component';
|
|
3
|
+
import { ApplicationinsightsAngularpluginErrorService } from './applicationinsights-angularplugin-error.service';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export class ApplicationinsightsAngularpluginJsModule {
|
|
6
|
+
}
|
|
7
|
+
ApplicationinsightsAngularpluginJsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: ApplicationinsightsAngularpluginJsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
8
|
+
ApplicationinsightsAngularpluginJsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: ApplicationinsightsAngularpluginJsModule, declarations: [AngularPlugin], exports: [AngularPlugin] });
|
|
9
|
+
ApplicationinsightsAngularpluginJsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: ApplicationinsightsAngularpluginJsModule, providers: [
|
|
10
|
+
ApplicationinsightsAngularpluginErrorService
|
|
11
|
+
], imports: [[]] });
|
|
12
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: ApplicationinsightsAngularpluginJsModule, decorators: [{
|
|
13
|
+
type: NgModule,
|
|
14
|
+
args: [{
|
|
15
|
+
declarations: [AngularPlugin],
|
|
16
|
+
imports: [],
|
|
17
|
+
exports: [AngularPlugin],
|
|
18
|
+
providers: [
|
|
19
|
+
ApplicationinsightsAngularpluginErrorService
|
|
20
|
+
]
|
|
21
|
+
}]
|
|
22
|
+
}] });
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwbGljYXRpb25pbnNpZ2h0cy1hbmd1bGFycGx1Z2luLWpzLm1vZHVsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL2FwcGxpY2F0aW9uaW5zaWdodHMtYW5ndWxhcnBsdWdpbi1qcy9zcmMvbGliL2FwcGxpY2F0aW9uaW5zaWdodHMtYW5ndWxhcnBsdWdpbi1qcy5tb2R1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUN6QyxPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0sa0RBQWtELENBQUM7QUFDakYsT0FBTyxFQUFFLDRDQUE0QyxFQUFFLE1BQU0sbURBQW1ELENBQUM7O0FBV2pILE1BQU0sT0FBTyx3Q0FBd0M7O3FJQUF4Qyx3Q0FBd0M7c0lBQXhDLHdDQUF3QyxpQkFScEMsYUFBYSxhQUdsQixhQUFhO3NJQUtaLHdDQUF3QyxhQUp4QztRQUNULDRDQUE0QztLQUM3QyxZQUxRLEVBQ1I7MkZBTVUsd0NBQXdDO2tCQVRwRCxRQUFRO21CQUFDO29CQUNSLFlBQVksRUFBRSxDQUFDLGFBQWEsQ0FBQztvQkFDN0IsT0FBTyxFQUFFLEVBQ1I7b0JBQ0QsT0FBTyxFQUFFLENBQUMsYUFBYSxDQUFDO29CQUN4QixTQUFTLEVBQUU7d0JBQ1QsNENBQTRDO3FCQUM3QztpQkFDRiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IE5nTW9kdWxlIH0gZnJvbSAnQGFuZ3VsYXIvY29yZSc7XHJcbmltcG9ydCB7IEFuZ3VsYXJQbHVnaW4gfSBmcm9tICcuL2FwcGxpY2F0aW9uaW5zaWdodHMtYW5ndWxhcnBsdWdpbi1qcy5jb21wb25lbnQnO1xyXG5pbXBvcnQgeyBBcHBsaWNhdGlvbmluc2lnaHRzQW5ndWxhcnBsdWdpbkVycm9yU2VydmljZSB9IGZyb20gJy4vYXBwbGljYXRpb25pbnNpZ2h0cy1hbmd1bGFycGx1Z2luLWVycm9yLnNlcnZpY2UnO1xyXG5cclxuQE5nTW9kdWxlKHtcclxuICBkZWNsYXJhdGlvbnM6IFtBbmd1bGFyUGx1Z2luXSxcclxuICBpbXBvcnRzOiBbXHJcbiAgXSxcclxuICBleHBvcnRzOiBbQW5ndWxhclBsdWdpbl0sXHJcbiAgcHJvdmlkZXJzOiBbXHJcbiAgICBBcHBsaWNhdGlvbmluc2lnaHRzQW5ndWxhcnBsdWdpbkVycm9yU2VydmljZVxyXG4gIF1cclxufSlcclxuZXhwb3J0IGNsYXNzIEFwcGxpY2F0aW9uaW5zaWdodHNBbmd1bGFycGx1Z2luSnNNb2R1bGUgeyB9XHJcbiJdfQ==
|
|
File without changes
|
|
@@ -4,4 +4,5 @@
|
|
|
4
4
|
export * from './lib/applicationinsights-angularplugin-js.component';
|
|
5
5
|
export * from './lib/applicationinsights-angularplugin-js.module';
|
|
6
6
|
export * from './lib/applicationinsights-angularplugin-error.service';
|
|
7
|
-
|
|
7
|
+
export * from './lib/IErrorService';
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3Byb2plY3RzL2FwcGxpY2F0aW9uaW5zaWdodHMtYW5ndWxhcnBsdWdpbi1qcy9zcmMvcHVibGljLWFwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsc0RBQXNELENBQUM7QUFDckUsY0FBYyxtREFBbUQsQ0FBQztBQUNsRSxjQUFjLHVEQUF1RCxDQUFDO0FBQ3RFLGNBQWMscUJBQXFCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKlxyXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2YgYXBwbGljYXRpb25pbnNpZ2h0cy1hbmd1bGFycGx1Z2luLWpzXHJcbiAqL1xyXG5cclxuZXhwb3J0ICogZnJvbSAnLi9saWIvYXBwbGljYXRpb25pbnNpZ2h0cy1hbmd1bGFycGx1Z2luLWpzLmNvbXBvbmVudCc7XHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL2FwcGxpY2F0aW9uaW5zaWdodHMtYW5ndWxhcnBsdWdpbi1qcy5tb2R1bGUnO1xyXG5leHBvcnQgKiBmcm9tICcuL2xpYi9hcHBsaWNhdGlvbmluc2lnaHRzLWFuZ3VsYXJwbHVnaW4tZXJyb3Iuc2VydmljZSc7XHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL0lFcnJvclNlcnZpY2UnO1xyXG4iXX0=
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, Component, NgModule } from '@angular/core';
|
|
3
|
+
import { PropertiesPluginIdentifier, Util } from '@microsoft/applicationinsights-common';
|
|
4
|
+
import { arrForEach, BaseTelemetryPlugin, getLocation, LoggingSeverity, _InternalMessageId } from '@microsoft/applicationinsights-core-js';
|
|
5
|
+
import { NavigationEnd } from '@angular/router';
|
|
6
|
+
|
|
7
|
+
class ApplicationinsightsAngularpluginErrorService {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.errorServices = [];
|
|
10
|
+
if (ApplicationinsightsAngularpluginErrorService.instance === null) {
|
|
11
|
+
ApplicationinsightsAngularpluginErrorService.instance = this;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
set plugin(analyticsPlugin) {
|
|
15
|
+
this.analyticsPlugin = analyticsPlugin;
|
|
16
|
+
}
|
|
17
|
+
addErrorHandler(errorService) {
|
|
18
|
+
this.errorServices.push(errorService);
|
|
19
|
+
}
|
|
20
|
+
handleError(error) {
|
|
21
|
+
if (this.analyticsPlugin) {
|
|
22
|
+
this.analyticsPlugin.trackException({ exception: error });
|
|
23
|
+
}
|
|
24
|
+
if (this.errorServices && this.errorServices.length > 0) {
|
|
25
|
+
arrForEach(this.errorServices, errorService => {
|
|
26
|
+
if (errorService.handleError && typeof errorService.handleError === 'function') {
|
|
27
|
+
errorService.handleError(error);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
ApplicationinsightsAngularpluginErrorService.instance = null;
|
|
34
|
+
ApplicationinsightsAngularpluginErrorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: ApplicationinsightsAngularpluginErrorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
35
|
+
ApplicationinsightsAngularpluginErrorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: ApplicationinsightsAngularpluginErrorService, providedIn: 'root' });
|
|
36
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: ApplicationinsightsAngularpluginErrorService, decorators: [{
|
|
37
|
+
type: Injectable,
|
|
38
|
+
args: [{
|
|
39
|
+
providedIn: 'root'
|
|
40
|
+
}]
|
|
41
|
+
}], ctorParameters: function () { return []; } });
|
|
42
|
+
|
|
43
|
+
// eslint-disable-next-line @angular-eslint/component-class-suffix
|
|
44
|
+
class AngularPlugin extends BaseTelemetryPlugin {
|
|
45
|
+
constructor() {
|
|
46
|
+
super(...arguments);
|
|
47
|
+
this.priority = 186;
|
|
48
|
+
this.identifier = 'AngularPlugin';
|
|
49
|
+
}
|
|
50
|
+
initialize(config, core, extensions, pluginChain) {
|
|
51
|
+
super.initialize(config, core, extensions, pluginChain);
|
|
52
|
+
const self = this;
|
|
53
|
+
const ctx = self._getTelCtx();
|
|
54
|
+
const extConfig = ctx.getExtCfg(self.identifier, { router: null, errorServices: null });
|
|
55
|
+
arrForEach(extensions, ext => {
|
|
56
|
+
const identifier = ext.identifier;
|
|
57
|
+
if (identifier === 'ApplicationInsightsAnalytics') {
|
|
58
|
+
self.analyticsPlugin = ext;
|
|
59
|
+
if (ApplicationinsightsAngularpluginErrorService.instance !== null) {
|
|
60
|
+
ApplicationinsightsAngularpluginErrorService.instance.plugin = self.analyticsPlugin;
|
|
61
|
+
if (extConfig.errorServices && Array.isArray(extConfig.errorServices)) {
|
|
62
|
+
arrForEach(extConfig.errorServices, (errorService) => {
|
|
63
|
+
ApplicationinsightsAngularpluginErrorService.instance.addErrorHandler(errorService);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (identifier === PropertiesPluginIdentifier) {
|
|
69
|
+
self.propertiesPlugin = ext;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
if (extConfig.router) {
|
|
73
|
+
let isPageInitialLoad = true;
|
|
74
|
+
const pageViewTelemetry = {
|
|
75
|
+
uri: extConfig.router.url
|
|
76
|
+
};
|
|
77
|
+
self.trackPageView(pageViewTelemetry);
|
|
78
|
+
extConfig.router.events.subscribe(event => {
|
|
79
|
+
if (event instanceof NavigationEnd) {
|
|
80
|
+
// for page initial load, do not call trackPageView twice
|
|
81
|
+
if (isPageInitialLoad) {
|
|
82
|
+
isPageInitialLoad = false;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const pvt = {
|
|
86
|
+
uri: extConfig.router.url,
|
|
87
|
+
properties: { duration: 0 } // SPA route change loading durations are undefined, so send 0
|
|
88
|
+
};
|
|
89
|
+
self.trackPageView(pvt);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Add Part A fields to the event
|
|
96
|
+
*
|
|
97
|
+
* @param event The event that needs to be processed
|
|
98
|
+
*/
|
|
99
|
+
processTelemetry(event, itemCtx) {
|
|
100
|
+
this.processNext(event, itemCtx);
|
|
101
|
+
}
|
|
102
|
+
trackPageView(pageView) {
|
|
103
|
+
const self = this;
|
|
104
|
+
if (self.analyticsPlugin) {
|
|
105
|
+
const location = getLocation();
|
|
106
|
+
if (self.propertiesPlugin && self.propertiesPlugin.context && self.propertiesPlugin.context.telemetryTrace) {
|
|
107
|
+
self.propertiesPlugin.context.telemetryTrace.traceID = Util.generateW3CId();
|
|
108
|
+
self.propertiesPlugin.context.telemetryTrace.name = location && location.pathname || '_unknown_';
|
|
109
|
+
}
|
|
110
|
+
self.analyticsPlugin.trackPageView(pageView);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
self.diagLog().throwInternal(
|
|
114
|
+
// eslint-disable-next-line max-len
|
|
115
|
+
LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, 'Analytics plugin is not available, Angular plugin telemetry will not be sent: ');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
AngularPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AngularPlugin, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
120
|
+
AngularPlugin.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.3", type: AngularPlugin, selector: "lib-applicationinsights-angularplugin-js", usesInheritance: true, ngImport: i0, template: ``, isInline: true });
|
|
121
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AngularPlugin, decorators: [{
|
|
122
|
+
type: Component,
|
|
123
|
+
args: [{
|
|
124
|
+
selector: 'lib-applicationinsights-angularplugin-js',
|
|
125
|
+
template: ``,
|
|
126
|
+
styles: []
|
|
127
|
+
}]
|
|
128
|
+
}] });
|
|
129
|
+
|
|
130
|
+
class ApplicationinsightsAngularpluginJsModule {
|
|
131
|
+
}
|
|
132
|
+
ApplicationinsightsAngularpluginJsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: ApplicationinsightsAngularpluginJsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
133
|
+
ApplicationinsightsAngularpluginJsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: ApplicationinsightsAngularpluginJsModule, declarations: [AngularPlugin], exports: [AngularPlugin] });
|
|
134
|
+
ApplicationinsightsAngularpluginJsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: ApplicationinsightsAngularpluginJsModule, providers: [
|
|
135
|
+
ApplicationinsightsAngularpluginErrorService
|
|
136
|
+
], imports: [[]] });
|
|
137
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: ApplicationinsightsAngularpluginJsModule, decorators: [{
|
|
138
|
+
type: NgModule,
|
|
139
|
+
args: [{
|
|
140
|
+
declarations: [AngularPlugin],
|
|
141
|
+
imports: [],
|
|
142
|
+
exports: [AngularPlugin],
|
|
143
|
+
providers: [
|
|
144
|
+
ApplicationinsightsAngularpluginErrorService
|
|
145
|
+
]
|
|
146
|
+
}]
|
|
147
|
+
}] });
|
|
148
|
+
|
|
149
|
+
/*
|
|
150
|
+
* Public API Surface of applicationinsights-angularplugin-js
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Generated bundle index. Do not edit.
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
export { AngularPlugin, ApplicationinsightsAngularpluginErrorService, ApplicationinsightsAngularpluginJsModule };
|
|
158
|
+
//# sourceMappingURL=microsoft-applicationinsights-angularplugin-js.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"microsoft-applicationinsights-angularplugin-js.mjs","sources":["../../../projects/applicationinsights-angularplugin-js/src/lib/applicationinsights-angularplugin-error.service.ts","../../../projects/applicationinsights-angularplugin-js/src/lib/applicationinsights-angularplugin-js.component.ts","../../../projects/applicationinsights-angularplugin-js/src/lib/applicationinsights-angularplugin-js.module.ts","../../../projects/applicationinsights-angularplugin-js/src/public-api.ts","../../../projects/applicationinsights-angularplugin-js/src/microsoft-applicationinsights-angularplugin-js.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\r\nimport { IAppInsights } from '@microsoft/applicationinsights-common';\r\nimport { arrForEach } from '@microsoft/applicationinsights-core-js';\r\nimport { IErrorService } from './IErrorService';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class ApplicationinsightsAngularpluginErrorService implements IErrorService {\r\n public static instance: ApplicationinsightsAngularpluginErrorService = null;\r\n private analyticsPlugin: IAppInsights;\r\n private errorServices: IErrorService[] = [];\r\n\r\n constructor() {\r\n if (ApplicationinsightsAngularpluginErrorService.instance === null) {\r\n ApplicationinsightsAngularpluginErrorService.instance = this;\r\n }\r\n }\r\n\r\n public set plugin(analyticsPlugin: IAppInsights) {\r\n this.analyticsPlugin = analyticsPlugin;\r\n }\r\n\r\n public addErrorHandler(errorService: IErrorService): void {\r\n this.errorServices.push(errorService);\r\n }\r\n\r\n handleError(error: any): void {\r\n if (this.analyticsPlugin) {\r\n this.analyticsPlugin.trackException({ exception: error });\r\n }\r\n\r\n if (this.errorServices && this.errorServices.length > 0) {\r\n arrForEach(this.errorServices, errorService => {\r\n if (errorService.handleError && typeof errorService.handleError === 'function') {\r\n errorService.handleError(error);\r\n }\r\n });\r\n }\r\n }\r\n}\r\n\r\n","import { Component } from '@angular/core';\r\nimport {\r\n IConfig, IPageViewTelemetry, IAppInsights, PropertiesPluginIdentifier, Util\r\n} from '@microsoft/applicationinsights-common';\r\nimport {\r\n IPlugin, IConfiguration, IAppInsightsCore,\r\n ITelemetryPlugin, BaseTelemetryPlugin, arrForEach, ITelemetryItem, ITelemetryPluginChain,\r\n IProcessTelemetryContext, _InternalMessageId, LoggingSeverity, getLocation\r\n} from '@microsoft/applicationinsights-core-js';\r\nimport { NavigationEnd, Router } from '@angular/router';\r\n// For types only\r\nimport * as properties from '@microsoft/applicationinsights-properties-js';\r\nimport { ApplicationinsightsAngularpluginErrorService } from './applicationinsights-angularplugin-error.service';\r\nimport { IErrorService } from './IErrorService';\r\n\r\ninterface IAngularExtensionConfig {\r\n /**\r\n * Angular router for enabling Application Insights PageView tracking.\r\n */\r\n router?: Router;\r\n\r\n /**\r\n * Custom error service for global error handling.\r\n */\r\n errorServices?: IErrorService[];\r\n}\r\n\r\n@Component({\r\n selector: 'lib-applicationinsights-angularplugin-js',\r\n template: ``,\r\n styles: []\r\n})\r\n// eslint-disable-next-line @angular-eslint/component-class-suffix\r\nexport class AngularPlugin extends BaseTelemetryPlugin {\r\n public priority = 186;\r\n public identifier = 'AngularPlugin';\r\n\r\n private analyticsPlugin: IAppInsights;\r\n private propertiesPlugin: properties.PropertiesPlugin;\r\n\r\n initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain) {\r\n super.initialize(config, core, extensions, pluginChain);\r\n const self = this;\r\n const ctx = self._getTelCtx();\r\n const extConfig = ctx.getExtCfg<IAngularExtensionConfig>(self.identifier, { router: null, errorServices: null });\r\n arrForEach(extensions, ext => {\r\n const identifier = (ext as ITelemetryPlugin).identifier;\r\n if (identifier === 'ApplicationInsightsAnalytics') {\r\n self.analyticsPlugin = (ext as any) as IAppInsights;\r\n if (ApplicationinsightsAngularpluginErrorService.instance !== null) {\r\n ApplicationinsightsAngularpluginErrorService.instance.plugin = self.analyticsPlugin;\r\n if (extConfig.errorServices && Array.isArray(extConfig.errorServices)) {\r\n arrForEach(extConfig.errorServices, (errorService: IErrorService) => {\r\n ApplicationinsightsAngularpluginErrorService.instance.addErrorHandler(errorService);\r\n });\r\n }\r\n }\r\n }\r\n if (identifier === PropertiesPluginIdentifier) {\r\n self.propertiesPlugin = (ext as any) as properties.PropertiesPlugin;\r\n }\r\n });\r\n\r\n if (extConfig.router) {\r\n let isPageInitialLoad = true;\r\n const pageViewTelemetry: IPageViewTelemetry = {\r\n uri: extConfig.router.url\r\n };\r\n self.trackPageView(pageViewTelemetry);\r\n extConfig.router.events.subscribe(event => {\r\n if (event instanceof NavigationEnd) {\r\n // for page initial load, do not call trackPageView twice\r\n if (isPageInitialLoad) {\r\n isPageInitialLoad = false;\r\n return;\r\n }\r\n const pvt: IPageViewTelemetry = {\r\n uri: extConfig.router.url,\r\n properties: { duration: 0 } // SPA route change loading durations are undefined, so send 0\r\n };\r\n self.trackPageView(pvt);\r\n }\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Add Part A fields to the event\r\n *\r\n * @param event The event that needs to be processed\r\n */\r\n processTelemetry(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext) {\r\n this.processNext(event, itemCtx);\r\n }\r\n\r\n trackPageView(pageView: IPageViewTelemetry) {\r\n const self = this;\r\n\r\n if (self.analyticsPlugin) {\r\n const location = getLocation();\r\n if (self.propertiesPlugin && self.propertiesPlugin.context && self.propertiesPlugin.context.telemetryTrace) {\r\n self.propertiesPlugin.context.telemetryTrace.traceID = Util.generateW3CId();\r\n self.propertiesPlugin.context.telemetryTrace.name = location && location.pathname || '_unknown_';\r\n }\r\n self.analyticsPlugin.trackPageView(pageView);\r\n } else {\r\n self.diagLog().throwInternal(\r\n // eslint-disable-next-line max-len\r\n LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, 'Analytics plugin is not available, Angular plugin telemetry will not be sent: ');\r\n }\r\n }\r\n}\r\n","import { NgModule } from '@angular/core';\r\nimport { AngularPlugin } from './applicationinsights-angularplugin-js.component';\r\nimport { ApplicationinsightsAngularpluginErrorService } from './applicationinsights-angularplugin-error.service';\r\n\r\n@NgModule({\r\n declarations: [AngularPlugin],\r\n imports: [\r\n ],\r\n exports: [AngularPlugin],\r\n providers: [\r\n ApplicationinsightsAngularpluginErrorService\r\n ]\r\n})\r\nexport class ApplicationinsightsAngularpluginJsModule { }\r\n","/*\r\n * Public API Surface of applicationinsights-angularplugin-js\r\n */\r\n\r\nexport * from './lib/applicationinsights-angularplugin-js.component';\r\nexport * from './lib/applicationinsights-angularplugin-js.module';\r\nexport * from './lib/applicationinsights-angularplugin-error.service';\r\nexport * from './lib/IErrorService';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;MAQa,4CAA4C;IAKvD;QAFQ,kBAAa,GAAoB,EAAE,CAAC;QAG1C,IAAI,4CAA4C,CAAC,QAAQ,KAAK,IAAI,EAAE;YAClE,4CAA4C,CAAC,QAAQ,GAAG,IAAI,CAAC;SAC9D;KACF;IAED,IAAW,MAAM,CAAC,eAA6B;QAC7C,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;KACxC;IAEM,eAAe,CAAC,YAA2B;QAChD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;KACvC;IAED,WAAW,CAAC,KAAU;QACpB,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,SAAS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