keenlabs / KeenClient-Java

Official Java client for the Keen IO API. Build analytics features directly into your Java apps.
https://keen.io/docs
MIT License
74 stars 43 forks source link

Global properties overrides keenProperties when global has keen key #66

Closed louiszuckerman closed 8 years ago

louiszuckerman commented 8 years ago

Not sure if you'd call this a bug, but it was surprising to me when I ran into it...

If your global properties has key keen then anything supplied in the event's keenProperties parameter will be ignored.

I ran into this when setting keen.timestamp with a global properties evaluator. That prevented me from sending keen.addons or keen.location.coordinates with my events. It was surprising because there was no error/warning to indicate that something was being discarded. Everything looked OK on the sender, but the events were showing up incomplete in keen.

Thanks!

louiszuckerman commented 8 years ago

I wrote a solution to do a shallow merge of the globals & event properties, for both keen & non-keen keys. This lets you have keen.addons in a global and set keen.timestamp in an event, for example. The merge order is static globals, overridden by dynamic globals, overridden by per-event properties. This is applied to keen properties & non-keen properties alike.