Skip to content

Commit

Permalink
[MOLOCO] Add a new field Platform Name in settings (segmentio#2114)
Browse files Browse the repository at this point in the history
* Add platform name

* Set platformName optional, and use platformId as a default value
  • Loading branch information
heonjang authored Jul 9, 2024
1 parent 781959c commit 78de0cd
Show file tree
Hide file tree
Showing 14 changed files with 457 additions and 375 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@ describe('Moloco MCM', () => {
currency: 'USD',
price: 12.34,
quantity: 1,
seller_id: 'cs032b-11ee-9a73-0n5e570313ef',
seller_id: 'cs032b-11ee-9a73-0n5e570313ef'
},
{
id: '456',
currency: 'USD',
price: 56.78,
quantity: 2,
seller_id: 'cs032b-11ee-9a73-w5e570313ef',
seller_id: 'cs032b-11ee-9a73-w5e570313ef'
}
],
revenue: {
currency: 'USD',
price: 69.12,
price: 69.12
},
search_query: 'iphone',
page_id: '/home',
referrer_page_id: 'google.com',
shipping_charge: {
currency: 'USD',
price: 5.00
price: 5.0
}
}

Expand Down Expand Up @@ -79,7 +79,7 @@ describe('Moloco MCM', () => {
amount: 12.34
},
quantity: 1,
seller_id: 'cs032b-11ee-9a73-0n5e570313ef',
seller_id: 'cs032b-11ee-9a73-0n5e570313ef'
},
{
id: '456',
Expand All @@ -88,23 +88,32 @@ describe('Moloco MCM', () => {
amount: 56.78
},
quantity: 2,
seller_id: 'cs032b-11ee-9a73-w5e570313ef',
seller_id: 'cs032b-11ee-9a73-w5e570313ef'
}
],
revenue: {
currency: 'USD',
amount: 69.12,
amount: 69.12
},
search_query: 'iphone',
page_id: '/home',
referrer_page_id: 'google.com',
shipping_charge: {
currency: 'USD',
amount: 5.00
amount: 5.0
}
}

const output: MolocoEventPayload = convertEvent({ eventType: TEST_EVENT_TYPE, payload: input, settings: { channel_type: 'APP', platformId: 'any_plat_id', apiKey: 'any_api_key'}})

const output: MolocoEventPayload = convertEvent({
eventType: TEST_EVENT_TYPE,
payload: input,
settings: {
channel_type: 'APP',
platformId: 'any_plat_id',
platformName: 'any_plat_name',
apiKey: 'any_api_key'
}
})
expect(output).toEqual(expectedOutput)
})

Expand All @@ -130,26 +139,26 @@ describe('Moloco MCM', () => {
currency: 'USD',
price: 12.34,
quantity: 1,
seller_id: 'cs032b-11ee-9a73-0n5e570313ef',
seller_id: 'cs032b-11ee-9a73-0n5e570313ef'
},
{
id: '456',
currency: 'USD',
price: 56.78,
quantity: 2,
seller_id: 'cs032b-11ee-9a73-w5e570313ef',
seller_id: 'cs032b-11ee-9a73-w5e570313ef'
}
],
revenue: {
currency: 'USD',
price: 69.12,
price: 69.12
},
search_query: 'iphone',
page_id: '/home',
referrer_page_id: 'google.com',
shipping_charge: {
currency: 'USD',
price: 5.00
price: 5.0
}
}

Expand Down Expand Up @@ -178,7 +187,7 @@ describe('Moloco MCM', () => {
amount: 12.34
},
quantity: 1,
seller_id: 'cs032b-11ee-9a73-0n5e570313ef',
seller_id: 'cs032b-11ee-9a73-0n5e570313ef'
},
{
id: '456',
Expand All @@ -187,23 +196,32 @@ describe('Moloco MCM', () => {
amount: 56.78
},
quantity: 2,
seller_id: 'cs032b-11ee-9a73-w5e570313ef',
seller_id: 'cs032b-11ee-9a73-w5e570313ef'
}
],
revenue: {
currency: 'USD',
amount: 69.12,
amount: 69.12
},
search_query: 'iphone',
page_id: '/home',
referrer_page_id: 'google.com',
shipping_charge: {
currency: 'USD',
amount: 5.00
amount: 5.0
}
}

const output: MolocoEventPayload = convertEvent({ eventType: TEST_EVENT_TYPE, payload: input, settings: { channel_type: 'APP', platformId: 'any_plat_id', apiKey: 'any_api_key'}})

const output: MolocoEventPayload = convertEvent({
eventType: TEST_EVENT_TYPE,
payload: input,
settings: {
channel_type: 'APP',
platformId: 'any_plat_id',
platformName: 'any_plat_name',
apiKey: 'any_api_key'
}
})
expect(output).toEqual(expectedOutput)
})

Expand All @@ -229,26 +247,26 @@ describe('Moloco MCM', () => {
currency: 'USD',
price: 12.34,
quantity: 1,
seller_id: 'cs032b-11ee-9a73-0n5e570313ef',
seller_id: 'cs032b-11ee-9a73-0n5e570313ef'
},
{
id: '456',
currency: 'USD',
price: 56.78,
quantity: 2,
seller_id: 'cs032b-11ee-9a73-w5e570313ef',
seller_id: 'cs032b-11ee-9a73-w5e570313ef'
}
],
revenue: {
currency: 'USD',
price: 69.12,
price: 69.12
},
search_query: 'iphone',
page_id: '/home',
referrer_page_id: 'google.com',
shipping_charge: {
currency: 'USD',
price: 5.00
price: 5.0
}
}

