21 Mar 2025
10:14 AM
- last edited on
24 Mar 2025
07:23 AM
by
MaciejNeumann
Hello everyone!
Dynatrace is set up within the company and applications have been created, which are successfully receiving RUM traffic. However, some applications that are manually injected have been created through the creation of detection rules, meaning they are presented as auto injected by Dynatrace.
I need to accurately determine whether each application has been injected manually or automatically, along with identifying the specific injection format (OneAgent JS Tag, JS Tag, Inline code, or code snippet).
This will help me, among other things, determine which manually injected applications were created through detection rules and, hence, should be re-created as agentless.
To ascertain the type and format of an injection, I utilize the following function in the Developer Tools console of the web page associated with the application: dT_.gdi() (Source). The output provides various details, for instance:
In my exploration of this function, I have identified a few key points:
According to the documentation, "For automatic injection, different injection formats of the RUM JavaScript look different, but what they all have in common is the data-dtconfig attribute." (source: Rum JavaScript injection).
However, this contradicts my findings with dT_.gdi(), as the automatically injected CodeSnippetDeferred and CodeSnippetSync scripts do not contain this attribute, yet dT_.gdi() recognizes them correctly.
My conclusion on this part is that the documentation is wrong.
dT_.gdi() will determine a web application with a CodeSnippetDeferred injection as a CodeSnippetSync injection. From my testings, dT._gdi() seems to be looking for the defer keyword, which is not present in the CodeSnippetDeferred. Indeed, the only difference between both code snippets is the presence of the keyword async in the CodeSnippetDefered.
My conclusion on this part is that dT_.gdi() is wrong.
Given this, my questions are the following:
Thank you in advance for your feedback .
Solved! Go to Solution.
24 Mar 2025 12:44 PM
Hi
I just retested everything and can not confirm your findings regarding dT_.gdi(). (I can however confirm that the documentation regarding the data-dtconfig attribute is wrong and will follow up on that internally).
These are my test results:
Automatic
OneAgent JavaScript Tag
<script type="text/javascript" src="[...]" data-dtconfig="[...]"></script>
"OneAgent JavaScripTag automatically injected"
CodeSnippet Sync
<script type="text/javascript">[...]</script>
<script type="text/javascript" src="/ajax/ruxitagentjs_A7fhrux_10307250109101944.js"></script>
"CodeSnippetSync automatically injected"
Code Snippet Deferred
<script type="text/javascript">[...]</script>
<script type="text/javascript" src="/ajax/ruxitagentjs_A7fhrux_10307250109101944.js" defer="defer"></script>
"CodeSnippetDeferred automatically injected"
Inlined
<script type="text/javascript" data-dtconfig="[...]">[...]</script>
"InlineCode automatically injected"
Manually
OneAgent JavaScript Tag
<script type="text/javascript" src="[...]" data-dtconfig="[...]" crossorigin="anonymous"></script>
"OneAgent JavaScripTag manually injected"
Codesnippet Sync
<script type="text/javascript">[...]</script>
<script id="dtjsagentdw" type="text/javascript" src="[...]" crossorigin="anonymous"></script>
"CodeSnippetSync manually injected"
Code Snippet Deferred
<script type="text/javascript">[...]</script>
<script src="[...]" defer="defer" id="dtjsagent" crossorigin="anonymous"></script>
"CodeSnippetDeferred manually injected"
Inlined
<script type="text/javascript" data-dtconfig="[...]">[...]</script>
"InlineCode manually injected"
JavaScript Tag
<script type="text/javascript" src="[...]"></script>
"JavaScriptTag manually injected"
In my samples dT_.gdi() detected all formats correctly. The thing you mentioned is that dT_.gdi() is searching for "defer", but the only difference is "async", seems to be a misunderstanding though. Internally our config flag is called "async" to tell the JavaScript code to inject the deferred code (this goes back to the time we were still working on appmon).
But this is an internal detail and AFAIK not documented anywhere. The dT_.gdi() function correctly identifies it as deferred snippet though.
I'm happy to have another look, if you provide more information though.
Simon
24 Mar 2025 12:49 PM
And as another remark directly to your questions:
24 Mar 2025 02:49 PM
Hello,
Thank you for your prompt response!
I should have included it in my first post, but here is the result from one of our web applications that leaves me confused:
We have a web application where a CodeSnippetDeferred has been manually injected. The injected code snippet does include the async keyword, which, if I understand correctly from your earlier response, suggests that the code snippet is indeed deferred.
However, when I inspect the web page using DevTools, I notice the following:
<script type="text/javascript"></script>
<script id="dtjsagentdw" type="text/javascript" src="[...]"></script>
I see that the defer="defer" attribute is absent. It is also not present in the snippet provided by the Dynatrace UI when I opt for manual injection of CodeSnippetDeferred for any application.
This has led me to speculate that the dT_.gdi() method may be outputting a manually injected CodeSnippetSync due to the absence of the defer attribute.
Thank you for you assistance,
Jordi
26 Mar 2025 09:58 AM
Hi Jordi
Is it possible that you have copied the Deferred Snippet, but have changed the setting in the UI to something else afterwards?
As you may know, one of the big advantages of the dynatrace JavaScript is that we can dynamically update the config. So what I think happens is that the first time you open the page, it is injected deferred. Then we receive a config update from the server side which switches the injection mechanism and therefore your script tag is no longer injected deferred?
You can check the UI to confirm, but you should also be able to confirm by loading your page in Incognito mode (=completely fresh) and check the tag. At this point, the script tag should be injected deferred. After a refresh of the page, the script tag would then be injected without the defer attribute.
Simon
28 Mar 2025 10:54 AM
Hello Simon,
The issue did indeed come from the fact that the config is dynamically updated. When opening the web page in incognito mode, the defer tag is present. And when refreshing the page, the defer tag is absent.
Thank you.
Jordi
24 Mar 2025 11:01 PM
There is also a property of applicationType that is tracked within the Dynatrace tenant under the Application (dt.entity.application) entity. This may be useful with a DQL query like the below in a Notebook:
fetch dt.entity.application
| fieldsAdd entity.name, applicationType