From 936ba46303a793ed70b134d14d71c1864b6bae39 Mon Sep 17 00:00:00 2001 From: shrouti1507 Date: Mon, 18 Nov 2024 10:17:44 +0530 Subject: [PATCH] fix: adding uuid transformation for airship --- package-lock.json | 5 +++-- package.json | 2 +- src/v0/destinations/airship/transform.js | 10 ++++++++++ .../destinations/airship/processor/data.ts | 4 ++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0422078f21..dd490e88c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -73,7 +73,7 @@ "truncate-utf8-bytes": "^1.0.2", "ua-parser-js": "^1.0.37", "unset-value": "^2.0.1", - "uuid": "^9.0.0", + "uuid": "^9.0.1", "valid-url": "^1.0.9", "zod": "^3.22.4" }, @@ -21872,11 +21872,12 @@ }, "node_modules/uuid": { "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", "funding": [ "https://github.com/sponsors/broofa", "https://github.com/sponsors/ctavan" ], - "license": "MIT", "bin": { "uuid": "dist/bin/uuid" } diff --git a/package.json b/package.json index 907c340cbf..75a618574c 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,7 @@ "truncate-utf8-bytes": "^1.0.2", "ua-parser-js": "^1.0.37", "unset-value": "^2.0.1", - "uuid": "^9.0.0", + "uuid": "^9.0.1", "valid-url": "^1.0.9", "zod": "^3.22.4" }, diff --git a/src/v0/destinations/airship/transform.js b/src/v0/destinations/airship/transform.js index 091c9b7f39..d60439f45e 100644 --- a/src/v0/destinations/airship/transform.js +++ b/src/v0/destinations/airship/transform.js @@ -1,3 +1,4 @@ +const { v5 } = require('uuid'); const { InstrumentationError, ConfigurationError } = require('@rudderstack/integrations-lib'); const { EventType } = require('../../../constants'); @@ -120,6 +121,12 @@ const identifyResponseBuilder = (message, { Config }) => { return arrayPayload; }; +const transformSessionId = (rawSessionId) => { + const NAMESPACE = v5.DNS; + const uuidV5 = v5(rawSessionId, NAMESPACE); + return uuidV5; +}; + const trackResponseBuilder = async (message, { Config }) => { let name = message.event; if (!name) { @@ -128,6 +135,9 @@ const trackResponseBuilder = async (message, { Config }) => { name = name.toLowerCase(); const payload = constructPayload(message, trackMapping); + if (isDefinedAndNotNullAndNotEmpty(payload.session_id)) { + payload.session_id = transformSessionId(payload.session_id); + } let properties = {}; properties = extractCustomFields(message, properties, ['properties'], AIRSHIP_TRACK_EXCLUSION); if (!isEmptyObject(properties)) { diff --git a/test/integrations/destinations/airship/processor/data.ts b/test/integrations/destinations/airship/processor/data.ts index 3a6c5394cb..74b1c2a628 100644 --- a/test/integrations/destinations/airship/processor/data.ts +++ b/test/integrations/destinations/airship/processor/data.ts @@ -2321,7 +2321,7 @@ export const data = [ ip: '0.0.0.0', os: { name: '', version: '' }, screen: { density: 2 }, - sessionId: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + sessionId: '1731403898', }, type: 'track', messageId: '84e26acc-56a5-4835-8233-591137fca468', @@ -2365,7 +2365,7 @@ export const data = [ user: { named_user_id: 'testuserId1' }, body: { name: 'product_clicked', - session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + session_id: 'd5627eac-795d-5005-9bb4-2c7c0af6cab0', }, }, JSON_ARRAY: {},