Skip to content

Commit

Permalink
chore: update id logic, add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yashasvibajpai committed Apr 1, 2024
1 parent b55ef38 commit a3e56f4
Show file tree
Hide file tree
Showing 3 changed files with 312 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ steps:
let data = .message.traits
let identifierType = .message.context.externalId[0].identifierType;
let identifierValue = .message.context.externalId[0].id;
let ClientId = identifierValue;
data.ClientId = ClientId;
data = $.setIdentifier(data, identifierType, identifierValue)
data
- name: buildResponseForProcessTransformation
Expand All @@ -34,8 +33,3 @@ steps:
response.body.JSON = $.outputs.prepareData
console.log(JSON.stringify(response));
response
# header should change to clientID, YCLID etc
# batching support -> rtWorkflow

15 changes: 15 additions & 0 deletions src/cdk/v2/destinations/yandex_metrica_offline_events/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const setIdentifier = (data, identifierType, identifierValue) => {
const updatedData = data;
if (identifierType === 'ClientId') {
updatedData.ClientId = identifierValue;
} else if (identifierType === 'YCLID') {
updatedData.Yclid = identifierValue;
} else if (identifierType === 'UserId') {
updatedData.UserId = identifierValue;
}
return updatedData;
};

module.exports = {
setIdentifier,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
export const data = [
{
name: 'yandex_metrica_offline_events',
description: 'Successful identify event with YCLID identifier type',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
message: {
type: 'identify',
traits: {
Price: '100',
Target: 'GOAL1',
Currency: 'RUB',
DateTime: '1481718166',
},
userId: '',
channel: 'sources',
context: {
sources: {
job_id: '2du7rQyxlbIJl4LKgZAaaErEjcE',
version: '1849/merge',
job_run_id: 'cnsn3tt5fleigsfclr6g',
task_run_id: 'cnsn3tt5fleigsfclr70',
},
externalId: [
{
id: '133591247640966458',
type: 'YANDEX_METRICA_OFFLINE_EVENTS-conversions',
identifierType: 'YCLID',
},
],
mappedToDestination: 'true',
},
recordId: '1',
rudderId: '14a58046-23a5-46bd-afbf-87c8acaa9d2e',
messageId: '91ef85d9-b170-440c-bae2-6284d4070338',
},
destination: {
DestinationDefinition: {
Config: {
cdkV2Enabled: true,
},
},
Config: {
counterId: '574342423',
goalId: '23432565',
rudderAccountId: '2du7fLeK82nk9L2Xd1X507uiD1B',
authStatus: 'active',
},
},
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
},
output: {
response: {
status: 200,
body: [
{
output: {
version: '1',
type: 'REST',
method: 'POST',
endpoint: '',
headers: {},
params: {},
body: {
JSON: {
Currency: 'RUB',
DateTime: '1481718166',
Price: '100',
Target: 'GOAL1',
Yclid: '133591247640966458',
},
JSON_ARRAY: {},
XML: {},
FORM: {},
},
files: {},
userId: '',
},
statusCode: 200,
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
},
},
{
name: 'yandex_metrica_offline_events',
description: 'Successful identify event with ClientId identifier type',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
message: {
type: 'identify',
traits: {
Price: '100',
Target: 'GOAL1',
Currency: 'RUB',
DateTime: '1481718166',
},
userId: '',
channel: 'sources',
context: {
sources: {
job_id: '2du7rQyxlbIJl4LKgZAaaErEjcE',
version: '1849/merge',
job_run_id: 'cnsn3tt5fleigsfclr6g',
task_run_id: 'cnsn3tt5fleigsfclr70',
},
externalId: [
{
id: '133591247640966458',
type: 'YANDEX_METRICA_OFFLINE_EVENTS-conversions',
identifierType: 'ClientId',
},
],
mappedToDestination: 'true',
},
recordId: '1',
rudderId: '14a58046-23a5-46bd-afbf-87c8acaa9d2e',
messageId: '91ef85d9-b170-440c-bae2-6284d4070338',
},
destination: {
DestinationDefinition: {
Config: {
cdkV2Enabled: true,
},
},
Config: {
counterId: '574342423',
goalId: '23432565',
rudderAccountId: '2du7fLeK82nk9L2Xd1X507uiD1B',
authStatus: 'active',
},
},
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
},
output: {
response: {
status: 200,
body: [
{
output: {
version: '1',
type: 'REST',
method: 'POST',
endpoint: '',
headers: {},
params: {},
body: {
JSON: {
Currency: 'RUB',
DateTime: '1481718166',
Price: '100',
Target: 'GOAL1',
ClientId: '133591247640966458',
},
JSON_ARRAY: {},
XML: {},
FORM: {},
},
files: {},
userId: '',
},
statusCode: 200,
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
},
},
{
name: 'yandex_metrica_offline_events',
description: 'Successful identify event with UserId identifier type',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
message: {
type: 'identify',
traits: {
Price: '100',
Target: 'GOAL1',
Currency: 'RUB',
DateTime: '1481718166',
},
userId: '',
channel: 'sources',
context: {
sources: {
job_id: '2du7rQyxlbIJl4LKgZAaaErEjcE',
version: '1849/merge',
job_run_id: 'cnsn3tt5fleigsfclr6g',
task_run_id: 'cnsn3tt5fleigsfclr70',
},
externalId: [
{
id: '133591247640966458',
type: 'YANDEX_METRICA_OFFLINE_EVENTS-conversions',
identifierType: 'UserId',
},
],
mappedToDestination: 'true',
},
recordId: '1',
rudderId: '14a58046-23a5-46bd-afbf-87c8acaa9d2e',
messageId: '91ef85d9-b170-440c-bae2-6284d4070338',
},
destination: {
DestinationDefinition: {
Config: {
cdkV2Enabled: true,
},
},
Config: {
counterId: '574342423',
goalId: '23432565',
rudderAccountId: '2du7fLeK82nk9L2Xd1X507uiD1B',
authStatus: 'active',
},
},
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
},
output: {
response: {
status: 200,
body: [
{
output: {
version: '1',
type: 'REST',
method: 'POST',
endpoint: '',
headers: {},
params: {},
body: {
JSON: {
Currency: 'RUB',
DateTime: '1481718166',
Price: '100',
Target: 'GOAL1',
UserId: '133591247640966458',
},
JSON_ARRAY: {},
XML: {},
FORM: {},
},
files: {},
userId: '',
},
statusCode: 200,
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
},
},
];

0 comments on commit a3e56f4

Please sign in to comment.