Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(integrations): onboard sprig destination #2857

Merged
merged 10 commits into from
Dec 12, 2023
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
mihir-4116 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading