michaelcarter / mixpanel-data-export-js

Mixpanel data export js
91 stars 38 forks source link

Shorthand syntax for `where` clause #12

Closed JuanCaicedo closed 8 years ago

JuanCaicedo commented 9 years ago

We were using this at work and thought it would be really nice if there was some short simple way to work input a where clause into the parameters.

Initially what we've thought is that it could somehow be a nested object of where conditions, which would get parsed out into the right string format in _requestParameterString().

We are going to work on this and hopefully put in a PR soon. Any thoughts on what would make this useful?

michaelcarter commented 9 years ago

Hi @JuanCaicedo,

I'd think this would be a great idea, only we're not actually able to filter the results we return to the user via MixPanel's API, but only after we've actually received them, at which point we get no speed benefits from including the filtering in this library, just a tiny amount of convenience.

Because of that, I'd lean more towards using something like lodash to filter the results after they've been received rather than baking the functionality into this library. What do you think?

JuanCaicedo commented 8 years ago

@michaelcarter Sorry for the long delay getting back to you! My impression is that the MixPanel API just takes a string that represents the "where" clause. That string needs to be a valid expression.

Currently you can format that expression yourself and pass it in, but it would be nice if there was a robust way to do that with an object representation.

That's how I understand it, but I have pretty limited knowledge of the MixPanel API. Let me know if you think this is something worth pursuing, otherwise I'll close out this issue.

michaelcarter commented 8 years ago

@JuanCaicedo Sorry I've taken forever (over a year turnaround time on this issue 🏆!) in getting back to you.

I think for the sake of keeping this library simple it makes sense to me to just continue passing in the string expression. We could build a fancy expression builder but MixPanel don't notify of changes to their API, so I feel like it'd end up out of date pretty quickly if we were to bake it into this SDK.

I'm going to close this issue but thanks for making me aware of this as a potential problem point for people in future.