From 55629d6d871d275de601a11ec223e0c283641d7b Mon Sep 17 00:00:00 2001 From: Debanjan Date: Thu, 14 Sep 2023 18:02:05 +0530 Subject: [PATCH] fix(redis): add destination_id in the key while preparing the event for profiles<>redis store --- src/v0/destinations/redis/transform.js | 7 ++++--- test/__tests__/data/redis_output.json | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/v0/destinations/redis/transform.js b/src/v0/destinations/redis/transform.js index f57cadb7e6..124569c8e8 100644 --- a/src/v0/destinations/redis/transform.js +++ b/src/v0/destinations/redis/transform.js @@ -31,9 +31,9 @@ const isSubEventTypeProfiles = (message) => { return sources.profiles_entity && sources.profiles_id_type && sources.profiles_model; }; -const transforrmSubEventTypeProfiles = (message, workspaceId) => { +const transformSubEventTypeProfiles = (message, workspaceId, destinationId) => { // form the hash - const hash = `${workspaceId}:${message.context.sources.profiles_entity}:${message.context.sources.profiles_id_type}:${message.userId}`; + const hash = `${workspaceId}:${destinationId}:${message.context.sources.profiles_entity}:${message.context.sources.profiles_id_type}:${message.userId}`; const key = `${message.context.sources.profiles_model}`; const value = JSON.stringify(message.traits); return { @@ -59,11 +59,12 @@ const process = (event) => { } const { prefix } = destination.Config; + const destinationId = destination.ID; const keyPrefix = isEmpty(prefix) ? '' : `${prefix.trim()}:`; if (isSubEventTypeProfiles(message)) { const { workspaceId } = metadata; - return transforrmSubEventTypeProfiles(message, workspaceId); + return transformSubEventTypeProfiles(message, workspaceId, destinationId); } const hmap = { diff --git a/test/__tests__/data/redis_output.json b/test/__tests__/data/redis_output.json index 57d8387041..69d2aa20c2 100644 --- a/test/__tests__/data/redis_output.json +++ b/test/__tests__/data/redis_output.json @@ -81,7 +81,7 @@ }, { "message": { - "hash": "some-workspace-id:some-entity:some-id-type:some-user-id", + "hash": "some-workspace-id:1WhcOCGgj9asZu850HvugU2C3Aq:some-entity:some-id-type:some-user-id", "key": "some-model", "value": "{\"MODEL_ID\":\"1691755780\",\"VALID_AT\":\"2023-08-11T11:32:44.963062Z\",\"USER_MAIN_ID\":\"rid5530313526204a95efe71d98cd17d5a1\",\"CHURN_SCORE_7_DAYS\":0.027986,\"PERCENTILE_CHURN_SCORE_7_DAYS\":0}" },