From 2b3a9b6260335266587a14d3f73114f429557a5c Mon Sep 17 00:00:00 2001 From: David Meiklejohn Date: Thu, 14 Nov 2024 13:40:24 +1000 Subject: [PATCH] WIP --- .../accoil_analytics/procWorkflow.yaml | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/cdk/v2/destinations/accoil_analytics/procWorkflow.yaml b/src/cdk/v2/destinations/accoil_analytics/procWorkflow.yaml index fd81f9d7d7..8be22eae85 100644 --- a/src/cdk/v2/destinations/accoil_analytics/procWorkflow.yaml +++ b/src/cdk/v2/destinations/accoil_analytics/procWorkflow.yaml @@ -13,6 +13,7 @@ steps: $.assert(.message.type, "message Type is not present. Aborting message."); $.assert(.message.type in {{$.EventType.([.TRACK, .PAGE, .SCREEN, .IDENTIFY, .GROUP])}}, "message type " + .message.type + " is not supported"); + $.assert(.destination.Config.apiKey, "apiKey must be supplied in destination config"); - name: prepareContext template: | @@ -27,31 +28,32 @@ steps: $.context.endpoint = $.endpointUrl(.destination.Config.apiKey); - name: trackPayload - condition: $.context.messageType == "track" + condition: $.context.messageType == {{$.EventType.TRACK}} template: | $.context.payload.event = .message.event; - $.context.payload.userId = .message.userId; - $.context.payload.timestamp = .message.timestamp; + $.context.payload.userId = message.().({{{{$.getGenericPaths("userId")}}}}) + $.context.payload.timestamp = .message.().({{{{$.getGenericPaths("timestamp")}}}}); - name: pagePayload - condition: $.context.messageType == "page" + condition: $.context.messageType == {{$.EventType.PAGE}} template: | - $.context.payload.userId = .message.userId; + $.context.payload.userId = .message.().({{{{$.getGenericPaths("userId")}}}}); $.context.payload.name = .message.event; - $.context.payload.timestamp = .message.timestamp; + $.context.payload.timestamp = .message.().({{{{$.getGenericPaths("timestamp")}}}}); - name: screenPayload - condition: $.context.messageType == "screen" + condition: $.context.messageType == {{$.EventType.SCREEN}} template: | - $.context.payload.userId = .message.userId; + $.context.payload.userId = .message.().({{{{$.getGenericPaths("userId")}}}}); $.context.payload.name = .message.event; - $.context.payload.timestamp = .message.timestamp; + $.context.payload.timestamp = .message.().({{{{$.getGenericPaths("timestamp")}}}}); - name: identifyPayload - condition: $.context.messageType == "identify" + condition: $.context.messageType == {{$.EventType.IDENTIFY}} template: | - $.context.payload.userId = .message.userId; + $.context.payload.userId = .message.().({{{{$.getGenericPaths("userId")}}}}); $.context.payload.traits = .message.traits ?? .message.context.traits; + $.context.payload.timestamp = .message.().({{{{$.getGenericPaths("timestamp")}}}}); # $.context.payload.traits.email = .message.traits.email; # $.context.payload.traits.name = .message.traits.name; # $.context.payload.traits.role = .message.traits.role; @@ -59,13 +61,13 @@ steps: # $.context.payload.traits.accountStatus = .message.traits.accountStatus; - name: groupPayload - condition: $.context.messageType == "group" + condition: $.context.messageType == {{$.EventType.GROUP}} template: | $.context.payload.anonymousId = .message.anonymousId; - $.context.payload.userId = .message.userId; + $.context.payload.userId = .message.().({{{{$.getGenericPaths("userId")}}}}); $.context.payload.groupId = .message.groupId; $.context.payload.name = .message.event; - $.context.payload.timestamp = .message.timestamp; + $.context.payload.timestamp = .message.().({{{{$.getGenericPaths("timestamp")}}}}); $.context.payload.traits = .message.traits ?? .message.context.traits; # $.context.payload.traits.name = .message.traits.name; # $.context.payload.traits.createdAt = .message.traits.createdAt; @@ -78,33 +80,33 @@ steps: $.assert($.context.payload.timestamp, "timestamp is required for all calls") - name: validateTrackPayload - condition: $.context.messageType == "track" + condition: $.context.messageType == {{$.EventType.TRACK}} template: | $.assert($.context.payload.event, "event is required for track call") $.assert($.context.payload.userId, "userId is required for track call") - name: validatePagePayload - condition: $.context.messageType == "page" + condition: $.context.messageType == {{$.EventType.PAGE}} template: | $.assert($.context.payload.userId, "userId is required for page call") - name: validateScreenPayload - condition: $.context.messageType == "screen" + condition: $.context.messageType == {{$.EventType.SCREEN}} template: | $.assert($.context.payload.userId, "userId is required for screen call") $.assert($.context.payload.timestamp, "timestamp is required for screen call") - name: validateIdentifyPayload - condition: $.context.messageType == "identify" + condition: $.context.messageType == {{$.EventType.IDENTIFY}} template: | - $.assert($.context.payload.userId, "userId is required for track call") - $.assert($.context.payload.timestamp, "timestamp is required for screen call") + $.assert($.context.payload.userId, "userId is required for identify call") + $.assert($.context.payload.timestamp, "timestamp is required for identify call") - name: validateGroupyPayload - condition: $.context.messageType == "group" + condition: $.context.messageType == {{$.EventType.GROUP}} template: | - $.assert($.context.payload.userId, "userId is required for track call") - $.assert($.context.payload.timestamp, "timestamp is required for screen call") + $.assert($.context.payload.userId, "userId is required for group call") + $.assert($.context.payload.timestamp, "timestamp is required for group call") - name: cleanPayload template: |