Skip to content

Commit

Permalink
fix(integrations): onboard sprig destination (#2857)
Browse files Browse the repository at this point in the history
* fix(integrations): onboard sprig destination

* chore: code review changes

* chore: code review changes
  • Loading branch information
mihir-4116 authored Dec 12, 2023
1 parent e8f2d1a commit ede22e3
Show file tree
Hide file tree
Showing 2 changed files with 577 additions and 0 deletions.
73 changes: 73 additions & 0 deletions src/cdk/v2/destinations/sprig/procWorkflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
bindings:
- name: EventType
path: ../../../../constants
- path: ../../bindings/jsontemplate
- name: defaultRequestConfig
path: ../../../../v0/util
- name: removeUndefinedAndNullValues
path: ../../../../v0/util

steps:
- name: messageType
template: |
.message.type.toLowerCase();
- name: validateInput
template: |
let messageType = $.outputs.messageType;
$.assert(messageType, "message Type is not present. Aborting");
$.assert(messageType in {{$.EventType.([.IDENTIFY, .TRACK])}}, "message type " + messageType + " is not supported");
$.assertConfig(.destination.Config.apiKey, "API Key is not present. Aborting");
- name: validateIdentifyPayload
condition: $.outputs.messageType === {{$.EventType.IDENTIFY}}
template: |
const userId = .message.({{{{$.getGenericPaths("userIdOnly")}}}});;
$.assert(userId, "userId is required");
- name: prepareIdentifyPayload
condition: $.outputs.messageType === {{$.EventType.IDENTIFY}}
template: |
$.context.payload = .message.({
userId: {{{{$.getGenericPaths("userIdOnly")}}}},
emailAddress: {{{{$.getGenericPaths("email")}}}},
attributes: .context.traits
});
$.context.payload = $.removeUndefinedAndNullValues($.context.payload);
- name: validateTrackPayload
condition: $.outputs.messageType === {{$.EventType.TRACK}}
template: |
const userId = .message.({{{{$.getGenericPaths("userIdOnly")}}}});;
$.assert(userId, "userId is required");
$.assert(.message.event, "event name is required");
- name: prepareTrackPayload
condition: $.outputs.messageType === {{$.EventType.TRACK}}
template: |
$.context.payload = .message.({
userId: {{{{$.getGenericPaths("userIdOnly")}}}},
emailAddress: {{{{$.getGenericPaths("email")}}}}
});
const events = [
{
event: .message.event,
timestamp: $.toMilliseconds(.message.().({{{{$.getGenericPaths("timestamp")}}}}))
}
]
$.context.payload.events = events;
$.context.payload = $.removeUndefinedAndNullValues($.context.payload);
- name: buildResponse
template: |
const response = $.defaultRequestConfig();
response.body.JSON = $.context.payload;
response.endpoint = "https://api.sprig.com/v2/users";
response.headers = {
"accept": "application/json",
"content-type": "application/json",
"authorization": "API-Key " + .destination.Config.apiKey
};
response
Loading

0 comments on commit ede22e3

Please sign in to comment.