-
Notifications
You must be signed in to change notification settings - Fork 116
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
feat: identify and track for loops #3976
Open
danrowden
wants to merge
7
commits into
rudderlabs:develop
Choose a base branch
from
danrowden:loops-destination
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+548
−0
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8bb7426
feat: identify and track for loops
danrowden 86eef8e
feat: test for mailing lists
danrowden 089ba09
Update src/cdk/v2/destinations/loops/procWorkflow.yaml
danrowden 22d690c
Merge branch 'develop' into loops-destination
danrowden 039aa46
fix: added response step; updated tests
danrowden 09adb2e
fix: better way to get email and userId
danrowden 30175b3
Merge branch 'rudderlabs:develop' into loops-destination
danrowden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
bindings: | ||
- name: EventType | ||
path: ../../../../constants | ||
- path: ../../bindings/jsontemplate | ||
exportAll: true | ||
- name: removeUndefinedAndNullValues | ||
path: ../../../../v0/util | ||
- name: defaultRequestConfig | ||
path: ../../../../v0/util | ||
|
||
steps: | ||
- name: messageType | ||
template: | | ||
.message.type.toLowerCase(); | ||
|
||
- name: validateInput | ||
template: | | ||
$.assert(.message.type, "message Type is not present. Aborting message."); | ||
$.assert(.message.type in {{$.EventType.([.TRACK, .IDENTIFY])}}, | ||
"message type " + .message.type + " is not supported"); | ||
|
||
- name: validateIdentifyEmail | ||
condition: $.outputs.messageType === {{$.EventType.IDENTIFY}} | ||
template: | | ||
const email = .message.({{{{$.getGenericPaths("emailOnly")}}}}); | ||
$.assert(email, "email is required. Aborting"); | ||
|
||
- name: validateTrackIdentifier | ||
condition: $.outputs.messageType === {{$.EventType.TRACK}} | ||
template: | | ||
const userId = .message.({{{{$.getGenericPaths("userIdOnly")}}}}); | ||
const email = .message.({{{{$.getGenericPaths("emailOnly")}}}}); | ||
$.assert(email || userId, "Either email or userId is required. Aborting"); | ||
|
||
- name: validateEventName | ||
condition: $.outputs.messageType === {{$.EventType.TRACK}} | ||
template: | | ||
$.assert(.message.event, "event is required for track call") | ||
|
||
- name: prepareContext | ||
template: | | ||
$.context.messageType = .message.type.toLowerCase(); | ||
$.context.payload = {}; | ||
|
||
- name: identifyPayload | ||
condition: $.outputs.messageType === {{$.EventType.IDENTIFY}} | ||
template: | | ||
$.context.endpoint = "https://app.loops.so/api/v1/contacts/update"; | ||
const payload = {} | ||
Object.assign(payload, .message.context.traits); | ||
payload.userId = .message.({{{{$.getGenericPaths("userIdOnly")}}}}); | ||
payload.email = .message.({{{{$.getGenericPaths("emailOnly")}}}}); | ||
$.context.payload = payload; | ||
|
||
- name: trackPayload | ||
condition: $.outputs.messageType === {{$.EventType.TRACK}} | ||
template: | | ||
$.context.endpoint = "https://app.loops.so/api/v1/events/send"; | ||
const payload = {} | ||
Object.assign(payload, .message.context.traits); | ||
payload.userId = .message.({{{{$.getGenericPaths("userIdOnly")}}}}); | ||
payload.email = .message.({{{{$.getGenericPaths("emailOnly")}}}}); | ||
payload.eventName = .message.event; | ||
payload.eventProperties = .message.properties; | ||
$.context.payload = payload; | ||
danrowden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: buildResponse | ||
template: | | ||
const response = $.defaultRequestConfig(); | ||
response.body.JSON = $.context.payload; | ||
response.endpoint = $.context.endpoint; | ||
response.headers = { | ||
"authorization": "Bearer " + .destination.Config.apiKey, | ||
"content-type": "application/json" | ||
}; | ||
response |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const email = .message.({{{{$.getGenericPaths("emailOnly")}}}});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this line do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will assign email value to available generic mapping of message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you suggest using that for
payload.userId
when creating the payloads further down, rather than using.message.userId
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes.
Also for payload creation you can do something like this:
this means =>