Skip to content

Commit

Permalink
Merge branch 'develop' into feat.id.stitching.changes.shopify.pixel.app
Browse files Browse the repository at this point in the history
  • Loading branch information
yashasvibajpai authored Nov 26, 2024
2 parents 83c8f52 + ed9fe55 commit 5f80756
Show file tree
Hide file tree
Showing 11 changed files with 406 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:

- name: Filter JS/TS Files
run: |
echo "${{ steps.files.outputs.added_modified }}" | tr ' ' '\n' | grep -E '\.(js|ts|jsx|tsx)$' > changed_files.txt
if [ ! -s changed_files.txt ]; then
changed_files=$(echo "${{ steps.files.outputs.added_modified }}" | tr ' ' '\n' | grep -E '\.(js|ts|jsx|tsx)$' || true)
if [ -z "$changed_files" ]; then
echo "No JS/TS files to format or lint."
exit 0
fi
Expand Down
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@

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.

### [1.85.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.85.0...v1.85.1) (2024-11-21)


### Bug Fixes

* braze subscription batch size ([#3897](https://github.com/rudderlabs/rudder-transformer/issues/3897)) ([ca71a31](https://github.com/rudderlabs/rudder-transformer/commit/ca71a318e4d8d098116fe539964b699254f58617))
* stringifying session ID for airship ([#3896](https://github.com/rudderlabs/rudder-transformer/issues/3896)) ([bb0b9dc](https://github.com/rudderlabs/rudder-transformer/commit/bb0b9dc1e5a56e8141c6cb56e89835ba61ee7761))

## [1.85.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.84.0...v1.85.0) (2024-11-18)


### Features

* added support to eu/us2 datacenter for gainsight px destination ([#3871](https://github.com/rudderlabs/rudder-transformer/issues/3871)) ([12ac3de](https://github.com/rudderlabs/rudder-transformer/commit/12ac3de6e7cc91a6cd52c33bc342f74bbaa8a631))
* iterable EUDC ([#3828](https://github.com/rudderlabs/rudder-transformer/issues/3828)) ([1c134f8](https://github.com/rudderlabs/rudder-transformer/commit/1c134f84601aaea78581078137cb9955de576f9e))
* iterable EUDC deleteUsers ([#3881](https://github.com/rudderlabs/rudder-transformer/issues/3881)) ([becb4fa](https://github.com/rudderlabs/rudder-transformer/commit/becb4fa54e9093ed69779f54c36864cb9d28d321))
* moved userSchema to connection config in GARL vdmv2 ([#3870](https://github.com/rudderlabs/rudder-transformer/issues/3870)) ([640a11e](https://github.com/rudderlabs/rudder-transformer/commit/640a11eb3dca5735fed3ad9ad5bd058974b069d6))
* now getting consent related fields from connection config from retl for GARL ([#3877](https://github.com/rudderlabs/rudder-transformer/issues/3877)) ([51bbc02](https://github.com/rudderlabs/rudder-transformer/commit/51bbc02d5b00ce1b8fe8c91b4a7041e926bae9bd))
* onboard linkedin audience destination ([#3857](https://github.com/rudderlabs/rudder-transformer/issues/3857)) ([f3ff409](https://github.com/rudderlabs/rudder-transformer/commit/f3ff4092d455508dd3354ffb22d345fa97f4d1f2))
* onboarding intercom v2 retl support ([#3843](https://github.com/rudderlabs/rudder-transformer/issues/3843)) ([3d7db73](https://github.com/rudderlabs/rudder-transformer/commit/3d7db7366e30df31c37cc473e344da82b49ed885))
* sources v2 spec support along with adapters ([04c0694](https://github.com/rudderlabs/rudder-transformer/commit/04c069486bdd3c101906fa6c621e983090fcab25))
* sources v2 spec support along with adapters ([#3810](https://github.com/rudderlabs/rudder-transformer/issues/3810)) ([c51cfbb](https://github.com/rudderlabs/rudder-transformer/commit/c51cfbb4664a8531dce23b2d06fe40997f95697e))
* update pinterest_tag single product events with new mapping ([#3858](https://github.com/rudderlabs/rudder-transformer/issues/3858)) ([8520278](https://github.com/rudderlabs/rudder-transformer/commit/85202781de3464bd46fe910159d2b143cd4209e8))


### Bug Fixes

* adding logger for undefined source event ([#3879](https://github.com/rudderlabs/rudder-transformer/issues/3879)) ([79e5979](https://github.com/rudderlabs/rudder-transformer/commit/79e597907eee126b4187e4534b2aa2253d1431da))
* adding uuid transformation for airship ([#3884](https://github.com/rudderlabs/rudder-transformer/issues/3884)) ([a80f874](https://github.com/rudderlabs/rudder-transformer/commit/a80f87486dc93b423e4fe6efbee6f4cb8330ba02))
* handling invalid timestamp for adjust source ([#3866](https://github.com/rudderlabs/rudder-transformer/issues/3866)) ([d57f48e](https://github.com/rudderlabs/rudder-transformer/commit/d57f48e989d18d469bea0de94293bc685300945b))
* revert gaec changes ([#3885](https://github.com/rudderlabs/rudder-transformer/issues/3885)) ([0aeaa39](https://github.com/rudderlabs/rudder-transformer/commit/0aeaa391b025fc68de6e3d63a6721f067c5be318))

## [1.84.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.83.2...v1.84.0) (2024-11-11)


Expand Down
4 changes: 2 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
@@ -1,6 +1,6 @@
{
"name": "rudder-transformer",
"version": "1.84.0",
"version": "1.85.1",
"description": "",
"homepage": "https://github.com/rudderlabs/rudder-transformer#readme",
"bugs": {
Expand Down
5 changes: 4 additions & 1 deletion src/v0/destinations/airship/data/airshipTrackConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
{
"destKey": "session_id",
"sourceKeys": ["properties.sessionId", "context.sessionId"],
"required": false
"required": false,
"metadata": {
"type": "toString"
}
},
{
"destKey": "transaction",
Expand Down
12 changes: 11 additions & 1 deletion src/v0/destinations/airship/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@ const {
extractCustomFields,
isEmptyObject,
simpleProcessRouterDest,
convertToUuid,
} = require('../../util');
const { JSON_MIME_TYPE } = require('../../util/constant');
const { transformSessionId } = require('./utils');

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

const transformSessionId = (rawSessionId) => {
try {
return convertToUuid(rawSessionId);
} catch (error) {
throw new InstrumentationError(`Failed to transform session ID: ${error.message}`);
}
};

const identifyResponseBuilder = (message, { Config }) => {
const tagPayload = constructPayload(message, identifyMapping);
const { apiKey, dataCenter } = Config;
Expand Down Expand Up @@ -129,6 +137,8 @@ const trackResponseBuilder = async (message, { Config }) => {

name = name.toLowerCase();
const payload = constructPayload(message, trackMapping);

// ref : https://docs.airship.com/api/ua/#operation-api-custom-events-post
if (isDefinedAndNotNullAndNotEmpty(payload.session_id)) {
payload.session_id = transformSessionId(payload.session_id);
}
Expand Down
12 changes: 0 additions & 12 deletions src/v0/destinations/airship/utils.js

This file was deleted.

6 changes: 3 additions & 3 deletions src/v0/destinations/braze/braze.util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ describe('processBatch', () => {
expect(result[0].batchedRequest[1].body.JSON.events.length).toBe(25); // Second batch contains remaining 25 events
expect(result[0].batchedRequest[1].body.JSON.purchases.length).toBe(25); // Second batch contains remaining 25 purchases
expect(result[0].batchedRequest[2].body.JSON.subscription_groups.length).toBe(50); // First batch contains 50 subscription group
expect(result[0].batchedRequest[3].body.JSON.subscription_groups.length).toBe(50); // First batch contains 25 subscription group
expect(result[0].batchedRequest[3].body.JSON.subscription_groups.length).toBe(50);
expect(result[0].batchedRequest[4].body.JSON.merge_updates.length).toBe(50); // First batch contains 50 merge_updates
expect(result[0].batchedRequest[5].body.JSON.merge_updates.length).toBe(50); // First batch contains 25 merge_updates
});
Expand Down Expand Up @@ -1104,8 +1104,8 @@ describe('processBatch', () => {
expect(result[0].batchedRequest[1].body.JSON.purchases.length).toBe(75); // Second batch contains remaining 75 purchases
expect(result[0].batchedRequest[2].body.JSON.purchases.length).toBe(10); // Third batch contains remaining 10 purchases
expect(result[0].batchedRequest[3].body.JSON.subscription_groups.length).toBe(50); // First batch contains 50 subscription group
expect(result[0].batchedRequest[4].body.JSON.subscription_groups.length).toBe(20); // First batch contains 20 subscription group
expect(result[0].batchedRequest[5].body.JSON.merge_updates.length).toBe(40); // First batch contains 50 merge_updates
expect(result[0].batchedRequest[4].body.JSON.subscription_groups.length).toBe(20); // Second batch contains 20 subscription group
expect(result[0].batchedRequest[5].body.JSON.merge_updates.length).toBe(40); // First batch contains 40 merge_updates
});

test('check success and failure scenarios both for processBatch', () => {
Expand Down
25 changes: 25 additions & 0 deletions src/v0/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const uaParser = require('ua-parser-js');
const moment = require('moment-timezone');
const sha256 = require('sha256');
const crypto = require('crypto');
const { v5 } = require('uuid');
const {
InstrumentationError,
BaseError,
Expand Down Expand Up @@ -2330,6 +2331,29 @@ const isEventSentByVDMV1Flow = (event) => event?.message?.context?.mappedToDesti

const isEventSentByVDMV2Flow = (event) =>
event?.connection?.config?.destination?.schemaVersion === VDM_V2_SCHEMA_VERSION;

const convertToUuid = (input) => {
const NAMESPACE = v5.DNS;

if (!isDefinedAndNotNull(input)) {
throw new InstrumentationError('Input is undefined or null.');
}

try {
// Stringify and trim the input
const trimmedInput = String(input).trim();

// Check for empty input after trimming
if (!trimmedInput) {
throw new InstrumentationError('Input is empty or invalid.');
}
// Generate and return UUID
return v5(trimmedInput, NAMESPACE);
} catch (error) {
const errorMessage = `Failed to transform input to uuid: ${error.message}`;
throw new InstrumentationError(errorMessage);
}
};
// ========================================================================
// EXPORTS
// ========================================================================
Expand Down Expand Up @@ -2456,4 +2480,5 @@ module.exports = {
getRelativePathFromURL,
removeEmptyKey,
isAxiosError,
convertToUuid,
};
64 changes: 64 additions & 0 deletions src/v0/util/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { InstrumentationError } = require('@rudderstack/integrations-lib');
const utilities = require('.');
const { getFuncTestData } = require('../../../test/testHelper');
const { FilteredEventsError } = require('./errorTypes');
const { v5 } = require('uuid');
const {
hasCircularReference,
flattenJson,
Expand All @@ -11,6 +12,7 @@ const {
groupRouterTransformEvents,
isAxiosError,
removeHyphens,
convertToUuid,
} = require('./index');
const exp = require('constants');

Expand Down Expand Up @@ -985,3 +987,65 @@ describe('removeHyphens', () => {
});
});
});

describe('convertToUuid', () => {
const NAMESPACE = v5.DNS;

test('should generate UUID for valid string input', () => {
const input = 'testInput';
const expectedUuid = '7ba1e88f-acf9-5528-9c1c-0c897ed80e1e';
const result = convertToUuid(input);
expect(result).toBe(expectedUuid);
});

test('should generate UUID for valid numeric input', () => {
const input = 123456;
const expectedUuid = 'a52b2702-9bcf-5701-852a-2f4edc640fe1';
const result = convertToUuid(input);
expect(result).toBe(expectedUuid);
});

test('should trim spaces and generate UUID', () => {
const input = ' testInput ';
const expectedUuid = '7ba1e88f-acf9-5528-9c1c-0c897ed80e1e';
const result = convertToUuid(input);
expect(result).toBe(expectedUuid);
});

test('should throw an error for empty input', () => {
const input = '';
expect(() => convertToUuid(input)).toThrow(InstrumentationError);
expect(() => convertToUuid(input)).toThrow('Input is empty or invalid.');
});

test('to throw an error for null input', () => {
const input = null;
expect(() => convertToUuid(input)).toThrow(InstrumentationError);
expect(() => convertToUuid(input)).toThrow('Input is undefined or null');
});

test('to throw an error for undefined input', () => {
const input = undefined;
expect(() => convertToUuid(input)).toThrow(InstrumentationError);
expect(() => convertToUuid(input)).toThrow('Input is undefined or null');
});

test('should throw an error for input that is whitespace only', () => {
const input = ' ';
expect(() => convertToUuid(input)).toThrow(InstrumentationError);
expect(() => convertToUuid(input)).toThrow('Input is empty or invalid.');
});

test('should handle long string input gracefully', () => {
const input = 'a'.repeat(1000);
const expectedUuid = v5(input, NAMESPACE);
const result = convertToUuid(input);
expect(result).toBe(expectedUuid);
});

test('any invalid input if stringified does not throw error', () => {
const input = {};
const result = convertToUuid(input);
expect(result).toBe('672ca00c-37f4-5d71-b8c3-6ae0848080ec');
});
});
Loading

0 comments on commit 5f80756

Please sign in to comment.