<?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 Re: Unable to set a custom attribute after initial load for Next.js web app (RUM) in Splunk AppDynamics</title>
    <link>https://community.splunk.com/t5/Splunk-AppDynamics/Unable-to-set-a-custom-attribute-after-initial-load-for-Next-js/m-p/721087#M2390</link>
    <description>&lt;P&gt;HI&amp;nbsp;&lt;A href="https://community.appdynamics.com/t5/user/viewprofilepage/user-id/168631"&gt;@Ben.Howl&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;Thanks for asking your question on the Community. It's been a few days and the Community has not jumped in, I wanted to let you know you can always contact AppD Support or even your AppD CSM.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.appdynamics.com/t5/Knowledge-Base/How-do-I-submit-a-Support-ticket-An-FAQ/m-p/28959#U28959" class="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;How do I submit a Support ticket? An FAQ&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you find a solution or any other bit of help to this question, it would be helpful if you could come back and share that as a reply.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Mar 2024 15:36:30 GMT</pubDate>
    <dc:creator>iamryan</dc:creator>
    <dc:date>2024-03-28T15:36:30Z</dc:date>
    <item>
      <title>Unable to set a custom attribute after initial load for Next.js web app (RUM)</title>
      <link>https://community.splunk.com/t5/Splunk-AppDynamics/Unable-to-set-a-custom-attribute-after-initial-load-for-Next-js/m-p/721086#M2389</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;
&lt;P&gt;Tech stack: Next.js 13 (pages router)&lt;/P&gt;
&lt;P&gt;I've been following the guide&amp;nbsp;&lt;A href="https://docs.appdynamics.com/display/GOVAPM234/Add+Custom+User+Data+to+a+Page+Browser+Snapshot" target="_blank" rel="noopener nofollow noreferrer"&gt;https://docs.appdynamics.com/display/GOVAPM234/Add+Custom+User+Data+to+a+Page+Browser+Snapshot&lt;/A&gt;&amp;nbsp;to set custom attributes.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On the initial page I load the AppDynamics script provided below&lt;/P&gt;


&lt;PRE class="lia-code-sample language-javascript"&gt;&lt;CODE&gt;window['adrum-start-time'] = new Date().getTime()
;((config) =&amp;gt; {
  config.appKey = 'XXX'
  config.adrumExtUrlHttp = 'http://cdn.appdynamics.com'
  config.adrumExtUrlHttps = 'https://cdn.appdynamics.com'
  config.beaconUrlHttp = 'http://syd-col.eum-appdynamics.com'
  config.beaconUrlHttps = 'https://syd-col.eum-appdynamics.com'
  config.useHTTPSAlways = true
  config.xd = { enable: true }
  config.resTiming = { bufSize: 200, clearResTimingOnBeaconSend: true }
  config.maxUrlLength = 512;
  config.userEventInfo = {
    PageView: getAppDynamicsUserInfo(),
    VPageView: getAppDynamicsUserInfo(),
  }
})(window['adrum-config'] || (window['adrum-config'] = {}))&lt;/CODE&gt;&lt;/PRE&gt;


&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&lt;STRONG&gt;getAppDynamicsUserInfo&lt;/STRONG&gt; is a function attached to window and will return the attribute &lt;STRONG&gt;sessionId&lt;/STRONG&gt; always and if available, another attribute called &lt;STRONG&gt;customerId.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;On the initial page load, the &lt;STRONG&gt;sessionId&lt;/STRONG&gt; is sent and viewable on AppDynamics Analyze view. When I get to the page where the &lt;STRONG&gt;customerId&lt;/STRONG&gt; is available, it is not sent to AppDynamics.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I inspect &lt;STRONG&gt;window["adrum-config"] &lt;/STRONG&gt;or use &lt;STRONG&gt;ADRUM.conf.userConf, &lt;/STRONG&gt;I can see both &lt;STRONG&gt;sessionId&lt;/STRONG&gt; and &lt;STRONG&gt;customerId.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;In the above script I've tried just setting &lt;STRONG&gt;PageView&lt;/STRONG&gt; and just setting &lt;STRONG&gt;VPageView&lt;/STRONG&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In terms of methods of loading the above script, I've used the Next.js Script component and tried the following:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Load the above as an external script file on different pages (different react components)&lt;/LI&gt;
&lt;LI&gt;Load the above in different versions of the same script file (different names) on different pages&lt;/LI&gt;
&lt;LI&gt;Added the above script into a React component and loaded the component on different pages&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I've also tried to use the AJAX method to intercept http calls. It intercepts the http call but does not result in sending the user data to AppDynamics.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition to trying to set it via config.userInfo as above, I've tried to use the following options as well.&amp;nbsp;&lt;/P&gt;


&lt;PRE class="lia-code-sample language-javascript"&gt;&lt;CODE&gt;(function (info) {
   info.PageView = getAppDynamicsUserInfo
   info.VPageView = getAppDynamicsUserInfo
})(config.userEventInfo || (config.userEventInfo = {}))

(function (info) {
   info.PageView = getAppDynamicsUserInfo()
   info.VPageView = getAppDynamicsUserInfo()
})(config.userEventInfo || (config.userEventInfo = {}))

​&lt;/CODE&gt;&lt;/PRE&gt;


&lt;P&gt;Any help is appreciated, thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2024 06:20:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-AppDynamics/Unable-to-set-a-custom-attribute-after-initial-load-for-Next-js/m-p/721086#M2389</guid>
      <dc:creator>Ben_Howl</dc:creator>
      <dc:date>2024-03-27T06:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to set a custom attribute after initial load for Next.js web app (RUM)</title>
      <link>https://community.splunk.com/t5/Splunk-AppDynamics/Unable-to-set-a-custom-attribute-after-initial-load-for-Next-js/m-p/721087#M2390</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;A href="https://community.appdynamics.com/t5/user/viewprofilepage/user-id/168631"&gt;@Ben.Howl&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;Thanks for asking your question on the Community. It's been a few days and the Community has not jumped in, I wanted to let you know you can always contact AppD Support or even your AppD CSM.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.appdynamics.com/t5/Knowledge-Base/How-do-I-submit-a-Support-ticket-An-FAQ/m-p/28959#U28959" class="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;How do I submit a Support ticket? An FAQ&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you find a solution or any other bit of help to this question, it would be helpful if you could come back and share that as a reply.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2024 15:36:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-AppDynamics/Unable-to-set-a-custom-attribute-after-initial-load-for-Next-js/m-p/721087#M2390</guid>
      <dc:creator>iamryan</dc:creator>
      <dc:date>2024-03-28T15:36:30Z</dc:date>
    </item>
  </channel>
</rss>

