<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic JavaScript function that triggers custom action and XHR request in Real User Monitoring</title>
    <link>https://community.dynatrace.com/t5/Real-User-Monitoring/JavaScript-function-that-triggers-custom-action-and-XHR-request/m-p/229271#M5468</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;i would like to find out if i have a JavaScript function (e.g. submitSentiments()) that trigger both an XHR request and a custom action, how will the actions be captured/recorded in Dynatrace?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would it be a case of:&lt;/P&gt;&lt;P&gt;1) 2 actions? 1 XHR action, 1 custom action or&lt;/P&gt;&lt;P&gt;2) 1 root action with one XHR request and 1 custom action group together since they are trigger by the same button click.&lt;/P&gt;&lt;PRE&gt;function submitSentiment(value) {&lt;BR /&gt;&lt;BR /&gt;//XHR action&lt;BR /&gt;fetch('https://jsonplaceholder.typicode.com/submit')&lt;BR /&gt;.then(response =&amp;gt; response.json())&lt;BR /&gt;.then(data =&amp;gt; {})&lt;BR /&gt;.catch(error =&amp;gt; {});&lt;BR /&gt;&lt;BR /&gt;//Custom action&lt;BR /&gt;var action = window.dtrum.enterAction('Submit sentiment');&lt;BR /&gt;window.dtrum.leaveAction(action);&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Mon, 20 Nov 2023 09:43:30 GMT</pubDate>
    <dc:creator>Weilin1</dc:creator>
    <dc:date>2023-11-20T09:43:30Z</dc:date>
    <item>
      <title>JavaScript function that triggers custom action and XHR request</title>
      <link>https://community.dynatrace.com/t5/Real-User-Monitoring/JavaScript-function-that-triggers-custom-action-and-XHR-request/m-p/229271#M5468</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;i would like to find out if i have a JavaScript function (e.g. submitSentiments()) that trigger both an XHR request and a custom action, how will the actions be captured/recorded in Dynatrace?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would it be a case of:&lt;/P&gt;&lt;P&gt;1) 2 actions? 1 XHR action, 1 custom action or&lt;/P&gt;&lt;P&gt;2) 1 root action with one XHR request and 1 custom action group together since they are trigger by the same button click.&lt;/P&gt;&lt;PRE&gt;function submitSentiment(value) {&lt;BR /&gt;&lt;BR /&gt;//XHR action&lt;BR /&gt;fetch('https://jsonplaceholder.typicode.com/submit')&lt;BR /&gt;.then(response =&amp;gt; response.json())&lt;BR /&gt;.then(data =&amp;gt; {})&lt;BR /&gt;.catch(error =&amp;gt; {});&lt;BR /&gt;&lt;BR /&gt;//Custom action&lt;BR /&gt;var action = window.dtrum.enterAction('Submit sentiment');&lt;BR /&gt;window.dtrum.leaveAction(action);&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 09:43:30 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Real-User-Monitoring/JavaScript-function-that-triggers-custom-action-and-XHR-request/m-p/229271#M5468</guid>
      <dc:creator>Weilin1</dc:creator>
      <dc:date>2023-11-20T09:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript function that triggers custom action and XHR request</title>
      <link>https://community.dynatrace.com/t5/Real-User-Monitoring/JavaScript-function-that-triggers-custom-action-and-XHR-request/m-p/229275#M5469</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/52140"&gt;@Weilin1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Given a JavaScript &lt;STRONG&gt;submitSentiment(value)&lt;/STRONG&gt; function that triggers both an XHR request and a custom action, Dynatrace is likely to register these actions as follows:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;XHR action:&lt;/STRONG&gt; the XHR request made by the fetch API call to "&lt;A href="https://jsonplaceholder.typicode.com/submit" target="_blank" rel="noopener"&gt;https://jsonplaceholder.typicode.com/submit&lt;/A&gt;" will be captured as an XHR action. Dynatrace automatically tracks XHR requests and associates them with user actions. This is seen as an interaction with the backend service.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Custom action:&lt;/STRONG&gt; a custom action defined by window.dtrum.enterAction('Submit sentiment') and window.dtrum.leaveAction(action) will be registered as a separate custom user action. Custom actions are defined explicitly in the code to denote specific interactions or behaviours that are important to track.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Dynatrace sees them as two separate actions because they are conceptually different - one is a network request to the server and the other is a custom action defined in the application.&lt;/P&gt;&lt;P&gt;There may still be an option two:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Main action&lt;/STRONG&gt;: The general interaction (e.g. clicking a button) that triggers the submitSentiment function can be considered the user's main action.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Nested actions&lt;/STRONG&gt;: Within this main action, Dynatrace will capture the XHR request and custom action as nested actions. Both are part of a wider user interaction, but are tracked individually for detailed analysis.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;In this option, Dynatrace groups the actions together because they are part of a single sequence of user interactions, providing a holistic view of what happens when a user performs a specific action (e.g. clicking a button that triggers a submitSentiment).&lt;/P&gt;&lt;P&gt;Hope it helps&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Radek&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 09:54:22 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Real-User-Monitoring/JavaScript-function-that-triggers-custom-action-and-XHR-request/m-p/229275#M5469</guid>
      <dc:creator>radek_jasinski</dc:creator>
      <dc:date>2023-11-20T09:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript function that triggers custom action and XHR request</title>
      <link>https://community.dynatrace.com/t5/Real-User-Monitoring/JavaScript-function-that-triggers-custom-action-and-XHR-request/m-p/229282#M5471</link>
      <description>&lt;P&gt;Hi Radek,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the explanation. It really helpful.&lt;/P&gt;&lt;P&gt;I am hoping that it will be option 1, that Dynatrace see them as 2 different actions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But i am also afraid that option 2 might happen. Hence how can i prevent option 2 from happening?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 10:09:28 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Real-User-Monitoring/JavaScript-function-that-triggers-custom-action-and-XHR-request/m-p/229282#M5471</guid>
      <dc:creator>Weilin1</dc:creator>
      <dc:date>2023-11-20T10:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript function that triggers custom action and XHR request</title>
      <link>https://community.dynatrace.com/t5/Real-User-Monitoring/JavaScript-function-that-triggers-custom-action-and-XHR-request/m-p/229288#M5472</link>
      <description>&lt;P&gt;What you can do is make sure that the custom action and the XHR request are defined as separate actions in the code. This includes clearly separating blocks of code and ensuring they are called independently. Additionally, assign unique identifiers or names to each action. This should help:)&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 10:15:46 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Real-User-Monitoring/JavaScript-function-that-triggers-custom-action-and-XHR-request/m-p/229288#M5472</guid>
      <dc:creator>radek_jasinski</dc:creator>
      <dc:date>2023-11-20T10:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript function that triggers custom action and XHR request</title>
      <link>https://community.dynatrace.com/t5/Real-User-Monitoring/JavaScript-function-that-triggers-custom-action-and-XHR-request/m-p/229291#M5473</link>
      <description>&lt;P&gt;Would something like this work?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function submitSentiment(value) {

//Custom action
var action = window.dtrum.enterAction('Submit sentiment');
window.dtrum.leaveAction(action);

//XHR action
fetch('https://jsonplaceholder.typicode.com/submit')
.then(response =&amp;gt; response.json())
.then(data =&amp;gt; { 
var action = dtrum.enterXhrAction('xhr', 3,'https://jsonplaceholder.typicode.com/submit');
dtrum.leaveXhrAction(action); 
})
.catch(error =&amp;gt; {});
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this what you mean by&amp;nbsp;&lt;SPAN&gt;defined as separate actions?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 10:27:22 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Real-User-Monitoring/JavaScript-function-that-triggers-custom-action-and-XHR-request/m-p/229291#M5473</guid>
      <dc:creator>Weilin1</dc:creator>
      <dc:date>2023-11-20T10:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript function that triggers custom action and XHR request</title>
      <link>https://community.dynatrace.com/t5/Real-User-Monitoring/JavaScript-function-that-triggers-custom-action-and-XHR-request/m-p/229309#M5476</link>
      <description>&lt;P&gt;Yes, it looks good&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 11:35:15 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Real-User-Monitoring/JavaScript-function-that-triggers-custom-action-and-XHR-request/m-p/229309#M5476</guid>
      <dc:creator>radek_jasinski</dc:creator>
      <dc:date>2023-11-20T11:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript function that triggers custom action and XHR request</title>
      <link>https://community.dynatrace.com/t5/Real-User-Monitoring/JavaScript-function-that-triggers-custom-action-and-XHR-request/m-p/229412#M5484</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 00:44:15 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Real-User-Monitoring/JavaScript-function-that-triggers-custom-action-and-XHR-request/m-p/229412#M5484</guid>
      <dc:creator>Weilin1</dc:creator>
      <dc:date>2023-11-21T00:44:15Z</dc:date>
    </item>
  </channel>
</rss>

