import { NgModule , ModuleWithProviders , Optional , SkipSelf } from '@angular/core' ; import { CommonModule } from '@angular/common' ; import { AppInsightsConfig , AppInsightsService } from './src/app-insight.service' ; export { SeverityLevel , AppInsightsConfig , AppInsightsService } from './src/app-insight.service' ; @ NgModule ( { imports : [ CommonModule ] , declarations : [ ] , exports : [ ] , providers : [ AppInsightsService ] } ) export class ApplicationInsightsModule { constructor ( @ Optional ( ) @ SkipSelf ( ) parentModule , appInsightsService ) { if ( ! parentModule ) { appInsightsService . init ( ) ; } } static forRoot ( config ) { return { ngModule : ApplicationInsightsModule , providers : [ { provide : AppInsightsConfig , useValue : config } , AppInsightsService ] } ; } }