{"id":15547885,"url":"https://github.com/goenning/ng-appinsights","last_synced_at":"2025-03-19T01:30:58.259Z","repository":{"id":40666286,"uuid":"216505877","full_name":"goenning/ng-appinsights","owner":"goenning","description":"Connect your Angular applications to Azure Application Insights to automatically track dependency calls, performance metrics and error logging. Use custom events to track anything you want!","archived":false,"fork":false,"pushed_at":"2023-01-13T10:45:31.000Z","size":1176,"stargazers_count":2,"open_issues_count":6,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T13:46:50.442Z","etag":null,"topics":["angular","appinsights","application-insights","azure","microsoft-application-insights"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goenning.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-21T07:37:11.000Z","updated_at":"2023-09-21T09:45:17.000Z","dependencies_parsed_at":"2023-02-09T15:31:36.658Z","dependency_job_id":null,"html_url":"https://github.com/goenning/ng-appinsights","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goenning%2Fng-appinsights","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goenning%2Fng-appinsights/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goenning%2Fng-appinsights/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goenning%2Fng-appinsights/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goenning","download_url":"https://codeload.github.com/goenning/ng-appinsights/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243958082,"owners_count":20374792,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","appinsights","application-insights","azure","microsoft-application-insights"],"created_at":"2024-10-02T13:12:16.471Z","updated_at":"2025-03-19T01:30:57.915Z","avatar_url":"https://github.com/goenning.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ng-appinsights\n\nA simple wrapper of Application Insights JS Library for Angular applications. \n\nSupported features are:\n- Simple setup (no modules required)\n- Deferred Initialization\n- Built-in Global Error Handler\n\n## Installation\n\nUsing npm:\n\n```bash\nnpm install --save ng-appinsights\n```\n\n## Usage\n\nTo initialize Application Insights, add the following to your entry point module (usually `app.module.ts`):\n\n```typescript\nimport { APP_INSIGHTS_CONFIG } from 'ng-appinsights';\n\n@NgModule({\n  declarations: [\n    AppComponent\n  ],\n  imports: [\n    BrowserModule\n  ],\n  providers: [\n    {\n      provide: APP_INSIGHTS_CONFIG,\n      useValue: {\n        instrumentationKey: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx',\n        enableAutoRouteTracking: true,\n        // Visit https://github.com/microsoft/ApplicationInsights-JS to know all possible configurations.\n      }\n    }\n  ],\n  bootstrap: [AppComponent]\n})\nexport class AppModule { }\n```\n\nImport the `AppInsightsService` into your components and use the available tracking methods.\n\n```typescript\nimport { Component } from '@angular/core';\nimport { AppInsightsService } from 'ng-appinsights';\n\n@Component({\n  selector: 'app-root',\n  templateUrl: './app.component.html'\n})\nexport class AppComponent {\n  count = 0;\n\n  constructor(private appInsights: AppInsightsService) {\n  }\n\n  increment(): void {\n    this.count++;\n    this.appInsights.trackEvent('increment', { count: this.count });\n  }\n\n  decrement(): void {\n    this.count--;\n    this.appInsights.trackEvent('decrement', { count: this.count });\n  }\n}\n```\n\n## Deferred Initialization\n\nYou may also skip the configuration on the Module and do it using the Service at any time.\n\n```typescript\nimport { Component } from '@angular/core';\nimport { AppInsightsService } from 'ng-appinsights';\n\n@Component({\n  selector: 'app-root',\n  templateUrl: './my.component.html'\n})\nexport class MyComponent {\n  constructor(private appInsights: AppInsightsService) {\n  }\n\n  init(): void {\n    this.appInsights.init({\n      instrumentationKey: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx',\n    });\n  }\n}\n```\n\n## Global Error Handler\n\nYou may also include the built-in Error Handler which will automatically send exception events to AI for every errors that occurs inside your application.\n\n```typescript\nimport { AppInsightsErrorHandler } from 'ng-appinsights';\n\n@NgModule({\n  declarations: [\n    AppComponent\n  ],\n  imports: [\n    BrowserModule\n  ],\n  providers: [\n    { provide: ErrorHandler, useClass: AppInsightsErrorHandler },\n  ],\n  bootstrap: [AppComponent]\n})\nexport class AppModule { }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoenning%2Fng-appinsights","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoenning%2Fng-appinsights","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoenning%2Fng-appinsights/lists"}