From 5c981e12c8e203c80229881a07704c6413c842a9 Mon Sep 17 00:00:00 2001 From: Ujjwal Abhishek <63387036+ujjwal-ab@users.noreply.github.com> Date: Mon, 25 Sep 2023 19:10:55 +0530 Subject: [PATCH] feat: update google_cloud_function implementation as per custom destination (#2652) * feat: update google_cloud_function implementation as per custom destination flow * fix: remove old test suit --- .../google_cloud_function/config.js | 7 - .../google_cloud_function/transform.js | 16 +- .../google_cloud_function/util.js | 50 +- .../google_cloud_function_router_input.json | 170 ----- .../google_cloud_function_router_output.json | 55 -- test/__tests__/google_cloud_function.test.js | 27 - .../google_cloud_function/processor/data.ts | 185 +++++ .../google_cloud_function/router/data.ts | 652 ++++++++++++++++++ 8 files changed, 850 insertions(+), 312 deletions(-) delete mode 100644 src/v0/destinations/google_cloud_function/config.js delete mode 100644 test/__tests__/data/google_cloud_function_router_input.json delete mode 100644 test/__tests__/data/google_cloud_function_router_output.json delete mode 100644 test/__tests__/google_cloud_function.test.js create mode 100644 test/integrations/destinations/google_cloud_function/processor/data.ts create mode 100644 test/integrations/destinations/google_cloud_function/router/data.ts diff --git a/src/v0/destinations/google_cloud_function/config.js b/src/v0/destinations/google_cloud_function/config.js deleted file mode 100644 index 40efc2c04c..0000000000 --- a/src/v0/destinations/google_cloud_function/config.js +++ /dev/null @@ -1,7 +0,0 @@ -const TRIGGERTYPE = { - HTTP: 'http', - HTTPS: 'https', -}; -module.exports = { - TRIGGERTYPE, -}; diff --git a/src/v0/destinations/google_cloud_function/transform.js b/src/v0/destinations/google_cloud_function/transform.js index e2c01cd8bc..e74d539e3f 100644 --- a/src/v0/destinations/google_cloud_function/transform.js +++ b/src/v0/destinations/google_cloud_function/transform.js @@ -1,29 +1,19 @@ const _ = require('lodash'); const { - defaultRequestConfig, - defaultPostRequestConfig, getSuccessRespEvents, checkInvalidRtTfEvents, handleRtTfSingleEventError, } = require('../../util'); -const { generateBatchedPayload, validateDestinationConfig, addHeader } = require('./util'); +const { generateBatchedPayload, validateDestinationConfig } = require('./util'); // Main process Function to handle transformation function process(event) { const { message, destination } = event; - const { googleCloudFunctionUrl } = destination.Config; - // Config Validation validateDestinationConfig(destination); - const response = defaultRequestConfig(); - // adding header - addHeader(response, destination.Config); - response.method = defaultPostRequestConfig.requestMethod; - response.body.JSON = message; - response.endpoint = googleCloudFunctionUrl; - + const response = message; return response; } @@ -37,7 +27,7 @@ function batchEvents(successRespList, maxBatchSize = 10) { const batchEventResponse = generateBatchedPayload(chunk); batchedResponseList.push( getSuccessRespEvents( - batchEventResponse.batchedRequest, + batchEventResponse.message, batchEventResponse.metadata, batchEventResponse.destination, true, diff --git a/src/v0/destinations/google_cloud_function/util.js b/src/v0/destinations/google_cloud_function/util.js index 10c4365b77..0a4fb9f4de 100644 --- a/src/v0/destinations/google_cloud_function/util.js +++ b/src/v0/destinations/google_cloud_function/util.js @@ -1,77 +1,47 @@ -const { defaultBatchRequestConfig } = require('../../util'); -const { JSON_MIME_TYPE } = require('../../util/constant'); const { ConfigurationError } = require('../../util/errorTypes'); -const { TRIGGERTYPE } = require('./config'); - /** * validate destination config * @param {*} param0 */ const validateDestinationConfig = ({ Config }) => { - // throw error if google Cloud Function is not provided + // throw error if google Cloud Function URL is not provided if (!Config.googleCloudFunctionUrl) { throw new ConfigurationError('[GCF]:: Url not found. Aborting'); } - if ( - Config.triggerType === 'https' && // for triggerType https gcloud Authorization is mandatory - !Config.gcloudAuthorization - ) { - throw new ConfigurationError('[GCF]:: Access Token not found. Aborting'); + if (Config.requireAuthentication && !Config.credentials) { + throw new ConfigurationError( + '[GCF]:: Service Account credentials are required if your function required authentication. Aborting', + ); } }; -/** - * add headers in the payload that is provided in destination config - * @param {*} response - * @param {*} Config - */ -function addHeader(response, Config) { - const { triggerType, apiKeyId, gcloudAuthorization } = Config; - - response.headers = { 'content-type': JSON_MIME_TYPE }; - if (apiKeyId) { - const basicAuth = Buffer.from(`apiKey:${apiKeyId}`).toString('base64'); - response.headers.ApiKey = `Basic ${basicAuth}`; - } - if (TRIGGERTYPE.HTTPS === triggerType.toLowerCase()) { - response.headers.Authorization = `bearer ${gcloudAuthorization}`; - } -} - /** * Create GoogleCloudFunction Batch payload based on the passed events * @param {*} events * @returns */ + function generateBatchedPayload(events) { - const batchResponseList = []; const metadata = []; // extracting destination // from the first event in a batch const { destination } = events[0]; - const { googleCloudFunctionUrl } = destination.Config; - let batchEventResponse = defaultBatchRequestConfig(); + let batchEventResponse = events.map((event) => event.message); // Batch event into dest batch structure events.forEach((ev) => { - batchResponseList.push(ev.message.body.JSON); + // batchResponseList.push(ev.message.body.JSON); metadata.push(ev.metadata); }); - batchEventResponse.batchedRequest.body.JSON_ARRAY = { - batch: JSON.stringify(batchResponseList), - }; - batchEventResponse.batchedRequest.endpoint = googleCloudFunctionUrl; - addHeader(batchEventResponse.batchedRequest, destination.Config); batchEventResponse = { - ...batchEventResponse, - metadata, + message: batchEventResponse, destination, + metadata, }; return batchEventResponse; } module.exports = { validateDestinationConfig, - addHeader, generateBatchedPayload, }; diff --git a/test/__tests__/data/google_cloud_function_router_input.json b/test/__tests__/data/google_cloud_function_router_input.json deleted file mode 100644 index f3f829fdad..0000000000 --- a/test/__tests__/data/google_cloud_function_router_input.json +++ /dev/null @@ -1,170 +0,0 @@ -[ - { - "destination": { - "Config": { - "triggerType": "Http", - "apiKeyId": "randomAPI", - "enableBatchInput": true, - "googleCloudFunctionUrl": "https://us-central1-big-query-integration-poc.cloudfunctions.net/rudderv1", - "maxBatchSize": "2" - } - }, - "metadata": { - "jobId": "1" - }, - "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": "anon_id", - "type": "identify", - "traits": { - "email": "cosmo@krammer.com", - "name": "Cosmo Krammer", - "linkedinUrl": "https://linkedin.com/cosmo-krammer", - "location": "New York", - "emailOptOut": true, - "masterAvatarTypeCode": 10 - }, - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - }, - { - "destination": { - "Config": { - "triggerType": "Http", - "apiKeyId": "randomAPI", - "enableBatchInput": true, - "googleCloudFunctionUrl": "", - "maxBatchSize": "2" - } - }, - "metadata": { - "jobId": "2" - }, - "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": "anon_id", - "type": "identify", - "traits": { - "email": "cosmo@krammer.com", - "name": "Cosmo Krammer", - "linkedinUrl": "https://linkedin.com/cosmo-krammer", - "location": "New York", - "emailOptOut": true, - "masterAvatarTypeCode": 10 - }, - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - }, - { - "destination": { - "Config": { - "triggerType": "Http", - "apiKeyId": "randomAPI", - "enableBatchInput": true, - "googleCloudFunctionUrl": "https://us-central1-big-query-integration-poc.cloudfunctions.net/rudderv1", - "maxBatchSize": "2" - } - }, - "metadata": { - "jobId": "3" - }, - "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": "anon_id", - "type": "identify", - "traits": { - "email": "cosmo@krammer.com", - "name": "Cosmo Krammer", - "linkedinUrl": "https://linkedin.com/cosmo-krammer", - "location": "New York", - "emailOptOut": true, - "masterAvatarTypeCode": 10 - }, - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - } -] diff --git a/test/__tests__/data/google_cloud_function_router_output.json b/test/__tests__/data/google_cloud_function_router_output.json deleted file mode 100644 index 890cca7180..0000000000 --- a/test/__tests__/data/google_cloud_function_router_output.json +++ /dev/null @@ -1,55 +0,0 @@ -[ - { - "batchedRequest": { - "version": "1", - "type": "REST", - "method": "POST", - "endpoint": "https://us-central1-big-query-integration-poc.cloudfunctions.net/rudderv1", - "headers": { - "content-type": "application/json", - "ApiKey": "Basic YXBpS2V5OnJhbmRvbUFQSQ==" - }, - "params": {}, - "body": { - "JSON": {}, - "JSON_ARRAY": { - "batch": "[{\"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\":\"anon_id\",\"type\":\"identify\",\"traits\":{\"email\":\"cosmo@krammer.com\",\"name\":\"Cosmo Krammer\",\"linkedinUrl\":\"https://linkedin.com/cosmo-krammer\",\"location\":\"New York\",\"emailOptOut\":true,\"masterAvatarTypeCode\":10},\"integrations\":{\"All\":true},\"sentAt\":\"2019-10-14T09:03:22.563Z\"},{\"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\":\"anon_id\",\"type\":\"identify\",\"traits\":{\"email\":\"cosmo@krammer.com\",\"name\":\"Cosmo Krammer\",\"linkedinUrl\":\"https://linkedin.com/cosmo-krammer\",\"location\":\"New York\",\"emailOptOut\":true,\"masterAvatarTypeCode\":10},\"integrations\":{\"All\":true},\"sentAt\":\"2019-10-14T09:03:22.563Z\"}]" - }, - "XML": {}, - "FORM": {} - }, - "files": {} - }, - "metadata": [{ "jobId": "1" }, { "jobId": "3" }], - "batched": true, - "statusCode": 200, - "destination": { - "Config": { - "triggerType": "Http", - "apiKeyId": "randomAPI", - "enableBatchInput": true, - "googleCloudFunctionUrl": "https://us-central1-big-query-integration-poc.cloudfunctions.net/rudderv1", - "maxBatchSize": "2" - } - } - }, - { - "destination": { - "Config": { - "triggerType": "Http", - "apiKeyId": "randomAPI", - "enableBatchInput": true, - "googleCloudFunctionUrl": "", - "maxBatchSize": "2" - } - }, - "metadata": [{ "jobId": "2" }], - "batched": false, - "statusCode": 400, - "error": "[GCF]:: Url not found. Aborting", - "statTags": { - "errorCategory": "dataValidation", - "errorType": "configuration" - } - } -] diff --git a/test/__tests__/google_cloud_function.test.js b/test/__tests__/google_cloud_function.test.js deleted file mode 100644 index cec89300aa..0000000000 --- a/test/__tests__/google_cloud_function.test.js +++ /dev/null @@ -1,27 +0,0 @@ -const integration = "google_cloud_function"; -const name = "google_cloud_function"; - -const fs = require("fs"); -const path = require("path"); -const version = "v0"; - -const transformer = require(`../../src/${version}/destinations/${integration}/transform`); - -// Router Test Data -const inputRouterDataFile = fs.readFileSync( - path.resolve(__dirname, `./data/${integration}_router_input.json`) -); -const outputRouterDataFile = fs.readFileSync( - path.resolve(__dirname, `./data/${integration}_router_output.json`) -); -const inputRouterData = JSON.parse(inputRouterDataFile); -const expectedRouterData = JSON.parse(outputRouterDataFile); - -describe(`${name} Tests`, () => { - describe("Router Tests", () => { - it("Payload", async () => { - const routerOutput = await transformer.processRouterDest(inputRouterData); - expect(routerOutput).toEqual(expectedRouterData); - }); - }); -}); diff --git a/test/integrations/destinations/google_cloud_function/processor/data.ts b/test/integrations/destinations/google_cloud_function/processor/data.ts new file mode 100644 index 0000000000..87a4c5b7ec --- /dev/null +++ b/test/integrations/destinations/google_cloud_function/processor/data.ts @@ -0,0 +1,185 @@ +export const data = [ + { + name: 'google_cloud_function', + description: 'Successful request', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + functionEnvironment: 'gen1', + requireAuthentication: false, + enableBatchInput: false, + googleCloudFunctionUrl: + 'https://us-central1-big-query-integration-poc.cloudfunctions.net/rudderv1', + }, + }, + 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: 'anon_id', + type: 'identify', + traits: { + email: 'cosmo@krammer.com', + name: 'Cosmo Krammer', + linkedinUrl: 'https://linkedin.com/cosmo-krammer', + location: 'New York', + emailOptOut: true, + masterAvatarTypeCode: 10, + }, + integrations: { All: true }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + method: 'POST', + }, + pathSuffix: '', + }, + output: { + response: { + status: 200, + body: [ + { + output: { + 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: 'anon_id', + type: 'identify', + traits: { + email: 'cosmo@krammer.com', + name: 'Cosmo Krammer', + linkedinUrl: 'https://linkedin.com/cosmo-krammer', + location: 'New York', + emailOptOut: true, + masterAvatarTypeCode: 10, + }, + integrations: { All: true }, + sentAt: '2019-10-14T09:03:22.563Z', + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'google_cloud_function', + description: + '[GCF]:: Service Account credentials are required if your function required authentication. Aborting', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + functionEnvironment: 'gen1', + requireAuthentication: true, + enableBatchInput: false, + googleCloudFunctionUrl: + 'https://us-central1-big-query-integration-poc.cloudfunctions.net/rudderv1', + }, + }, + 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: 'anon_id', + type: 'identify', + traits: { + email: 'cosmo@krammer.com', + name: 'Cosmo Krammer', + linkedinUrl: 'https://linkedin.com/cosmo-krammer', + location: 'New York', + emailOptOut: true, + masterAvatarTypeCode: 10, + }, + integrations: { All: true }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + method: 'POST', + }, + pathSuffix: '', + }, + output: { + response: { + status: 200, + body: [ + { + error: + '[GCF]:: Service Account credentials are required if your function required authentication. Aborting', + statTags: { + destType: 'GOOGLE_CLOUD_FUNCTION', + errorCategory: 'dataValidation', + errorType: 'configuration', + feature: 'processor', + implementation: 'native', + module: 'destination', + }, + statusCode: 400, + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/google_cloud_function/router/data.ts b/test/integrations/destinations/google_cloud_function/router/data.ts new file mode 100644 index 0000000000..0661d4cb15 --- /dev/null +++ b/test/integrations/destinations/google_cloud_function/router/data.ts @@ -0,0 +1,652 @@ +export const data = [ + { + name: 'google_cloud_function', + description: 'Test 0', + feature: 'router', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + input: [ + { + destination: { + Config: { + triggerType: 'Http', + apiKeyId: 'randomAPI', + enableBatchInput: true, + googleCloudFunctionUrl: + 'https://us-central1-big-query-integration-poc.cloudfunctions.net/rudderv1', + maxBatchSize: '2', + }, + }, + metadata: { + jobId: '1', + }, + 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: 'anon_id', + type: 'identify', + traits: { + email: 'cosmo@krammer.com', + name: 'Cosmo Krammer', + linkedinUrl: 'https://linkedin.com/cosmo-krammer', + location: 'New York', + emailOptOut: true, + masterAvatarTypeCode: 10, + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + { + destination: { + Config: { + triggerType: 'Http', + apiKeyId: 'randomAPI', + enableBatchInput: true, + googleCloudFunctionUrl: '', + maxBatchSize: '2', + }, + }, + metadata: { + jobId: '2', + }, + 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: 'anon_id', + type: 'identify', + traits: { + email: 'cosmo@krammer.com', + name: 'Cosmo Krammer', + linkedinUrl: 'https://linkedin.com/cosmo-krammer', + location: 'New York', + emailOptOut: true, + masterAvatarTypeCode: 10, + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + { + destination: { + Config: { + triggerType: 'Http', + apiKeyId: 'randomAPI', + enableBatchInput: true, + googleCloudFunctionUrl: + 'https://us-central1-big-query-integration-poc.cloudfunctions.net/rudderv1', + maxBatchSize: '2', + }, + }, + metadata: { + jobId: '3', + }, + 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: 'anon_id', + type: 'identify', + traits: { + email: 'cosmo@krammer.com', + name: 'Cosmo Krammer', + linkedinUrl: 'https://linkedin.com/cosmo-krammer', + location: 'New York', + emailOptOut: true, + masterAvatarTypeCode: 10, + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + destType: 'google_cloud_function', + }, + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: [ + { + batchedRequest: [ + { + 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: 'anon_id', + type: 'identify', + traits: { + email: 'cosmo@krammer.com', + name: 'Cosmo Krammer', + linkedinUrl: 'https://linkedin.com/cosmo-krammer', + location: 'New York', + emailOptOut: true, + masterAvatarTypeCode: 10, + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + { + 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: 'anon_id', + type: 'identify', + traits: { + email: 'cosmo@krammer.com', + name: 'Cosmo Krammer', + linkedinUrl: 'https://linkedin.com/cosmo-krammer', + location: 'New York', + emailOptOut: true, + masterAvatarTypeCode: 10, + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + ], + metadata: [{ jobId: '1' }, { jobId: '3' }], + batched: true, + statusCode: 200, + destination: { + Config: { + triggerType: 'Http', + apiKeyId: 'randomAPI', + enableBatchInput: true, + googleCloudFunctionUrl: + 'https://us-central1-big-query-integration-poc.cloudfunctions.net/rudderv1', + maxBatchSize: '2', + }, + }, + }, + { + destination: { + Config: { + triggerType: 'Http', + apiKeyId: 'randomAPI', + enableBatchInput: true, + googleCloudFunctionUrl: '', + maxBatchSize: '2', + }, + }, + metadata: [{ jobId: '2' }], + batched: false, + statusCode: 400, + error: '[GCF]:: Url not found. Aborting', + statTags: { + destType: 'GOOGLE_CLOUD_FUNCTION', + errorCategory: 'dataValidation', + feature: 'router', + implementation: 'native', + module: 'destination', + errorType: 'configuration', + }, + }, + ], + }, + }, + }, + }, + { + name: 'google_cloud_function', + description: 'Test 0', + feature: 'router', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + input: [ + { + destination: { + Config: { + triggerType: 'Http', + apiKeyId: 'randomAPI', + enableBatchInput: true, + googleCloudFunctionUrl: + 'https://us-central1-big-query-integration-poc.cloudfunctions.net/rudderv1', + maxBatchSize: '2', + }, + }, + metadata: { + jobId: '1', + }, + 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: 'anon_id', + type: 'identify', + traits: { + email: 'cosmo@krammer.com', + name: 'Cosmo Krammer', + linkedinUrl: 'https://linkedin.com/cosmo-krammer', + location: 'New York', + emailOptOut: true, + masterAvatarTypeCode: 10, + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + { + destination: { + Config: { + triggerType: 'Http', + apiKeyId: 'randomAPI', + enableBatchInput: true, + googleCloudFunctionUrl: '', + maxBatchSize: '2', + }, + }, + metadata: { + jobId: '2', + }, + 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: 'anon_id', + type: 'identify', + traits: { + email: 'cosmo@krammer.com', + name: 'Cosmo Krammer', + linkedinUrl: 'https://linkedin.com/cosmo-krammer', + location: 'New York', + emailOptOut: true, + masterAvatarTypeCode: 10, + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + { + destination: { + Config: { + triggerType: 'Http', + apiKeyId: 'randomAPI', + enableBatchInput: true, + googleCloudFunctionUrl: + 'https://us-central1-big-query-integration-poc.cloudfunctions.net/rudderv1', + maxBatchSize: '2', + }, + }, + metadata: { + jobId: '3', + }, + 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: 'anon_id', + type: 'identify', + traits: { + email: 'cosmo@krammer.com', + name: 'Cosmo Krammer', + linkedinUrl: 'https://linkedin.com/cosmo-krammer', + location: 'New York', + emailOptOut: true, + masterAvatarTypeCode: 10, + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + destType: 'google_cloud_function', + }, + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: [ + { + batchedRequest: [ + { + 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: 'anon_id', + type: 'identify', + traits: { + email: 'cosmo@krammer.com', + name: 'Cosmo Krammer', + linkedinUrl: 'https://linkedin.com/cosmo-krammer', + location: 'New York', + emailOptOut: true, + masterAvatarTypeCode: 10, + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + { + 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: 'anon_id', + type: 'identify', + traits: { + email: 'cosmo@krammer.com', + name: 'Cosmo Krammer', + linkedinUrl: 'https://linkedin.com/cosmo-krammer', + location: 'New York', + emailOptOut: true, + masterAvatarTypeCode: 10, + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + ], + metadata: [{ jobId: '1' }, { jobId: '3' }], + batched: true, + statusCode: 200, + destination: { + Config: { + triggerType: 'Http', + apiKeyId: 'randomAPI', + enableBatchInput: true, + googleCloudFunctionUrl: + 'https://us-central1-big-query-integration-poc.cloudfunctions.net/rudderv1', + maxBatchSize: '2', + }, + }, + }, + { + destination: { + Config: { + triggerType: 'Http', + apiKeyId: 'randomAPI', + enableBatchInput: true, + googleCloudFunctionUrl: '', + maxBatchSize: '2', + }, + }, + metadata: [{ jobId: '2' }], + batched: false, + statusCode: 400, + error: '[GCF]:: Url not found. Aborting', + statTags: { + destType: 'GOOGLE_CLOUD_FUNCTION', + errorCategory: 'dataValidation', + feature: 'router', + implementation: 'native', + module: 'destination', + errorType: 'configuration', + }, + }, + ], + }, + }, + }, + }, +];