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.

Allways Error: value for items is missing

See original GitHub issue

Hi community.

I’m dealing with this issue, i don’t know if i’m doing something wrong, but every time i call logEvent with “items” property i get an error saying “value for items is missing”

this is my implementation

FirebaseAnalytics.logEvent({
      name: "product_click", params: {
        content_type: "page_view",
        item_id: producto.id,
        item_name: producto.nombre,
        comerce_id: producto.comercio,
        source: "selections",
        items: [{
          tipo: "producto",
          nombre: producto.nombre,
          id: producto.id
        }],
      }
    });

i see the error occurs in FirebaseAnalytics.java line 149 since in mi implementation “Item” is not an String, Integer, Doble en so on.

while (keys.hasNext()) {
            String key = keys.next();
            Object value = params.get(key);

            if (value instanceof String) {
              bundle.putString(key, (String) value);
            } else if (value instanceof Integer) {
              bundle.putInt(key, (Integer) value);
            } else if (value instanceof Double) {
              bundle.putDouble(key, (Double) value);
            } else if (value instanceof Long) {
              bundle.putLong(key, (Long) value);
            } else {
              call.reject("value for " + key + " is missing");
            }
          }

I need help, thanks in advance.

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
yunusfillikcommented, Feb 6, 2021

Hi there, add JSONArray condition for e-commerce. Go to FirebaseAnalytics.java;

node_modules\@capacitor-community\firebase- 
analytics\android\src\main\java\com\getcapacitor\community\firebaseanalytics\FirebaseAnalytics.java

After then add this imports.

import org.json.JSONObject;
import org.json.JSONArray;
import java.util.ArrayList;

and find a logEvent function in FirebaseAnalytics.java you should to add 1 more if else condition for value instanceof JSONArray.

this is my code

    while (keys.hasNext()) {
      String key = keys.next();
      Object value = params.get(key);
      if (value instanceof String) {
        bundle.putString(key, (String) value);
      } else if (value instanceof Integer) {
        bundle.putInt(key, (Integer) value);
      } else if (value instanceof Double) {
        bundle.putDouble(key, (Double) value);
      } else if (value instanceof Long) {
        bundle.putLong(key, (Long) value);
      } else if (value instanceof JSONArray) { //add this condition for items

        JSONArray items = (JSONArray) value;
        ArrayList itemBundleList = new ArrayList();

        for (int i = 0; i < items.length(); i++) {
          Bundle itemBundle = new Bundle();
          JSONObject itemParams = items.getJSONObject(i);
          Iterator<String> itemKeys = itemParams.keys();

          while (itemKeys.hasNext()) {
            String itemKey = itemKeys.next();
            Object itemValue = itemParams.get(itemKey);
            if (itemValue instanceof String) {
              itemBundle.putString(itemKey, (String) itemValue);
            } else if (itemValue instanceof Integer) {
              itemBundle.putInt(itemKey, (Integer) itemValue);
            } else if (itemValue instanceof Double) {
              itemBundle.putDouble(itemKey, (Double) itemValue);
            } else if (itemValue instanceof Long) {
              itemBundle.putLong(itemKey, (Long) itemValue);
            }
          }

          itemBundleList.add(itemBundle);
        }

        bundle.putParcelableArrayList(key, itemBundleList);
      } else {
        call.reject("value for " + key + " is missing");
      }
    }

image

You can check this docs for more information.

1reaction
StErMicommented, Sep 29, 2021

Hi there I can confirm that with the "@capacitor-community/firebase-analytics": "^1.0.0" I still have this issue but only for Android.

Every event that has items as a custom parameter won’t track those items if I check out the Firebase Debug View.

Do you know how to fix it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to correct a #N/A error
Solution: Either make sure that the lookup value exists in the source data, or use an error handler such as IFERROR in the...
Read more >
Error codes for optional checks - mypy 0.991 documentation
Error codes for optional checks#. This section documents various errors codes that mypy generates only if you enable certain options. See Error codes...
Read more >
Identification error MISSING_MATCHING_ATTRIBUTES ...
Missing minimum set of values for criterion attributes for an identification rule. Resolution. Determine the identifier used: Navigate to Configuration > ...
Read more >
Excel Data Validation Tips and Troubleshooting
On the Ribbon, click File, and then click Open · Click Computer, then click Browse · Select the file with the missing data...
Read more >
What's the most appropriate HTTP status code for an "item ...
Well, the answer is simple. Always try to attach a body to any errors that you returned from code. Errors that are returned...
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