Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into chore.log-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Sai Sankeerth committed Jun 21, 2024
2 parents cb516bc + a08de31 commit 8ac2c23
Show file tree
Hide file tree
Showing 9 changed files with 353 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,10 @@
"context.traits.action_source",
"properties.action_source"
]
},
{
"destKey": "advertiser_tracking_enabled",
"sourceKeys": "context.device.adTrackingEnabled",
"required": false
}
]
9 changes: 8 additions & 1 deletion src/v0/sources/revenuecat/transform.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const { camelCase } = require('lodash');
const moment = require('moment');
const { removeUndefinedAndNullValues, isDefinedAndNotNull } = require('../../util');
const { isDefinedAndNotNullAndNotEmpty } = require('@rudderstack/integrations-lib');
const { removeUndefinedAndNullValues, isDefinedAndNotNull, generateUUID } = require('../../util');

const Message = require('../message');

function process(event) {
Expand All @@ -9,6 +11,11 @@ function process(event) {
// we are setting event type as track always
message.setEventType('track');

message.userId = event?.event?.app_user_id || event?.event?.original_app_user_id || '';
if (!isDefinedAndNotNullAndNotEmpty(message.userId)) {
message.anonymousId = generateUUID();
}

const properties = {};
// dump all event properties to message.properties after converting them to camelCase
if (event.event) {
Expand Down
5 changes: 1 addition & 4 deletions src/v0/util/facebookUtils/networkHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ const errorDetailsMap = {
"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()
.setStatus(400)
.setMessage('Invalid Parameter')
.build(),
default: new ErrorDetailsExtractorBuilder().setStatus(400).setMessageField('message').build(),
},
1: {
// An unknown error occurred.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
body: {
output: {
status: 400,
message: 'Invalid Parameter',
message: 'Unsupported post request. some problem with sent parameters',
statTags,
response: [
{
error: 'Invalid Parameter',
error: 'Unsupported post request. some problem with sent parameters',
statusCode: 400,
metadata: generateMetadata(1),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export const v0TestData = [
body: {
output: {
status: 400,
message: 'Invalid Parameter',
message: 'Unsupported post request. some problem with sent parameters',
destinationResponse: {
error: {
message: 'Unsupported post request. some problem with sent parameters',
Expand Down
113 changes: 112 additions & 1 deletion test/integrations/destinations/facebook_pixel/router/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export const mockFns = (_) => {
export const data = [
{
name: 'facebook_pixel',
description: 'Test 0',
description:
'Test 0: General batch request with two events, one track and one identify event with advancedMapping set to false and true respectively',
feature: 'router',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -201,4 +202,114 @@ export const data = [
},
},
},
{
name: 'facebook_pixel',
description:
'Test 1 : adTrackingEnabled is passed in context, advertiser_tracking_enabled set to true',
feature: 'router',
module: 'destination',
version: 'v0',
input: {
request: {
body: {
input: [
{
message: {
anonymousId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1',
destination_props: { Fb: { app_id: 'RudderFbApp' } },
context: {
device: {
id: 'df16bffa-5c3d-4fbb-9bce-3bab098129a7R',
manufacturer: 'Xiaomi',
model: 'Redmi 6',
name: 'xiaomi',
adTrackingEnabled: true,
},
network: { carrier: 'Banglalink' },
os: { name: 'android', version: '8.1.0' },
screen: { height: '100', density: 50 },
traits: {
email: '[email protected]',
anonymousId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1',
},
},
event: 'spin_result',
integrations: { All: true },
message_id: 'a80f82be-9bdc-4a9f-b2a5-15621ee41df8',
properties: { revenue: 400, additional_bet_index: 0 },
timestamp: '2023-10-14T15:46:51.693229+05:30',
type: 'track',
},
metadata: { jobId: 1, userId: 'u1' },
destination: {
Config: {
limitedDataUsage: true,
blacklistPiiProperties: [{ blacklistPiiProperties: '', blacklistPiiHash: false }],
removeExternalId: true,
accessToken: '09876',
pixelId: 'dummyPixelId',
eventsToEvents: [{ from: '', to: '' }],
eventCustomProperties: [{ eventCustomProperties: '' }],
valueFieldIdentifier: '',
advancedMapping: false,
whitelistPiiProperties: [{ whitelistPiiProperties: '' }],
},
Enabled: true,
},
},
],
destType: 'facebook_pixel',
},
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: [
{
batchedRequest: {
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://graph.facebook.com/v18.0/dummyPixelId/events?access_token=09876',
headers: {},
params: {},
body: {
JSON: {},
XML: {},
JSON_ARRAY: {},
FORM: {
data: [
'{"user_data":{"em":"48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08"},"event_name":"spin_result","event_time":1697278611,"advertiser_tracking_enabled":true,"action_source":"other","custom_data":{"additional_bet_index":0,"value":400}}',
],
},
},
files: {},
},
metadata: [{ jobId: 1, userId: 'u1' }],
batched: false,
statusCode: 200,
destination: {
Config: {
limitedDataUsage: true,
blacklistPiiProperties: [{ blacklistPiiProperties: '', blacklistPiiHash: false }],
removeExternalId: true,
accessToken: '09876',
pixelId: 'dummyPixelId',
eventsToEvents: [{ from: '', to: '' }],
eventCustomProperties: [{ eventCustomProperties: '' }],
valueFieldIdentifier: '',
advancedMapping: false,
whitelistPiiProperties: [{ whitelistPiiProperties: '' }],
},
Enabled: true,
},
},
],
},
},
},
},
].map((d) => ({ ...d, mockFns }));
Original file line number Diff line number Diff line change
Expand Up @@ -424,4 +424,50 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
},
},
},
{
id: 'fbca_v1_scenario_9',
name: 'fb_custom_audience',
description: 'user deletion failed differently created custom audience',
successCriteria: 'Fail with status code 400 and sending the actual error message.',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload({
method: 'DELETE',
endpoint: getEndPoint('aud-value-based'),
headers: {
'test-dest-response-key': 'validAccessToken',
},
params: testParams2,
}),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
status: 400,
message: '(#100) Value-Based Custom Audience requires LOOKALIKE_VALUE attribute.',
statTags: {
...statTags,
errorCategory: 'network',
errorType: 'aborted',
},
response: [
{
error: '(#100) Value-Based Custom Audience requires LOOKALIKE_VALUE attribute.',
statusCode: 400,
metadata: generateMetadata(1),
},
],
},
},
},
},
},
];
41 changes: 41 additions & 0 deletions test/integrations/destinations/fb_custom_audience/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,4 +583,45 @@ export const networkCallsData = [
status: 400,
},
},
{
httpReq: {
version: '1',
type: 'REST',
method: 'DELETE',
endpoint: getEndPoint('aud-value-based'),
headers: {
'test-dest-response-key': 'validAccessToken',
},
params: {
access_token: 'ABC',
payload: {
is_raw: true,
data_source: {
sub_type: 'ANYTHING',
},
schema: ['DOBY', 'PHONE', 'GEN', 'FI', 'MADID', 'ZIP', 'ST', 'COUNTRY'],
data: [['2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN']],
},
},
userId: '',
body: {
JSON: {},
XML: {},
JSON_ARRAY: {},
FORM: {},
},
files: {},
},
httpRes: {
data: {
error: {
message: '(#100) Value-Based Custom Audience requires LOOKALIKE_VALUE attribute.',
type: 'OAuthException',
code: 100,
fbtrace_id: 'ADB2jAGDMC_CbfM9430kDdQ',
},
},
status: 400,
},
},
];
Loading

0 comments on commit 8ac2c23

Please sign in to comment.