Expand Down Expand Up @@ -277,7 +295,7 @@ describe('Moloco MCM', () => {
amount: 12.34
},
quantity: 1,
seller_id: 'cs032b-11ee-9a73-0n5e570313ef',
seller_id: 'cs032b-11ee-9a73-0n5e570313ef'
},
{
id: '456',
Expand All @@ -286,27 +304,35 @@ describe('Moloco MCM', () => {
amount: 56.78
},
quantity: 2,
seller_id: 'cs032b-11ee-9a73-w5e570313ef',
seller_id: 'cs032b-11ee-9a73-w5e570313ef'
}
],
revenue: {
currency: 'USD',
amount: 69.12,
amount: 69.12
},
search_query: 'iphone',
page_id: '/home',
referrer_page_id: 'google.com',
shipping_charge: {
currency: 'USD',
amount: 5.00
amount: 5.0
}
}

const output: MolocoEventPayload = convertEvent({ eventType: TEST_EVENT_TYPE, payload: input, settings: { channel_type: 'APP', platformId: 'any_plat_id', apiKey: 'any_api_key'}})

const output: MolocoEventPayload = convertEvent({
eventType: TEST_EVENT_TYPE,
payload: input,
settings: {
channel_type: 'APP',
platformId: 'any_plat_id',
platformName: 'any_plat_name',
apiKey: 'any_api_key'
}
})
expect(output).toEqual(expectedOutput)
})


it('tests an event payload with a missing field (session_id)', async () => {
const input: SegmentEventPayload = {
event_id: '12e64c12-f386-42c9-871b-8dg3e539ad19',
Expand All @@ -328,26 +354,26 @@ describe('Moloco MCM', () => {
currency: 'USD',
price: 12.34,
quantity: 1,
seller_id: 'cs032b-11ee-9a73-0n5e570313ef',
seller_id: 'cs032b-11ee-9a73-0n5e570313ef'
},
{
id: '456',
currency: 'USD',
price: 56.78,
quantity: 2,
seller_id: 'cs032b-11ee-9a73-w5e570313ef',
seller_id: 'cs032b-11ee-9a73-w5e570313ef'
}
],
revenue: {
currency: 'USD',
price: 69.12,
price: 69.12
},
search_query: 'iphone',
page_id: '/home',
referrer_page_id: 'google.com',
shipping_charge: {
currency: 'USD',
price: 5.00
price: 5.0
}
}

Expand Down Expand Up @@ -375,7 +401,7 @@ describe('Moloco MCM', () => {
amount: 12.34
},
quantity: 1,
seller_id: 'cs032b-11ee-9a73-0n5e570313ef',
seller_id: 'cs032b-11ee-9a73-0n5e570313ef'
},
{
id: '456',
Expand All @@ -384,23 +410,32 @@ describe('Moloco MCM', () => {
amount: 56.78
},
quantity: 2,
seller_id: 'cs032b-11ee-9a73-w5e570313ef',
seller_id: 'cs032b-11ee-9a73-w5e570313ef'
}
],
revenue: {
currency: 'USD',
amount: 69.12,
amount: 69.12
},
search_query: 'iphone',
page_id: '/home',
referrer_page_id: 'google.com',
shipping_charge: {
currency: 'USD',
amount: 5.00
amount: 5.0
}
}

const output: MolocoEventPayload = convertEvent({ eventType: TEST_EVENT_TYPE, payload: input, settings: { channel_type: 'APP', platformId: 'any_plat_id', apiKey: 'any_api_key'}})

const output: MolocoEventPayload = convertEvent({
eventType: TEST_EVENT_TYPE,
payload: input,
settings: {
channel_type: 'APP',
platformId: 'any_plat_id',
platformName: 'any_plat_name',
apiKey: 'any_api_key'
}
})
expect(output).toEqual(expectedOutput)
})

Expand All @@ -425,19 +460,30 @@ describe('Moloco MCM', () => {
id: '123',
price: 12.34,
quantity: 1,
seller_id: 'cs032b-11ee-9a73-0n5e570313ef',
seller_id: 'cs032b-11ee-9a73-0n5e570313ef'
},
{
id: '456',
currency: 'USD',
price: 56.78,
quantity: 2,
seller_id: 'cs032b-11ee-9a73-w5e570313ef',
seller_id: 'cs032b-11ee-9a73-w5e570313ef'
}
]
}

expect(() => convertEvent({ eventType: TEST_EVENT_TYPE, payload: input, settings: { channel_type: 'APP', platformId: 'any_plat_id', apiKey: 'any_api_key'} })).toThrowError(PayloadValidationError)
expect(() =>
convertEvent({
eventType: TEST_EVENT_TYPE,
payload: input,
settings: {
channel_type: 'APP',
platformId: 'any_plat_id',
platformName: 'any_plat_name',
apiKey: 'any_api_key'
}
})
).toThrowError(PayloadValidationError)
})
})
})
Loading

0 comments on commit 78de0cd

Please sign in to comment.