Skip to content

Commit

Permalink
feat: klaviyo profile mapping (#3105)
Browse files Browse the repository at this point in the history
* feat: update klaviyo profile mapping

* test: update testcases
  • Loading branch information
Gauravudia authored Feb 28, 2024
1 parent 8a20886 commit 2761786
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 16 deletions.
25 changes: 23 additions & 2 deletions src/v0/destinations/klaviyo/data/KlaviyoIdentify.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@
"traits.address.region",
"context.traits.region",
"context.traits.address.region",
"properties.region"
"properties.region",
"traits.state",
"traits.address.state",
"context.traits.address.state",
"context.traits.state",
"properties.state"
],
"required": false
},
Expand All @@ -77,14 +82,19 @@
"sourceKeys": [
"traits.zip",
"traits.postalcode",
"traits.postalCode",
"traits.address.zip",
"traits.address.postalcode",
"traits.address.postalCode",
"context.traits.zip",
"context.traits.postalcode",
"context.traits.postalCode",
"context.traits.address.zip",
"context.traits.address.postalcode",
"context.traits.address.postalCode",
"properties.zip",
"properties.postalcode"
"properties.postalcode",
"properties.postalCode"
],
"required": false
},
Expand All @@ -97,5 +107,16 @@
"destKey": "location.timezone",
"sourceKeys": ["traits.timezone", "context.traits.timezone", "properties.timezone"],
"required": false
},
{
"destKey": "location.address1",
"sourceKeys": [
"traits.street",
"traits.address.street",
"context.traits.street",
"context.traits.address.street",
"properties.street"
],
"required": false
}
]
25 changes: 23 additions & 2 deletions src/v0/destinations/klaviyo/data/KlaviyoProfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@
"traits.address.region",
"context.traits.region",
"context.traits.address.region",
"properties.region"
"properties.region",
"traits.state",
"traits.address.state",
"context.traits.address.state",
"context.traits.state",
"properties.state"
],
"required": false
},
Expand All @@ -61,14 +66,19 @@
"sourceKeys": [
"traits.zip",
"traits.postalcode",
"traits.postalCode",
"traits.address.zip",
"traits.address.postalcode",
"traits.address.postalCode",
"context.traits.zip",
"context.traits.postalcode",
"context.traits.postalCode",
"context.traits.address.zip",
"context.traits.address.postalcode",
"context.traits.address.postalCode",
"properties.zip",
"properties.postalcode"
"properties.postalcode",
"properties.postalCode"
],
"required": false
},
Expand All @@ -81,5 +91,16 @@
"destKey": "$image",
"sourceKeys": ["traits.image", "context.traits.image", "properties.image"],
"required": false
},
{
"destKey": "$address1",
"sourceKeys": [
"traits.street",
"traits.address.street",
"context.traits.street",
"context.traits.address.street",
"properties.street"
],
"required": false
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const commonTraits = {
},
};

const commonTraits2 = { ...commonTraits, street: '63, Shibuya' };

const commonOutputUserProps = {
external_id: 'user@1',
email: '[email protected]',
Expand All @@ -67,6 +69,12 @@ const commonOutputUserProps = {
},
};

const commonOutputUserProps2 = {
...commonOutputUserProps,
location: { ...commonOutputUserProps.location, address1: '63, Shibuya' },
properties: { ...commonOutputUserProps.properties, street: '63, Shibuya' },
};

const commonOutputSubscriptionProps = {
list_id: 'XUepkK',
subscriptions: [
Expand Down Expand Up @@ -116,7 +124,7 @@ export const identifyData: ProcessorTestData[] = [
destination,
message: generateSimplifiedIdentifyPayload({
context: {
traits: commonTraits,
traits: commonTraits2,
},
anonymousId,
userId,
Expand All @@ -140,7 +148,7 @@ export const identifyData: ProcessorTestData[] = [
JSON: {
data: {
type: 'profile',
attributes: commonOutputUserProps,
attributes: commonOutputUserProps2,
id: '01GW3PHVY0MTCDGS0A1612HARX',
},
},
Expand Down Expand Up @@ -188,7 +196,7 @@ export const identifyData: ProcessorTestData[] = [
userId,
context: {
traits: {
...commonTraits,
...commonTraits2,
friend: {
names: {
first: 'Alice',
Expand Down Expand Up @@ -221,9 +229,9 @@ export const identifyData: ProcessorTestData[] = [
type: 'profile',
id: '01GW3PHVY0MTCDGS0A1612HARX',
attributes: {
...commonOutputUserProps,
...commonOutputUserProps2,
properties: {
...commonOutputUserProps.properties,
...commonOutputUserProps2.properties,
'friend.age': 25,
'friend.names.first': 'Alice',
'friend.names.last': 'Smith',
Expand Down Expand Up @@ -278,7 +286,7 @@ export const identifyData: ProcessorTestData[] = [
userId,
context: {
traits: {
...commonTraits,
...commonTraits2,
email: '[email protected]',
},
},
Expand Down Expand Up @@ -334,7 +342,7 @@ export const identifyData: ProcessorTestData[] = [
userId,
context: {
traits: {
...commonTraits,
...commonTraits2,
properties: { ...commonTraits.properties, subscribe: false },
},
},
Expand All @@ -358,7 +366,7 @@ export const identifyData: ProcessorTestData[] = [
JSON: {
data: {
type: 'profile',
attributes: commonOutputUserProps,
attributes: commonOutputUserProps2,
id: '01GW3PHVY0MTCDGS0A1612HARX',
},
},
Expand Down Expand Up @@ -390,7 +398,7 @@ export const identifyData: ProcessorTestData[] = [
sentAt,
userId,
context: {
traits: commonTraits,
traits: commonTraits2,
},
anonymousId,
originalTimestamp,
Expand All @@ -414,9 +422,9 @@ export const identifyData: ProcessorTestData[] = [
data: {
type: 'profile',
attributes: removeUndefinedAndNullValues({
...commonOutputUserProps,
...commonOutputUserProps2,
properties: {
...commonOutputUserProps.properties,
...commonOutputUserProps2.properties,
_id: userId,
},
// remove external_id from the payload
Expand Down Expand Up @@ -546,7 +554,7 @@ export const identifyData: ProcessorTestData[] = [
userId,
context: {
traits: removeUndefinedAndNullValues({
...commonTraits,
...commonTraits2,
email: undefined,
phone: undefined,
}),
Expand Down

0 comments on commit 2761786

Please sign in to comment.