Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Abid_Jamil_-_Mobile_App_Performance.pdf

Abid Jamil
December 16, 2022
22

 Abid_Jamil_-_Mobile_App_Performance.pdf

Abid Jamil

December 16, 2022
Tweet

Transcript

  1. Crashlytics Dependencies // Add the dependency for the Crashlytics Gradle

    plugi n 
 classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2' 
 Project Level Build Gradle
  2. Crashlytics Dependencies // Add the dependencies for the Crashlytics and

    Analytics libraries 
 // When using the BoM, you don't specify versions in Firebase library dependencie s implementation 'com.google.firebase:firebase-crashlytics ' implementation ‘com.google.firebase:firebase-analytics ' 
 App Level Build Gradle
  3. Crashlytics Dependencies // Add the Crashlytics Gradle plugin
 
 id

    'com.google.firebase.crashlytics' 
 App Level Build Gradle
  4. Create firebase.json at Root { "react-native": { "crashlytics_debug_enabled": false, "crashlytics_disable_auto_disabler":

    true, "crashlytics_auto_collection_enabled": true, "crashlytics_is_error_generation_on_js_crash_enabled": true, "crashlytics_javascript_exception_handler_chaining_enabled": true } }
  5. Get attached with user crashlytics().log('User signed in.'); await Promise.all([ crashlytics().setUserId(user.uid),

    crashlytics().setAttribute('cleverTapId', String(user.clevertapId)), crashlytics().setAttributes({ role: 'user', phone: user.phone, email: user.email, username: user.username, }), ]);
  6. Create logs for better debuggin g crashlytics().log('App mounted.’); crashlytics().log(‘Cart Opened.’);

    crashlytics().log(‘Promo Applied.’); crashlytics().log(JSON.Stringify(orderData));
  7. Performance Dependencies // Add the dependency for the Crashlytics Gradle

    plugi n 
 classpath 'com.google.firebase:firebase-perf-gradle:2.9.2' 
 Project Level Build Gradle
  8. Performance Dependencies // Add the dependencies for the Crashlytics and

    Analytics libraries 
 // When using the BoM, you don't specify versions in Firebase library dependencie s implementation 'com.google.firebase:firebase-perf '   
 App Level Build Gradle
  9. Performance Dependencies // Add the Crashlytics Gradle plugin
 
 id

    ‘com.google.firebase.perf' 
 App Level Build Gradle
  10. Create firebase.json at Root { "react-native": { "crashlytics_debug_enabled": false, "crashlytics_disable_auto_disabler":

    true, "crashlytics_auto_collection_enabled": true, "crashlytics_is_error_generation_on_js_crash_enabled": true, "crashlytics_javascript_exception_handler_chaining_enabled": true } }
  11. Create a custom trace for each scenario perf().startTrace("HomeScreenRendering").then((_trace)=>{ trace =

    _trace _trace.putAttribute('user', user?.id) }).catch((e)=>{console.log(e)}) trace.stop();
  12. Create a custom trace for each scenario async function getRequest(url)

    { // Define the network metric const metric = await perf().newHttpMetric(url, 'GET'); // Define meta details metric.putAttribute('user', 'abcd'); // Start the metric await metric.start(); // Perform a HTTP request and provide response information const response = await fetch(url); metric.setHttpResponseCode(response.status); metric.setResponseContentType(response.headers.get('Content-Type')); metric.setResponsePayloadSize(response.headers.get('Content-Length')); // Stop the metric await metric.stop(); return response.json(); }