11# Angular Azure Application Insights implementation
22
3- ## Connect your Angular client-side to Microsofts Application Insights with this easy-to-use Module.
3+ ## Connect your Angular client-side to Microsofts Application Insights with this easy-to-use Module
44
55> Application Insights is an extensible Application Performance Management (APM) service for web developers on multiple platforms. Use it to monitor your live web application. It will automatically detect performance anomalies. It includes powerful analytics tools to help you diagnose issues and to understand what users actually do with your app.
66
77[ ![ npm] ( https://img.shields.io/npm/v/@markpieszak/ng-application-insights.svg?label=npm%20version&color=5b1096&style=for-the-badge )] ( https://www.npmjs.com/@markpieszak/ng-application-insights )
88[ ![ Minzipped Size] ( https://img.shields.io/bundlephobia/minzip/@markpieszak/ng-application-insights?color=e51384&style=for-the-badge )] ( https://bundlephobia.com/result?p=@markpieszak/ng-application-insights )
99[ ![ NPM Downloads] ( https://img.shields.io/npm/dw/@markpieszak/ng-application-insights.svg?color=b31ae7&style=for-the-badge )] ( https://www.npmjs.com/@markpieszak/ng-application-insights )
10- [ ![ MIT License] ( https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge&color=e51384 )] ( /LICENSE )
10+ [ ![ MIT License] ( https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge&color=e51384 )] ( /LICENSE )
1111
1212---
1313
1414<p align =" center " >
1515 <a href =" https://trilon.io " target =" _blank " >
16- <img width="500" height="auto" src="https://trilon.io/trilon-logo-clear.png" alt="Trilon.io - Angular Universal, NestJS, JavaScript Application Consulting Development and Training">
16+ <img width="500" height="auto" src="https://trilon.io/trilon-logo-clear.png" alt="Trilon.io - Angular Universal, NestJS, JavaScript Application Consulting Development and Training">
1717 </a >
1818</p >
1919
20-
2120<h3 align =" center " > Made with :heart: by <a href =" https://trilon.io " >Trilon.io</a ></h3 >
2221
2322---
@@ -28,6 +27,10 @@ Install & save the library to your package.json:
2827
2928``` bash
3029$ npm i -S @markpieszak/ng-application-insights
30+
31+ # yarn
32+
33+ $ yarn add @markpieszak/ng-application-insights
3134```
3235
3336---
@@ -97,7 +100,7 @@ export class ShoppingCartComponent {
97100
98101## Usage with Aspnetcore-Angular2-Universal repo or JavaScriptServices ( apps w/ Server-side rendering )
99102
100- > ie: https://github.com/TrilonIO/aspnetcore-angular-universal
103+ > ie: < https://github.com/TrilonIO/aspnetcore-angular-universal >
101104
102105First, make sure you are only importing the library & the server within the ** browser-app.module** NgModule (do not share it within a common one, as the server isn't able to use this library during it's server-renders).
103106
@@ -106,25 +109,25 @@ Secondly, make sure you are calling the `injector` to get AppInsightsService dur
106109``` typescript
107110export class HomeComponent implements OnInit {
108111
109- private AIService: AppInsightsService ;
110- private isBrowser: boolean ;
112+ private AIService: AppInsightsService ;
113+ private isBrowser: boolean ;
111114
112- constructor (@Inject (PLATFORM_ID ) private platformId , private injector : Injector ) {
113- this .isBrowser = isPlatformBrowser (this .platformId );
114- }
115+ constructor (@Inject (PLATFORM_ID ) private platformId , private injector : Injector ) {
116+ this .isBrowser = isPlatformBrowser (this .platformId );
117+ }
115118
116- ngOnInit() { // <--
117- if (this .isBrowser ) { // <-- only run if isBrowser
118- this .AIService = <AppInsightsService >this .injector .get (AppInsightsService ); // <-- using the Injector, get the Service
119- this .AIService .trackEvent (' Testing' , { ' user' : ' me' });
120- }
121- }
119+ ngOnInit() { // <--
120+ if (this .isBrowser ) { // <-- only run if isBrowser
121+ this .AIService = <AppInsightsService >this .injector .get (AppInsightsService ); // <-- using the Injector, get the Service
122+ this .AIService .trackEvent (' Testing' , { ' user' : ' me' });
123+ }
124+ }
122125}
123126```
124127
125128## API
126129
127- You can see a list of the API here: https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#class-appinsights
130+ You can see a list of the API here: < https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#class-appinsights >
128131
129132``` typescript
130133AppInsightsService .trackEvent ()
@@ -164,27 +167,26 @@ npm run lint
164167
165168# License
166169
167- [ ![ MIT License] ( https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge&color=e51384 )] ( /LICENSE )
170+ [ ![ MIT License] ( https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge&color=e51384 )] ( /LICENSE )
168171
169- Copyright (c) 2016-2020 [ Mark Pieszak] ( https://twitter.com/MarkPieszak )
172+ Copyright (c) 2016-2021 [ Mark Pieszak] ( https://twitter.com/MarkPieszak )
170173
171174[ ![ Twitter Follow] ( https://img.shields.io/twitter/follow/MarkPieszak.svg?style=social )] ( https://twitter.com/MarkPieszak )
172175
173176----
174177
175178# Trilon - JavaScript, ASP.NET, Node, NestJS - Consulting | Training | Development
176179
177- Check out ** [ Trilon.io] ( https://Trilon.io ) ** for more info!
180+ Check out ** [ Trilon.io] ( https://Trilon.io ) ** for more info!
178181
179182Contact us at
< [email protected] > , and let's talk about your projects needs.
180183
181184<p align =" center " >
182185 <a href =" https://trilon.io " target =" _blank " >
183- <img src="https://trilon.io/trilon-logo-clear.png" alt="Trilon.io - Angular Universal, NestJS, JavaScript Application Consulting Development and Training">
186+ <img src="https://trilon.io/trilon-logo-clear.png" alt="Trilon.io - Angular Universal, NestJS, JavaScript Application Consulting Development and Training">
184187 </a >
185188</p >
186189
187- ## Follow Trilon online:
190+ ## Follow Trilon online
188191
189192Twitter: [ @Trilon_io] ( http://twitter.com/Trilon_io )
190-
0 commit comments