From 53710f91a94a631861512093a46acf97534eb607 Mon Sep 17 00:00:00 2001 From: Sai Sankeerth Date: Mon, 15 Jul 2024 15:33:30 +0530 Subject: [PATCH] fix: add user-agent header in api calls --- src/cdk/v2/destinations/intercom/utils.js | 1 + src/v0/destinations/intercom/networkHandler.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cdk/v2/destinations/intercom/utils.js b/src/cdk/v2/destinations/intercom/utils.js index 7e609d5c967..17606316837 100644 --- a/src/cdk/v2/destinations/intercom/utils.js +++ b/src/cdk/v2/destinations/intercom/utils.js @@ -78,6 +78,7 @@ const getHeaders = (destination, apiVersion) => ({ Authorization: `Bearer ${destination.Config.apiKey}`, Accept: JSON_MIME_TYPE, 'Intercom-Version': apiVersion === 'v1' ? '1.4' : '2.10', + 'User-Agent': process.env.INTERCOM_USER_AGENT_HEADER ?? 'RudderStack', }); /** diff --git a/src/v0/destinations/intercom/networkHandler.js b/src/v0/destinations/intercom/networkHandler.js index 8485dac52e9..76ba2c81b14 100644 --- a/src/v0/destinations/intercom/networkHandler.js +++ b/src/v0/destinations/intercom/networkHandler.js @@ -23,12 +23,18 @@ const destResponseHandler = (responseParams) => { }; }; +const prepareIntercomProxyRequest = (request) => { + const preparedRequest = prepareProxyRequest(request); + preparedRequest.headers['User-Agent'] = process.env.INTERCOM_USER_AGENT_HEADER ?? 'RudderStack'; + return preparedRequest; +}; + // eslint-disable-next-line @typescript-eslint/naming-convention class networkHandler { constructor() { this.responseHandler = destResponseHandler; this.proxy = proxyRequest; - this.prepareProxy = prepareProxyRequest; + this.prepareProxy = prepareIntercomProxyRequest; this.processAxiosResponse = processAxiosResponse; } }