Environment specific Javascript resource

Environment specific Javascript resource

  

Good Morning, 

There may be a simple answer to this question which I am missing, so hopefully someone can help.

We currently use AppDynamics to monitor our applications and want to include some of our OutSystems apps in these metrics. To add the AppDynamics user monitoring we simply need to include a javascript file as close to the top of the screen as possible (very similar to GoogeAnalytics). 

I can easily do this by copying the contents of a .js file into the eSpace JavaScript and it works...however..the JavaScript contains a key which is different between environments.

Therefore the question is, How can I include a javascript file, or use variables in the JavaScript that can vary between environments without the need to republish (similar to site properties is guess!) 

Thanks in advance 

Neil



Hi Neil,

You can create a web block for javascrpt with a input parameter for key and also create a site property for assigning key for different environments.

Pass this site property as input to your webblock.


Regards

-PJ- 

Thanks for the response, I have been involved in other tasks so am only now returning to this.

I have tried the web block and input parameter approach already with some success, however in the context of what I am trying to do it doesn't fully satisfy my requirement.

Where I am now is that I can already include a Javascript resource using the AddJavaScriptTag action which works well, however I now need to set a javascript variable immediately before the Javascript I am adding. The resource file being added uses a key variable, so really the only thing I need to do now is set the javascript variable on my page with a site property, it is this I am not sure about now.

So, an example of what I need is.. the bold text is what i need to generate, with the key value from a site property - the rest i think i am Ok with

<head>
<script>
window["adrum-app-key"] = "AAM-AAB-AUM";
</script>
<script src="https://cdn.appdynamics.com/adrum/adrum-latest.js"></script>
. . .
. . .
</head>

Thanks Neil