Skip to content

Instantly share code, notes, and snippets.

@walkerofmargins
Last active March 6, 2019 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walkerofmargins/991733b701b32b7dce314a46a4a949eb to your computer and use it in GitHub Desktop.
Save walkerofmargins/991733b701b32b7dce314a46a4a949eb to your computer and use it in GitHub Desktop.
JQL to identify MTU issue where a single event caused an overage
function main() {
return Events({
/* Dec */
from_date: "2018-12-01",
to_date: "2018-12-31",
// /* Jan */
// from_date: "2019-01-01",
// to_date: "2019-01-31",
// /* Feb */
// from_date: "2019-02-01",
// to_date: "2019-02-28",
event_selectors: [{
event: ''
}]
})
// .groupByUser(["name"], mixpanel.reducer.count())
.groupByUser(function(state, event) {
//Beginning state is Event only is true
state = state || {
OptInOnly: true
};
_.each(event, function(event) {
if (event.name !== '$opt_in') {
state.OptInOnly = false;
}
});
return state;
})
.filter(function(item) {
return item.value.OptInOnly === true
})
.reduce(mixpanel.reducer.count())
}
function main() {
return Events({
from_date: '2019-02-01',
to_date: '2019-02-28',
event_selectors: [{
selector: 'not (event["$event_name"] == "$campaign_delivery" \
or event["$event_name"] == "$campaign_bounced" \
or event["$event_name"] == "$campaign_marked_spam" \
or event["$event_name"] == "$journey_entered" \
or event["$event_name"] == "$message_suppressed" \
or event["$event_name"] == "$unsubscribe")'
}]
})
.groupByUser(function(state, events){
state = state || {count: 0, hasDoneOptedIn: 0};
_.each(events,function(e){
state.count++;
if(e.name === '$opt_in'){
state.hasDoneOptedIn = true;
}
});
return state;
})
.filter(function(e){ return e.value.hasDoneOptedIn && e.value.count == 3 })
.reduce(mixpanel.reducer.count());
}
function main() {
return Events({
from_date: "2019-02-01",
to_date: "2019-02-28",
})
.filter(function(e) {
return e.distinct_id === "0000BE16-B10F-495F-A800-2DDB0E126684"
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment