Skip to content

Commit

Permalink
fix: handle response formation for custom event
Browse files Browse the repository at this point in the history
  • Loading branch information
utsabc committed May 28, 2024
1 parent c75366d commit f86419f
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 58 deletions.
3 changes: 2 additions & 1 deletion src/v0/destinations/ga4/customMappingsHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ const handleCustomMappings = (message, Config) => {
rawPayload = { ...rawPayload, events: [ga4EventPayload] };

boilerplateOperations(rawPayload, message, Config, rsEvent);
return rawPayload;

return buildDeliverablePayload(rawPayload, Config);
}

const processedPayloads = validMappings.map((mapping) => {
Expand Down
134 changes: 77 additions & 57 deletions test/integrations/destinations/ga4/processor/customMappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,67 +525,87 @@ export const customMappingTestCases = [
body: [
{
output: {
user_id: 'root_user',
timestamp_micros: 1651105389000000,
non_personalized_ads: false,
user_properties: {
firstName: {
value: 'John',
},
lastName: {
value: 'Gomes',
},
city: {
value: 'London',
},
state: {
value: 'UK',
},
group: {
value: 'test group',
},
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://www.google-analytics.com/mp/collect',
headers: {
HOST: 'www.google-analytics.com',
'Content-Type': 'application/json',
},
params: {
api_secret: 'dummyApiSecret',
measurement_id: 'G-T40PE6KET4',
},
events: [
{
name: 'Product_Viewed',
params: {
engagement_time_msec: 1,
list_id: 'random_list_id',
category: 'random_category',
storePrice: 456,
prices_0_id: 'store-price',
prices_0_value: 456,
prices_1_id: 'desk-price',
prices_1_value: 567,
products_0_product_id: 883213,
products_0_name: 'Salt',
products_0_coupon: 'HHH',
products_0_price: 100,
products_0_position: 1,
products_0_quantity: 10,
products_0_affiliation: 'NADA',
products_0_currency: 'INR',
products_0_discount: '2%',
products_0_item_category3: 'grocery',
products_1_product_id: 213123,
products_1_name: 'Sugar',
products_1_coupon: 'III',
products_1_price: 200,
products_1_position: 2,
products_1_quantity: 20,
products_1_affiliation: 'ADNA',
products_1_currency: 'INR',
products_1_discount: '5%',
products_1_item_category2: 'regulars',
products_1_item_category3: 'grocery',
products_1_some_data: 'someValue',
body: {
JSON: {
user_id: 'root_user',
timestamp_micros: 1651105389000000,
non_personalized_ads: false,
user_properties: {
firstName: {
value: 'John',
},
lastName: {
value: 'Gomes',
},
city: {
value: 'London',
},
state: {
value: 'UK',
},
group: {
value: 'test group',
},
},
events: [
{
name: 'Product_Viewed',
params: {
engagement_time_msec: 1,
list_id: 'random_list_id',
category: 'random_category',
storePrice: 456,
prices_0_id: 'store-price',
prices_0_value: 456,
prices_1_id: 'desk-price',
prices_1_value: 567,
products_0_product_id: 883213,
products_0_name: 'Salt',
products_0_coupon: 'HHH',
products_0_price: 100,
products_0_position: 1,
products_0_quantity: 10,
products_0_affiliation: 'NADA',
products_0_currency: 'INR',
products_0_discount: '2%',
products_0_item_category3: 'grocery',
products_1_product_id: 213123,
products_1_name: 'Sugar',
products_1_coupon: 'III',
products_1_price: 200,
products_1_position: 2,
products_1_quantity: 20,
products_1_affiliation: 'ADNA',
products_1_currency: 'INR',
products_1_discount: '5%',
products_1_item_category2: 'regulars',
products_1_item_category3: 'grocery',
products_1_some_data: 'someValue',
},
},
],
consent: {
ad_user_data: 'DENIED',
ad_personalization: 'GRANTED',
},
},
],
consent: {
ad_user_data: 'DENIED',
ad_personalization: 'GRANTED',
JSON_ARRAY: {},
XML: {},
FORM: {},
},
files: {},
userId: '',
},
statusCode: 200,
Expand Down

0 comments on commit f86419f

Please sign in to comment.