Question

JQL query runs into weird syntax error

  • 13 June 2022
  • 0 replies
  • 27 views

Hello,

 

I have the following JQL code to return users and the count of their events within certain days of their sign up date. The code below works if I try and filter for one user but returns an error when I remove that constraint.

 The error message is

 

s.Recv failed: rpc error: code = FailedPrecondition desc = Uncaught exception TypeError: Cannot read property 'split' of undefined days(tuple.event.time, Date.parse(tuple.user.properties.signup_date.split('T')[0])) <= 14 ^ Stack trace: TypeError: Cannot read property 'split' of undefined at <anonymous>:16:80

 

Any help or pointers would be much appreciated. Thanks

function main() {
var joinedTable = join(
Events({
from_date: "2022-03-01",
to_date: "2022-07-10",
}),
People(),
{ type:"inner", selectors:[{selector:
'event["distinct_id"] == user["distinct_id"]'}]})
return (
joinedTable.filter(function(tuple) {
// comment the distinct_id to return all results
return tuple.user.distinct_id == 37484
&&
days(tuple.event.time, Date.parse(tuple.user.properties['Sign up date'].split('T')[0])) <= 14
})
.groupBy(["user.properties.$email", "event.name"], mixpanel.reducer.count())
);
}

function days(date_1, date_2) {
let difference = date_1 - date_2;
let TotalDays = Math.ceil(difference / (1000 * 3600 * 24));
return TotalDays;
}

 


0 replies

Be the first to reply!

Reply