From fac967b98ac48185543a99a50d10064b7075e7ad Mon Sep 17 00:00:00 2001 From: Tim Broder Date: Fri, 21 Sep 2018 13:00:11 -0400 Subject: [PATCH 1/2] Create Event by cohort.jql.js --- JQL/Event by cohort.jql.js | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 JQL/Event by cohort.jql.js diff --git a/JQL/Event by cohort.jql.js b/JQL/Event by cohort.jql.js new file mode 100644 index 0000000..cae1874 --- /dev/null +++ b/JQL/Event by cohort.jql.js @@ -0,0 +1,43 @@ +function main() { + var activeUUIDs = [ + "000-000-000-000", + ]; + var activeEmails = [ + "tim@kidfund.us", + ]; + + return join( + Events({ + from_date: "2017-01-01", + to_date: "2018-09-20" + }), + People()) + .filter(function (tuple) { + return tuple.event + && tuple.event.name + && tuple.user + && + ( + (tuple.user.properties.uuid + && activeUUIDs.includes(tuple.user.properties.uuid) + ) + || + (tuple.user.properties.email + && activeEmails.includes(tuple.user.properties.email) + ) + ); + }) + .groupByUser(function (state, tuples) { + var inviteEvent = tuples.find(function (tuple) { + var event = tuple.event; + return ( + event.name == "Invite Sent" + || event.name == "Tell Friend Sent" + //|| event.name == "Invite Opened" + //|| event.name == "Tell Friend Opened" + ); + }); + return inviteEvent !== undefined; + }) + .groupBy(["value"], mixpanel.reducer.count()); +} From 500b361806a6b123d0a26e3b9a94eeac222c210e Mon Sep 17 00:00:00 2001 From: Michael Helmbrecht Date: Fri, 21 Sep 2018 14:00:33 -0400 Subject: [PATCH 2/2] Move event names into array --- JQL/Event by cohort.jql.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/JQL/Event by cohort.jql.js b/JQL/Event by cohort.jql.js index cae1874..dacce5f 100644 --- a/JQL/Event by cohort.jql.js +++ b/JQL/Event by cohort.jql.js @@ -5,6 +5,13 @@ function main() { var activeEmails = [ "tim@kidfund.us", ]; + + var queryEventNames = [ + "Invite Sent", + "Tell Friend Sent", + // "Invite Opened", + // "Tell Friend Opened", + ]; return join( Events({ @@ -28,16 +35,12 @@ function main() { ); }) .groupByUser(function (state, tuples) { - var inviteEvent = tuples.find(function (tuple) { - var event = tuple.event; - return ( - event.name == "Invite Sent" - || event.name == "Tell Friend Sent" - //|| event.name == "Invite Opened" - //|| event.name == "Tell Friend Opened" - ); + var firstQueryEvent = tuples.find(function (tuple) { + var eventName = tuple.event.name; + return eventName && + queryEventNames.includes(eventName); }); - return inviteEvent !== undefined; + return firstQueryEvent !== undefined; }) .groupBy(["value"], mixpanel.reducer.count()); }