Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase analytics displays incorrect data in DebugView

I'm using Firebase Analytics. I registered two user properties and I have two custom events, each events includes 3 to 50 different options options. I met the problem that when I set the user property, very often DebugView displays the old user property for the event or is not displayed at all. Sometimes it works correctly. Please tell me how it can be fixed?

My code.

final class FirebaseAnalyticsManager {

    enum ScreenType {
        case editStoryScreen, homeScreen, previewStoryScreen, storeItemPreviewScreen

        var name: String {
            switch self {
            case .editStoryScreen:
                return "Edit Story Screen"
            case .homeScreen:
                return "Home Screen"
            case .previewStoryScreen:
                return "Preview Story Screen"
            case .storeItemPreviewScreen:
                return "Store Item Preview Screen"
            }
        }
    }

    enum Event {
        case templateSelected, mediaExport

        var name: String {
            switch self {
            case .templateSelected:
                return "TemplateSelected"
            case .mediaExport:
                return "MediaExport"
            }
        }
    }

    enum MediaExportDestination {
        case story, page, pageToInstagram

        var name: String {
            switch self {
            case .story:
                return "Story"
            case .page:
                return "Page"
            case .pageToInstagram:
                return "PageToInstagram"
            }
        }
    }

    private enum Keys: String {
        case exportType, templateName
    }

    private init() { }
    static let shared = FirebaseAnalyticsManager()

    open func trackScreen(_ screenType: ScreenType, screenClass: String?) {
        Analytics.setScreenName(screenType.name, screenClass: screenClass)
    }

    private func trackEvent(_ event: Event, parameters: [String : NSObject]?) {
        Analytics.logEvent(event.name, parameters: parameters)
    }

    open func trackTemplateSelected(_ templateName: String) {
        let key = Keys.templateName.rawValue
        Analytics.setUserProperty(templateName, forName: key)
        var parameters = [String : NSObject]()
        parameters[key] = templateName as NSObject
        trackEvent(.templateSelected, parameters: parameters)
    }

    open func trackMediaExport(_ destination: MediaExportDestination) {
        let key = Keys.exportType.rawValue
        Analytics.setUserProperty(destination.name, forName: key)
        var parameters = [String : NSObject]()
        parameters[key] = destination.name as NSObject
        trackEvent(.mediaExport, parameters: parameters)
    }

}

In this event, all data is correct. enter image description here enter image description here

In this event, the data is incorrect, since it should be Template5 in userProperties. enter image description here enter image description here

like image 847
Alexander Khitev Avatar asked May 22 '18 10:05

Alexander Khitev


1 Answers

Firebase team answered to me

Hi there, I just got an update from our engineers confirming that it is indeed a bug in our end. They are already working on a fix for this issue, but I can’t share details or timeline as to when this will be fixed. Please keep tabs on our release notes for any updates regarding this.

like image 180
Alexander Khitev Avatar answered Oct 22 '22 01:10

Alexander Khitev