Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(release): pull hotfix-release/v1.46.1 into main #2749

Merged
merged 4 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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.46.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.46.0...v1.46.1) (2023-10-19)
krishna2020 marked this conversation as resolved.
Show resolved Hide resolved

### Bug Fixes

* add gzip support compatibility ([#2745](https://github.com/rudderlabs/rudder-transformer/issues/2745)) ([d72410f](https://github.com/rudderlabs/rudder-transformer/commit/d72410f7962e702218be3c2414de62341ca29e39))

## [1.46.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.45.3...v1.46.0) (2023-10-18)


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.46.0",
"version": "1.46.1",
"description": "",
"homepage": "https://github.com/rudderlabs/rudder-transformer#readme",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion src/v0/destinations/braze/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ async function processIdentify(message, destination) {
);
if (!isHttpStatusSuccess(brazeIdentifyResp.status)) {
throw new NetworkError(
'Braze identify failed',
`Braze identify failed - ${JSON.stringify(brazeIdentifyResp.response)}`,
brazeIdentifyResp.status,
{
[tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(brazeIdentifyResp.status),
Expand Down
8 changes: 4 additions & 4 deletions src/v0/destinations/mp/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,10 @@ const processRouterDest = async (inputs, reqMetadata) => {
const { engageEvents, groupsEvents, trackEvents, importEvents, batchErrorRespList } =
groupEventsByEndpoint(transformedPayloads);

const engageRespList = batchEvents(engageEvents, ENGAGE_MAX_BATCH_SIZE);
const groupsRespList = batchEvents(groupsEvents, GROUPS_MAX_BATCH_SIZE);
const trackRespList = batchEvents(trackEvents, TRACK_MAX_BATCH_SIZE);
const importRespList = batchEvents(importEvents, IMPORT_MAX_BATCH_SIZE);
const engageRespList = batchEvents(engageEvents, ENGAGE_MAX_BATCH_SIZE, reqMetadata);
const groupsRespList = batchEvents(groupsEvents, GROUPS_MAX_BATCH_SIZE, reqMetadata);
const trackRespList = batchEvents(trackEvents, TRACK_MAX_BATCH_SIZE, reqMetadata);
const importRespList = batchEvents(importEvents, IMPORT_MAX_BATCH_SIZE, reqMetadata);
const batchSuccessRespList = [
...engageRespList,
...groupsRespList,
Expand Down
12 changes: 7 additions & 5 deletions src/v0/destinations/mp/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
batchMultiplexedEvents,
getSuccessRespEvents,
defaultBatchRequestConfig,
IsGzipSupported,
} = require('../../util');
const {
ConfigCategory,
Expand Down Expand Up @@ -212,16 +213,17 @@ const groupEventsByEndpoint = (events) => {
};
};

const generateBatchedPayloadForArray = (events) => {
const generateBatchedPayloadForArray = (events, reqMetadata) => {
const { batchedRequest } = defaultBatchRequestConfig();
const firstEvent = events[0];
batchedRequest.endpoint = firstEvent.endpoint;
batchedRequest.headers = firstEvent.headers;
batchedRequest.params = firstEvent.params;

const batchResponseList = events.flatMap((event) => JSON.parse(event.body.JSON_ARRAY.batch));
// Gzipping the payload for /import endpoint
if (firstEvent.endpoint.includes('import')) {

if (IsGzipSupported(reqMetadata) && firstEvent.endpoint.includes('import')) {
// Gzipping the payload for /import endpoint
batchedRequest.body.GZIP = { payload: JSON.stringify(batchResponseList) };
} else {
batchedRequest.body.JSON_ARRAY = { batch: JSON.stringify(batchResponseList) };
Expand All @@ -230,10 +232,10 @@ const generateBatchedPayloadForArray = (events) => {
return batchedRequest;
};

const batchEvents = (successRespList, maxBatchSize) => {
const batchEvents = (successRespList, maxBatchSize, reqMetadata) => {
const batchedEvents = batchMultiplexedEvents(successRespList, maxBatchSize);
return batchedEvents.map((batch) => {
const batchedRequest = generateBatchedPayloadForArray(batch.events);
const batchedRequest = generateBatchedPayloadForArray(batch.events, reqMetadata);
return getSuccessRespEvents(batchedRequest, batch.metadata, batch.destination, true);
});
};
Expand Down
9 changes: 7 additions & 2 deletions src/v0/destinations/mp/util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const {
batchEvents,
generateBatchedPayloadForArray,
} = require('./util');
const { FEATURE_GZIP_SUPPORT } = require('../../util/constant');

const destinationMock = {
Config: {
Expand Down Expand Up @@ -524,7 +525,9 @@ describe('Mixpanel utils test', () => {
version: '1',
};

const result = generateBatchedPayloadForArray(events);
const result = generateBatchedPayloadForArray(events, {
features: { [FEATURE_GZIP_SUPPORT]: true },
});

expect(result).toEqual(expectedBatchedRequest);
});
Expand Down Expand Up @@ -560,7 +563,9 @@ describe('Mixpanel utils test', () => {
version: '1',
};

const result = generateBatchedPayloadForArray(events);
const result = generateBatchedPayloadForArray(events, {
features: { [FEATURE_GZIP_SUPPORT]: true },
});

expect(result).toEqual(expectedBatchedRequest);
});
Expand Down
2 changes: 2 additions & 0 deletions src/v0/util/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const API_CALL = 'api_call_count';
const JSON_MIME_TYPE = 'application/json';

const FEATURE_FILTER_CODE = 'filter-code';
const FEATURE_GZIP_SUPPORT = 'gzip-support';

const HTTP_STATUS_CODES = {
// 1xx Informational
Expand Down Expand Up @@ -89,4 +90,5 @@ module.exports = {
HTTP_STATUS_CODES,
USER_LEAD_CACHE_TTL,
FEATURE_FILTER_CODE,
FEATURE_GZIP_SUPPORT,
};
23 changes: 17 additions & 6 deletions src/v0/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
REFRESH_TOKEN,
AUTH_STATUS_INACTIVE,
} = require('../../adapters/networkhandler/authConstants');
const { FEATURE_FILTER_CODE } = require('./constant');
const { FEATURE_FILTER_CODE, FEATURE_GZIP_SUPPORT } = require('./constant');

// ========================================================================
// INLINERS
// ========================================================================
Expand Down Expand Up @@ -372,7 +373,7 @@

// Check what type of gender and convert to f or m
const getFbGenderVal = (gender) => {
if (typeof (gender) !== 'string') {
if (typeof gender !== 'string') {
return null;
}
if (
Expand Down Expand Up @@ -2050,11 +2051,20 @@
return '';
};

const validateEventType = event => {
if(!event || typeof event !== "string"){
throw new InstrumentationError("Event is a required field and should be a string");
const validateEventType = (event) => {
if (!event || typeof event !== 'string') {
throw new InstrumentationError('Event is a required field and should be a string');
}
}
};

const IsGzipSupported = (reqMetadata = {}) => {
if (reqMetadata && typeof reqMetadata === 'object' && !Array.isArray(reqMetadata)) {
const { features } = reqMetadata;
return !!features?.[FEATURE_GZIP_SUPPORT];
}
return false;

Check warning on line 2065 in src/v0/util/index.js

View check run for this annotation

Codecov / codecov/patch

src/v0/util/index.js#L2065

Added line #L2065 was not covered by tests
};

// ========================================================================
// EXPORTS
// ========================================================================
Expand Down Expand Up @@ -2161,4 +2171,5 @@
getAuthErrCategoryFromErrDetailsAndStCode,
getAuthErrCategoryFromStCode,
isNewStatusCodesAccepted,
IsGzipSupported,
};
Loading
Loading