I am trying to use JQl to get a breakdown of how much our users use our feature x number of months since the first started using it.
What I’ve gotten so far:
let month = '0';
function main() {
return Events({
from_date: "2015-06-06",
to_date: "2020-07-06",
})
.groupByUser(function(state, events) {
state = state || {last_event : null, last_time: 0, eventsByMonth: {}};
if(!state.fist_time && !state.first_event) {
state.first_event = events[0].name;
state.first_time = events[0].time;
}
_.each(events, function(e) {
let key = Math.floor((new Date(e.time).getTime() - new Date(state.first_time).getTime() )/ (1000*60*60*24*30))
if(!state.eventsByMonth[key])
{
state.eventsByMonth[key] = 0;
}
state.eventsByMonth[key]++;
state.last_event = e.name;
state.last_time = e.time;
});
return state;
})
.map(function(m) {
return m.value.eventsByMonth
})
.reduce(mixpanel.reducer.numeric_percentiles(month ,
[10, 25, 50, 75, 90, 99, 99.999]),
)
}
My problem is I would very much like to get this list out for all the months in a single report, but i can’t figure out how to call multiple reducers on the result after the map function.
I want a result with all the months printed out at once kind of like this:
% 0 1 2 3 ...
10 5 6 4 3 ...
25 7 8 9 2 …
…
But right now I can only get it printing out one month a time.
Or is there a better way to get this info? I couldn’t figure out how to do this built into any of the views mixpanel has.