emperorsreeni / angularjs-application-insights-v2

AngularJs library for Microsoft Application Insights JavaScript V2 SDK
MIT License
2 stars 6 forks source link

Will crash bootstrap if not configured #13

Open cj-dalley opened 2 years ago

cj-dalley commented 2 years ago

Hi All, how do we conditionally setup AppInsights if a key is present? We only use AppInsights in Production, and we'd like the option to have AppInsights not start at all if no instrumentationkey (or config) is present. Can we do that?

I am getting the following error; image

And if I provide a configuration, I must provide an instrumentationKey.

Apart from doing something hacky like this.

if (constants.instrumentationKey) { applicationInsightsServiceProvider.configure({ instrumentationKey: constants.instrumentationKey, applicationName: 'App', autoStateChangeTracking: false, autoLogTracking: true, sessionExpirationMs: 1800000 }); } else { // configure a dummy instance with telemetry disabled, cause we don't want it applicationInsightsServiceProvider.configure({ instrumentationKey: 'this-is-a-fake-key-cause-eff', disableTelemetry: true }); }