Hi there
I’m trying to get a list of distinct_id’s filtered by an event, and unique per day. So I expect to see duplicate distinct_id’s only when the date changes. My code below delivers a list of distinct_ids and the desired parameters, but I can’t get it to group by date so there are no duplicates.
Some of my grouping attempts are commented out. They are based on what I could find as an example at the bottom of the following page: https://help.mixpanel.com/hc/en-us/articles/115004509406-Distinct-IDs-.
In using that example, I found that the additional properties I’m asking for, became unreadable.
I hope that makes sense, my code is below.
Thank you!
var File_Opened = [{event: "File Opened"}] ;
function getYearMonth(date) { return date.toISOString().substr(0, 10); }
function main() { return Events({ from_date: '2020-10-29', to_date: '2020-11-01', event_selectors: File_Opened }) // .filter(function(event) {return event.properties.$event_name === 'File Opened'}) // .groupBy(["event.properties.$distinct_id"],mixpanel.reducer.null()) .map(function(event){ return { "id": event.properties.$distinct_id, // "distinct_id": event.key[0], "name": event.properties.$event_name, // "time": new Date(event.time).toISOString(), "Day_only": getYearMonth(new Date(event.time)), "Enabling Entitlement": event.properties["Enabling Entitlement"] }; }) ; }