Skip to content

Commit

Permalink
Merge branch 'develop' into fix.bugsnag-issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwal-ab authored Nov 6, 2023
2 parents 51b8bb7 + 6e89cd3 commit 980758f
Show file tree
Hide file tree
Showing 5 changed files with 347 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/v0/destinations/adobe_analytics/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
isDefinedAndNotNull,
isDefinedAndNotNullAndNotEmpty,
getIntegrationsObj,
removeUndefinedAndNullValues,
simpleProcessRouterDest,
} = require('../../util');
const {
Expand Down Expand Up @@ -394,7 +395,7 @@ const handleTrack = (message, destinationConfig) => {
break;
}

return payload;
return removeUndefinedAndNullValues(payload);
};

const process = async (event) => {
Expand Down
10 changes: 10 additions & 0 deletions src/v0/sources/revenuecat/mapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"sourceKeys": "event.type",
"destKeys": "event"
},
{
"sourceKeys": "event.id",
"destKeys": "messageId"
}
]
47 changes: 47 additions & 0 deletions src/v0/sources/revenuecat/transform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const { camelCase } = require('lodash');
const moment = require('moment');
const { removeUndefinedAndNullValues, isDefinedAndNotNull } = require('../../util');
const Message = require('../message');

function process(event) {
const message = new Message(`RevenueCat`);

// we are setting event type as track always
message.setEventType('track');

const properties = {};
// dump all event properties to message.properties after converting them to camelCase
if (event.event) {
Object.keys(event.event).forEach((key) => {
properties[camelCase(key)] = event.event[key];
});
message.setProperty('properties', properties);
}

// setting up app_user_id to externalId : revenuecatAppUserId
if (event?.event?.app_user_id) {
message.context.externalId = [
{
type: 'revenuecatAppUserId',
id: event?.event?.app_user_id,
},
];
}

if (
isDefinedAndNotNull(event?.event?.event_timestamp_ms) &&
moment(event?.event?.event_timestamp_ms).isValid()
) {
const validTimestamp = new Date(event.event.event_timestamp_ms).toISOString();
message.setProperty('originalTimestamp', validTimestamp);
message.setProperty('sentAt', validTimestamp);
}
message.event = event?.event?.type;
message.messageId = event?.event?.id;

// removing undefined and null values from message
removeUndefinedAndNullValues(message);
return message;
}

