Skip to content

Commit

Permalink
fix: add missing userid and anonymousid for revenuecat source
Browse files Browse the repository at this point in the history
  • Loading branch information
yashasvibajpai committed Jun 19, 2024
1 parent c68dca2 commit 9e90a1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/v0/sources/revenuecat/transform.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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();

Check warning on line 15 in src/v0/sources/revenuecat/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/sources/revenuecat/transform.js#L15

Added line #L15 was not covered by tests
}

const properties = {};
// dump all event properties to message.properties after converting them to camelCase
if (event.event) {
Expand Down
2 changes: 2 additions & 0 deletions test/integrations/sources/revenuecat/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 9e90a1c

Please sign in to comment.