diff --git a/src/v0/sources/auth0/transform.js b/src/v0/sources/auth0/transform.js index 4b78621418..b2330443bd 100644 --- a/src/v0/sources/auth0/transform.js +++ b/src/v0/sources/auth0/transform.js @@ -1,6 +1,5 @@ const path = require('path'); const fs = require('fs'); -const { InstrumentationError } = require('@rudderstack/integrations-lib'); const { removeUndefinedAndNullValues } = require('../../util'); const { getGroupId } = require('./util'); // import mapping json using JSON.parse to preserve object key order @@ -59,11 +58,10 @@ function processEvents(eventList) { } else { response = prepareTrackPayload(data); } - if (response?.userId) { - // eslint-disable-next-line camelcase - response.properties.log_id = log_id; - responses.push(removeUndefinedAndNullValues(response)); - } + + // eslint-disable-next-line camelcase + response.properties.log_id = log_id; + responses.push(removeUndefinedAndNullValues(response)); } }); return responses; @@ -74,11 +72,7 @@ function process(events) { if (!Array.isArray(events)) { eventList = events.logs || [events]; } - const responses = processEvents(eventList); - if (responses.length === 0) { - throw new InstrumentationError('UserId is not present'); - } - return responses; + return processEvents(eventList); } exports.process = process; diff --git a/test/__tests__/data/auth0_source.json b/test/__tests__/data/auth0_source.json index e3190bd683..739933dd1f 100644 --- a/test/__tests__/data/auth0_source.json +++ b/test/__tests__/data/auth0_source.json @@ -1147,18 +1147,51 @@ "log_id": "90020221031055712103169676686005480714681762668315934738" } }, - "output": { - "statusCode": 400, - "error": "UserId is not present", - "statTags": { - "errorCategory": "dataValidation", - "errorType": "instrumentation", - "module": "source", - "implementation": "native", - "destinationId": "Non determinable", - "workspaceId": "Non determinable" + "output": [ + { + "type": "identify", + "sentAt": "2022-10-31T05:57:06.859Z", + "traits": { + "connection": "Username-Password-Authentication", + "connection_id": "con_djwCjiwyID0vZy1S" + }, + "userId": "", + "context": { + "traits": { + "userId": "", + "user_name": "testRudderlabs+21@gmail.com" + }, + "library": { + "name": "unknown", + "version": "unknown" + }, + "userAgent": "unknown", + "request_ip": "35.166.202.113", + "integration": { + "name": "Auth0" + } + }, + "properties": { + "log_id": "90020221031055712103169676686005480714681762668315934738", + "details": { + "body": { + "email": "testRudderlabs+21@gmail.com", + "tenant": "dev-cu4jy2zgao6yx15x", + "password": "dummyPassword", + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "connection": "Username-Password-Authentication" + } + }, + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "client_name": "All Applications", + "description": "" + }, + "integrations": { + "Auth0": false + }, + "originalTimestamp": "2022-10-31T05:57:06.859Z" } - } + ] }, { "description": "UserId is missing for all the requests in a batch", @@ -1205,17 +1238,76 @@ } } ], - "output": { - "statusCode": 400, - "error": "UserId is not present", - "statTags": { - "errorCategory": "dataValidation", - "errorType": "instrumentation", - "module": "source", - "implementation": "native", - "destinationId": "Non determinable", - "workspaceId": "Non determinable" + "output": [ + { + "type": "identify", + "userId": "", + "sentAt": "2022-10-31T05:57:06.859Z", + "traits": { + "connection": "Username-Password-Authentication", + "connection_id": "con_djwCjiwyID0vZy1S" + }, + "context": { + "traits": { + "userId": "", + "user_name": "testRudderlabs+21@gmail.com" + }, + "library": { + "name": "unknown", + "version": "unknown" + }, + "userAgent": "unknown", + "request_ip": "35.166.202.113", + "integration": { + "name": "Auth0" + } + }, + "properties": { + "log_id": "90020221031055712103169676686005480714681762668315934738", + "details": { + "body": { + "email": "testRudderlabs+21@gmail.com", + "tenant": "dev-cu4jy2zgao6yx15x", + "password": "dummyPassword", + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "connection": "Username-Password-Authentication" + } + }, + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "client_name": "All Applications", + "description": "" + }, + "integrations": { + "Auth0": false + }, + "originalTimestamp": "2022-10-31T05:57:06.859Z" + }, + { + "type": "track", + "event": "Success API Operation", + "sentAt": "2022-10-31T05:57:06.874Z", + "context": { + "library": { + "name": "unknown", + "version": "unknown" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", + "request_ip": "35.166.202.113", + "integration": { + "name": "Auth0" + } + }, + "properties": { + "log_id": "90020221031055712103169676686007898566320991926665347090", + "client_id": "vQcJNDTxsM1W72eHFonRJdzyOvawlwIt", + "client_name": "", + "description": "Create a User" + }, + "integrations": { + "Auth0": false + }, + "originalTimestamp": "2022-10-31T05:57:06.874Z" } - } + ] } ]