# @omaxel/angular-ms-app-insights

> Utility library to easily configure Microsoft Application Insights into an Angular project.

Latest version **1.0.2** (published 2023-03-08) · 0 weekly downloads

## Install

```sh
npm install @omaxel/angular-ms-app-insights
pnpm add @omaxel/angular-ms-app-insights
yarn add @omaxel/angular-ms-app-insights
bun add @omaxel/angular-ms-app-insights
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-03-08 |
| First published | 2023-03-08 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 44.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Omar Muscatello |
| Maintainers | omaxel |

## Links

- npm: https://www.npmjs.com/package/@omaxel/angular-ms-app-insights
- Repository: https://github.com/omaxel/angular-ms-app-insights
- Homepage: https://github.com/omaxel/angular-ms-app-insights#readme
- Issues: https://github.com/omaxel/angular-ms-app-insights/issues
- npm.io page: https://npm.io/package/@omaxel/angular-ms-app-insights

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.3.0

## Recent versions

- 1.0.2 (latest) — 2023-03-08
- 1.0.1 — 2023-03-08
- 1.0.0 — 2023-03-08

## README

# Angular Microsoft Application Insights
Utility library to easily configure  Microsoft Application Insights into an Angular project.

## Installation
Install dependencies first:
```
npm i @microsoft/applicationinsights-angularplugin-js @microsoft/applicationinsights-web
```
then install the package:
```
npm i @omaxel/angular-ms-app-insights 
```

## Usage

- Configure the module in `app.module.ts`
  ```
  AppInsightsModule.forRoot({
    connectionString: 'YOUR_CONNECTION_STRING',~~~~
    appName: 'YOUR_APP_NAME',
  
    // Optionals
    appVersion: 'YOUR_APP_VERSION',
    appBuildNumber: 'YOUR_APP_BUILD_NUMBER'
  }),
  ```
- In the `app.component.ts` file, call the `init` method:
  ```
  import { Component } from '@angular/core';
  import { AppInsightsService } from "@omaxel/angular-ms-app-insights";
  
  @Component({
    selector: 'app-root',
    templateUrl: './app.component.html'
  })
  export class AppComponent {
    constructor(appInsightsService: AppInsightsService) {
      appInsightsService.init();
    }
  }
  ```

## Track custom events
You can call the `trackEvent` method of `AppInsightsService` to track a custom event:
```
@Component({
  selector: 'app-example',
  templateUrl: './example.component.html'
})
export class ExampleComponent {
  constructor(private appInsightsService: AppInsightsService) { }
  
  onClick() {
    this.appInsightsService.trackEvent('my-event-name', { myProperty: 'my-value' });
  }
}
```

---
_Source: https://npm.io/package/@omaxel/angular-ms-app-insights · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
