'AngularJS version 1 - Application Insights integration

I am currently supporting an application that is built using AngluarJS Version 1. I am quite new to this.

I have a task to integrate the Azure Application Insights into this application. The below reference link gives info about the integration using npm https://docs.microsoft.com/en-us/azure/azure-monitor/app/javascript

I am not sure how to write the below code in AngularJS, this gives the error. import { ApplicationInsights } from '@microsoft/applicationinsights-web'

Please help or if there are any references please share.



Solution 1:[1]

Either we can use NPM Setup and Snippet Setup.

For NPM

npm i --save @microsoft/applicationinsights-web

Configure Angular APP and Include Dependencies

You can use the environment.ts file to store the Instrumentation Key

export const environment =  
{  
    .  .  . 
    appInsights:  { instrumentationKey:  '<Your Instrumentation Key>'  
    }  
};

Add Dependency to package.json Restore it using npm install

"dependencies":  {  "@microsoft/applicationinsights-web":  "~2.4.4",
...
}

Refer here for further steps

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DelliganeshS-MT