module.exports = { process };
4 changes: 2 additions & 2 deletions test/__tests__/data/adobe_analytics.json
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,6 @@
},
"messageId": "1578564113557-af022c68-429e-4af4-b99b-2b9174056383",
"properties": {
"order_id": "1234",
"affiliation": "Apple Store",
"value": 20,
"revenue": 15.0,
Expand All @@ -1019,6 +1018,7 @@
"discount": 1.5,
"coupon": "ImagePro",
"currency": "USD",
"purchaseId": "p101",
"products": [
{
"product_id": "123",
Expand Down Expand Up @@ -1205,7 +1205,7 @@
"JSON": {},
"JSON_ARRAY": {},
"XML": {
"payload": "<?xml version=\"1.0\" encoding=\"utf-8\"?><request><browserHeight>1794</browserHeight><browserWidth>1080</browserWidth><campaign>sales campaign</campaign><channel>web</channel><currencyCode>USD</currencyCode><ipaddress>127.0.0.1</ipaddress><language>en-US</language><purchaseID>1234</purchaseID><transactionID>1234</transactionID><userAgent>Dalvik/2.1.0 (Linux; U; Android 9; Android SDK built for x86 Build/PSR1.180720.075)</userAgent><referrer>https://www.google.com/search?q=estore+bestseller</referrer><contextData><roott01>roottval001</roott01></contextData><eVar6>RudderLabs JavaScript SDK</eVar6><linkType>o</linkType><linkName>checkout started</linkName><linkURL>https://www.estore.com/best-seller/1</linkURL><timestamp>2020-01-09T10:01:53.558Z</timestamp><marketingcloudorgid>mktcloudid001</marketingcloudorgid><events>scCheckout</events><products>Games;Monopoly;1;14.00,Games;UNO;2;6.90</products><reportSuiteID>footlockerrudderstackpoc</reportSuiteID></request>"
"payload": "<?xml version=\"1.0\" encoding=\"utf-8\"?><request><browserHeight>1794</browserHeight><browserWidth>1080</browserWidth><campaign>sales campaign</campaign><channel>web</channel><currencyCode>USD</currencyCode><ipaddress>127.0.0.1</ipaddress><language>en-US</language><userAgent>Dalvik/2.1.0 (Linux; U; Android 9; Android SDK built for x86 Build/PSR1.180720.075)</userAgent><referrer>https://www.google.com/search?q=estore+bestseller</referrer><contextData><roott01>roottval001</roott01></contextData><eVar6>RudderLabs JavaScript SDK</eVar6><linkType>o</linkType><linkName>checkout started</linkName><linkURL>https://www.estore.com/best-seller/1</linkURL><timestamp>2020-01-09T10:01:53.558Z</timestamp><marketingcloudorgid>mktcloudid001</marketingcloudorgid><purchaseID>p101</purchaseID><events>scCheckout</events><products>Games;Monopoly;1;14.00,Games;UNO;2;6.90</products><reportSuiteID>footlockerrudderstackpoc</reportSuiteID></request>"
},
"FORM": {}
},
Expand Down
286 changes: 286 additions & 0 deletions test/integrations/sources/revenuecat/data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
export const data = [
{
name: 'revenuecat',
description: 'Simple track call',
module: 'source',
version: 'v0',
input: {
request: {
body: [
{
api_version: '1.0',
event: {
aliases: [
'f8e14f51-0c76-49ba-8d67-c229f1875dd9',
'389ad6dd-bb40-4c03-9471-1353da2d55ec',
],
app_user_id: 'f8e14f51-0c76-49ba-8d67-c229f1875dd9',
commission_percentage: null,
country_code: 'US',
currency: null,
entitlement_id: null,
entitlement_ids: null,
environment: 'SANDBOX',
event_timestamp_ms: 1698617217232,
expiration_at_ms: 1698624417232,
id: '8CF0CD6C-CAF3-41FB-968A-661938235AF0',
is_family_share: null,
offer_code: null,
original_app_user_id: 'f8e14f51-0c76-49ba-8d67-c229f1875dd9',
original_transaction_id: null,
period_type: 'NORMAL',
presented_offering_id: null,
price: null,
price_in_purchased_currency: null,
product_id: 'test_product',
purchased_at_ms: 1698617217232,
store: 'APP_STORE',
subscriber_attributes: {
$displayName: {
updated_at_ms: 1698617217232,
value: 'Mister Mistoffelees',
},
$email: {
updated_at_ms: 1698617217232,
value: '[email protected]',
},
$phoneNumber: {
updated_at_ms: 1698617217232,
value: '+19795551234',
},
my_custom_attribute_1: {
updated_at_ms: 1698617217232,
value: 'catnip',
},
},
takehome_percentage: null,
tax_percentage: null,
transaction_id: null,
type: 'TEST',
},
},
],
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
pathSuffix: '',
},
output: {
response: {
status: 200,
body: [
{
output: {
batch: [
{
context: {
library: {
name: 'unknown',
version: 'unknown',
},
integration: {
name: 'RevenueCat',
},
externalId: [
{
type: 'revenuecatAppUserId',
id: 'f8e14f51-0c76-49ba-8d67-c229f1875dd9',
},
],
},
integrations: {
RevenueCat: false,
},
type: 'track',
properties: {
aliases: [
'f8e14f51-0c76-49ba-8d67-c229f1875dd9',
'389ad6dd-bb40-4c03-9471-1353da2d55ec',
],
appUserId: 'f8e14f51-0c76-49ba-8d67-c229f1875dd9',
commissionPercentage: null,
countryCode: 'US',
currency: null,
entitlementId: null,
entitlementIds: null,
environment: 'SANDBOX',
eventTimestampMs: 1698617217232,
expirationAtMs: 1698624417232,
id: '8CF0CD6C-CAF3-41FB-968A-661938235AF0',
isFamilyShare: null,
offerCode: null,
originalAppUserId: 'f8e14f51-0c76-49ba-8d67-c229f1875dd9',
originalTransactionId: null,
periodType: 'NORMAL',
presentedOfferingId: null,
price: null,
priceInPurchasedCurrency: null,
productId: 'test_product',
purchasedAtMs: 1698617217232,
store: 'APP_STORE',
subscriberAttributes: {
$displayName: {
updated_at_ms: 1698617217232,
value: 'Mister Mistoffelees',
},
$email: {
updated_at_ms: 1698617217232,
value: '[email protected]',
},
$phoneNumber: {
updated_at_ms: 1698617217232,
value: '+19795551234',
},
my_custom_attribute_1: {
updated_at_ms: 1698617217232,
value: 'catnip',
},
},
takehomePercentage: null,
taxPercentage: null,
transactionId: null,
type: 'TEST',
},
event: 'TEST',
messageId: '8CF0CD6C-CAF3-41FB-968A-661938235AF0',
originalTimestamp: '2023-10-29T22:06:57.232Z',
sentAt: '2023-10-29T22:06:57.232Z',
},
],
},
},
],
},
},
},
{
name: 'revenuecat',
description: 'Initial purchase event',
module: 'source',
version: 'v0',
input: {
request: {
body: [
{
api_version: '1.0',
event: {
aliases: ['yourCustomerAliasedID', 'yourCustomerAliasedID'],
app_id: 'yourAppID',
app_user_id: 'yourCustomerAppUserID',
commission_percentage: 0.3,
country_code: 'US',
currency: 'USD',
entitlement_id: 'pro_cat',
entitlement_ids: ['pro_cat'],
environment: 'PRODUCTION',
event_timestamp_ms: 1591121855319,
expiration_at_ms: 1591726653000,
id: 'UniqueIdentifierOfEvent',
is_family_share: false,
offer_code: 'free_month',
original_app_user_id: 'OriginalAppUserID',
original_transaction_id: '1530648507000',
period_type: 'NORMAL',
presented_offering_id: 'OfferingID',
price: 2.49,
price_in_purchased_currency: 2.49,
product_id: 'onemonth_no_trial',
purchased_at_ms: 1591121853000,
store: 'APP_STORE',
subscriber_attributes: {
'$Favorite Cat': {
updated_at_ms: 1581121853000,
value: 'Garfield',
},
},
takehome_percentage: 0.7,
tax_percentage: 0.3,
transaction_id: '170000869511114',
type: 'INITIAL_PURCHASE',
},
},
],
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
},
pathSuffix: '',
},
output: {
response: {
status: 200,
body: [
{
output: {
batch: [
{
context: {
library: {
name: 'unknown',
version: 'unknown',
},
integration: {
name: 'RevenueCat',
},
externalId: [
{
type: 'revenuecatAppUserId',
id: 'yourCustomerAppUserID',
},
],
},
integrations: {
RevenueCat: false,
},
type: 'track',
properties: {
aliases: ['yourCustomerAliasedID', 'yourCustomerAliasedID'],
appId: 'yourAppID',
appUserId: 'yourCustomerAppUserID',
commissionPercentage: 0.3,
countryCode: 'US',
currency: 'USD',
entitlementId: 'pro_cat',
entitlementIds: ['pro_cat'],
environment: 'PRODUCTION',
eventTimestampMs: 1591121855319,
expirationAtMs: 1591726653000,
id: 'UniqueIdentifierOfEvent',
isFamilyShare: false,
offerCode: 'free_month',
originalAppUserId: 'OriginalAppUserID',
originalTransactionId: '1530648507000',
periodType: 'NORMAL',
presentedOfferingId: 'OfferingID',
price: 2.49,
priceInPurchasedCurrency: 2.49,
productId: 'onemonth_no_trial',
purchasedAtMs: 1591121853000,
store: 'APP_STORE',
subscriberAttributes: {
'$Favorite Cat': {
updated_at_ms: 1581121853000,
value: 'Garfield',
},
},
takehomePercentage: 0.7,
taxPercentage: 0.3,
transactionId: '170000869511114',
type: 'INITIAL_PURCHASE',
},
event: 'INITIAL_PURCHASE',
messageId: 'UniqueIdentifierOfEvent',
originalTimestamp: '2020-06-02T18:17:35.319Z',
sentAt: '2020-06-02T18:17:35.319Z',
},
],
},
},
],
},
},
},
];

0 comments on commit 980758f

Please sign in to comment.