Skip to content

Commit ed9fe55

Browse files
authored
chore(release): pull main into develop post release v1.85.1 (#3902)
2 parents 6ec379d + 275e971 commit ed9fe55

File tree

10 files changed

+380
-21
lines changed

10 files changed

+380
-21
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
### [1.85.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.85.0...v1.85.1) (2024-11-21)
6+
7+
8+
### Bug Fixes
9+
10+
* braze subscription batch size ([#3897](https://github.com/rudderlabs/rudder-transformer/issues/3897)) ([ca71a31](https://github.com/rudderlabs/rudder-transformer/commit/ca71a318e4d8d098116fe539964b699254f58617))
11+
* stringifying session ID for airship ([#3896](https://github.com/rudderlabs/rudder-transformer/issues/3896)) ([bb0b9dc](https://github.com/rudderlabs/rudder-transformer/commit/bb0b9dc1e5a56e8141c6cb56e89835ba61ee7761))
12+
513
## [1.85.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.84.0...v1.85.0) (2024-11-18)
614

715

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rudder-transformer",
3-
"version": "1.85.0",
3+
"version": "1.85.1",
44
"description": "",
55
"homepage": "https://github.com/rudderlabs/rudder-transformer#readme",
66
"bugs": {

src/v0/destinations/airship/data/airshipTrackConfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
{
2323
"destKey": "session_id",
2424
"sourceKeys": ["properties.sessionId", "context.sessionId"],
25-
"required": false
25+
"required": false,
26+
"metadata": {
27+
"type": "toString"
28+
}
2629
},
2730
{
2831
"destKey": "transaction",

src/v0/destinations/airship/transform.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,20 @@ const {
2222
extractCustomFields,
2323
isEmptyObject,
2424
simpleProcessRouterDest,
25+
convertToUuid,
2526
} = require('../../util');
2627
const { JSON_MIME_TYPE } = require('../../util/constant');
27-
const { transformSessionId } = require('./utils');
2828

2929
const DEFAULT_ACCEPT_HEADER = 'application/vnd.urbanairship+json; version=3';
3030

31+
const transformSessionId = (rawSessionId) => {
32+
try {
33+
return convertToUuid(rawSessionId);
34+
} catch (error) {
35+
throw new InstrumentationError(`Failed to transform session ID: ${error.message}`);
36+
}
37+
};
38+
3139
const identifyResponseBuilder = (message, { Config }) => {
3240
const tagPayload = constructPayload(message, identifyMapping);
3341
const { apiKey, dataCenter } = Config;
@@ -129,6 +137,8 @@ const trackResponseBuilder = async (message, { Config }) => {
129137

130138
name = name.toLowerCase();
131139
const payload = constructPayload(message, trackMapping);
140+
141+
// ref : https://docs.airship.com/api/ua/#operation-api-custom-events-post
132142
if (isDefinedAndNotNullAndNotEmpty(payload.session_id)) {
133143
payload.session_id = transformSessionId(payload.session_id);
134144
}

src/v0/destinations/airship/utils.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/v0/destinations/braze/braze.util.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ describe('processBatch', () => {
982982
expect(result[0].batchedRequest[1].body.JSON.events.length).toBe(25); // Second batch contains remaining 25 events
983983
expect(result[0].batchedRequest[1].body.JSON.purchases.length).toBe(25); // Second batch contains remaining 25 purchases
984984
expect(result[0].batchedRequest[2].body.JSON.subscription_groups.length).toBe(50); // First batch contains 50 subscription group
985-
expect(result[0].batchedRequest[3].body.JSON.subscription_groups.length).toBe(50); // First batch contains 25 subscription group
985+
expect(result[0].batchedRequest[3].body.JSON.subscription_groups.length).toBe(50);
986986
expect(result[0].batchedRequest[4].body.JSON.merge_updates.length).toBe(50); // First batch contains 50 merge_updates
987987
expect(result[0].batchedRequest[5].body.JSON.merge_updates.length).toBe(50); // First batch contains 25 merge_updates
988988
});
@@ -1104,8 +1104,8 @@ describe('processBatch', () => {
11041104
expect(result[0].batchedRequest[1].body.JSON.purchases.length).toBe(75); // Second batch contains remaining 75 purchases
11051105
expect(result[0].batchedRequest[2].body.JSON.purchases.length).toBe(10); // Third batch contains remaining 10 purchases
11061106
expect(result[0].batchedRequest[3].body.JSON.subscription_groups.length).toBe(50); // First batch contains 50 subscription group
1107-
expect(result[0].batchedRequest[4].body.JSON.subscription_groups.length).toBe(20); // First batch contains 20 subscription group
1108-
expect(result[0].batchedRequest[5].body.JSON.merge_updates.length).toBe(40); // First batch contains 50 merge_updates
1107+
expect(result[0].batchedRequest[4].body.JSON.subscription_groups.length).toBe(20); // Second batch contains 20 subscription group
1108+
expect(result[0].batchedRequest[5].body.JSON.merge_updates.length).toBe(40); // First batch contains 40 merge_updates
11091109
});
11101110

11111111
test('check success and failure scenarios both for processBatch', () => {

src/v0/util/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const uaParser = require('ua-parser-js');
1616
const moment = require('moment-timezone');
1717
const sha256 = require('sha256');
1818
const crypto = require('crypto');
19+
const { v5 } = require('uuid');
1920
const {
2021
InstrumentationError,
2122
BaseError,
@@ -2330,6 +2331,29 @@ const isEventSentByVDMV1Flow = (event) => event?.message?.context?.mappedToDesti
23302331

23312332
const isEventSentByVDMV2Flow = (event) =>
23322333
event?.connection?.config?.destination?.schemaVersion === VDM_V2_SCHEMA_VERSION;
2334+
2335+
const convertToUuid = (input) => {
2336+
const NAMESPACE = v5.DNS;
2337+
2338+
if (!isDefinedAndNotNull(input)) {
2339+
throw new InstrumentationError('Input is undefined or null.');
2340+
}
2341+
2342+
try {
2343+
// Stringify and trim the input
2344+
const trimmedInput = String(input).trim();
2345+
2346+
// Check for empty input after trimming
2347+
if (!trimmedInput) {
2348+
throw new InstrumentationError('Input is empty or invalid.');
2349+
}
2350+
// Generate and return UUID
2351+
return v5(trimmedInput, NAMESPACE);
2352+
} catch (error) {
2353+
const errorMessage = `Failed to transform input to uuid: ${error.message}`;
2354+
throw new InstrumentationError(errorMessage);
2355+
}
2356+
};
23332357
// ========================================================================
23342358
// EXPORTS
23352359
// ========================================================================
@@ -2456,4 +2480,5 @@ module.exports = {
24562480
getRelativePathFromURL,
24572481
removeEmptyKey,
24582482
isAxiosError,
2483+
convertToUuid,
24592484
};

src/v0/util/index.test.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const { InstrumentationError } = require('@rudderstack/integrations-lib');
22
const utilities = require('.');
33
const { getFuncTestData } = require('../../../test/testHelper');
44
const { FilteredEventsError } = require('./errorTypes');
5+
const { v5 } = require('uuid');
56
const {
67
hasCircularReference,
78
flattenJson,
@@ -11,6 +12,7 @@ const {
1112
groupRouterTransformEvents,
1213
isAxiosError,
1314
removeHyphens,
15+
convertToUuid,
1416
} = require('./index');
1517
const exp = require('constants');
1618

@@ -985,3 +987,65 @@ describe('removeHyphens', () => {
985987
});
986988
});
987989
});
990+
991+
describe('convertToUuid', () => {
992+
const NAMESPACE = v5.DNS;
993+
994+
test('should generate UUID for valid string input', () => {
995+
const input = 'testInput';
996+
const expectedUuid = '7ba1e88f-acf9-5528-9c1c-0c897ed80e1e';
997+
const result = convertToUuid(input);
998+
expect(result).toBe(expectedUuid);
999+
});
1000+
1001+
test('should generate UUID for valid numeric input', () => {
1002+
const input = 123456;
1003+
const expectedUuid = 'a52b2702-9bcf-5701-852a-2f4edc640fe1';
1004+
const result = convertToUuid(input);
1005+
expect(result).toBe(expectedUuid);
1006+
});
1007+
1008+
test('should trim spaces and generate UUID', () => {
1009+
const input = ' testInput ';
1010+
const expectedUuid = '7ba1e88f-acf9-5528-9c1c-0c897ed80e1e';
1011+
const result = convertToUuid(input);
1012+
expect(result).toBe(expectedUuid);
1013+
});
1014+
1015+
test('should throw an error for empty input', () => {
1016+
const input = '';
1017+
expect(() => convertToUuid(input)).toThrow(InstrumentationError);
1018+
expect(() => convertToUuid(input)).toThrow('Input is empty or invalid.');
1019+
});
1020+
1021+
test('to throw an error for null input', () => {
1022+
const input = null;
1023+
expect(() => convertToUuid(input)).toThrow(InstrumentationError);
1024+
expect(() => convertToUuid(input)).toThrow('Input is undefined or null');
1025+
});
1026+
1027+
test('to throw an error for undefined input', () => {
1028+
const input = undefined;
1029+
expect(() => convertToUuid(input)).toThrow(InstrumentationError);
1030+
expect(() => convertToUuid(input)).toThrow('Input is undefined or null');
1031+
});
1032+
1033+
test('should throw an error for input that is whitespace only', () => {
1034+
const input = ' ';
1035+
expect(() => convertToUuid(input)).toThrow(InstrumentationError);
1036+
expect(() => convertToUuid(input)).toThrow('Input is empty or invalid.');
1037+
});
1038+
1039+
test('should handle long string input gracefully', () => {
1040+
const input = 'a'.repeat(1000);
1041+
const expectedUuid = v5(input, NAMESPACE);
1042+
const result = convertToUuid(input);
1043+
expect(result).toBe(expectedUuid);
1044+
});
1045+
1046+
test('any invalid input if stringified does not throw error', () => {
1047+
const input = {};
1048+
const result = convertToUuid(input);
1049+
expect(result).toBe('672ca00c-37f4-5d71-b8c3-6ae0848080ec');
1050+
});
1051+
});

0 commit comments

Comments
 (0)