diff --git a/.vscode/settings.json b/.vscode/settings.json
index c5c4e38b2df4..cbca78c2e151 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -2,7 +2,7 @@
"prettier.requireConfig": true,
"prettier.configPath": ".prettierrc",
"[typescript]": {
- "editor.defaultFormatter": "esbenp.prettier-vscode",
+ "editor.defaultFormatter": "vscode.typescript-language-features",
"editor.formatOnSave": true
},
"[javascript]": {
diff --git a/test/integrations/destinations/webhook/mocks.ts b/test/integrations/destinations/webhook/mocks.ts
new file mode 100644
index 000000000000..993549673d29
--- /dev/null
+++ b/test/integrations/destinations/webhook/mocks.ts
@@ -0,0 +1,5 @@
+const webhookUtils = require('../../../../src/v0/destinations/webhook/utils');
+
+export const defaultMockFns = (_) => {
+ jest.spyOn(webhookUtils, 'isFeatureEnabled').mockResolvedValue(true);
+};
diff --git a/test/integrations/destinations/webhook/processor/data.ts b/test/integrations/destinations/webhook/processor/data.ts
index c81fc3150164..2835e1c67d71 100644
--- a/test/integrations/destinations/webhook/processor/data.ts
+++ b/test/integrations/destinations/webhook/processor/data.ts
@@ -1,9 +1,10 @@
-import { head } from 'lodash';
+import { defaultMockFns } from '../mocks';
export const data = [
{
name: 'webhook',
- description: 'Test with different content-type',
+ description:
+ 'Feature Flag is enabled for formatted body based on content-type | Content type: x-www-form-urlencoded',
feature: 'processor',
module: 'destination',
version: 'v0',
@@ -127,7 +128,7 @@ export const data = [
},
metadata: {
destinationId: 'destId',
- workspaceId: '1QH0ppCx6PD5kMmirglALJMTKax',
+ workspaceId: 'wspId',
},
},
],
@@ -159,13 +160,439 @@ export const data = [
},
metadata: {
destinationId: 'destId',
- workspaceId: '1QH0ppCx6PD5kMmirglALJMTKax',
+ workspaceId: 'wspId',
+ },
+ statusCode: 200,
+ },
+ ],
+ },
+ },
+ mockFns: defaultMockFns,
+ },
+ {
+ name: 'webhook',
+ description:
+ 'Feature Flag is enabled for formatted body based on content-type | Content type: xml',
+ feature: 'processor',
+ module: 'destination',
+ version: 'v0',
+ input: {
+ request: {
+ body: [
+ {
+ message: {
+ anonymousId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1',
+ context: {
+ device: {
+ id: 'df16bffa-5c3d-4fbb-9bce-3bab098129a7R',
+ manufacturer: 'Xiaomi',
+ model: 'Redmi 6',
+ name: 'xiaomi',
+ },
+ network: {
+ carrier: 'Banglalink',
+ },
+ os: {
+ name: 'android',
+ version: '8.1.0',
+ },
+ traits: {
+ address: {
+ city: 'Dhaka',
+ country: 'Bangladesh',
+ },
+ anonymousId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1',
+ },
+ },
+ event: 'spin_result',
+ integrations: {
+ All: true,
+ },
+ message_id: 'a80f82be-9bdc-4a9f-b2a5-15621ee41df8',
+ properties: {
+ additional_bet_index: 0,
+ battle_id: 'N/A',
+ bet_amount: 9,
+ bet_level: 1,
+ bet_multiplier: 1,
+ coin_balance: 9466052,
+ current_module_name: 'CasinoGameModule',
+ days_in_game: 0,
+ extra_param: 'N/A',
+ fb_profile: '0',
+ featureGameType: 'N/A',
+ game_fps: 30,
+ game_id: 'fireEagleBase',
+ game_name: 'FireEagleSlots',
+ gem_balance: 0,
+ graphicsQuality: 'HD',
+ idfa: '2bf99787-33d2-4ae2-a76a-c49672f97252',
+ internetReachability: 'ReachableViaLocalAreaNetwork',
+ isLowEndDevice: 'False',
+ is_auto_spin: 'False',
+ is_turbo: 'False',
+ isf: 'False',
+ ishighroller: 'False',
+ jackpot_win_amount: 90,
+ jackpot_win_type: 'Silver',
+ level: 6,
+ lifetime_gem_balance: 0,
+ no_of_spin: 1,
+ player_total_battles: 0,
+ player_total_shields: 0,
+ start_date: '2019-08-01',
+ total_payments: 0,
+ tournament_id: 'T1561970819',
+ userId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1',
+ versionSessionCount: 2,
+ win_amount: 0,
+ },
+ timestamp: '2019-09-01T15:46:51.693229+05:30',
+ type: 'track',
+ user_properties: {
+ coin_balance: 9466052,
+ current_module_name: 'CasinoGameModule',
+ fb_profile: '0',
+ game_fps: 30,
+ game_name: 'FireEagleSlots',
+ gem_balance: 0,
+ graphicsQuality: 'HD',
+ idfa: '2bf99787-33d2-4ae2-a76a-c49672f97252',
+ internetReachability: 'ReachableViaLocalAreaNetwork',
+ isLowEndDevice: false,
+ level: 6,
+ lifetime_gem_balance: 0,
+ player_total_battles: 0,
+ player_total_shields: 0,
+ start_date: '2019-08-01',
+ total_payments: 0,
+ userId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1',
+ versionSessionCount: 2,
+ },
+ },
+ destination: {
+ Config: {
+ webhookUrl: 'http://6b0e6a60.ngrok.io',
+ headers: [
+ {
+ from: '',
+ to: '',
+ },
+ {
+ from: 'test2',
+ to: 'value2',
+ },
+ {
+ from: 'content-type',
+ to: 'application/xml',
+ },
+ ],
+ },
+ DestinationDefinition: {
+ Config: {
+ cdkV2Enabled: true,
+ },
+ },
+ },
+ metadata: {
+ destinationId: 'destId',
+ workspaceId: 'wspId',
+ },
+ },
+ ],
+ },
+ },
+ output: {
+ response: {
+ status: 200,
+ body: [
+ {
+ output: {
+ body: {
+ JSON: {},
+ JSON_ARRAY: {},
+ XML: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1df16bffa-5c3d-4fbb-9bce-3bab098129a7RXiaomiRedmi 6xiaomiBanglalinkandroid8.1.0DhakaBangladeshc82cbdff-e5be-4009-ac78-cdeea09ab4b1spin_resulttruea80f82be-9bdc-4a9f-b2a5-15621ee41df80N/A9119466052CasinoGameModule0N/A0N/A30fireEagleBaseFireEagleSlots0HD2bf99787-33d2-4ae2-a76a-c49672f97252ReachableViaLocalAreaNetworkFalseFalseFalseFalseFalse90Silver601002019-08-010T1561970819c82cbdff-e5be-4009-ac78-cdeea09ab4b1202019-09-01T15:46:51.693229+05:30track9466052CasinoGameModule030FireEagleSlots0HD2bf99787-33d2-4ae2-a76a-c49672f97252ReachableViaLocalAreaNetworkfalse60002019-08-010c82cbdff-e5be-4009-ac78-cdeea09ab4b12',
+ FORM: {},
+ },
+ version: '1',
+ userId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1',
+ type: 'REST',
+ method: 'POST',
+ endpoint: 'http://6b0e6a60.ngrok.io',
+ headers: {
+ 'content-type': 'application/xml',
+ test2: 'value2',
+ },
+ params: {},
+ files: {},
+ },
+ metadata: {
+ destinationId: 'destId',
+ workspaceId: 'wspId',
+ },
+ statusCode: 200,
+ },
+ ],
+ },
+ },
+ mockFns: defaultMockFns,
+ },
+ {
+ name: 'webhook',
+ description:
+ 'Feature Flag is enabled for formatted body based on content-type | Content type: json',
+ feature: 'processor',
+ module: 'destination',
+ version: 'v0',
+ input: {
+ request: {
+ body: [
+ {
+ message: {
+ anonymousId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1',
+ context: {
+ device: {
+ id: 'df16bffa-5c3d-4fbb-9bce-3bab098129a7R',
+ manufacturer: 'Xiaomi',
+ model: 'Redmi 6',
+ name: 'xiaomi',
+ },
+ network: {
+ carrier: 'Banglalink',
+ },
+ os: {
+ name: 'android',
+ version: '8.1.0',
+ },
+ traits: {
+ address: {
+ city: 'Dhaka',
+ country: 'Bangladesh',
+ },
+ anonymousId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1',
+ },
+ },
+ event: 'spin_result',
+ integrations: {
+ All: true,
+ },
+ message_id: 'a80f82be-9bdc-4a9f-b2a5-15621ee41df8',
+ properties: {
+ additional_bet_index: 0,
+ battle_id: 'N/A',
+ bet_amount: 9,
+ bet_level: 1,
+ bet_multiplier: 1,
+ coin_balance: 9466052,
+ current_module_name: 'CasinoGameModule',
+ days_in_game: 0,
+ extra_param: 'N/A',
+ fb_profile: '0',
+ featureGameType: 'N/A',
+ game_fps: 30,
+ game_id: 'fireEagleBase',
+ game_name: 'FireEagleSlots',
+ gem_balance: 0,
+ graphicsQuality: 'HD',
+ idfa: '2bf99787-33d2-4ae2-a76a-c49672f97252',
+ internetReachability: 'ReachableViaLocalAreaNetwork',
+ isLowEndDevice: 'False',
+ is_auto_spin: 'False',
+ is_turbo: 'False',
+ isf: 'False',
+ ishighroller: 'False',
+ jackpot_win_amount: 90,
+ jackpot_win_type: 'Silver',
+ level: 6,
+ lifetime_gem_balance: 0,
+ no_of_spin: 1,
+ player_total_battles: 0,
+ player_total_shields: 0,
+ start_date: '2019-08-01',
+ total_payments: 0,
+ tournament_id: 'T1561970819',
+ userId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1',
+ versionSessionCount: 2,
+ win_amount: 0,
+ },
+ timestamp: '2019-09-01T15:46:51.693229+05:30',
+ type: 'track',
+ user_properties: {
+ coin_balance: 9466052,
+ current_module_name: 'CasinoGameModule',
+ fb_profile: '0',
+ game_fps: 30,
+ game_name: 'FireEagleSlots',
+ gem_balance: 0,
+ graphicsQuality: 'HD',
+ idfa: '2bf99787-33d2-4ae2-a76a-c49672f97252',
+ internetReachability: 'ReachableViaLocalAreaNetwork',
+ isLowEndDevice: false,
+ level: 6,
+ lifetime_gem_balance: 0,
+ player_total_battles: 0,
+ player_total_shields: 0,
+ start_date: '2019-08-01',
+ total_payments: 0,
+ userId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1',
+ versionSessionCount: 2,
+ },
+ },
+ destination: {
+ Config: {
+ webhookUrl: 'http://6b0e6a60.ngrok.io',
+ headers: [
+ {
+ from: '',
+ to: '',
+ },
+ {
+ from: 'test2',
+ to: 'value2',
+ },
+ {
+ from: 'content-type',
+ to: 'application/json',
+ },
+ ],
+ },
+ DestinationDefinition: {
+ Config: {
+ cdkV2Enabled: true,
+ },
+ },
+ },
+ metadata: {
+ destinationId: 'destId',
+ workspaceId: 'wspId',
+ },
+ },
+ ],
+ },
+ },
+ output: {
+ response: {
+ status: 200,
+ body: [
+ {
+ output: {
+ body: {
+ JSON: {
+ anonymousId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1',
+ context: {
+ device: {
+ id: 'df16bffa-5c3d-4fbb-9bce-3bab098129a7R',
+ manufacturer: 'Xiaomi',
+ model: 'Redmi 6',
+ name: 'xiaomi',
+ },
+ network: {
+ carrier: 'Banglalink',
+ },
+ os: {
+ name: 'android',
+ version: '8.1.0',
+ },
+ traits: {
+ address: {
+ city: 'Dhaka',
+ country: 'Bangladesh',
+ },
+ anonymousId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1',
+ },
+ },
+ event: 'spin_result',
+ integrations: {
+ All: true,
+ },
+ message_id: 'a80f82be-9bdc-4a9f-b2a5-15621ee41df8',
+ properties: {
+ additional_bet_index: 0,
+ battle_id: 'N/A',
+ bet_amount: 9,
+ bet_level: 1,
+ bet_multiplier: 1,
+ coin_balance: 9466052,
+ current_module_name: 'CasinoGameModule',
+ days_in_game: 0,
+ extra_param: 'N/A',
+ fb_profile: '0',
+ featureGameType: 'N/A',
+ game_fps: 30,
+ game_id: 'fireEagleBase',
+ game_name: 'FireEagleSlots',
+ gem_balance: 0,
+ graphicsQuality: 'HD',
+ idfa: '2bf99787-33d2-4ae2-a76a-c49672f97252',
+ internetReachability: 'ReachableViaLocalAreaNetwork',
+ isLowEndDevice: 'False',
+ is_auto_spin: 'False',
+ is_turbo: 'False',
+ isf: 'False',
+ ishighroller: 'False',
+ jackpot_win_amount: 90,
+ jackpot_win_type: 'Silver',
+ level: 6,
+ lifetime_gem_balance: 0,
+ no_of_spin: 1,
+ player_total_battles: 0,
+ player_total_shields: 0,
+ start_date: '2019-08-01',
+ total_payments: 0,
+ tournament_id: 'T1561970819',
+ userId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1',
+ versionSessionCount: 2,
+ win_amount: 0,
+ },
+ timestamp: '2019-09-01T15:46:51.693229+05:30',
+ type: 'track',
+ user_properties: {
+ coin_balance: 9466052,
+ current_module_name: 'CasinoGameModule',
+ fb_profile: '0',
+ game_fps: 30,
+ game_name: 'FireEagleSlots',
+ gem_balance: 0,
+ graphicsQuality: 'HD',
+ idfa: '2bf99787-33d2-4ae2-a76a-c49672f97252',
+ internetReachability: 'ReachableViaLocalAreaNetwork',
+ isLowEndDevice: false,
+ level: 6,
+ lifetime_gem_balance: 0,
+ player_total_battles: 0,
+ player_total_shields: 0,
+ start_date: '2019-08-01',
+ total_payments: 0,
+ userId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1',
+ versionSessionCount: 2,
+ },
+ },
+ JSON_ARRAY: {},
+ XML: {},
+ FORM: {},
+ },
+ version: '1',
+ userId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1',
+ type: 'REST',
+ method: 'POST',
+ endpoint: 'http://6b0e6a60.ngrok.io',
+ headers: {
+ 'content-type': 'application/json',
+ test2: 'value2',
+ },
+ params: {},
+ files: {},
+ },
+ metadata: {
+ destinationId: 'destId',
+ workspaceId: 'wspId',
},
statusCode: 200,
},
],
},
},
+ mockFns: defaultMockFns,
},
{
name: 'webhook',