on 03 Jan 2023 02:41 AM - edited on 03 Jan 2023 09:57 AM by Karolina_Linda
A session gets tagged when SDK API method is called.
Dynatrace.identifyUser("john.doe@example.com");
for both Android and iOS.
Review the logs.
From the Application => Mobile app settings => Instrumentation settings.
If opt-in mode is enabled
Make sure that, for iOS, in the plist DTXUserOptIn is set to true or, for Android, in the configuration file that userOptIn set to true
From Logs iOS: DTXUserOptIn , value: 1, Android : userOptIn=true
Confirm that the application code has the privacy notice added so users can set their preferences. Example here.
import Dynatrace
// Privacy settings configured below are only provided
// to allow a quick start with capturing monitoring data.
// This has to be requested from the user
// (e.g. in a privacy settings screen) and the user decision
// has to be applied similar to this example.
let privacyConfig = Dynatrace.userPrivacyOptions()
privacyConfig.dataCollectionLevel = .userBehavior
privacyConfig.crashReportingOptedIn = true
privacyConfig.crashReplayOptedIn = true
Dynatrace.applyUserPrivacyOptions(privacyConfig) { (Bool) in
// callback after privacy changed
}
// Privacy settings configured below are only provided
// to allow a quick start with capturing monitoring data.
// This has to be requested from the user
// (e.g. in a privacy settings screen) and the user decision
// has to be applied similar to this example.
Dynatrace.applyUserPrivacyOptions(UserPrivacyOptions.builder()
.withDataCollectionLevel(DataCollectionLevel.USER_BEHAVIOR)
.withCrashReportingOptedIn(true)
.build());
These parts of code can be found in Application => Mobile app settings => Instrumentation wizard for each platform.
In this situation, USER_BEHAVIOR is the only status in which the user will be tagged.
IOS
Search in the xcode console logs for the following, Here "Kazuya" name is tagged.
CREATED IDENTIFY_USER EVENT: <DTXMeasurement 0x7fcd89521410: visitorId=7868376413403 sessionId=12 sessionSequence=0 name=Kazuya startTimestamp=2021-08-19 14:13:56 +0000 customValue=0 duration=0.000000 sent=0 connectionType=w networkProtocol=802.11x batteryStrengthPercent=-2 freeMemoryPercent=0 activeMemoryPercent=42 inactiveMemoryPercent=42 wiredMemoryPercent=9 portraitOrientation=1 currentTag=-1 enclosingTag=0 customValueDouble=0.000000 eventType=60 self.eventTypeString=IdentifyUser lifecycleSequence0=18 lifecycleSequence1=0 lifecycleSequence2=0 lifecycleSequence3=0 threadId=1 bytesReceived=0 bytesSent=0 >
Android
In this example, the application user is tagged with "Ace Ventura" and the corresponding log entry can be found in Logcat (either in Android Studio or with the adb logcat command-line tool)
2021-08-19 11:41:59.818 10455-10455/com.dynatrace.mobilelab D/dtxAgentCore
NOTE: |
So if we are sure that the Dynatrace.identifyUser is being called and sometimes users are not tagged.
We have to confirm that this line of code "Dynatrace.identifyUser" is being called.
An easy way to do that is to print in the log a custom message
Example:
print("***WILL START TAGGING***")
Dynatrace.identifyUser("john.doe@example.com");
print("***Tagged the user***")
If you don't see the printed parts in the logs, then identifyUser was never called.
Also, make sure that the passed variable to identify the user is not null or empty (simply by printing its value to the logs.)
If you pass a null or empty string to Dynatrace.identifyUser(""); the sessions won't be tagged.
From iOS logs:
Here the visitor ID is 14054083387977
From the logs search for visitorID: <visitorID>
2021-08-23 14:29:40.045093+0200 DynaPods[7304:249306] 🔼 FINE 📡 Communication [DTXCommunicationsManager.m:1118-12803-2] sendMetrics for visitorId: 14054083387977 sessionId: 151, number of metrics to send: 12
From Android logs:
Here the visitor's session ID is 3672025434
From the logs at the beacon search for vi=<visitorID>
#12712.aPOST url[https://bf62926nek.bf.dynatrace.com/mbeacon?type=m&srvid=3&app=012cb464-3e06-4454-ada1-db0ec2db871a&va=8.217.1.1003&tt=maandroid&pt=0&resp=json&cts=1625491826087&si=3672025434_4] data[vv=3&va=8.217.1.1003&ap=012cb464-3e06-4454-ada1-db0ec2db871a&an=MySafaricom&ai=com.safaricom.mysafaricom&vn=1.8.0-beta-rc01&vb=10816&vi=3672025434&sn=4&ss=0&rm=1850&cp=ARMv7+rev+4+%28v7l%29&os=Android+10&mf=HMD+Global&md=Nokia+2.4&rj=g&ul=en_GB&sw=720&sh=1600&sd=280&pt=0&so=p&bl=100&fm=723&cr=SAF+FOR+YOU&ct=w&np=802.11x&tt=maandroid&dl=2&cl=2&vs=2&fv=pl&tv=1625
or if there is a web request that is tagged by the android agent via MT_<visitorID>
Mobile Sessions are split: