cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

React Native - Android - No Actions

rgarzon1
Pro

Hi.

Doing a implementation of RN in a client we are facing 2 problems.

1- actions were not being capture we check the opt in its disabled but even so, it is necessary to set this as part of the main app.

opt in disabled

rgarzon1_5-1669708531814.png

yet this its necessary. to capture the actions add this code to the app.

let privacyConfig = new UserPrivacyOptions(DataCollectionLevel.UserBehavior , true);
Dynatrace.applyUserPrivacyOptions(privacyConfig);


this as part for my understanding its not working properly, because if the opt-in its disabled its not necesary to implement the privacy config.

now we are getting the actions as names ( icon names) but its something that we can handle. with dtActionName

  • dtActionName: Use a custom property called dtActionName

well this its the 2 problem.

the client ask to to use dtActionName inside a button. in a test before implement it on their app. its required to see it working before.

in this journey (in theory easy one), i am using the default app that its created with npx command

npx react-native init dynajs --template react-native-template-typescript@latest

this create a app with RN 0.70.6 and i am adding some navigation tabs.

rgarzon1_0-1669708202855.pngrgarzon1_1-1669708240961.png

its a simple one app for testing purposes. and i am facing the same problem. no regular actions are being capture,

i just create 3 tabs, 2 buttons and 2 touchable events.

the tab buttons arent being capture, the bizevent button neither, the "PRESIONAME" button its a Dynatrace.enterAction so its being captured. and a touchable event its no being capture.

last time this happen to me i just add the privacy config (even when its not necesary) and this work and started to capture actions on 0.67 version. now in RN 0.70.6 its not working the same recipe.

i just doing the normal thing

react-native start --reset-cache
npx instrumentDynatrace
npx react-native run-android

i am using even the default config that its made with npx dyntraceconfig command because the one that we can download its not working neither.

the logs just look fine.

#INFO [2022-11-29 02:30:26]: Starting instrumentation of React Native application ..
#INFO [2022-11-29 02:30:26]: Dynatrace React Native Plugin - Version 2.253.2
#INFO [2022-11-29 02:30:27]: Trying to read configuration file: D:\66-Programas\android\reactnativeapp\reactdyna\dynajs\dynajs\dynatrace.config.js
#INFO [2022-11-29 02:30:27]: Starting Android Instrumentation with Dynatrace!
#INFO [2022-11-29 02:30:27]: Dynatrace plugin & agent already added to build.gradle
#INFO [2022-11-29 02:30:27]: Replaced old configuration with current configuration in dynatrace.gradle
#INFO [2022-11-29 02:30:27]: Finished Android Instrumentation with Dynatrace!
#INFO [2022-11-29 02:30:27]: Starting iOS Instrumentation with Dynatrace!
#INFO [2022-11-29 02:30:27]: Not generating a new plist as the current plist and dynatrace.config.js iOS properties are identical!
#INFO [2022-11-29 02:30:27]: Finished iOS Instrumentation with Dynatrace!
#INFO [2022-11-29 02:30:27]: Patching SourceMap generation of Metro ..
#INFO [2022-11-29 02:30:27]: Patching of SourceMap already happened!
#INFO [2022-11-29 02:30:27]: Finished instrumentation of React Native application ..

rgarzon1_10-1669709694285.png

if anyone have a idea. please i am open to try it. i really dont know what i am missing here.

fuelled by coffee and curiosity.
9 REPLIES 9

matthias_hochri
Dynatrace Pro
Dynatrace Pro

Hi,

The problem is known already and is happening because internally the metro bundler changed the resolution of the JSX Tags. There will be an update this week.

Thanks.

Thank you matthias.

so, the problem its only for 0.70+ or any react version ? . i even try to modify the babel as the documentation says. without success.

rgarzon1_0-1669730718121.png

fuelled by coffee and curiosity.

The problem occurs only with newer RN version which include a newer metro version. So since metro 0.72 they changed the JSX Tag resolution.

If you have changed the babel.config.js already, this actually should work. What kind of Buttons do you use? Directly from React Native? After changing the babel.config.js, did you reset the cache of Metro? (--reset-cache)

Hi matthias

i am trying with the most basic buttons.

<TouchableHighlight {...{ "dtActionName": "CustomActionName" }}><Text>Custom Action Name</Text></TouchableHighlight>
or
export class Button extends React.Component<ButtonProps> {}
rgarzon1_0-1669734877640.png
but maybe i am missing something. the client its working with the same but using the Atomic design..
for the deploy i do this every time.
react-native start --reset-cache
npx instrumentDynatrace
npx react-native run-android
fuelled by coffee and curiosity.

matthias_hochri_0-1669792013801.png

Here you can see my example. I created a totally new RN project. Included a button. Logs are created with the title of the button (What log is only the content of the onPress). Later on I add a dtActionName MyName and it works as well.

I guess from this point we need to start a support ticket and we will happily look into this as we are interested if there is something we didn't consider.

HI matthias.

i just go back to RN 0.69.5 , and all its working just fine. but in the 0.70.6 isnt it. even with metro modifications.

rgarzon1_0-1669825029999.png

the actions are being detected but skipped by the opt-in in the 0.70. is what i notice.

thank you for your reply

fuelled by coffee and curiosity.

Okay that's odd. My example above is with 0.70.6. So what do you mean by opt-in, can you elaborate on that? Is it possible to host your sample project somewhere and I take a quick look? (Remove appId and beaconUrl from config)

Hi Matthias.

one of our first problem was that the opt-in was disabled on the UI of the page but the actions were not being capture.

until we add to the app

let privacyConfig = new UserPrivacyOptions(DataCollectionLevel.UserBehavior , true);
Dynatrace.applyUserPrivacyOptions(privacyConfig);

and maybe we think well, was enable on the configuration "dynatrace.config.js" , but there as well was disabled with "userOptIn false"
so i was thinking that maybe its something related to it . actions being execute but not recorded.
related to the project: i was using this https://github.com/rdlook04/gitreact

fuelled by coffee and curiosity.

Hi @rgarzon1 
I am specific user actions not recorded when you used the userOptIn, and if it is set to true, then you have to use the configuration. 

let privacyConfig = new UserPrivacyOptions(DataCollectionLevel.UserBehavior , true);
Dynatrace.applyUserPrivacyOptions(privacyConfig);

In case you set it to false in dynatrace.config file, use the above code and initiate userOptIn, which won't capture user actions. Hence, I suppose this is what happened to you. 

Love more, hate less; Technology for all, together we grow.

Featured Posts