Skip to content

Commit

Permalink
Merge branch 'develop' into feat.tiktok_audience
Browse files Browse the repository at this point in the history
  • Loading branch information
mihir-4116 authored Nov 1, 2023
2 parents 53b7cb9 + c38f14f commit a74f61e
Show file tree
Hide file tree
Showing 22 changed files with 1,405 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/draft-new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest

# Only allow release stakeholders to initiate releases
if: (github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/hotfix/')) && (github.actor == 'ItsSudip' || github.actor == 'krishna2020' || github.actor == 'saikumarrs' || github.actor == 'sandeepdsvs' || github.actor == 'shrouti1507' || github.actor == 'anantjain45823' || github.actor == 'chandumlg' || github.actor == 'mihir-4116') && (github.triggering_actor == 'ItsSudip' || github.triggering_actor == 'krishna2020' || github.triggering_actor == 'saikumarrs' || github.triggering_actor == 'sandeepdsvs' || github.triggering_actor == 'shrouti1507' || github.triggering_actor == 'anantjain45823' || github.triggering_actor == 'chandumlg' || github.triggering_actor == 'mihir-4116')
if: (github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/hotfix/')) && (github.actor == 'ItsSudip' || github.actor == 'krishna2020' || github.actor == 'saikumarrs' || github.actor == 'sandeepdsvs' || github.actor == 'shrouti1507' || github.actor == 'anantjain45823' || github.actor == 'chandumlg' || github.actor == 'mihir-4116' || github.actor == 'yashasvibajpai' || github.actor == 'sanpj2292') && (github.triggering_actor == 'ItsSudip' || github.triggering_actor == 'krishna2020' || github.triggering_actor == 'saikumarrs' || github.triggering_actor == 'sandeepdsvs' || github.triggering_actor == 'shrouti1507' || github.triggering_actor == 'anantjain45823' || github.triggering_actor == 'chandumlg' || github.triggering_actor == 'mihir-4116' || github.triggering_actor == 'yashasvibajpai' || github.triggering_actor == 'sanpj2292')
steps:
- name: Checkout
uses: actions/[email protected]
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

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.47.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.46.5...v1.47.0) (2023-10-30)


### Features

* add custom utm parameters to mixpanel ([#2771](https://github.com/rudderlabs/rudder-transformer/issues/2771)) ([9c4fcd3](https://github.com/rudderlabs/rudder-transformer/commit/9c4fcd3595534a8b563df3467e23c94c580f08a6))
* add support filtering component tests by feature and index ([#2748](https://github.com/rudderlabs/rudder-transformer/issues/2748)) ([146f1c6](https://github.com/rudderlabs/rudder-transformer/commit/146f1c63db4e895c7d5ce2848a1b60e7c5bb9fb6))
* onboard destination ortto ([#2730](https://github.com/rudderlabs/rudder-transformer/issues/2730)) ([9be5740](https://github.com/rudderlabs/rudder-transformer/commit/9be5740d8670890b0318da3d37f258ddc5e35445))
* onboard facebook custom audience to transformer proxy ([#2769](https://github.com/rudderlabs/rudder-transformer/issues/2769)) ([14c5e40](https://github.com/rudderlabs/rudder-transformer/commit/14c5e40284af7df9e4f5b262ad226dd3afef226e))
* add custom event name support in pinterest v5 ([#2773](https://github.com/rudderlabs/rudder-transformer/pull/2773)) ([a586a92](https://github.com/rudderlabs/rudder-transformer/commit/a586a92bf410679d0f3aa7012d4d10f8e2f515d5))


### Bug Fixes

* bugsnag error for salesforce ([#2753](https://github.com/rudderlabs/rudder-transformer/issues/2753)) ([a2ccdad](https://github.com/rudderlabs/rudder-transformer/commit/a2ccdad52a1fb88f962745800cb45d605b5e0bf3))
* oom kill while stringifying large response json ([#2754](https://github.com/rudderlabs/rudder-transformer/issues/2754)) ([c8baf5b](https://github.com/rudderlabs/rudder-transformer/commit/c8baf5b2b6325d9e30200339055dcbefd780936c))
* salesforce: handle ECONNABORTED error ([#2732](https://github.com/rudderlabs/rudder-transformer/issues/2732)) ([6b23a9b](https://github.com/rudderlabs/rudder-transformer/commit/6b23a9b33acd28fdacaa2390c1970a1fa4415ffa))

### [1.46.5](https://github.com/rudderlabs/rudder-transformer/compare/v1.46.4...v1.46.5) (2023-10-23)


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.5",
"version": "1.47.0",
"description": "",
"homepage": "https://github.com/rudderlabs/rudder-transformer#readme",
"bugs": {
Expand Down
6 changes: 2 additions & 4 deletions src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,8 @@ steps:
eventNames = $.convertToSnakeCase(eventNames);
eventNames.length === 0 ? eventNames = $.ecomEventMaps.(){eventInLowerCase in .src}.dest[] ?? [];
(eventNames.length === 0 && .destination.Config.sendAsCustomEvent) ? eventNames = ["custom"];
(eventNames.length === 0 && $.outputs.apiVersion === {{$.API_VERSION.v3}}) ? eventNames = [event];
$.assertConfig(eventNames.length > 0,
event + " is not mapped in UI. Make sure to map the event in UI or enable the 'send as custom event' setting")
eventNames
eventNames.length === 0 ? eventNames = [event];
eventNames;
- name: payload
template: |
Expand Down
6 changes: 6 additions & 0 deletions src/v0/destinations/fb_custom_audience/networkHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { networkHandler, errorResponseHandler } = require('../../util/facebookUtils/networkHandler');

module.exports = {
networkHandler,
errorResponseHandler,
};
24 changes: 0 additions & 24 deletions src/v0/destinations/mp/data/MPEventPropertiesConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,6 @@
"sourceKeys": "context.screen.density",
"destKey": "$screen_dpi"
},
{
"sourceKeys": "context.campaign.name",
"destKey": "utm_campaign"
},
{
"sourceKeys": "context.campaign.source",
"destKey": "utm_source"
},
{
"sourceKeys": "context.campaign.medium",
"destKey": "utm_medium"
},
{
"sourceKeys": "context.campaign.term",
"destKey": "utm_term"
},
{
"sourceKeys": "context.campaign.content",
"destKey": "utm_content"
},
{
"sourceKeys": "context.campaign.test",
"destKey": "utm_test"
},
{
"sourceKeys": "context.network.carrier",
"destKey": "$carrier"
Expand Down
3 changes: 3 additions & 0 deletions src/v0/destinations/mp/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const {
const {
createIdentifyResponse,
isImportAuthCredentialsAvailable,
buildUtmParams,
combineBatchRequestsWithSameJobIds,
groupEventsByEndpoint,
batchEvents,
Expand Down Expand Up @@ -179,6 +180,7 @@ const getEventValueForTrackEvent = (message, destination) => {
token: destination.Config.token,
distinct_id: message.userId || message.anonymousId,
time: unixTimestamp,
...buildUtmParams(message.context?.campaign),
};

if (destination.Config?.identityMergeApi === 'simplified') {
Expand Down Expand Up @@ -267,6 +269,7 @@ const processPageOrScreenEvents = (message, type, destination) => {
token: destination.Config.token,
distinct_id: message.userId || message.anonymousId,
time: toUnixTimestamp(message.timestamp),
...buildUtmParams(message.context?.campaign),
};
if (destination.Config?.identityMergeApi === 'simplified') {
properties = {
Expand Down
31 changes: 31 additions & 0 deletions src/v0/destinations/mp/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
getSuccessRespEvents,
defaultBatchRequestConfig,
IsGzipSupported,
isObject,
} = require('../../util');
const {
ConfigCategory,
Expand Down Expand Up @@ -173,6 +174,35 @@ const removeDuplicateMetadata = (mergedBatches) => {
});
};

/**
* Builds UTM parameters from a campaign object.
*
* @param {Object} campaign - The campaign object containing the campaign details.
* @returns {Object} - The object containing the UTM parameters extracted from the campaign object.
*
* @example
* const campaign = {
* name: 'summer_sale',
* source: 'newsletter',
* medium: 'email'
* };
* { utm_campaign: 'summer_sale', utm_source: 'newsletter', utm_medium: 'email' }
*/
const buildUtmParams = (campaign) => {
const utmParams = {};
if (isObject(campaign)) {
Object.keys(campaign).forEach((key) => {
if (key === 'name') {
utmParams.utm_campaign = campaign[key];
} else {
utmParams[`utm_${key}`] = campaign[key];
}
});
}

return utmParams;
};

/**
* Group events with the same endpoint together in batches
* @param {*} events - An array of events
Expand Down Expand Up @@ -295,6 +325,7 @@ const combineBatchRequestsWithSameJobIds = (inputBatches) => {
module.exports = {
createIdentifyResponse,
isImportAuthCredentialsAvailable,
buildUtmParams,
groupEventsByEndpoint,
generateBatchedPayloadForArray,
batchEvents,
Expand Down
32 changes: 32 additions & 0 deletions src/v0/destinations/mp/util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const {
groupEventsByEndpoint,
batchEvents,
generateBatchedPayloadForArray,
buildUtmParams,
} = require('./util');
const { FEATURE_GZIP_SUPPORT } = require('../../util/constant');

Expand Down Expand Up @@ -570,4 +571,35 @@ describe('Mixpanel utils test', () => {
expect(result).toEqual(expectedBatchedRequest);
});
});

describe('Unit test cases for buildUtmParams', () => {
it('should return an empty object when campaign is undefined', () => {
const campaign = undefined;
const result = buildUtmParams(campaign);
expect(result).toEqual({});
});

it('should return an empty object when campaign is an empty object', () => {
const campaign = {};
const result = buildUtmParams(campaign);
expect(result).toEqual({});
});

it('should return an empty object when campaign is not an object', () => {
const campaign = [{ name: 'test' }];
const result = buildUtmParams(campaign);
expect(result).toEqual({});
});

it('should handle campaign object with null/undefined values', () => {
const campaign = { name: null, source: 'rudder', medium: 'rudder', test: undefined };
const result = buildUtmParams(campaign);
expect(result).toEqual({
utm_campaign: null,
utm_source: 'rudder',
utm_medium: 'rudder',
test: undefined,
});
});
});
});
18 changes: 6 additions & 12 deletions src/v0/destinations/pinterest_tag/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const convertToSnakeCase = (eventName) =>
const deduceTrackScreenEventName = (message, Config) => {
let eventName;
const { event, name } = message;
const { apiVersion = API_VERSION.v3, eventsMapping, sendAsCustomEvent } = Config;
const { eventsMapping, sendAsCustomEvent } = Config;
const trackEventOrScreenName = event || name;
if (!trackEventOrScreenName) {
throw new InstrumentationError('event_name could not be mapped. Aborting');
Expand Down Expand Up @@ -209,17 +209,11 @@ const deduceTrackScreenEventName = (message, Config) => {
return ['custom'];
}

if (apiVersion === API_VERSION.v3) {
/*
Step 4: In case both of the above stated cases fail, will send the event name as it is.
This is going to be reflected as "unknown" event in conversion API dashboard.
*/
return [trackEventOrScreenName];
}

throw new ConfigurationError(
`${event} is not mapped in UI. Make sure to map the event in UI or enable the 'send as custom event' setting`,
);
/*
Step 4: In case all of the above stated cases failed, will send the event name as it is.
This is going to be reflected as "unknown" event in conversion API dashboard.
*/
return [trackEventOrScreenName];
};

/**
Expand Down
46 changes: 45 additions & 1 deletion src/v0/util/facebookUtils/networkHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const errorDetailsMap = {
33: new ErrorDetailsExtractorBuilder()
.setStatus(400)
.setMessage(
"Object with ID 'PIXEL_ID' does not exist, cannot be loaded due to missing permissions, or does not support this operation",
"Object with ID 'PIXEL_ID' / 'DATASET_ID' / 'AUDIENCE_ID' does not exist, cannot be loaded due to missing permissions, or does not support this operation",
)
.build(),
default: new ErrorDetailsExtractorBuilder()
Expand Down Expand Up @@ -151,6 +151,50 @@ const errorDetailsMap = {
.setMessage('API User Too Many Calls')
.build(),
},
// facebook custom audience related error codes
// ref:
// https://developers.facebook.com/docs/marketing-api/reference/custom-audience/#error-codes-4
// https://developers.facebook.com/docs/marketing-api/error-reference/
294: {
default: new ErrorDetailsExtractorBuilder()
.setStatus(400)
.setMessage(
'Missing permission. Please make sure you have ads_management permission and the application is included in the allowlist',
)
.build(),
},
1487301: {
default: new ErrorDetailsExtractorBuilder()
.setStatus(400)
.setMessage(
'Custom Audience Unavailable: The custom audience you are trying to use has not been shared with your ad account',
)
.build(),
},
1487366: {
default: new ErrorDetailsExtractorBuilder()
.setStatus(400)
.setMessage('Custom Audience Has Been Deleted')
.build(),
},
2650: {
default: new ErrorDetailsExtractorBuilder()
.setStatus(400)
.setMessage('Failed to update the custom audience')
.build(),
},
105: {
default: new ErrorDetailsExtractorBuilder()
.setStatus(400)
.setMessage('The number of parameters exceeded the maximum for this operation')
.build(),
},
80003: {
default: new ErrorDetailsExtractorBuilder()
.setStatus(429)
.setMessage('There have been too many calls to this ad-account.')
.build(),
},
};

const getErrorDetailsFromErrorMap = (error) => {
Expand Down
2 changes: 1 addition & 1 deletion test/__tests__/data/facebook_pixel_proxy_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
{
"output": {
"status": 400,
"message": "Object with ID 'PIXEL_ID' does not exist, cannot be loaded due to missing permissions, or does not support this operation",
"message": "Object with ID 'PIXEL_ID' / 'DATASET_ID' / 'AUDIENCE_ID' does not exist, cannot be loaded due to missing permissions, or does not support this operation",
"destinationResponse": {
"error": {
"message": "Unsupported post request. Object with ID '1234567891234569' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
Expand Down
2 changes: 1 addition & 1 deletion test/__tests__/data/fb_proxy_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
{
"output": {
"status": 400,
"message": "Object with ID 'PIXEL_ID' does not exist, cannot be loaded due to missing permissions, or does not support this operation",
"message": "Object with ID 'PIXEL_ID' / 'DATASET_ID' / 'AUDIENCE_ID' does not exist, cannot be loaded due to missing permissions, or does not support this operation",
"destinationResponse": {
"error": {
"message": "Unsupported post request. Object with ID '1234567891234569' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
Expand Down
Loading

0 comments on commit a74f61e

Please sign in to comment.