question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error sending event to firebase analytics. W/FA: Value is too long

See original GitHub issue

Bug Report

Problem

I searched but found nothing related to it.

I’m developing an e-commerce app with ionic in wich i’m sending events to the firebase analytics using this plugin following the steps described here. However, when I try to send a list of products in the event view_cart I get the following error in logcat: W/FA: Value is too long; discarded. Value kind, name, value length: param, items, 204

This is the log of the event I sent: V/FA-SVC: Logging event: origin=app,name=view_cart,params=Bundle[{ga_event_origin(_o)=app, ga_error_length(_el)=204, ga_error_value(_ev)=items, ga_screen_class(_sc)=MainActivity, ga_screen_id(_si)=-6971504103994550923, ga_screen(_sn)=carrinho, ga_error(_err)=4, value=36.0, currency=BRL, local_nome=Pizzaria CNM, local_id=108}]

Code

const items = [];
this.listaPedidoClienteProduto.forEach(item => {
  const prod: Produto = new Produto(item.produto);
  const valor = prod.valorPromocao ? prod.valorPromocao : prod.valorVenda;

  items.push({
      item_id: prod.id.toString(),
      item_name: prod.descricaoPnm,
      quantity: item.quantidade ? item.quantidade : 1,
      price: valor
  });
});

this.firebaseCordova.logEvent('view_cart', {
  currency: 'BRL',
  value: this.valorTotalPedido,
  items: items
}).then((res: any) => {
  if(res !== "OK") {
      console.log(res);
  }
}).catch((error: any) => console.error(error));

I decided to debug the plugin code (src/android/FirebasePlugin.java) and realized that the JsonArray is not being verified, only the Integer and Double are:

image

The array ‘items’ is send as a string exceeding the limit of 100 character array allowed by Firebase.

I changed the code on my local machine so I get it working as expected:

...
if (value instanceof Integer || value instanceof Double) {
    bundle.putFloat(key, ((Number) value).floatValue());
} else if(value instanceof JSONArray) {
    JSONArray jsonArray = (JSONArray) value;
    final Bundle itemListBundle = new Bundle();
    ArrayList<Parcelable> bundles = new ArrayList<>();
    for (int index = 0 ; index < jsonArray.length(); index++) {
        JSONObject jsonObject = jsonArray.getJSONObject(index);

        Iterator<String> iterator = jsonObject.keys();
        while (iterator.hasNext()) {
            String keyObj = iterator.next();
            Object valueObj = jsonObject.get(keyObj);
            if (valueObj instanceof Integer || valueObj instanceof Double) {
                itemListBundle.putFloat(keyObj, ((Number) valueObj).floatValue());
            } else {
                itemListBundle.putString(keyObj, valueObj.toString());
            }
        }
        bundles.add(itemListBundle);
    }
    bundle.putParcelableArrayList(key, bundles);
} else {
    bundle.putString(key, value.toString());
}
...

I didn’t make a pull request because I believe I should change it on IOS too, but I have no knowledge in this area.

Version information cordova info

  cordova-common@3.2.1          
  cordova-create@2.0.0          
  cordova-fetch@2.0.1            
  cordova-serve@3.0.0            
                                 
Environment:                    
  OS: win32                      
  Node: v12.18.0                
  npm: 6.14.6                    
                                 
Plugins:                        
  cordova-custom-config          
  cordova-plugin-androidx        
  cordova-plugin-androidx-adapter
  cordova-plugin-badge          
  cordova-plugin-device          
  cordova-plugin-facebook4      
  cordova-plugin-firebasex      
  cordova-plugin-geolocation    
  cordova-plugin-inappbrowser    
  cordova-plugin-ionic-keyboard  
  cordova-plugin-ionic-webview  
  cordova-plugin-local-notificati
  cordova-plugin-sign-in-with-app
  cordova-plugin-splashscreen    
  cordova-plugin-statusbar      
  cordova-plugin-uniquedeviceid  
  cordova-plugin-whitelist      
  cordova-support-android-plugin
  cordova-support-google-services

Checklist

  • I have read the issue reporting guidelines
  • I confirm this is a suspected bug or issue that will affect other users
  • I have read the documentation thoroughly and it does not help solve my issue.
  • I searched for existing GitHub issues
  • I included all the necessary information above

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
marcelonnunescommented, Sep 2, 2020

@alyleite , All right ?

Could you help me with an issue I’m facing with Remote Config. I saw that you managed to solve a bug in (src / android / FirebasePlugin.java). I think the error is also in that file, but I don’t know much about Java. If you can help me, thank you very much 😃.

Error with Remote Config -> https://github.com/dpa99c/cordova-plugin-firebasex/issues/501

0reactions
alyleitecommented, Sep 18, 2020

@dpa99c Could I pull for Android only?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Analytics error codes - Firebase - Google
Error Code Cause Value 4 Event parameter value is too long Name of invalid parameter 5 Event has more than 25 parameters None 7 User property...
Read more >
Firebase Analytics event logging error - Stack Overflow
Here is the list of the Firebase Analytics error codes: 1 - Invalid Firebase project id. ... 4 - Event parameter value is...
Read more >
Collection and configuration limits - Firebase Help
Collection and configuration limits. Collection limits. Analytics does not log events, event parameters, and user properties that exceed the following limits.
Read more >
Sending events | Measurement Protocol for Google Analytics 4
The identifier for a Firebase app. Found in the Firebase console under: Project Settings > General > Your Apps > App ID. Note:...
Read more >
How Long Does it Take for My Firebase Analytics Data to ...
On iOS devices, Firebase will also send down data when your app moves into the background. So if a user tries your app...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found