Skip to content
This repository has been archived by the owner on May 17, 2022. It is now read-only.

N.2 Init Performance

Hadi Tavakoli edited this page Jul 8, 2019 · 1 revision

Initialize Firebase Performance

You can initialize the Performance ANE by calling Perf.init(); As soon as you initialized the firebasePerformance.ane in your project, you will be able to create custom traces for monitoring your app's performance

Notice: Before initializing Performance, you must have already successfuly initialized the FirebaseCore.

You can monitor if the Performance ANE is monitoring your app or not by seting the Perf.collectionEnabled property to true or false.

Check the Firebase console for Performance Monitoring results

  1. After initializing the Performance ANE and making sure that Performance collection is enabled, build your app.
  2. Test your app using either:
  • An Android emulator with a recent image and Google Play services 15.0.0 or later
  • A test device with Google Play services 15.0.0 or later.
  1. Confirm that Performance Monitoring results display in the Firebase console.

(Optional) Add custom traces and custom metrics

A custom trace is a report of performance data associated with some of the code in your app. To learn more about custom traces, see the Performance Monitoring overview.

You can have multiple custom traces in your app, and it's possible to have more than one custom trace running at a time. Each custom trace can have one or more metrics to count performance-related events in your app, and those metrics are associated with the traces that create them.

Note that names for custom traces and metrics must meet the following requirements: no leading or trailing whitespace, no leading underscore (_) character, and max length is 32 characters.

To start and stop a custom trace, wrap the code that you want to trace with lines of code similar to the following (this example uses a custom trace name of test_trace):

import com.myflashlab.air.extensions.firebase.performance.*;

var myTrace:PerfTrace = Perf.newTrace("test_trace");
myTrace.start();

// code that you want to trace

myTrace.stop();

To add a custom metric, add lines of code similar to the following each time that the event occurs. For example, this custom metric counts performance-related events that occur in your app, such as cache hits and misses (using example event names of item_cache_hit and item_cache_miss and an increment of 1).

var myTrace:PerfTrace = Perf.newTrace("test_trace");
myTrace.start();

// code that you want to trace (and log custom metrics)
var item:Item = cache.fetch("item");
if (item != null)
{
    myTrace.incrementMetric("item_cache_hit", 1);
}
else
{
    myTrace.incrementMetric("item_cache_miss", 1);
}

myTrace.stop();

(Optional) Add monitoring for specific network requests

Performance Monitoring collects network requests automatically. Although this includes most network requests for your app, some might not be reported.

To include custom network requests in Performance Monitoring, add the following code to your app:

var httpMetric:HttpMetric = Perf.newHttpMetric("https://www.google.com", URLRequestMethod.GET);
httpMetric.start();

var request:URLRequest = new URLRequest();
request.url = "https://www.google.com";
request.method = URLRequestMethod.GET;

var loader:URLLoader = new URLLoader();

loader.addEventListener(IOErrorEvent.IO_ERROR, function (event:IOErrorEvent):void {
	trace(event.toString());
});

loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, function (event:HTTPStatusEvent):void {
	trace("httpStatusHandler: " + event);
				
	httpMetric.setHttpResponseCode(event.status);
	httpMetric.stop();
});

loader.load(request);

The HTTP/S network requests that you specifically capture in this way appear in the Firebase console along with the network requests that Performance Monitoring captures automatically.

After you've validated Performance Monitoring using one or more test devices, you can deploy the updated version of your app to your users.

Note: Depending on the behavior of your code and networking libraries used by your code, Performance Monitoring might only report HTTP/S network requests that are completed. This means that HTTP/S connections that are left open might not be reported.

Debug your integration (Android)

You can enable debug logging for Performance Monitoring at build time, by adding a <meta-data> element to your app's manifest .xml file, like so:

<application>
    <meta-data
      android:name="firebase_performance_logcat_enabled"
      android:value="true" />
</application>

You can view trace and HTTP/S network request logging using logcat filtering. Performance Monitoring log messages are tagged with FirebasePerformance, and you can filter them using following command:

$ adb logcat -s FirebasePerformance

DISCRIMINATION: Firebase SDKs are developed by Google and they own every copyright to the Firebase "native" projects. However, we have used their "compiled" native SDKs to develop the ActionScript API to be used in AdobeAIR mobile projects. Moreover, as far as the documentations, we have copied and when needed has modified the Google documents so it will fit the needs of AdobeAIR community. If you wish to see the original documentations in Android/iOS, visit here. But if you are interested to do things in AdobeAIR, then you are in the right place.

Introduction to Firebase ANEs collection for Adobe Air apps


Get Started with Firebase Core in AIR

  1. Prerequisites
  2. Add Firebase to your app
  3. Add the Firebase SDK
  4. Init Firebase Core
  5. Available ANEs
  6. Managing Firebase iid

Get Started with Analytics

  1. Add Analytics ANE
  2. Init Analytics ANE
  3. Log Events
  4. Set User Properties

Get Started with Crashlytics

  1. Add Crashlytics ANE
  2. Test Your Implementation
  3. Customize Crash Reports
  4. Upload .dSYM for iOS apps

Get Started with DynamicLinks

  1. Add DynamicLinks ANE
  2. Init DynamicLinks ANE
  3. Create DynamicLinks
  4. Receive DynamicLinks
  5. View Analytics

Get Started with Authentication

  1. Add Authentication
  2. Init Authentication
  3. Manage Users
  4. Phone Number
  5. Custom Auth
  6. Anonymous Auth
  7. State in Email Actions
  8. Email Link Authentication

Get Started with FCM + OneSignal

  1. Add FCM ANE
  2. Init FCM ANE
  3. Send Your 1st Message
  4. Send Msg to Topics
  5. Understanding FCM Messages
  6. init OneSignal

Get Started with Firestore

  1. Add Firestore
  2. Init Firestore
  3. Add Data
  4. Transactions & Batches
  5. Delete Data
  6. Manage the Console
  7. Get Data
  8. Get Realtime Updates
  9. Simple and Compound
  10. Order and Limit Data
  11. Paginate Data
  12. Manage Indexes
  13. Secure Data
  14. Offline Data
  15. Where to Go From Here

Get Started with Realtime Database

  1. Add Realtime Database
  2. Init Realtime Database
  3. Structure Your Database
  4. Save Data
  5. Retrieve Data
  6. Enable Offline Capabilities

Get Started with Remote Config

  1. Parameters and Conditions
  2. Add Remote Config
  3. Init Remote Config

Get Started with Performance

  1. Add Performance ANE
  2. Init & Start Monitoring

Get Started with Storage

  1. Add Storage ANE
  2. Init Storage ANE
  3. Upload Files to Storage
  4. Download Files to Air
  5. Use File Metadata
  6. Delete Files

Get Started with Functions

  1. Write & Deploy Functions
  2. Add Functions ANE
  3. Init Functions
Clone this wiki locally