diff --git a/src/processTrip.js b/src/processTrip.js index a942085..071e1d8 100644 --- a/src/processTrip.js +++ b/src/processTrip.js @@ -11,28 +11,24 @@ export async function processTrip(activity, usefulRequestHeaders) { }, ) let body = await res.json() - let unparsedData = body + let unparsedData = { body } let cards = body?.data?.cards?.filter((card) => { - return card.type != "MapCard" && card.type != "TripStatsCard" + return !["MapCard", "TripStatsCard"].includes(card.type) }) + if (cards?.length) { + unparsedData = { cards } + } let breakdown = cards?.find((card) => card.type == "TripAllPartiesBreakdownCard") || cards?.find((card) => card.type == "TripBreakdownCard") if (breakdown) { let components = breakdown.components?.filter((comp) => { - return ( - comp.type != "header" && - comp.type != "divider" && - comp.type != "collapsableSection" - ) + return !["header", "divider", "collapsableSection"].includes(comp.type) }) if (components?.length) { - unparsedData = components + unparsedData = { components } } } - if (cards?.length) { - unparsedData = cards - } return { uuid: activity.uuid, recognizedAt: new Date((activity.recognizedAt ?? 1) * 1000).toISOString(),