From 4250f837836b985ecccb3dd6ad0e3790a707fa83 Mon Sep 17 00:00:00 2001 From: Sanjay <71065320+Sanjay-Veernala@users.noreply.github.com> Date: Tue, 26 Sep 2023 19:01:01 +0530 Subject: [PATCH] chore(test-suite): moved destinations to new test suite component --- ...{stats_output.json => statisg_output.json} | 266 ++-- test/__tests__/data/statsig_input.json | 1150 ++++++++--------- test/__tests__/statsig-cdk.test.ts | 19 +- 3 files changed, 710 insertions(+), 725 deletions(-) rename test/__tests__/data/{stats_output.json => statisg_output.json} (82%) diff --git a/test/__tests__/data/stats_output.json b/test/__tests__/data/statisg_output.json similarity index 82% rename from test/__tests__/data/stats_output.json rename to test/__tests__/data/statisg_output.json index 1740bc9d50..11b3553f4c 100644 --- a/test/__tests__/data/stats_output.json +++ b/test/__tests__/data/statisg_output.json @@ -1,6 +1,9 @@ [ - { - "message": { + { + "body": { + "XML": {}, + "JSON_ARRAY": {}, + "JSON": { "anonymousId": "8d872292709c6fbe", "channel": "mobile", "context": { @@ -81,19 +84,24 @@ "type": "track", "userId": "sample_user_id" }, - "destination": { - "DestinationDefinition": { - "Config": { - "cdkEnabled": true - } - }, - "Config": { - "secretKey": "secret-tHe5ecr37" - } - } + "FORM": {} + }, + "files": {}, + "endpoint": "https://api.statsig.com/v1/webhooks/rudderstack", + "headers": { + "content-type": "application/json", + "STATSIG-API-KEY": "secret-tHe5ecr37" }, - { - "message": { + "version": "1", + "params": {}, + "type": "REST", + "method": "POST" + }, + { + "body": { + "XML": {}, + "JSON_ARRAY": {}, + "JSON": { "anonymousId": "8d872292709c6fbe", "channel": "mobile", "context": { @@ -167,19 +175,24 @@ "type": "identify", "userId": "sample_user_id" }, - "destination": { - "DestinationDefinition": { - "Config": { - "cdkEnabled": true - } - }, - "Config": { - "secretKey": "secret-tHe5ecr37" - } - } + "FORM": {} }, - { - "message": { + "files": {}, + "endpoint": "https://api.statsig.com/v1/webhooks/rudderstack", + "headers": { + "content-type": "application/json", + "STATSIG-API-KEY": "secret-tHe5ecr37" + }, + "version": "1", + "params": {}, + "type": "REST", + "method": "POST" + }, + { + "body": { + "XML": {}, + "JSON_ARRAY": {}, + "JSON": { "anonymousId": "8d872292709c6fbe", "channel": "mobile", "context": { @@ -253,19 +266,24 @@ "type": "page", "userId": "sample_user_id" }, - "destination": { - "DestinationDefinition": { - "Config": { - "cdkEnabled": true - } - }, - "Config": { - "secretKey": "secret-tHe5ecr37" - } - } + "FORM": {} + }, + "files": {}, + "endpoint": "https://api.statsig.com/v1/webhooks/rudderstack", + "headers": { + "content-type": "application/json", + "STATSIG-API-KEY": "secret-tHe5ecr37" }, - { - "message": { + "version": "1", + "params": {}, + "type": "REST", + "method": "POST" + }, + { + "body": { + "XML": {}, + "JSON_ARRAY": {}, + "JSON": { "anonymousId": "8d872292709c6fbe", "channel": "mobile", "context": { @@ -339,19 +357,24 @@ "type": "screen", "userId": "sample_user_id" }, - "destination": { - "DestinationDefinition": { - "Config": { - "cdkEnabled": true - } - }, - "Config": { - "secretKey": "secret-tHe5ecr37" - } - } + "FORM": {} }, - { - "message": { + "files": {}, + "endpoint": "https://api.statsig.com/v1/webhooks/rudderstack", + "headers": { + "content-type": "application/json", + "STATSIG-API-KEY": "secret-tHe5ecr37" + }, + "version": "1", + "params": {}, + "type": "REST", + "method": "POST" + }, + { + "body": { + "XML": {}, + "JSON_ARRAY": {}, + "JSON": { "anonymousId": "8d872292709c6fbe", "channel": "mobile", "context": { @@ -425,19 +448,24 @@ "type": "screen", "userId": "sample_user_id" }, - "destination": { - "DestinationDefinition": { - "Config": { - "cdkEnabled": true - } - }, - "Config": { - "secretKey": "secret-4n07h3rsecr3t" - } - } + "FORM": {} + }, + "files": {}, + "endpoint": "https://api.statsig.com/v1/webhooks/rudderstack", + "headers": { + "content-type": "application/json", + "STATSIG-API-KEY": "secret-4n07h3rsecr3t" }, - { - "message": { + "version": "1", + "params": {}, + "type": "REST", + "method": "POST" + }, + { + "body": { + "XML": {}, + "JSON_ARRAY": {}, + "JSON": { "channel": "web", "context": { "app": { @@ -497,19 +525,24 @@ "previousId": "sampleusrRudder3", "sentAt": "2020-10-20T08:14:28.778Z" }, - "destination": { - "DestinationDefinition": { - "Config": { - "cdkEnabled": true - } - }, - "Config": { - "secretKey": "secret-tHe5ecr37" - } - } + "FORM": {} }, - { - "message": { + "files": {}, + "endpoint": "https://api.statsig.com/v1/webhooks/rudderstack", + "headers": { + "content-type": "application/json", + "STATSIG-API-KEY": "secret-tHe5ecr37" + }, + "version": "1", + "params": {}, + "type": "REST", + "method": "POST" + }, + { + "body": { + "XML": {}, + "JSON_ARRAY": {}, + "JSON": { "channel": "web", "context": { "app": { @@ -555,73 +588,20 @@ }, "sentAt": "2019-10-14T09:03:22.563Z" }, - "destination": { - "DestinationDefinition": { - "Config": { - "cdkEnabled": true - } - }, - "Config": { - "secretKey": "secret-tHe5ecr37" - } - } + "FORM": {} }, - { - "message": { - "channel": "web", - "context": { - "app": { - "build": "1.0.0", - "name": "RudderLabs JavaScript SDK", - "namespace": "com.rudderlabs.javascript", - "version": "1.0.0" - }, - "library": { - "name": "RudderLabs JavaScript SDK", - "version": "1.0.0" - }, - "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36", - "locale": "en-US", - "ip": "0.0.0.0", - "os": { - "name": "", - "version": "" - }, - "screen": { - "density": 2 - } - }, - "messageId": "84e26acc-56a5-4835-8233-591137fca468", - "session_id": "3049dc4c-5a95-4ccd-a3e7-d74a7e411f22", - "originalTimestamp": "2019-10-14T09:03:17.562Z", - "anonymousId": "123456", - "userId": "123456", - "type": "NOT_A_TYPE", - "traits": { - "anonymousId": "123456", - "email": "test@rudderstack.com", - "address": { - "city": "kolkata", - "country": "India", - "postalCode": 712136, - "state": "WB", - "street": "" - } - }, - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - }, - "destination": { - "DestinationDefinition": { - "Config": { - "cdkEnabled": true - } - }, - "Config": { - "secretKey": "secret-tHe5ecr37" - } - } - } - ] \ No newline at end of file + "files": {}, + "endpoint": "https://api.statsig.com/v1/webhooks/rudderstack", + "headers": { + "content-type": "application/json", + "STATSIG-API-KEY": "secret-tHe5ecr37" + }, + "version": "1", + "params": {}, + "type": "REST", + "method": "POST" + }, + { + "error": "message type \"NOT_A_TYPE\" not supported for \"statsig\"" + } +] diff --git a/test/__tests__/data/statsig_input.json b/test/__tests__/data/statsig_input.json index 1740bc9d50..dbcf0666e9 100644 --- a/test/__tests__/data/statsig_input.json +++ b/test/__tests__/data/statsig_input.json @@ -1,627 +1,627 @@ [ - { - "message": { - "anonymousId": "8d872292709c6fbe", - "channel": "mobile", - "context": { - "app": { - "build": "1", - "name": "AMTestProject", - "namespace": "com.rudderstack.android.rudderstack.sampleAndroidApp", - "version": "1.0" - }, - "device": { - "id": "8d872292709c6fbe", - "manufacturer": "Google", - "model": "AOSPonIAEmulator", - "name": "generic_x86_arm", - "type": "android" - }, - "library": { - "name": "com.rudderstack.android.sdk.core", - "version": "1.0.2" - }, - "locale": "en-US", - "network": { - "carrier": "Android", - "bluetooth": false, - "cellular": true, - "wifi": true - }, - "os": { - "name": "Android", - "version": "9" - }, - "screen": { - "density": 420, - "height": 1794, - "width": 1080 - }, - "timezone": "Asia/Kolkata", - "traits": { - "address": { - "city": "Kolkata", - "country": "India", - "postalcode": "700096", - "state": "West bengal", - "street": "Park Street" - }, - "age": "30", - "anonymousId": "8d872292709c6fbe", - "birthday": "2020-05-26", - "createdat": "18th March 2020", - "description": "Premium User for 3 years", - "email": "identify@test.com", - "firstname": "John", - "userId": "sample_user_id", - "lastname": "Sparrow", - "name": "John Sparrow", - "id": "sample_user_id", - "phone": "9112340345", - "username": "john_sparrow" - }, - "userAgent": "Dalvik/2.1.0 (Linux; U; Android 9; AOSP on IA Emulator Build/PSR1.180720.117)" + { + "message": { + "anonymousId": "8d872292709c6fbe", + "channel": "mobile", + "context": { + "app": { + "build": "1", + "name": "AMTestProject", + "namespace": "com.rudderstack.android.rudderstack.sampleAndroidApp", + "version": "1.0" }, - "event": "Product Clicked", - "integrations": { - "All": true + "device": { + "id": "8d872292709c6fbe", + "manufacturer": "Google", + "model": "AOSPonIAEmulator", + "name": "generic_x86_arm", + "type": "android" }, - "messageId": "1590431830915-73bed370-5889-436d-9a9e-0c0e0c809d06", - "properties": { - "revenue": "30", - "currency": "USD", - "quantity": "5", - "test_key_2": { - "test_child_key_1": "test_child_value_1" - }, - "price": "58.0" + "library": { + "name": "com.rudderstack.android.sdk.core", + "version": "1.0.2" }, - "originalTimestamp": "2020-05-25T18:37:10.917Z", - "sentAt": "2020-05-25T18:37:10.917Z", - "type": "track", - "userId": "sample_user_id" - }, - "destination": { - "DestinationDefinition": { - "Config": { - "cdkEnabled": true - } + "locale": "en-US", + "network": { + "carrier": "Android", + "bluetooth": false, + "cellular": true, + "wifi": true }, - "Config": { - "secretKey": "secret-tHe5ecr37" - } - } - }, - { - "message": { - "anonymousId": "8d872292709c6fbe", - "channel": "mobile", - "context": { - "app": { - "build": "1", - "name": "AMTestProject", - "namespace": "com.rudderstack.android.rudderstack.sampleAndroidApp", - "version": "1.0" - }, - "device": { - "id": "8d872292709c6fbe", - "manufacturer": "Google", - "model": "AOSP on IA Emulator", - "name": "generic_x86_arm", - "type": "android" - }, - "library": { - "name": "com.rudderstack.android.sdk.core", - "version": "1.0.2" - }, - "locale": "en-US", - "network": { - "carrier": "Android", - "bluetooth": false, - "cellular": true, - "wifi": true - }, - "os": { - "name": "Android", - "version": "9" - }, - "screen": { - "density": 420, - "height": 1794, - "width": 1080 - }, - "timezone": "Asia/Kolkata", - "traits": { - "address": { - "city": "Kolkata", - "country": "India", - "postalcode": "700096", - "state": "West bengal", - "street": "Park Street" - }, - "age": "30", - "anonymousId": "8d872292709c6fbe", - "birthday": "2020-05-26", - "createdat": "18th March 2020", - "description": "Premium User for 3 years", - "email": "identify@test.com", - "firstname": "John", - "userId": "sample_user_id", - "lastname": "Sparrow", - "name": "John Sparrow", - "id": "sample_user_id", - "phone": "9876543210", - "username": "john_sparrow", - "quantity": "5", - "price": "56.0" - }, - "userAgent": "Dalvik/2.1.0 (Linux; U; Android 9; AOSP on IA Emulator Build/PSR1.180720.117)" + "os": { + "name": "Android", + "version": "9" }, - "event": "identify", - "integrations": { - "All": true + "screen": { + "density": 420, + "height": 1794, + "width": 1080 }, - "messageId": "1590431830865-3be680d6-7dcd-4b05-8460-f3acc30046d9", - "originalTimestamp": "2020-05-25T18:37:10.865Z", - "sentAt": "2020-05-25T18:37:10.917Z", - "type": "identify", - "userId": "sample_user_id" + "timezone": "Asia/Kolkata", + "traits": { + "address": { + "city": "Kolkata", + "country": "India", + "postalcode": "700096", + "state": "West bengal", + "street": "Park Street" + }, + "age": "30", + "anonymousId": "8d872292709c6fbe", + "birthday": "2020-05-26", + "createdat": "18th March 2020", + "description": "Premium User for 3 years", + "email": "identify@test.com", + "firstname": "John", + "userId": "sample_user_id", + "lastname": "Sparrow", + "name": "John Sparrow", + "id": "sample_user_id", + "phone": "9112340345", + "username": "john_sparrow" + }, + "userAgent": "Dalvik/2.1.0 (Linux; U; Android 9; AOSP on IA Emulator Build/PSR1.180720.117)" + }, + "event": "Product Clicked", + "integrations": { + "All": true }, - "destination": { - "DestinationDefinition": { - "Config": { - "cdkEnabled": true - } + "messageId": "1590431830915-73bed370-5889-436d-9a9e-0c0e0c809d06", + "properties": { + "revenue": "30", + "currency": "USD", + "quantity": "5", + "test_key_2": { + "test_child_key_1": "test_child_value_1" }, + "price": "58.0" + }, + "originalTimestamp": "2020-05-25T18:37:10.917Z", + "sentAt": "2020-05-25T18:37:10.917Z", + "type": "track", + "userId": "sample_user_id" + }, + "destination": { + "DestinationDefinition": { "Config": { - "secretKey": "secret-tHe5ecr37" + "cdkEnabled": true } + }, + "Config": { + "secretKey": "secret-tHe5ecr37" } - }, - { - "message": { - "anonymousId": "8d872292709c6fbe", - "channel": "mobile", - "context": { - "app": { - "build": "1", - "name": "AMTestProject", - "namespace": "com.rudderstack.android.rudderstack.sampleAndroidApp", - "version": "1.0" - }, - "device": { - "id": "8d872292709c6fbe", - "manufacturer": "Google", - "model": "AOSP on IA Emulator", - "name": "generic_x86_arm", - "type": "android" - }, - "library": { - "name": "com.rudderstack.android.sdk.core", - "version": "1.0.2" - }, - "locale": "en-US", - "network": { - "carrier": "Android", - "bluetooth": false, - "cellular": true, - "wifi": true - }, - "os": { - "name": "Android", - "version": "9" - }, - "screen": { - "density": 420, - "height": 1794, - "width": 1080 - }, - "timezone": "Asia/Kolkata", - "traits": { - "address": { - "city": "Kolkata", - "country": "India", - "postalcode": "700096", - "state": "West bengal", - "street": "Park Street" - }, - "age": "30", - "anonymousId": "8d872292709c6fbe", - "birthday": "2020-05-26", - "createdat": "18th March 2020", - "description": "Premium User for 3 years", - "email": "page@test.com", - "firstname": "John", - "userId": "sample_user_id", - "lastname": "Sparrow", - "name": "John Sparrow", - "id": "sample_user_id", - "phone": "9876543210", - "username": "john_sparrow", - "quantity": "5", - "price": "56.0" - }, - "userAgent": "Dalvik/2.1.0 (Linux; U; Android 9; AOSP on IA Emulator Build/PSR1.180720.117)" + } + }, + { + "message": { + "anonymousId": "8d872292709c6fbe", + "channel": "mobile", + "context": { + "app": { + "build": "1", + "name": "AMTestProject", + "namespace": "com.rudderstack.android.rudderstack.sampleAndroidApp", + "version": "1.0" }, - "event": "page", - "integrations": { - "All": true + "device": { + "id": "8d872292709c6fbe", + "manufacturer": "Google", + "model": "AOSP on IA Emulator", + "name": "generic_x86_arm", + "type": "android" }, - "messageId": "1590431830865-3be680d6-7dcd-4b05-8460-f3acc30046d9", - "originalTimestamp": "2020-05-25T18:37:10.865Z", - "sentAt": "2020-05-25T18:37:10.917Z", - "type": "page", - "userId": "sample_user_id" - }, - "destination": { - "DestinationDefinition": { - "Config": { - "cdkEnabled": true - } + "library": { + "name": "com.rudderstack.android.sdk.core", + "version": "1.0.2" + }, + "locale": "en-US", + "network": { + "carrier": "Android", + "bluetooth": false, + "cellular": true, + "wifi": true + }, + "os": { + "name": "Android", + "version": "9" + }, + "screen": { + "density": 420, + "height": 1794, + "width": 1080 }, + "timezone": "Asia/Kolkata", + "traits": { + "address": { + "city": "Kolkata", + "country": "India", + "postalcode": "700096", + "state": "West bengal", + "street": "Park Street" + }, + "age": "30", + "anonymousId": "8d872292709c6fbe", + "birthday": "2020-05-26", + "createdat": "18th March 2020", + "description": "Premium User for 3 years", + "email": "identify@test.com", + "firstname": "John", + "userId": "sample_user_id", + "lastname": "Sparrow", + "name": "John Sparrow", + "id": "sample_user_id", + "phone": "9876543210", + "username": "john_sparrow", + "quantity": "5", + "price": "56.0" + }, + "userAgent": "Dalvik/2.1.0 (Linux; U; Android 9; AOSP on IA Emulator Build/PSR1.180720.117)" + }, + "event": "identify", + "integrations": { + "All": true + }, + "messageId": "1590431830865-3be680d6-7dcd-4b05-8460-f3acc30046d9", + "originalTimestamp": "2020-05-25T18:37:10.865Z", + "sentAt": "2020-05-25T18:37:10.917Z", + "type": "identify", + "userId": "sample_user_id" + }, + "destination": { + "DestinationDefinition": { "Config": { - "secretKey": "secret-tHe5ecr37" + "cdkEnabled": true } + }, + "Config": { + "secretKey": "secret-tHe5ecr37" } - }, - { - "message": { - "anonymousId": "8d872292709c6fbe", - "channel": "mobile", - "context": { - "app": { - "build": "1", - "name": "AMTestProject", - "namespace": "com.rudderstack.android.rudderstack.sampleAndroidApp", - "version": "1.0" - }, - "device": { - "id": "8d872292709c6fbe", - "manufacturer": "Google", - "model": "AOSP on IA Emulator", - "name": "generic_x86_arm", - "type": "android" - }, - "library": { - "name": "com.rudderstack.android.sdk.core", - "version": "1.0.2" - }, - "locale": "en-US", - "network": { - "carrier": "Android", - "bluetooth": false, - "cellular": true, - "wifi": true - }, - "os": { - "name": "Android", - "version": "9" - }, - "screen": { - "density": 420, - "height": 1794, - "width": 1080 - }, - "timezone": "Asia/Kolkata", - "traits": { - "address": { - "city": "Kolkata", - "country": "India", - "postalcode": "700096", - "state": "West bengal", - "street": "Park Street" - }, - "age": "30", - "anonymousId": "8d872292709c6fbe", - "birthday": "2020-05-26", - "createdat": "18th March 2020", - "description": "Premium User for 3 years", - "email": "screen@test.com", - "firstname": "John", - "userId": "sample_user_id", - "lastname": "Sparrow", - "name": "John Sparrow", - "id": "sample_user_id", - "phone": "9876543210", - "username": "john_sparrow", - "quantity": "5", - "price": "56.0" - }, - "userAgent": "Dalvik/2.1.0 (Linux; U; Android 9; AOSP on IA Emulator Build/PSR1.180720.117)" + } + }, + { + "message": { + "anonymousId": "8d872292709c6fbe", + "channel": "mobile", + "context": { + "app": { + "build": "1", + "name": "AMTestProject", + "namespace": "com.rudderstack.android.rudderstack.sampleAndroidApp", + "version": "1.0" }, - "event": "screen", - "integrations": { - "All": true + "device": { + "id": "8d872292709c6fbe", + "manufacturer": "Google", + "model": "AOSP on IA Emulator", + "name": "generic_x86_arm", + "type": "android" }, - "messageId": "1590431830865-3be680d6-7dcd-4b05-8460-f3acc30046d9", - "originalTimestamp": "2020-05-25T18:37:10.865Z", - "sentAt": "2020-05-25T18:37:10.917Z", - "type": "screen", - "userId": "sample_user_id" - }, - "destination": { - "DestinationDefinition": { - "Config": { - "cdkEnabled": true - } + "library": { + "name": "com.rudderstack.android.sdk.core", + "version": "1.0.2" + }, + "locale": "en-US", + "network": { + "carrier": "Android", + "bluetooth": false, + "cellular": true, + "wifi": true + }, + "os": { + "name": "Android", + "version": "9" }, + "screen": { + "density": 420, + "height": 1794, + "width": 1080 + }, + "timezone": "Asia/Kolkata", + "traits": { + "address": { + "city": "Kolkata", + "country": "India", + "postalcode": "700096", + "state": "West bengal", + "street": "Park Street" + }, + "age": "30", + "anonymousId": "8d872292709c6fbe", + "birthday": "2020-05-26", + "createdat": "18th March 2020", + "description": "Premium User for 3 years", + "email": "page@test.com", + "firstname": "John", + "userId": "sample_user_id", + "lastname": "Sparrow", + "name": "John Sparrow", + "id": "sample_user_id", + "phone": "9876543210", + "username": "john_sparrow", + "quantity": "5", + "price": "56.0" + }, + "userAgent": "Dalvik/2.1.0 (Linux; U; Android 9; AOSP on IA Emulator Build/PSR1.180720.117)" + }, + "event": "page", + "integrations": { + "All": true + }, + "messageId": "1590431830865-3be680d6-7dcd-4b05-8460-f3acc30046d9", + "originalTimestamp": "2020-05-25T18:37:10.865Z", + "sentAt": "2020-05-25T18:37:10.917Z", + "type": "page", + "userId": "sample_user_id" + }, + "destination": { + "DestinationDefinition": { "Config": { - "secretKey": "secret-tHe5ecr37" + "cdkEnabled": true } + }, + "Config": { + "secretKey": "secret-tHe5ecr37" } - }, - { - "message": { - "anonymousId": "8d872292709c6fbe", - "channel": "mobile", - "context": { - "app": { - "build": "1", - "name": "AMTestProject", - "namespace": "com.rudderstack.android.rudderstack.sampleAndroidApp", - "version": "1.0" - }, - "device": { - "id": "8d872292709c6fbe", - "manufacturer": "Google", - "model": "AOSP on IA Emulator", - "name": "generic_x86_arm", - "type": "android" - }, - "library": { - "name": "com.rudderstack.android.sdk.core", - "version": "1.0.2" - }, - "locale": "en-US", - "network": { - "carrier": "Android", - "bluetooth": false, - "cellular": true, - "wifi": true - }, - "os": { - "name": "Android", - "version": "9" - }, - "screen": { - "density": 420, - "height": 1794, - "width": 1080 - }, - "timezone": "Asia/Kolkata", - "traits": { - "address": { - "city": "Kolkata", - "country": "India", - "postalcode": "700096", - "state": "West bengal", - "street": "Park Street" - }, - "age": "30", - "anonymousId": "8d872292709c6fbe", - "birthday": "2020-05-26", - "createdat": "18th March 2020", - "description": "Premium User for 3 years", - "email": "screen@test.com", - "firstname": "John", - "userId": "sample_user_id", - "lastname": "Sparrow", - "name": "John Sparrow", - "id": "sample_user_id", - "phone": "9876543210", - "username": "john_sparrow", - "quantity": "5", - "price": "56.0" - }, - "userAgent": "Dalvik/2.1.0 (Linux; U; Android 9; AOSP on IA Emulator Build/PSR1.180720.117)" + } + }, + { + "message": { + "anonymousId": "8d872292709c6fbe", + "channel": "mobile", + "context": { + "app": { + "build": "1", + "name": "AMTestProject", + "namespace": "com.rudderstack.android.rudderstack.sampleAndroidApp", + "version": "1.0" }, - "event": "screen", - "integrations": { - "All": true + "device": { + "id": "8d872292709c6fbe", + "manufacturer": "Google", + "model": "AOSP on IA Emulator", + "name": "generic_x86_arm", + "type": "android" }, - "messageId": "1590431830865-3be680d6-7dcd-4b05-8460-f3acc30046d9", - "originalTimestamp": "2020-05-25T18:37:10.865Z", - "sentAt": "2020-05-25T18:37:10.917Z", - "type": "screen", - "userId": "sample_user_id" - }, - "destination": { - "DestinationDefinition": { - "Config": { - "cdkEnabled": true - } + "library": { + "name": "com.rudderstack.android.sdk.core", + "version": "1.0.2" }, + "locale": "en-US", + "network": { + "carrier": "Android", + "bluetooth": false, + "cellular": true, + "wifi": true + }, + "os": { + "name": "Android", + "version": "9" + }, + "screen": { + "density": 420, + "height": 1794, + "width": 1080 + }, + "timezone": "Asia/Kolkata", + "traits": { + "address": { + "city": "Kolkata", + "country": "India", + "postalcode": "700096", + "state": "West bengal", + "street": "Park Street" + }, + "age": "30", + "anonymousId": "8d872292709c6fbe", + "birthday": "2020-05-26", + "createdat": "18th March 2020", + "description": "Premium User for 3 years", + "email": "screen@test.com", + "firstname": "John", + "userId": "sample_user_id", + "lastname": "Sparrow", + "name": "John Sparrow", + "id": "sample_user_id", + "phone": "9876543210", + "username": "john_sparrow", + "quantity": "5", + "price": "56.0" + }, + "userAgent": "Dalvik/2.1.0 (Linux; U; Android 9; AOSP on IA Emulator Build/PSR1.180720.117)" + }, + "event": "screen", + "integrations": { + "All": true + }, + "messageId": "1590431830865-3be680d6-7dcd-4b05-8460-f3acc30046d9", + "originalTimestamp": "2020-05-25T18:37:10.865Z", + "sentAt": "2020-05-25T18:37:10.917Z", + "type": "screen", + "userId": "sample_user_id" + }, + "destination": { + "DestinationDefinition": { "Config": { - "secretKey": "secret-4n07h3rsecr3t" + "cdkEnabled": true } - } - }, - { - "message": { - "channel": "web", - "context": { - "app": { - "build": "1.0.0", - "name": "RudderLabs JavaScript SDK", - "namespace": "com.rudderlabs.javascript", - "version": "1.1.5" - }, - "traits": { - "name": "Shehan Study", - "category": "SampleIdentify", - "email": "test@rudderstack.com", - "plan": "Open source", - "logins": 5, - "createdAt": 1599264000 - }, - "library": { - "name": "RudderLabs JavaScript SDK", - "version": "1.1.5" - }, - "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36", - "locale": "en-US", - "os": { - "name": "", - "version": "" - }, - "screen": { - "density": 0.8999999761581421 - }, - "campaign": { - "source": "google", - "medium": "medium", - "term": "keyword", - "content": "some content", - "name": "some campaign", - "test": "other value" - }, - "page": { - "path": "/destinations/amplitude", - "referrer": "", - "search": "", - "title": "", - "url": "https://docs.rudderstack.com/destinations/amplitude", - "category": "destination", - "initial_referrer": "https://docs.rudderstack.com", - "initial_referring_domain": "docs.rudderstack.com" - } - }, - "type": "alias", - "messageId": "dd46338d-5f83-493b-bd28-3b48f55d0be8", - "originalTimestamp": "2020-10-20T08:14:28.778Z", - "anonymousId": "my-anonymous-id-new", - "userId": "newUserIdAlias", - "integrations": { - "All": true - }, - "previousId": "sampleusrRudder3", - "sentAt": "2020-10-20T08:14:28.778Z" }, - "destination": { - "DestinationDefinition": { - "Config": { - "cdkEnabled": true - } + "Config": { + "secretKey": "secret-tHe5ecr37" + } + } + }, + { + "message": { + "anonymousId": "8d872292709c6fbe", + "channel": "mobile", + "context": { + "app": { + "build": "1", + "name": "AMTestProject", + "namespace": "com.rudderstack.android.rudderstack.sampleAndroidApp", + "version": "1.0" }, + "device": { + "id": "8d872292709c6fbe", + "manufacturer": "Google", + "model": "AOSP on IA Emulator", + "name": "generic_x86_arm", + "type": "android" + }, + "library": { + "name": "com.rudderstack.android.sdk.core", + "version": "1.0.2" + }, + "locale": "en-US", + "network": { + "carrier": "Android", + "bluetooth": false, + "cellular": true, + "wifi": true + }, + "os": { + "name": "Android", + "version": "9" + }, + "screen": { + "density": 420, + "height": 1794, + "width": 1080 + }, + "timezone": "Asia/Kolkata", + "traits": { + "address": { + "city": "Kolkata", + "country": "India", + "postalcode": "700096", + "state": "West bengal", + "street": "Park Street" + }, + "age": "30", + "anonymousId": "8d872292709c6fbe", + "birthday": "2020-05-26", + "createdat": "18th March 2020", + "description": "Premium User for 3 years", + "email": "screen@test.com", + "firstname": "John", + "userId": "sample_user_id", + "lastname": "Sparrow", + "name": "John Sparrow", + "id": "sample_user_id", + "phone": "9876543210", + "username": "john_sparrow", + "quantity": "5", + "price": "56.0" + }, + "userAgent": "Dalvik/2.1.0 (Linux; U; Android 9; AOSP on IA Emulator Build/PSR1.180720.117)" + }, + "event": "screen", + "integrations": { + "All": true + }, + "messageId": "1590431830865-3be680d6-7dcd-4b05-8460-f3acc30046d9", + "originalTimestamp": "2020-05-25T18:37:10.865Z", + "sentAt": "2020-05-25T18:37:10.917Z", + "type": "screen", + "userId": "sample_user_id" + }, + "destination": { + "DestinationDefinition": { "Config": { - "secretKey": "secret-tHe5ecr37" + "cdkEnabled": true } + }, + "Config": { + "secretKey": "secret-4n07h3rsecr3t" } - }, - { - "message": { - "channel": "web", - "context": { - "app": { - "build": "1.0.0", - "name": "RudderLabs JavaScript SDK", - "namespace": "com.rudderlabs.javascript", - "version": "1.0.0" - }, - "library": { - "name": "RudderLabs JavaScript SDK", - "version": "1.0.0" - }, - "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36", - "locale": "en-US", - "ip": "0.0.0.0", - "os": { - "name": "", - "version": "" - }, - "screen": { - "density": 2 - } + } + }, + { + "message": { + "channel": "web", + "context": { + "app": { + "build": "1.0.0", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "1.1.5" }, - "messageId": "84e26acc-56a5-4835-8233-591137fca468", - "session_id": "3049dc4c-5a95-4ccd-a3e7-d74a7e411f22", - "originalTimestamp": "2019-10-14T09:03:17.562Z", - "anonymousId": "123456", - "userId": "123456", - "type": "group", "traits": { - "anonymousId": "123456", + "name": "Shehan Study", + "category": "SampleIdentify", "email": "test@rudderstack.com", - "address": { - "city": "kolkata", - "country": "India", - "postalCode": 712136, - "state": "WB", - "street": "" - } + "plan": "Open source", + "logins": 5, + "createdAt": 1599264000 }, - "integrations": { - "All": true + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "1.1.5" }, - "sentAt": "2019-10-14T09:03:22.563Z" - }, - "destination": { - "DestinationDefinition": { - "Config": { - "cdkEnabled": true - } + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36", + "locale": "en-US", + "os": { + "name": "", + "version": "" }, + "screen": { + "density": 0.8999999761581421 + }, + "campaign": { + "source": "google", + "medium": "medium", + "term": "keyword", + "content": "some content", + "name": "some campaign", + "test": "other value" + }, + "page": { + "path": "/destinations/amplitude", + "referrer": "", + "search": "", + "title": "", + "url": "https://docs.rudderstack.com/destinations/amplitude", + "category": "destination", + "initial_referrer": "https://docs.rudderstack.com", + "initial_referring_domain": "docs.rudderstack.com" + } + }, + "type": "alias", + "messageId": "dd46338d-5f83-493b-bd28-3b48f55d0be8", + "originalTimestamp": "2020-10-20T08:14:28.778Z", + "anonymousId": "my-anonymous-id-new", + "userId": "newUserIdAlias", + "integrations": { + "All": true + }, + "previousId": "sampleusrRudder3", + "sentAt": "2020-10-20T08:14:28.778Z" + }, + "destination": { + "DestinationDefinition": { "Config": { - "secretKey": "secret-tHe5ecr37" + "cdkEnabled": true } + }, + "Config": { + "secretKey": "secret-tHe5ecr37" } - }, - { - "message": { - "channel": "web", - "context": { - "app": { - "build": "1.0.0", - "name": "RudderLabs JavaScript SDK", - "namespace": "com.rudderlabs.javascript", - "version": "1.0.0" - }, - "library": { - "name": "RudderLabs JavaScript SDK", - "version": "1.0.0" - }, - "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36", - "locale": "en-US", - "ip": "0.0.0.0", - "os": { - "name": "", - "version": "" - }, - "screen": { - "density": 2 - } + } + }, + { + "message": { + "channel": "web", + "context": { + "app": { + "build": "1.0.0", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "1.0.0" }, - "messageId": "84e26acc-56a5-4835-8233-591137fca468", - "session_id": "3049dc4c-5a95-4ccd-a3e7-d74a7e411f22", - "originalTimestamp": "2019-10-14T09:03:17.562Z", - "anonymousId": "123456", - "userId": "123456", - "type": "NOT_A_TYPE", - "traits": { - "anonymousId": "123456", - "email": "test@rudderstack.com", - "address": { - "city": "kolkata", - "country": "India", - "postalCode": 712136, - "state": "WB", - "street": "" - } + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "1.0.0" }, - "integrations": { - "All": true + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36", + "locale": "en-US", + "ip": "0.0.0.0", + "os": { + "name": "", + "version": "" }, - "sentAt": "2019-10-14T09:03:22.563Z" + "screen": { + "density": 2 + } }, - "destination": { - "DestinationDefinition": { - "Config": { - "cdkEnabled": true - } + "messageId": "84e26acc-56a5-4835-8233-591137fca468", + "session_id": "3049dc4c-5a95-4ccd-a3e7-d74a7e411f22", + "originalTimestamp": "2019-10-14T09:03:17.562Z", + "anonymousId": "123456", + "userId": "123456", + "type": "group", + "traits": { + "anonymousId": "123456", + "email": "test@rudderstack.com", + "address": { + "city": "kolkata", + "country": "India", + "postalCode": 712136, + "state": "WB", + "street": "" + } + }, + "integrations": { + "All": true + }, + "sentAt": "2019-10-14T09:03:22.563Z" + }, + "destination": { + "DestinationDefinition": { + "Config": { + "cdkEnabled": true + } + }, + "Config": { + "secretKey": "secret-tHe5ecr37" + } + } + }, + { + "message": { + "channel": "web", + "context": { + "app": { + "build": "1.0.0", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "1.0.0" }, + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "1.0.0" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36", + "locale": "en-US", + "ip": "0.0.0.0", + "os": { + "name": "", + "version": "" + }, + "screen": { + "density": 2 + } + }, + "messageId": "84e26acc-56a5-4835-8233-591137fca468", + "session_id": "3049dc4c-5a95-4ccd-a3e7-d74a7e411f22", + "originalTimestamp": "2019-10-14T09:03:17.562Z", + "anonymousId": "123456", + "userId": "123456", + "type": "NOT_A_TYPE", + "traits": { + "anonymousId": "123456", + "email": "test@rudderstack.com", + "address": { + "city": "kolkata", + "country": "India", + "postalCode": 712136, + "state": "WB", + "street": "" + } + }, + "integrations": { + "All": true + }, + "sentAt": "2019-10-14T09:03:22.563Z" + }, + "destination": { + "DestinationDefinition": { "Config": { - "secretKey": "secret-tHe5ecr37" + "cdkEnabled": true } + }, + "Config": { + "secretKey": "secret-tHe5ecr37" } } - ] \ No newline at end of file + } +] diff --git a/test/__tests__/statsig-cdk.test.ts b/test/__tests__/statsig-cdk.test.ts index 5c2679469f..79bb3e9fae 100644 --- a/test/__tests__/statsig-cdk.test.ts +++ b/test/__tests__/statsig-cdk.test.ts @@ -1,4 +1,4 @@ -const fs = require("fs"); +import fs from 'fs'; import path from 'path'; import { processCdkV2Workflow } from '../../src/cdk/v2/handler'; import tags from '../../src/v0/util/tags'; @@ -6,18 +6,23 @@ import tags from '../../src/v0/util/tags'; const integration = 'statsig'; const destName = 'Statsig'; -const testDataFile = fs.readFileSync( - path.resolve(__dirname, `./data/${integration}.json`) +const inputDataFile = fs.readFileSync(path.resolve(__dirname, `./data/${integration}_input.json`), { + encoding: 'utf8', +}); +const outputDataFile = fs.readFileSync( + path.resolve(__dirname, `./data/${integration}_cdk_output.json`), + { encoding: 'utf8' }, ); -const testData = JSON.parse(testDataFile); +const inputData = JSON.parse(inputDataFile); +const expectedData = JSON.parse(outputDataFile); describe(`${destName} Tests`, () => { describe('Processor Tests', () => { - testData.forEach((dataPoint, index) => { + inputData.forEach((input, index) => { it(`${destName} - payload: ${index}`, async () => { - const expected = dataPoint.output; + const expected = expectedData[index]; try { - const output = await processCdkV2Workflow(integration, dataPoint.input, tags.FEATURES.PROCESSOR); + const output = await processCdkV2Workflow(integration, input, tags.FEATURES.PROCESSOR); expect(output).toEqual(expected); } catch (error: any) { expect(error.message).toEqual(expected.error);