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..dc8543fbc5 100644 --- a/src/v0/destinations/airship/transform.js +++ b/src/v0/destinations/airship/transform.js @@ -24,6 +24,7 @@ const { simpleProcessRouterDest, } = require('../../util'); const { JSON_MIME_TYPE } = require('../../util/constant'); +const { transformSessionId } = require('./utils'); const DEFAULT_ACCEPT_HEADER = 'application/vnd.urbanairship+json; version=3'; @@ -128,6 +129,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/src/v0/destinations/airship/utils.js b/src/v0/destinations/airship/utils.js new file mode 100644 index 0000000000..0ef637245f --- /dev/null +++ b/src/v0/destinations/airship/utils.js @@ -0,0 +1,12 @@ +const { v5 } = require('uuid'); + +// ref : https://docs.airship.com/api/ua/#operation-api-custom-events-post +const transformSessionId = (rawSessionId) => { + const NAMESPACE = v5.DNS; + const uuidV5 = v5(rawSessionId, NAMESPACE); + return uuidV5; +}; + +module.exports = { + transformSessionId, +}; diff --git a/test/integrations/destinations/airship/processor/data.ts b/test/integrations/destinations/airship/processor/data.ts index 3a6c5394cb..a72495d23d 100644 --- a/test/integrations/destinations/airship/processor/data.ts +++ b/test/integrations/destinations/airship/processor/data.ts @@ -2296,7 +2296,7 @@ export const data = [ }, { name: 'airship', - description: 'Test 22', + description: 'Test 22 : session id gets converted to v5 uuid format', feature: 'processor', module: 'destination', version: 'v0', @@ -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: {},