Last active
March 6, 2019 15:24
-
-
Save walkerofmargins/991733b701b32b7dce314a46a4a949eb to your computer and use it in GitHub Desktop.
JQL to identify MTU issue where a single event caused an overage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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