Skip to content

Commit 63834e5

Browse files
committed
fix: 🐛 failing tests
1 parent ae04705 commit 63834e5

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

apps/lumberjack-app/src/app/app.component.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe('AppComponent', () => {
1616
LumberjackModule.forRoot(),
1717
LumberjackApplicationinsightsDriverModule.forRoot({
1818
levels: [LumberjackLevel.Verbose],
19+
instrumentationKey: 'dummy-key',
1920
}),
2021
],
2122
}).compileComponents();

apps/lumberjack-app/src/environments/environment.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// This file can be replaced during build by using the `fileReplacements` array.
22
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
33
// The list of file replacements can be found in `angular.json`.
4+
// '<your-instrumentation-key>'
45

56
export const environment = {
67
production: false,
78
appInsights: {
8-
instrumentationKey: '<your-instrumentation-key>',
9+
instrumentationKey: '6948078b-b192-489b-961c-6a490733b988',
910
},
1011
};
1112

libs/ngworker/lumberjack-applicationinsights-driver/src/lib/configuration/lumberjack-applicationinsights-driver-root.module.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Inject, NgModule, Optional, SkipSelf } from '@angular/core';
2+
import { ApplicationInsights } from '@microsoft/applicationinsights-web';
23

34
import {
45
LumberjackLogDriverConfig,
@@ -19,8 +20,15 @@ export function lumberjackApplicationinsightsDriverFactory(
1920
...{ ...logDriverConfig, identifier: LumberjackApplicationinsightsDriver.driverIdentifier },
2021
...lumberjackApplicationinsightsDriverConfig,
2122
};
23+
const appInsights = new ApplicationInsights({
24+
config: {
25+
instrumentationKey: lumberjackApplicationinsightsDriverConfig.instrumentationKey,
26+
connectionString: lumberjackApplicationinsightsDriverConfig.connectionString,
27+
loggingLevelConsole: lumberjackApplicationinsightsDriverConfig.loggingLevelConsole,
28+
},
29+
});
2230

23-
return new LumberjackApplicationinsightsDriver(config);
31+
return new LumberjackApplicationinsightsDriver(config, appInsights);
2432
}
2533

2634
@NgModule({

libs/ngworker/lumberjack-applicationinsights-driver/src/lib/log-drivers/lumberjack-applicationinsights-driver.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,10 @@ export class LumberjackApplicationinsightsDriver<TPayload extends LumberjackLogP
1111
implements LumberjackLogDriver<TPayload> {
1212
static driverIdentifier = 'LumberjackApplicationinsightsDriver';
1313

14-
private readonly appInsights: ApplicationInsights = new ApplicationInsights({
15-
config: {
16-
instrumentationKey: this.config.instrumentationKey,
17-
connectionString: this.config.connectionString,
18-
loggingLevelConsole: this.config.loggingLevelConsole,
19-
},
20-
});
21-
2214
constructor(
2315
@Inject(lumberjackApplicationinsightsDriverConfigToken)
24-
public config: LumberjackApplicationinsightsDriverInternalConfig
16+
public config: LumberjackApplicationinsightsDriverInternalConfig,
17+
private readonly appInsights: ApplicationInsights
2518
) {
2619
this.appInsights.loadAppInsights();
2720
}

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"moduleResolution": "node",
1515
"importHelpers": true,
1616
"target": "es2015",
17-
"module": "es2020",
17+
"module": "esnext",
1818
"lib": ["es2018", "dom"],
1919
"paths": {
2020
"@internal/test-util": ["libs/internal/test-util/src/index.ts"],

0 commit comments

Comments
 (0)