diff --git a/src/v0/sources/revenuecat/transform.js b/src/v0/sources/revenuecat/transform.js index 17d05c3029..36944e10fa 100644 --- a/src/v0/sources/revenuecat/transform.js +++ b/src/v0/sources/revenuecat/transform.js @@ -1,13 +1,8 @@ const { camelCase } = require('lodash'); -const path = require('path'); -const fs = require('fs'); const moment = require('moment'); const { removeUndefinedAndNullValues, isDefinedAndNotNull } = require('../../util'); const Message = require('../message'); -// import mapping json using JSON.parse to preserve object key order -const mapping = JSON.parse(fs.readFileSync(path.resolve(__dirname, './mapping.json'), 'utf-8')); - function process(event) { const message = new Message(`RevenueCat`); @@ -23,8 +18,6 @@ function process(event) { message.setProperty('properties', properties); } - message.setPropertiesV2(event, mapping); - // setting up app_user_id to externalId : revenuecatAppUserId if (event?.event?.app_user_id) { message.context.externalId = [ @@ -35,11 +28,16 @@ function process(event) { ]; } - if (isDefinedAndNotNull(event?.event?.event_timestamp_ms) && moment(event?.event?.event_timestamp_ms).isValid()) { + 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); diff --git a/test/integrations/sources/revenuecat/data.ts b/test/integrations/sources/revenuecat/data.ts index 918f22feb5..4963781763 100644 --- a/test/integrations/sources/revenuecat/data.ts +++ b/test/integrations/sources/revenuecat/data.ts @@ -1,4 +1,4 @@ -const data = [ +export const data = [ { name: 'revenuecat', description: 'Simple track call', @@ -164,46 +164,42 @@ const data = [ request: { body: [ { - batch: [ - { - 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', + 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', @@ -288,7 +284,3 @@ const data = [ }, }, ]; - -module.exports = { - data, -};