Skip to content

Commit

Permalink
Merge branch 'production-staging' into feat.updateAM-SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSudip authored Aug 3, 2023
2 parents 74a5710 + 7dae737 commit 5a20ac5
Show file tree
Hide file tree
Showing 85 changed files with 575 additions and 379 deletions.
4 changes: 2 additions & 2 deletions .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = [
name: 'Core - CDN',
path: 'dist/legacy/rudder-analytics.min.js',
gzip: true,
limit: '37.2 kB',
limit: '37.5 kB',
},
{
name: 'All Integrations - CDN',
Expand All @@ -19,7 +19,7 @@ module.exports = [
name: 'Core - NPM',
path: 'dist/npm-lib/index.js',
gzip: true,
limit: '37.1 kB',
limit: '37.5 kB',
},
{
name: 'Service Worker - NPM',
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

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.

## [2.39.0](https://github.com/rudderlabs/rudder-sdk-js/compare/v2.38.1...v2.39.0) (2023-08-01)


### Features

* enhancement of device mode transformation ([#1169](https://github.com/rudderlabs/rudder-sdk-js/issues/1169)) ([7b5aea1](https://github.com/rudderlabs/rudder-sdk-js/commit/7b5aea1eea91511e4b68ad6fe895b638f4c4413a))


### Bug Fixes

* resolve issue with error reporting global key in IE11 for npm package ([#1241](https://github.com/rudderlabs/rudder-sdk-js/issues/1241)) ([1c45585](https://github.com/rudderlabs/rudder-sdk-js/commit/1c4558596c6fabaf7aa41e2824b4405a4dfd170c))

### [2.38.1](https://github.com/rudderlabs/rudder-sdk-js/compare/v2.38.0...v2.38.1) (2023-07-25)


Expand Down
65 changes: 19 additions & 46 deletions __tests__/transformationHandler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
} from '../__mocks__/fixtures';

describe('Test suite for device mode transformation feature', () => {

beforeAll(() => {
server.listen();
});
Expand All @@ -24,9 +23,9 @@ describe('Test suite for device mode transformation feature', () => {
});

let payload;

const destinationIds = ['id1', 'id2', 'id3'];
beforeEach(() => {
payload = createPayload(samplePageEvent, 'sample-auth-token');
payload = createPayload(samplePageEvent, destinationIds, 'sample-auth-token');
});

it('Validate payload format', () => {
Expand All @@ -37,6 +36,7 @@ describe('Test suite for device mode transformation feature', () => {
batch: [
{
orderNo: expect.any(Number),
destinationIds,
event: samplePageEvent.message,
},
],
Expand All @@ -48,7 +48,6 @@ describe('Test suite for device mode transformation feature', () => {

await DeviceModeTransformations.sendEventForTransformation(payload, retryCount)
.then((response) => {
expect(response.transformationServerAccess).toEqual(true);
expect(Array.isArray(response.transformedPayload)).toEqual(true);

const destObj = response.transformedPayload[0];
Expand All @@ -63,33 +62,12 @@ describe('Test suite for device mode transformation feature', () => {
});
});

it('Transformation server response is in wrong format in case of successful transformation', async () => {
DeviceModeTransformations.init(dummyWriteKey, `${dummyDataplaneHost}/invalidResponse`);

await DeviceModeTransformations.sendEventForTransformation(payload, retryCount)
.then((response) => {
console.log(response);
expect('to').toBe('fail');
})
.catch((e) => {
expect(typeof e).toBe('string');
});
});

it('Validate whether the SDK is sending the orginal event in case server returns 404', async () => {
DeviceModeTransformations.init(dummyWriteKey, `${dummyDataplaneHost}/accessDenied`);

await DeviceModeTransformations.sendEventForTransformation(payload, retryCount)
.then((response) => {
expect(response.transformationServerAccess).toEqual(false);
expect(response.transformedPayload).toEqual(payload.batch);

const destObj = response.transformedPayload[0];

expect(Object.prototype.hasOwnProperty.call(destObj, 'event')).toBe(true);
expect(Object.prototype.hasOwnProperty.call(destObj, 'orderNo')).toBe(true);
expect(Object.prototype.hasOwnProperty.call(destObj, 'id')).toBe(false);
expect(Object.prototype.hasOwnProperty.call(destObj, 'payload')).toEqual(false);
expect(response.status).toEqual(404);
})
.catch((e) => {
console.log(e);
Expand All @@ -101,10 +79,8 @@ describe('Test suite for device mode transformation feature', () => {
let counter = 0;
server.use(
rest.post(`${dummyDataplaneHost}/serverDown/transform`, (req, res, ctx) => {
counter +=1;
return res(
ctx.status(500)
)
counter += 1;
return res(ctx.status(500));
}),
);

Expand All @@ -113,30 +89,30 @@ describe('Test suite for device mode transformation feature', () => {
await DeviceModeTransformations.sendEventForTransformation(payload, retryCount)
.then((response) => {
console.log(response);
expect('to').toBe('fail');
expect(counter).toEqual(retryCount + 1); // retryCount+ first attempt
expect(response.errorMessage).toBe('Retries exhausted');
expect(response.status).toBe(500);
})
.catch((e) => {
expect(typeof e).toBe('string');
expect(counter).toEqual(retryCount + 1); // retryCount+ first attempt
});
});

it('Transformation server returning response for partial success,SDK silently drops the unsuccessful events and procced', async () => {
it('Should not filter transformed events that are not 200', async () => {
DeviceModeTransformations.init(dummyWriteKey, `${dummyDataplaneHost}/partialSuccess`);

await DeviceModeTransformations.sendEventForTransformation(payload, retryCount)
.then((response) => {
let totalTransformedEvents = 0;
let successfulTransformedEvents = 0;
let totalTransformedEventsInResponse = 0;
samplePayloadPartialSuccess.transformedBatch.forEach((dest) => {
totalTransformedEvents += dest.payload.length;
});
response.transformedPayload.forEach((dest) => {
dest.payload.forEach((tEvent) => {
if (tEvent.status === '200') successfulTransformedEvents++;
});
totalTransformedEventsInResponse += dest.payload.length;
});
expect(successfulTransformedEvents).toBeLessThan(totalTransformedEvents);
expect(totalTransformedEventsInResponse).toEqual(totalTransformedEvents);
})
.catch((e) => {
console.log(e);
Expand All @@ -150,7 +126,8 @@ describe('Test suite for device mode transformation feature', () => {
await DeviceModeTransformations.sendEventForTransformation(payload, retryCount)
.then((response) => {
console.log(response);
expect('to').toBe('fail');
expect(typeof response.errorMessage).toBe('string');
expect(response.status).toBe(400);
})
.catch((e) => {
expect(typeof e).toBe('string');
Expand All @@ -159,17 +136,14 @@ describe('Test suite for device mode transformation feature', () => {
});

it('Transformation server returns success after intermediate retry', async () => {

let counter = 0;
server.use(
rest.post(`${dummyDataplaneHost}/success/transform`, (req, res, ctx) => {
if(counter === 0){
counter +=1;
return res(
ctx.status(500)
)
if (counter === 0) {
counter += 1;
return res(ctx.status(500));
}
counter +=1;
counter += 1;
return res(ctx.status(200), ctx.json(samplePayloadSuccess));
}),
);
Expand All @@ -179,7 +153,6 @@ describe('Test suite for device mode transformation feature', () => {
await DeviceModeTransformations.sendEventForTransformation(payload, retryCount)
.then((response) => {
expect(counter).toBeGreaterThan(1);
expect(response.transformationServerAccess).toEqual(true);
expect(Array.isArray(response.transformedPayload)).toEqual(true);

const destObj = response.transformedPayload[0];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rudder-analytics",
"version": "2.38.1",
"version": "2.39.0",
"description": "",
"main": "./dist/browser.min.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rudder-sdk-js",
"version": "2.38.1",
"version": "2.39.0",
"description": "RudderStack Javascript SDK",
"main": "index.js",
"module": "index.es.js",
Expand Down
26 changes: 14 additions & 12 deletions sanity-suite/src/testBook/ResultAssertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ class ResultsAssertions {
const resultData = JSON.parse(result);
const expectedResultData = JSON.parse(expectedResult);

ignoredProperties.forEach((property) => {
if (
typeof objectPath.get(resultData, property.key) === property.type ||
property.optional === true
) {
objectPath.set(
resultData,
property.key,
objectPath.get(expectedResultData, property.key),
);
}
});
if (resultData.message) {
ignoredProperties.forEach((property) => {
if (
typeof objectPath.get(resultData, property.key) === property.type ||
property.optional === true
) {
objectPath.set(
resultData,
property.key,
objectPath.get(expectedResultData, property.key),
);
}
});
}

return JSON.stringify(resultData, undefined, 2);
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sonar.qualitygate.wait=false
sonar.projectKey=rudderlabs_rudder-sdk-js
sonar.organization=rudderlabs
sonar.projectName=rudder-sdk-js
sonar.projectVersion=2.38.1
sonar.projectVersion=2.39.0

# Meta-data for the project
sonar.links.scm=https://github.com/rudderlabs/rudder-sdk-js
Expand Down
Loading

0 comments on commit 5a20ac5

Please sign in to comment.