Search Unity

Firebase Analytics: 2020.3.x version custom events problem

Discussion in 'Package Manager' started by mfatihkavum, Nov 12, 2021.

  1. mfatihkavum

    mfatihkavum

    Joined:
    Sep 14, 2021
    Posts:
    1
    Hi,

    I have a problem with Firebase Analytics SDK. I can't get/see the custom events in the Firebase Dashboard. In other words, my implementation is not sending any custom events to Firebase side.

    - It's working (I can see my custom events) in Unity version 2019.3.17 (Debugview screenshot is added.) v2019DebugView.png
    - But I need to use Unity version 2020.3.x and with any of these 2020 unity versions I can't see my custom events. (I can still see the bulid-in events like "session_start" , "user_engagement", "screen_view" but i cant see my custom events like "progress", "gameStarted" etc)
    - The firebase versions that I tried: 7.2, 8.0, 8.1, 8.2 and 8.5. I get the same results with all of these Firebase version. Its working on Unity version 2019 but not working on 2020.

    ------ USED PROJECT -----
    - Im using the Firebase Sample project for the analytic in github. Link is:
    https://github.com/firebase/firebas...tics/testapp/Assets/Firebase/Sample/Analytics
    - Im using MainScene.unity and only UIHandler.cs script is running on it. I only added few lines to it to send event names as custom string.

    Code (CSharp):
    1. FirebaseAnalytics.LogEvent("progress", "percent", "0.4");  //Added line
    2. FirebaseAnalytics.LogEvent(FirebaseAnalytics.EventCheckoutProgress, "percent", "0.4");

    ------ XCODE LOGS -----
    InXcode, working version has these outputs in the xcode debug output window:
    https://docs.google.com/document/d/1QvSlCD-oOAi4seUBTebX0aoNkuRJSphR0Wu3rMMy-S8/edit?usp=sharing
    Not working versions have these outputs:
    https://docs.google.com/document/d/1AdLbCmr_CK2nZuvrVUz2oztBztWVuTgVc4W_jJ9nvDc/edit?usp=sharing

    I especially seeing two types of warning in the output that can be related to this issue, these are:
    - ...One of the two will be used. Which one is undefined...
    - ...Attempted to register protocol FIRAnalyticsInterop, but it already has an implementation....


    ------ TO SUMMARIZE -----
    To summarize my question up: Why i cant see my Firebase custom events in unity v2020, although I can see them using exactly the same code in unity v2019.
     
  2. unity_0FA93411CF28C941645E

    unity_0FA93411CF28C941645E

    Joined:
    Sep 23, 2021
    Posts:
    1
    I have the same issue.

    Unity version is: 2020.3.14
    Firebase Analytics version is: 8.4
     
  3. perplex_bcn

    perplex_bcn

    Joined:
    Mar 1, 2013
    Posts:
    22
    Also facing the same issue. It's working fine for Android. Not working for iOS.

    Unity version: 2020.3.12
    Firebase version: 8.6.2

    Any help is appreciated!
     
  4. perplex_bcn

    perplex_bcn

    Joined:
    Mar 1, 2013
    Posts:
    22

    Hi,
    The warning gave me a clue about the possible issue. I found a workaround for removing that warning. Now I can see the log from Firebase analytics when sending events at the Xcode console. I can also see the events when selecting Realtime from firebase console. It may take some time until they appear. You won't see them at the DebugView as it is only for Android devices.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using UnityEditor.Callbacks;
    4. using UnityEditor.iOS.Xcode;
    5. using System.IO;
    6. using System.Linq;
    7. using Crisalix.EditorHelpers;
    8.  
    9. public static class PostProcessBuildTasks
    10. {
    11.     [PostProcessBuild( 1000 )]
    12.     static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    13.     {
    14.         Debug.Log($"OnPostprocessBuild({buildTarget}, {path})");
    15.         UpdateXcodeProject( path );
    16.     }
    17.  
    18.     private static void UpdateXcodeProject ( string path )
    19.     {
    20.         // Load
    21.         string projectPath = Path.Combine( path, kXcodeTargetName + ".xcodeproj/project.pbxproj" );
    22.         var pbxProject = new PBXProject();
    23.         pbxProject.ReadFromFile( projectPath );
    24.  
    25.         string targetMain = pbxProject.GetUnityMainTargetGuid();
    26.  
    27.         // Remove OTHER_LDFLAGS from main target
    28.         // Example of one of the multiple messages that appears at the Xcode console:
    29.         // Class FIRAAdExposureReporter is implemented in both .../FirebaseTest.app/FirebaseTest
    30.         // and .../FirebaseTest.app/Frameworks/UnityFramework.framework/UnityFramework.
    31.         // One of the two will be used. Which one is undefined.
    32.  
    33.         foreach( var buildConfigName in pbxProject.BuildConfigNames() )
    34.         {
    35.             string configGuid = pbxProject.BuildConfigByName( targetMain, buildConfigName );
    36.             pbxProject.SetBuildPropertyForConfig( configGuid, "OTHER_LDFLAGS", string.Empty );
    37.         }
    38.         // Save
    39.         pbxProject.WriteToFile( projectPath );
    40.     }
    41.  
    42.     private const string kXcodeTargetName = "Unity-iPhone";
    43.  
    44. }
    45.  
    Hope this helps!
     
    joefspiro likes this.
  5. dandanthepizzaman666

    dandanthepizzaman666

    Joined:
    Jul 15, 2019
    Posts:
    6
    Hi I'm encountering the same issue as OP. Unity version 2020.3.14f1 Firebase SDK 8.6.1- Default iOS events are showing up in the dashboard, but custom events are only showing for Android. It's very late in the project to be updating Unity / FB SDK ... I don't understand the above workaround, could someone provide more details how to implement?
    Thanks!
     
  6. dandanthepizzaman666

    dandanthepizzaman666

    Joined:
    Jul 15, 2019
    Posts:
    6
    Resolved for me -
    I tried 2 things so one or both may be the solution.
    1- Updated to latest SDK 8.7.0 ( was using 8.6.1 )
    2- Added this Editor script as defined above
    Thanks for the script @perplex_bcn