From b27511da14a4f03e8c21a9c20c33e711472ec972 Mon Sep 17 00:00:00 2001 From: Landi <98327875+jmlandi@users.noreply.github.com> Date: Mon, 23 Dec 2024 02:06:41 -0300 Subject: [PATCH 1/2] fix: anonymousId overwriting userId at MoEngage destination (#3914) fix/moengage-anonymousid-over-userid Co-authored-by: Sudip Paul <67197965+ItsSudip@users.noreply.github.com> --- src/v0/destinations/moengage/transform.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v0/destinations/moengage/transform.js b/src/v0/destinations/moengage/transform.js index 8a16d9c7a7..2df921cb60 100644 --- a/src/v0/destinations/moengage/transform.js +++ b/src/v0/destinations/moengage/transform.js @@ -49,7 +49,7 @@ function responseBuilderSimple(message, category, destination) { // using base64 and prepends it with the string 'Basic '. Authorization: `Basic ${btoa(`${apiId}:${apiKey}`)}`, }; - response.userId = message.anonymousId || message.userId; + response.userId = message.userId || message.anonymousId; if (payload) { switch (category.type) { case 'identify': From 0814bb258e0488a2609f7539cac35066d9b60ec6 Mon Sep 17 00:00:00 2001 From: ItsSudip Date: Mon, 23 Dec 2024 10:57:28 +0530 Subject: [PATCH 2/2] chore: fix test cases --- .../destinations/moengage/processor/data.ts | 24 +++++++++---------- .../destinations/moengage/router/data.ts | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/integrations/destinations/moengage/processor/data.ts b/test/integrations/destinations/moengage/processor/data.ts index df6e1226b6..50309c0372 100644 --- a/test/integrations/destinations/moengage/processor/data.ts +++ b/test/integrations/destinations/moengage/processor/data.ts @@ -292,7 +292,7 @@ export const data = [ FORM: {}, }, files: {}, - userId: '4eb021e9-a2af-4926-ae82-fe996d12f3c5', + userId: 'rudder123', }, statusCode: 200, }, @@ -418,7 +418,7 @@ export const data = [ files: {}, method: 'POST', params: {}, - userId: '4eb021e9-a2af-4926-ae82-fe996d12f3c5', + userId: 'rudder123', headers: { 'MOE-APPKEY': 'W0ZHNMPI2O4KHJ48ZILZACRA', 'Content-Type': 'application/json', @@ -686,7 +686,7 @@ export const data = [ files: {}, method: 'POST', params: {}, - userId: '4eb021e9-a2af-4926-ae82-fe996d12f3c5', + userId: 'rudder123', headers: { 'MOE-APPKEY': 'W0ZHNMPI2O4KHJ48ZILZACRA', 'Content-Type': 'application/json', @@ -719,7 +719,7 @@ export const data = [ files: {}, method: 'POST', params: {}, - userId: '4eb021e9-a2af-4926-ae82-fe996d12f3c5', + userId: 'rudder123', headers: { 'MOE-APPKEY': 'W0ZHNMPI2O4KHJ48ZILZACRA', 'Content-Type': 'application/json', @@ -851,7 +851,7 @@ export const data = [ files: {}, method: 'POST', params: {}, - userId: '4eb021e9-a2af-4926-ae82-fe996d12f3c5', + userId: 'rudder123', headers: { 'MOE-APPKEY': 'W0ZHNMPI2O4KHJ48ZILZACRA', 'Content-Type': 'application/json', @@ -983,7 +983,7 @@ export const data = [ files: {}, method: 'POST', params: {}, - userId: '4eb021e9-a2af-4926-ae82-fe996d12f3c5', + userId: 'rudder123', headers: { 'MOE-APPKEY': 'W0ZHNMPI2O4KHJ48ZILZACRA', 'Content-Type': 'application/json', @@ -1875,7 +1875,7 @@ export const data = [ FORM: {}, }, files: {}, - userId: '4eb021e9-a2af-4926-ae82-fe996d12f3c5', + userId: 'rudder123', }, statusCode: 200, }, @@ -2008,7 +2008,7 @@ export const data = [ files: {}, method: 'POST', params: {}, - userId: '4eb021e9-a2af-4926-ae82-fe996d12f3c5', + userId: 'rudder123', headers: { 'MOE-APPKEY': 'W0ZHNMPI2O4KHJ48ZILZACRA', 'Content-Type': 'application/json', @@ -2041,7 +2041,7 @@ export const data = [ files: {}, method: 'POST', params: {}, - userId: '4eb021e9-a2af-4926-ae82-fe996d12f3c5', + userId: 'rudder123', headers: { 'MOE-APPKEY': 'W0ZHNMPI2O4KHJ48ZILZACRA', 'Content-Type': 'application/json', @@ -2318,7 +2318,7 @@ export const data = [ FORM: {}, }, files: {}, - userId: '4eb021e9-a2af-4926-ae82-fe996d12f3c5', + userId: 'rudder123', }, statusCode: 200, }, @@ -2599,7 +2599,7 @@ export const data = [ FORM: {}, }, files: {}, - userId: '4eb021e9-a2af-4926-ae82-fe996d12f3c5', + userId: 'rudder123', }, statusCode: 200, }, @@ -2875,7 +2875,7 @@ export const data = [ method: 'POST', params: {}, type: 'REST', - userId: 'anon-dummyId-1', + userId: 'userId16', version: '1', }, statusCode: 200, diff --git a/test/integrations/destinations/moengage/router/data.ts b/test/integrations/destinations/moengage/router/data.ts index b24453fd34..a31f407b2c 100644 --- a/test/integrations/destinations/moengage/router/data.ts +++ b/test/integrations/destinations/moengage/router/data.ts @@ -324,7 +324,7 @@ export const data = [ FORM: {}, }, files: {}, - userId: '4eb021e9-a2af-4926-ae82-fe996d12f3c5', + userId: 'rudder123', }, metadata: [{ jobId: 1, userId: 'u1' }], batched: false, @@ -393,7 +393,7 @@ export const data = [ FORM: {}, }, files: {}, - userId: '4eb021e9-a2af-4926-ae82-fe996d12f3c5', + userId: 'rudder123', }, metadata: [{ jobId: 2, userId: 'u1' }], batched: false,