Я пытаюсь внедрить реализацию Azure Application Insights в angular6,
я получил ошибку ниже:
Failed to initialize AppInsights JS SDK: Cannot load Application Insights SDK, no instrumentationKey was provided.
, что означает, что код, который я написал, выполняется (вдохновлено здесь )
export class AppInsightsService {
private config: Microsoft.ApplicationInsights.IConfig = {
instrumentationKey: AppConfig.configuration ? AppConfig.configuration.applicationInsights.instrumentationKey : null,
};
constructor() {
if (!AppInsights.config) {
AppInsights.downloadAndSetup(this.config);
}
}
перед функцией загрузки: -
{
provide: APP_INITIALIZER,
useFactory: initializeApp,
deps: [AppConfig], multi: true,
},
// Load app-settings which has key also.
export function initializeApp(appConfig: AppConfig): () => Promise<void> {
return () => appConfig.load();
}
load(): Promise<void> {
return new Promise<void>((resolve, reject) => {
this.http.get<Configuration>(this.baseUrl + 'api/BackEnd/GetAppSettings').toPromise().then((result) => {
AppConfig.configuration = result; `// here loading key from app settings.`
resolve();
}).catch((response: any) => {
});
});
}
вопрос: как я могу загрузить,
AppInsights.downloadAndSetup (this.config); после того, как я получил ключ от ответа функции загрузки?
Какое ваше лучшее предложение, как вы можете достичь того же типа APM в вашем приложении?
спасибо заранее.