diff --git a/src/v0/sources/revenuecat/transform.js b/src/v0/sources/revenuecat/transform.js index 36944e10fa..0491fb3270 100644 --- a/src/v0/sources/revenuecat/transform.js +++ b/src/v0/sources/revenuecat/transform.js @@ -1,6 +1,7 @@ const { camelCase } = require('lodash'); const moment = require('moment'); const { removeUndefinedAndNullValues, isDefinedAndNotNull } = require('../../util'); +const { generateUUID } = require('../../util'); const Message = require('../message'); function process(event) { @@ -9,6 +10,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 (!isDefinedAndNotNull(message.userId)) { + message.anonymousId = generateUUID(); + } + const properties = {}; // dump all event properties to message.properties after converting them to camelCase if (event.event) { diff --git a/test/integrations/sources/revenuecat/data.ts b/test/integrations/sources/revenuecat/data.ts index 4963781763..5da8a37728 100644 --- a/test/integrations/sources/revenuecat/data.ts +++ b/test/integrations/sources/revenuecat/data.ts @@ -144,6 +144,7 @@ export const data = [ type: 'TEST', }, event: 'TEST', + userId: 'f8e14f51-0c76-49ba-8d67-c229f1875dd9', messageId: '8CF0CD6C-CAF3-41FB-968A-661938235AF0', originalTimestamp: '2023-10-29T22:06:57.232Z', sentAt: '2023-10-29T22:06:57.232Z', @@ -272,6 +273,7 @@ export const data = [ type: 'INITIAL_PURCHASE', }, event: 'INITIAL_PURCHASE', + userId: 'yourCustomerAppUserID', messageId: 'UniqueIdentifierOfEvent', originalTimestamp: '2020-06-02T18:17:35.319Z', sentAt: '2020-06-02T18:17:35.319Z',