Skip to content

Commit

Permalink
fix: users events with proper default config
Browse files Browse the repository at this point in the history
  • Loading branch information
achettyiitr committed Aug 25, 2024
1 parent 78e7a95 commit 94fb868
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/warehouse/config/WHUserConfig.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
const { getFirstValidValue } = require('./helpers');

const rules = {
anonymous_id: 'anonymousId',
sent_at: 'sentAt',
timestamp: 'timestamp',
original_timestamp: 'originalTimestamp',
channel: 'channel',
context_ip: (message) => getFirstValidValue(message, ['context.ip', 'request_ip']),
context_request_ip: 'request_ip',
context_passed_ip: 'context.ip',
Expand Down
48 changes: 44 additions & 4 deletions test/__tests__/data/warehouse/integration_options_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,8 @@ const sampleEvents = {
},
{
"data": {
"anonymous_id": "97c46c81-3140-456d-b2a9-690d70aaca35",
"channel": "web",
"context_app_build": "1.0.0",
"context_app_name": "RudderLabs JavaScript SDK",
"context_app_namespace": "com.rudderlabs.javascript",
Expand All @@ -879,11 +881,16 @@ const sampleEvents = {
"context_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:84.0) Gecko/20100101 Firefox/84.0",
"email": "[email protected]",
"id": "user123",
"original_timestamp": "2020-01-24T06:29:02.364Z",
"phone": "+917836362334",
"received_at": "2020-01-24T06:29:02.403Z"
"received_at": "2020-01-24T06:29:02.403Z",
"sent_at": "2021-01-03T17:02:53.195Z",
"timestamp": "2020-01-24T06:29:02.403Z"
},
"metadata": {
"columns": {
"anonymous_id": "string",
"channel": "string",
"context_app_build": "string",
"context_app_name": "string",
"context_app_namespace": "string",
Expand All @@ -904,8 +911,11 @@ const sampleEvents = {
"context_user_agent": "string",
"email": "string",
"id": "string",
"original_timestamp": "datetime",
"phone": "string",
"received_at": "datetime",
"sent_at": "datetime",
"timestamp": "datetime",
"uuid_ts": "datetime"
},
"receivedAt": "2020-01-24T11:59:02.403+05:30",
Expand Down Expand Up @@ -1053,6 +1063,8 @@ const sampleEvents = {
},
{
"data": {
"anonymous_id": "97c46c81-3140-456d-b2a9-690d70aaca35",
"channel": "web",
"context_app_build": "1.0.0",
"context_app_name": "RudderLabs JavaScript SDK",
"context_app_namespace": "com.rudderlabs.javascript",
Expand All @@ -1073,11 +1085,16 @@ const sampleEvents = {
"context_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:84.0) Gecko/20100101 Firefox/84.0",
"email": "[email protected]",
"id": "user123",
"original_timestamp": "2020-01-24T06:29:02.364Z",
"phone": "+917836362334",
"received_at": "2020-01-24T06:29:02.403Z"
"received_at": "2020-01-24T06:29:02.403Z",
"sent_at": "2021-01-03T17:02:53.195Z",
"timestamp": "2020-01-24T06:29:02.403Z"
},
"metadata": {
"columns": {
"anonymous_id": "string",
"channel": "string",
"context_app_build": "string",
"context_app_name": "string",
"context_app_namespace": "string",
Expand All @@ -1099,8 +1116,11 @@ const sampleEvents = {
"email": "string",
"id": "string",
"loaded_at": "datetime",
"original_timestamp": "datetime",
"phone": "string",
"received_at": "datetime",
"sent_at": "datetime",
"timestamp": "datetime",
"uuid_ts": "datetime"
},
"receivedAt": "2020-01-24T11:59:02.403+05:30",
Expand Down Expand Up @@ -1178,6 +1198,8 @@ const sampleEvents = {
},
{
"data": {
"ANONYMOUS_ID": "97c46c81-3140-456d-b2a9-690d70aaca35",
"CHANNEL": "web",
"CONTEXT_APP_BUILD": "1.0.0",
"CONTEXT_APP_NAME": "RudderLabs JavaScript SDK",
"CONTEXT_APP_NAMESPACE": "com.rudderlabs.javascript",
Expand All @@ -1198,11 +1220,16 @@ const sampleEvents = {
"CONTEXT_USER_AGENT": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:84.0) Gecko/20100101 Firefox/84.0",
"EMAIL": "[email protected]",
"ID": "user123",
"ORIGINAL_TIMESTAMP": "2020-01-24T06:29:02.364Z",
"PHONE": "+917836362334",
"RECEIVED_AT": "2020-01-24T06:29:02.403Z"
"RECEIVED_AT": "2020-01-24T06:29:02.403Z",
"SENT_AT": "2021-01-03T17:02:53.195Z",
"TIMESTAMP": "2020-01-24T06:29:02.403Z"
},
"metadata": {
"columns": {
"ANONYMOUS_ID": "string",
"CHANNEL": "string",
"CONTEXT_APP_BUILD": "string",
"CONTEXT_APP_NAME": "string",
"CONTEXT_APP_NAMESPACE": "string",
Expand All @@ -1223,8 +1250,11 @@ const sampleEvents = {
"CONTEXT_USER_AGENT": "string",
"EMAIL": "string",
"ID": "string",
"ORIGINAL_TIMESTAMP": "datetime",
"PHONE": "string",
"RECEIVED_AT": "datetime",
"SENT_AT": "datetime",
"TIMESTAMP": "datetime",
"UUID_TS": "datetime"
},
"receivedAt": "2020-01-24T11:59:02.403+05:30",
Expand Down Expand Up @@ -1302,6 +1332,9 @@ const sampleEvents = {
},
{
"data": {
"_timestamp": "2020-01-24T06:29:02.403Z",
"anonymous_id": "97c46c81-3140-456d-b2a9-690d70aaca35",
"channel": "web",
"context_app_build": "1.0.0",
"context_app_name": "RudderLabs JavaScript SDK",
"context_app_namespace": "com.rudderlabs.javascript",
Expand All @@ -1322,11 +1355,16 @@ const sampleEvents = {
"context_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:84.0) Gecko/20100101 Firefox/84.0",
"email": "[email protected]",
"id": "user123",
"original_timestamp": "2020-01-24T06:29:02.364Z",
"phone": "+917836362334",
"received_at": "2020-01-24T06:29:02.403Z"
"received_at": "2020-01-24T06:29:02.403Z",
"sent_at": "2021-01-03T17:02:53.195Z"
},
"metadata": {
"columns": {
"_timestamp": "datetime",
"anonymous_id": "string",
"channel": "string",
"context_app_build": "string",
"context_app_name": "string",
"context_app_namespace": "string",
Expand All @@ -1347,8 +1385,10 @@ const sampleEvents = {
"context_user_agent": "string",
"email": "string",
"id": "string",
"original_timestamp": "datetime",
"phone": "string",
"received_at": "datetime",
"sent_at": "datetime",
"uuid_ts": "datetime"
},
"receivedAt": "2020-01-24T11:59:02.403+05:30",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ module.exports = {
},
{
"data": {
"anonymous_id": "97c46c81-3140-456d-b2a9-690d70aaca35",
"channel": "web",
"context_app_build": "1.0.0",
"context_app_name": "RudderLabs JavaScript SDK",
"context_app_namespace": "com.rudderlabs.javascript",
Expand All @@ -227,13 +229,18 @@ module.exports = {
"ct_map_nested_map_n_1": "nested prop 1",
"email": "[email protected]",
"id": "user123",
"original_timestamp": "2020-01-24T06:29:02.364Z",
"phone": "+917836362334",
"received_at": "2020-01-24T06:29:02.403Z",
"sent_at": "2021-01-03T17:02:53.195Z",
"t_map_nested_map_n_1": "nested prop 1",
"timestamp": "2020-01-24T06:29:02.403Z",
"up_map_nested_map_n_1": "nested prop 1"
},
"metadata": {
"columns": {
"anonymous_id": "string",
"channel": "string",
"context_app_build": "string",
"context_app_name": "string",
"context_app_namespace": "string",
Expand All @@ -257,9 +264,12 @@ module.exports = {
"ct_map_nested_map_n_1": "string",
"email": "string",
"id": "string",
"original_timestamp": "datetime",
"phone": "string",
"received_at": "datetime",
"sent_at": "datetime",
"t_map_nested_map_n_1": "string",
"timestamp": "datetime",
"up_map_nested_map_n_1": "string",
"uuid_ts": "datetime"
},
Expand Down Expand Up @@ -348,6 +358,8 @@ module.exports = {
},
{
"data": {
"anonymous_id": "97c46c81-3140-456d-b2a9-690d70aaca35",
"channel": "web",
"context_app_build": "1.0.0",
"context_app_name": "RudderLabs JavaScript SDK",
"context_app_namespace": "com.rudderlabs.javascript",
Expand All @@ -371,13 +383,18 @@ module.exports = {
"ct_map_nested_map_n_1": "nested prop 1",
"email": "[email protected]",
"id": "user123",
"original_timestamp": "2020-01-24T06:29:02.364Z",
"phone": "+917836362334",
"received_at": "2020-01-24T06:29:02.403Z",
"sent_at": "2021-01-03T17:02:53.195Z",
"t_map_nested_map_n_1": "nested prop 1",
"timestamp": "2020-01-24T06:29:02.403Z",
"up_map_nested_map_n_1": "nested prop 1"
},
"metadata": {
"columns": {
"anonymous_id": "string",
"channel": "string",
"context_app_build": "string",
"context_app_name": "string",
"context_app_namespace": "string",
Expand All @@ -401,9 +418,12 @@ module.exports = {
"ct_map_nested_map_n_1": "string",
"email": "string",
"id": "string",
"original_timestamp": "datetime",
"phone": "string",
"received_at": "datetime",
"sent_at": "datetime",
"t_map_nested_map_n_1": "string",
"timestamp": "datetime",
"up_map_nested_map_n_1": "string",
"uuid_ts": "datetime"
},
Expand Down Expand Up @@ -493,6 +513,8 @@ module.exports = {
},
{
"data": {
"anonymous_id": "97c46c81-3140-456d-b2a9-690d70aaca35",
"channel": "web",
"context_app_build": "1.0.0",
"context_app_name": "RudderLabs JavaScript SDK",
"context_app_namespace": "com.rudderlabs.javascript",
Expand All @@ -516,13 +538,18 @@ module.exports = {
"ct_map_nested_map_n_1": "nested prop 1",
"email": "[email protected]",
"id": "user123",
"original_timestamp": "2020-01-24T06:29:02.364Z",
"phone": "+917836362334",
"received_at": "2020-01-24T06:29:02.403Z",
"sent_at": "2021-01-03T17:02:53.195Z",
"t_map_nested_map_n_1": "nested prop 1",
"timestamp": "2020-01-24T06:29:02.403Z",
"up_map_nested_map_n_1": "nested prop 1"
},
"metadata": {
"columns": {
"anonymous_id": "string",
"channel": "string",
"context_app_build": "string",
"context_app_name": "string",
"context_app_namespace": "string",
Expand All @@ -547,9 +574,12 @@ module.exports = {
"email": "string",
"id": "string",
"loaded_at": "datetime",
"original_timestamp": "datetime",
"phone": "string",
"received_at": "datetime",
"sent_at": "datetime",
"t_map_nested_map_n_1": "string",
"timestamp": "datetime",
"up_map_nested_map_n_1": "string",
"uuid_ts": "datetime"
},
Expand Down Expand Up @@ -638,6 +668,8 @@ module.exports = {
},
{
"data": {
"anonymous_id": "97c46c81-3140-456d-b2a9-690d70aaca35",
"channel": "web",
"context_app_build": "1.0.0",
"context_app_name": "RudderLabs JavaScript SDK",
"context_app_namespace": "com.rudderlabs.javascript",
Expand All @@ -661,13 +693,18 @@ module.exports = {
"ct_map_nested_map_n_1": "nested prop 1",
"email": "[email protected]",
"id": "user123",
"original_timestamp": "2020-01-24T06:29:02.364Z",
"phone": "+917836362334",
"received_at": "2020-01-24T06:29:02.403Z",
"sent_at": "2021-01-03T17:02:53.195Z",
"t_map_nested_map_n_1": "nested prop 1",
"timestamp": "2020-01-24T06:29:02.403Z",
"up_map_nested_map_n_1": "nested prop 1"
},
"metadata": {
"columns": {
"anonymous_id": "string",
"channel": "string",
"context_app_build": "string",
"context_app_name": "string",
"context_app_namespace": "string",
Expand All @@ -691,9 +728,12 @@ module.exports = {
"ct_map_nested_map_n_1": "string",
"email": "string",
"id": "string",
"original_timestamp": "datetime",
"phone": "string",
"received_at": "datetime",
"sent_at": "datetime",
"t_map_nested_map_n_1": "string",
"timestamp": "datetime",
"up_map_nested_map_n_1": "string",
"uuid_ts": "datetime"
},
Expand Down Expand Up @@ -782,6 +822,8 @@ module.exports = {
},
{
"data": {
"ANONYMOUS_ID": "97c46c81-3140-456d-b2a9-690d70aaca35",
"CHANNEL": "web",
"CONTEXT_APP_BUILD": "1.0.0",
"CONTEXT_APP_NAME": "RudderLabs JavaScript SDK",
"CONTEXT_APP_NAMESPACE": "com.rudderlabs.javascript",
Expand All @@ -805,13 +847,18 @@ module.exports = {
"CT_MAP_NESTED_MAP_N_1": "nested prop 1",
"EMAIL": "[email protected]",
"ID": "user123",
"ORIGINAL_TIMESTAMP": "2020-01-24T06:29:02.364Z",
"PHONE": "+917836362334",
"RECEIVED_AT": "2020-01-24T06:29:02.403Z",
"SENT_AT": "2021-01-03T17:02:53.195Z",
"TIMESTAMP": "2020-01-24T06:29:02.403Z",
"T_MAP_NESTED_MAP_N_1": "nested prop 1",
"UP_MAP_NESTED_MAP_N_1": "nested prop 1"
},
"metadata": {
"columns": {
"ANONYMOUS_ID": "string",
"CHANNEL": "string",
"CONTEXT_APP_BUILD": "string",
"CONTEXT_APP_NAME": "string",
"CONTEXT_APP_NAMESPACE": "string",
Expand All @@ -835,8 +882,11 @@ module.exports = {
"CT_MAP_NESTED_MAP_N_1": "string",
"EMAIL": "string",
"ID": "string",
"ORIGINAL_TIMESTAMP": "datetime",
"PHONE": "string",
"RECEIVED_AT": "datetime",
"SENT_AT": "datetime",
"TIMESTAMP": "datetime",
"T_MAP_NESTED_MAP_N_1": "string",
"UP_MAP_NESTED_MAP_N_1": "string",
"UUID_TS": "datetime"
Expand Down
Loading

0 comments on commit 94fb868

Please sign in to comment.