Skip to content

Commit

Permalink
fix: adding uuid transformation for airship
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 committed Nov 18, 2024
1 parent c43f0bd commit 936ba46
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
10 changes: 10 additions & 0 deletions src/v0/destinations/airship/transform.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { v5 } = require('uuid');
const { InstrumentationError, ConfigurationError } = require('@rudderstack/integrations-lib');
const { EventType } = require('../../../constants');

Expand Down Expand Up @@ -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) {
Expand All @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions test/integrations/destinations/airship/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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: {},
Expand Down

0 comments on commit 936ba46

Please sign in to comment.