firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.67k stars 1.49k forks source link

Wrong documentation for parameter `AnalyticsParameterValue` #9400

Closed oklimberg closed 2 years ago

oklimberg commented 2 years ago

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

The documentation for parameter 'AnalyticsParameterValue' states the following in version 8.8.0:

...Notes: Values for pre-defined currency-related events (such as kFIREventAddToCart) should be supplied using double as NSNumber and must be accompanied by a kFIRParameterCurrency parameter...."

However, when using the parameter in custom non-currency related events, the following error is emitted in the logs:

2022-03-01 14:16:45.880465+0100 H2M[10335:213183] 8.8.0 - [Firebase/Analytics][I-ACS013004] Event parameter value cannot be nil
2022-03-01 14:16:45.880644+0100 H2M[10335:213183] 8.8.0 - [Firebase/Analytics][I-ACS018014] Value parameter discarded. You must also supply a 3-letter ISO_4217 currency code in the currency parameter.

So in contrast to the documentation, the parameter AnalyticsParameterCurrency must always be used whenever parameter AnalyticsParameterValue is used

Steps to reproduce:

Just generate a custom event using the provided code snippet.

Relevant Code:

the event is generated using the following code:

let parameter:[String:Any] = [
    "category": "Routing",
    "action": "Open Route Planner Button Pressed",
    AnalyticsParameterValue: 1
]
Analytics.logEvent("Interaction", parameters: parameter)

firebase_analytics_bug_log.txt

google-oss-bot commented 2 years ago

I found a few problems with this issue:

rizafran commented 2 years ago

Hi @oklimberg, I tried to reproduce the issue using the sample snippet you provided, but I'm unable to get the value parameter error in the logs. Can you share an mcve that will reproduce the issue?

oklimberg commented 2 years ago

Hi @rizafran, the problem seems to be related to one of my Firebase projects. If I switch the GoogleService-Info.plist from the project where i encountered the issue (STAGE environment of an app) to the TEST version, the issue is gone. Attaching the plist to this case does not feel right, so is there another way to provide the file to you?

oklimberg commented 2 years ago

This issue might be related to conversion issues.

Looking at the following section from [GA4] Set up and manage conversion events:

Ecommerce and custom events For ecommerce and custom events that you mark as conversions, the value event parameter supplied with conversion events must be a number, and it must be accompanied by a currency code, in a 3-letter ISO_4217 format. If the currency parameter is missing or invalid, Analytics records the events as conversions with the correct event count, but the events won't be sent to Google Ads.

It is now clear, that for custom events marked as conversions, there is probably some kind of check in place, that the parameter AnalyticsParameterValue should be accompanied by parameter AnalyticsParameterCurrency. But in contrast to the documentation, omitting the parameter AnalyticsParameterCurrency, will cause the parameter AnalyticsParameterValue to be removed instead of just not sending it to Google Ads. This does also happen for the Android SDK.

I also checked the TEST variant of our project, which did not cause the issue: The event had not been marked as conversion. I changed this to match the STAGE project and will try to reproduce this tomorrow.

rizafran commented 2 years ago

Hi @oklimberg, thanks for sharing your findings and providing your feedback regarding the documentation that causes confusion. Also, per checking, it seems that the Firebase support team were able to handle your ticket and they have filed a feature request for this. With this, I'll be closing the ticket for now, but feel free to reopen if you have any other questions.

oklimberg commented 2 years ago

Hi @rizafran , in case the SDK is working as intended, the documentation will be improved and the case is tracked somewhere else, yes closing this issue is fine. Could you provide a link to the other issue? Support team just told me, the opened a feature request on my behalf, but did not provide a link to it either.

rizafran commented 2 years ago

@oklimberg, currently, we don't have any public tracker for internally filed feature requests. We can only do our best to relay the feedback to the team but it will still depend on prioritization and on our roadmap. When similar developers are requesting for that same feature, we will make sure that there will be upvotes to that existing request.