fix: journey date parsing

This commit is contained in:
Chris Anderson 2025-07-28 08:34:39 -05:00
parent 1c54973b13
commit bdeaaaf4c8
2 changed files with 13 additions and 8 deletions

View file

@ -165,7 +165,6 @@ const journeyStepsParamsSchema: JSONSchemaType<JourneyStepMapParams> = {
}
router.get('/:journeyId/steps', async ctx => {
console.log('run!')
ctx.body = await getJourneyStepMapForUI(ctx.state.journey!)
})

View file

@ -210,6 +210,7 @@ export class JourneyDelay extends JourneyStep {
this.hours = json?.data?.hours
this.days = json?.data?.days
this.time = json?.data?.time
this.date = json?.data?.date
this.exclusion_days = json?.data?.exclusion_days
}
@ -262,13 +263,18 @@ export class JourneyDelay extends JourneyStep {
}
return nextDate
} else if (this.format === 'date' && date) {
const compiledDate = compileTemplate(date)({
user: state.user.flatten(),
journey: state.stepData(),
})
const localDate = crossTimezoneCopy(new Date(compiledDate), 'UTC', timezone)
if (localDate < baseDate) return baseDate
return localDate
try {
const compiledDate = compileTemplate(date)({
user: state.user.flatten(),
journey: state.stepData(),
})
const localDate = crossTimezoneCopy(new Date(compiledDate), 'UTC', timezone)
if (localDate < baseDate) return baseDate
return localDate
} catch (error) {
logger.error({ error, date, timezone }, 'journey:delay:parse:error')
throw error
}
}
return baseDate