Open josephwegner opened 9 years ago
Yeah, I think custom events make sense here. The main benefit of going through CW instead of direct-to-keen is all the CW data model goodness you get to keep.
Interface could be something simple like:
CommonWeb.trackCustomEvent("click", $(".thing"), { "moar" : "properties" });
Or, like I think you were saying, just give access to a function that logs an event through CW and takes the properties you want to include:
// including the JS event object so CW can glean properties from it
$(".thing").click(function (event) { CommonWeb.sendCustomEvent(event, { "moar" : "properties" }});
Seems like offering both options wouldn't be too hard.
That trackCustomEvent
interface seems a little weird. I get what you're going for, but it seems pretty verbose for what we want to achieve.
I'm not sure if this is better, because it's kind of non-standard for javascript, but it might be more readable:
$('.thing').on('click', CommonWeb.customEvent({ "moar" : "properties" }));
That would essentially just return an bound instance of CommonWeb.sendCustomEvent
. This has the added benefit of not being so intertwined with jQuery - CommonWeb.customEvent()
could be passed as the callback for any sort of event handler.
Thoughts?
Like it.
On Thu, Mar 5, 2015 at 1:50 PM, Joe Wegner notifications@github.com wrote:
That
trackCustomEvent
interface seems a little weird. I get what you're going for, but it seems pretty verbose for what we want to achieve. I'm not sure if this is better, because it's kind of non-standard for javascript, but it might be more readable:$('.thing').on('click', CommonWeb.customEvent({ "moar" : "properties" }));
That would essentially just return an bound instance of
CommonWeb.sendCustomEvent
. This has the added benefit of not being so intertwined with jQuery -CommonWeb.customEvent()
could be passed as the callback for any sort of event handler.Thoughts?
Reply to this email directly or view it on GitHub: https://github.com/keen/common-web/issues/15#issuecomment-77437850
@josephwegner, was anyone able to get this done? This would be a really cool feature.
I'd like to get some opinions on this... I'm not sure if this is CommonWeb's problem to solve, or not.
CommonWeb kind of abstracts away the idea of what tracking backend you are using, so it's not entirely clear how I can track things that don't fall under the CommonWeb umbrella (ie: someone entered failed CC details into stripe checkout).
I know I could technically access the Keen client by digging through the internals of CommonWeb, but that's brittle and not ideal.
It might be nice to have a function like
CommonWeb.customEvent
, that essentially just wrapsCommonWeb.Callback
. Perhaps it would also merge in the global properties.