Skip to content

Commit

Permalink
refactor: linkedin audiences proc workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
koladilip committed Nov 18, 2024
1 parent be79187 commit b405129
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 34 deletions.
58 changes: 25 additions & 33 deletions src/cdk/v2/destinations/linkedin_audience/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ steps:
$.assertConfig(secret.accessToken, "Access Token is not present. Aborting");
$.assertConfig(config.audienceType, "audienceType is not present. Aborting");
$.assert(messageType, "Message Type is not present. Aborting message.");
$.assert(messageType.toLowerCase() === $.SUPPORTED_EVENT_TYPE, "Event type " + .message.type.toLowerCase() + " is not supported. Aborting message.");
$.assert(messageType.toLowerCase() === $.SUPPORTED_EVENT_TYPE, `Event type ${.message.type.toLowerCase()} is not supported. Aborting message.`);
$.assert(.message.fields, "`fields` is not present. Aborting message.");
$.assert(.message.identifiers, "`identifiers` is not present inside properties. Aborting message.");
$.assert($.containsAll([.message.action], $.ACTION_TYPES), "Unsupported action type. Aborting message.")
Expand All @@ -26,45 +26,37 @@ steps:
description: This step fetches the configs from different places and combines them.
template: |
const config = .connection.config.destination;
const secret = .metadata.secret;
const audienceType = config.audienceType;
const audienceId = config.audienceId;
const accessToken = secret.accessToken;
{
audienceType,
audienceId,
accessToken,
audienceType: config.audienceType,
audienceId: config.audienceId,
accessToken: .metadata.secret.accessToken,
isHashRequired: config.isHashRequired,
}
- name: hashIdentifiers
description: Hash identifiers
condition: $.outputs.getConfigs.isHashRequired === true && $.outputs.getConfigs.audienceType === 'user'
template: |
const hashedIdentifiers = $.hashIdentifiers(.message.identifiers);
hashedIdentifiers;
- name: prepareUserIds
description: Prepare user ids for user audience type
condition: $.outputs.getConfigs.audienceType === 'user'
template: |
const userIds = $.outputs.getConfigs.isHashRequired ? $.prepareUserIds($.outputs.hashIdentifiers) : $.prepareUserIds(.message.identifiers);
userIds;
- name: prepareUserTypeBasePayload
description: Prepare base payload for user audiences
condition: $.outputs.getConfigs.audienceType === 'user'
template: |
const payload = {
'elements': [
{
'action': $.generateActionType(.message.action),
'userIds': $.outputs.prepareUserIds,
....message.fields
steps:
- name: prepareUserIds
description: Prepare user ids for user audience type
template: |
const identifiers = $.outputs.getConfigs.isHashRequired === true ?
$.hashIdentifiers(.message.identifiers) :
.message.identifiers;
$.prepareUserIds(identifiers)
- name: preparePayload
description: Prepare base payload for user audiences
template: |
const payload = {
'elements': [
{
'action': $.generateActionType(.message.action),
'userIds': $.outputs.prepareUserTypeBasePayload.prepareUserIds,
....message.fields
}
]
}
]
}
payload;
payload;
- name: prepareCompanyTypeBasePayload
description: Prepare base payload for company audiences
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const businessTestData: ProcessorTestData[] = [
body: [
{
error:
'The "string" argument must be of type string. Received type number (12345): Workflow: procWorkflow, Step: hashIdentifiers, ChildStep: undefined, OriginalError: The "string" argument must be of type string. Received type number (12345)',
'The "string" argument must be of type string. Received type number (12345): Workflow: procWorkflow, Step: prepareUserTypeBasePayload, ChildStep: prepareUserIds, OriginalError: The "string" argument must be of type string. Received type number (12345)',
metadata: generateMetadata(1),
statTags: {
destType: 'LINKEDIN_AUDIENCE',
Expand Down

0 comments on commit b405129

Please sign in to comment.