function main() {
return Events({
from_date: "2023-01-01",
to_date: "2025-12-31",
event_selectors: [{event: "login"}]
})
.groupByUser(function(state, events) {
if (events.length > 0) {
// Get the time of the last login event
var lastLoginTime = events[events.length - 1].time;
// Convert to a Date object and format as ISO string
var lastLoginDate = new Date(lastLoginTime).toISOString().split('T')[0];
return {last_login_date: lastLoginDate};
}
return state;
});
}
I updated the code to work with my Mixpanel instance. Instead of showing distinct ID in the first column of the query results. How would I display email instead? kapa.ai