Telefonica / webview-bridge

Novum JavaScript Bridge
MIT License
26 stars 7 forks source link

Allow user to choose `event name` #11

Closed trinaldi closed 5 years ago

trinaldi commented 5 years ago

So far, event name is tied to event category.

With this commit the user is free to input the event name, if no name is given, use the event category as the name.

atabel commented 5 years ago

So far, event name is tied to event category

Yes, this is by design. This library is intended to work for web (google analytics) too, where action and category fields are mandatory. It's by design that category in GA (when used in web) must use the same value than event name in firebase (when used inside novum app webview).

trinaldi commented 5 years ago

So, when using the web interface the event name should be the same as the event category?

atabel commented 5 years ago

yes

trinaldi commented 5 years ago

@atabel Do you have any Google Analytics/Firebase source regarding the "by design" claim?

Here in Brazil we don't have the same nomenclature for event name and event category, neither in GA nor in Firebase.

trinaldi commented 5 years ago

Just to put things in perspective. I work at Vivo and we do not use event category for event_name. We're talking about all of our apps and web. I'd strongly recommend, if you guys wanna us to use this bridge, to create a branch br or whatever so we can manage our own nomenclature.

You can @ me at Novum Slack.

pladaria commented 5 years ago

Hi @trinaldi,

Thanks for your PR. We would love to help you with your issues but we don't fully understand what your problem is. Why can't you use current API?

logEvent: ({
    category: string; // Typically the object that was interacted with (e.g. 'Video')
    action: string; // The type of interaction (e.g. 'play')
    label?: string; // Useful for categorizing events (e.g. 'Fall Campaign')
    value?: number; // A numeric value associated with the event (e.g. 43)
})

By calling that function you are effectively sending to Android and iOS firebase:

logEvent(category, JSON.stringify({action, label, value}));

Why isn't that working for you? Could you please send us some event examples?

If your problem was Google Analytics, latest release (v2.0.0) no longer sends events to external (non-novum) GA instances.

trinaldi commented 5 years ago

@pladaria I'm out of the office now and I'll write a thorough response tomorrow with our codes, naming convention and all.

At the moment we're using Firebase's 'native' brigde. As you can see the first parameter is name - it is not the same as category. We use names such as interaction, noninteraction, etc...

So using the current version of this logEvent function we're stuck with the Event Category name, which in some apps - more precisely Meu Vivo Movel - has this kind of naming mvm:[feature]. Let's say we're at Packages. In this case all of the Event Category are mvm:packages.

Note that we're using : which is invalid for Event Name according to the Firebase Documentation (Error 2, more specifically - See below). So when we tried this version of the function we had the following:

logEvent('mvm:packages', JSON.stringify({action, label, value}));

Since : is an invalid char, logCat output the Error 2 message.

Using the logEvent example from Firebase, our code would log as:

logEvent('interaction', JSON.stringify({...params}));

Note that nowhere in the docs the Event Nameis tied to Event Category. As you mentioned, that's a convention used by NOVUM, which does not apply to Brazil. Hence my PR which let the user decide the Event Name.

Regarding Event Names

"... Some common events are suggested below, but you may also choose to specify custom Event types that are associated with your specific app. Each event type is identified by a unique name. Event names can be up to 40 characters long, may only contain alphanumeric characters and underscores ("_"), and must start with an alphabetic character. ..."

atabel commented 5 years ago

@trinaldi You can do this:

webviewBridge.logEvent({category: 'interaction', eventCategory: 'whateveryouwant', ...other});

This will make this call to firebase (in Android):

androidFirebase.logEvent('interaction', JSON.stringify({eventCategory: 'whateveryouwant', ...other}));
trinaldi commented 5 years ago

That's not the point of the PR. Nonetheless, I no longer work for Telefonica. I'm closing this PR.