question

Babar Q. avatar image
Babar Q. asked ·

Hybrid Mobile User Sessions and Web Requests/User Actions

Dear All,

We recently instrumented a hybrid mobile application using the Cordova plugin to have the Mobile RUM (external) performance data.

Now the following things bothering me:

  • Top web requests appearing under the network performance > top providers > our publically available external, which cannot correlate to any user session.
  • Secondly, the user session details are showing only the below events and actions.

Regards,

Babar

extensionsRUMuser session monitoringuser actionsmobileapp
1593688291947.png (17.1 KiB)
1593688308002.png (17.1 KiB)
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Matthias H. avatar image
Matthias H. answered ·

If you want to have more visibility there is currently a workaround possible:


async makeRequest() {
	// Set Mobile dtAdk cookie because native web request don't add cookies
	this.http.setCookie("YOUR_URL", "dtAdk=" + this.getCookieValue("dtAdk"));
	// Create XHR Action via JavaScript OneAgent
	let actionId = dtrum.enterXhrAction("Mobile First HTTP", XhrActionMode.CREATE_ACTION_WITH_USER_INPUT, 'YOUR_URL');
	// Make HTTP Request with x-dtpc, x-dtreferer and x-dynatrace header
	await this.http.get('YOUR_URL', {}, { "x-dtpc": this.getCookieValue("dtPC"), "x-dtreferer": dT_.gAR(actionId), "x-dynatrace": "" });
	// Leave XHR After request is done
	dtrum.leaveXhrAction(actionId);
}

getCookieValue(a) {
	var b = document.cookie.match('(^|[^;]+)\\s*' + a + '\\s*=\\s*([^;]+)');
	return b ? b.pop() : '';
}


this.http is the http library where you are firing the web requests. Basically this snippet does the following:

  1. Set the current dtAdk Cookie onto the URL where the request happens (This can be changed to the domain and not the URL directly)
  2. JS Agent is creating an XHR Action
  3. Web Request will be tagged with 3 dynatrace related headers (x-dtpc, x-dtreferer, x-dynatrace)
  4. Leave the XHR Action


Result: You have an XHR Action in the User session with a web request which is linked to the server side.

1 comment Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Hello @Matthias H.

Thank you for your kind reply with a workaround solution. Let me go back to the developers especially those who instrumented the mobile application and then I will come back to you for further assistance.

Regards,

Babar

0 Likes 0 · ·
Thomas B. avatar image
Thomas B. answered ·

Hi Babar!

for 1:

What kind of library are you using for the web requests? If they originate from a User Action in the web part and go through a library (or your own implementation) to the native part of the app, then they can not be correlated. Which libraries are you using?

for 2:

When setting up the Cordova mobile app through the Dynatrace instrumentation wizard, a web application is created. If the UI of your app is mainly written in web technologies, then all the User Actions will be sent to this web application. Please note that User Actions in the web application will only be created if they can be correlated with a web request.

–Thomas

3 comments Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Hello @Thomas B.

Thank you for your kind reply. Let me go back to the developers to grab this information and then I will come back to you for further assistance.

Regards,

Babar

0 Likes 0 · ·

Hello @Thomas B.

I got the below answer.

The HTTP requests are managed by the IBM Mobile First Plugin:

Regards,

Babar

0 Likes 0 · ·

Hey Babar! Thanks for the info. Does the snippet, that Matthias provided, solve the problem? If not, could you then please open a support request so this can be handled properly?

1 Like 1 · ·

Space Topics