Initialize New Relic JavaScript code with Angular 9

490 Views Asked by At

I am using New Relic Javascript code snippet to integrate New Relic in my Angular 9 app.

Everything works fine when I add this script tag in the head of my index.html page.

The problem: This JavaScript code snipped has some keys like applicationID and licenseKey which are hardcoded. I want to externalize these keys and want to pick them from the environment.ts file.

But I am unable to find the way through which I can achieve this.

I tried putting this JavaScript code in ngOnInit of my app.component.ts but it shows typescript errors.

I have another solution in my mind: set the keys in the session storage and after that load that code snippet dynamically so that it can access session storage and get the data from it. If it is a recommended approach, please guide me.

Please suggest if there is any workaround.

Thanks for your time.

0

There are 0 best solutions below