Skip to content

Commit

Permalink
chore(release): pull hotfix-release/v1.71.2 into main (#3561)
Browse files Browse the repository at this point in the history
  • Loading branch information
krishna2020 authored Jul 15, 2024
2 parents 9ea8a35 + 211be3f commit 2b5cf4f
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 175 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [1.71.2](https://github.com/rudderlabs/rudder-transformer/compare/v1.71.1...v1.71.2) (2024-07-15)


### Bug Fixes

* add user-agent header in api calls ([53710f9](https://github.com/rudderlabs/rudder-transformer/commit/53710f91a94a631861512093a46acf97534eb607))

### [1.71.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.71.0...v1.71.1) (2024-07-10)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rudder-transformer",
"version": "1.71.1",
"version": "1.71.2",
"description": "",
"homepage": "https://github.com/rudderlabs/rudder-transformer#readme",
"bugs": {
Expand Down
2 changes: 2 additions & 0 deletions src/cdk/v2/destinations/intercom/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});

/**
Expand Down Expand Up @@ -218,6 +219,7 @@ const attachUserAndCompany = (message, Config) => {
Authorization: `Bearer ${Config.apiKey}`,
Accept: JSON_MIME_TYPE,
'Intercom-Version': '1.4',
'User-Agent': process.env.INTERCOM_USER_AGENT_HEADER ?? 'RudderStack',
};
response.body.JSON = requestBody;
response.userId = anonymousId;
Expand Down
1 change: 1 addition & 0 deletions src/cdk/v2/destinations/intercom/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ describe('getHeaders utility test', () => {
Authorization: `Bearer ${destination.Config.apiKey}`,
Accept: 'application/json',
'Intercom-Version': '2.10',
'User-Agent': 'RudderStack',
};
const headers = getHeaders(destination, 'v2');
expect(headers).toEqual(expectedHeaders);
Expand Down
41 changes: 38 additions & 3 deletions src/v0/destinations/intercom/networkHandler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { RetryableError } = require('@rudderstack/integrations-lib');
const { proxyRequest, prepareProxyRequest } = require('../../../adapters/network');
const { prepareProxyRequest, httpSend } = require('../../../adapters/network');
const { processAxiosResponse } = require('../../../adapters/utils/networkUtils');

const errorResponseHandler = (destinationResponse, dest) => {
Expand All @@ -23,12 +23,47 @@ const destResponseHandler = (responseParams) => {
};
};

const prepareIntercomProxyRequest = (request) => {
const { metadata } = request;
const preparedRequest = prepareProxyRequest(request);
preparedRequest.headers['User-Agent'] = process.env.INTERCOM_USER_AGENT_HEADER ?? 'RudderStack';
return { ...preparedRequest, metadata };
};

/**
* depricating: handles proxying requests to destinations from server, expects requsts in "defaultRequestConfig"
* note: needed for test api
* @param {*} request
* @returns
*/
const intercomProxyRequest = async (request) => {
const { endpoint, data, method, params, headers, metadata } =
prepareIntercomProxyRequest(request);

const requestOptions = {
url: endpoint,
data,
params,
headers,
method,
};
const response = await httpSend(requestOptions, {
destType: 'intercom',
feature: 'proxy',
endpointPath: '/proxy',
requestMethod: 'POST',
module: 'router',
metadata,
});
return response;
};

// eslint-disable-next-line @typescript-eslint/naming-convention
class networkHandler {
constructor() {
this.responseHandler = destResponseHandler;
this.proxy = proxyRequest;
this.prepareProxy = prepareProxyRequest;
this.proxy = intercomProxyRequest;
this.prepareProxy = prepareIntercomProxyRequest;
this.processAxiosResponse = processAxiosResponse;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ const commonHeaders = {
Authorization: 'Bearer testApiKey',
Accept: 'application/json',
'Intercom-Version': '1.4',
'User-Agent': 'RudderStack',
};

const unauthorizedResponseHeaders = {
'Content-Type': 'application/json',
Authorization: 'Bearer invalidApiKey',
Accept: 'application/json',
'Intercom-Version': '1.4',
'User-Agent': 'RudderStack',
};

const createUserPayload = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const commonHeaders = {
Authorization: 'Bearer testApiKey',
Accept: 'application/json',
'Intercom-Version': '1.4',
'User-Agent': 'RudderStack',
};

const createUserPayload = {
Expand Down
6 changes: 3 additions & 3 deletions test/integrations/destinations/intercom/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const v0VersionHeaders = {
Authorization: 'Bearer testApiKey',
Accept: 'application/json',
'Intercom-Version': '1.4',
'User-Agent': 'RudderLabs',
'User-Agent': 'RudderStack',
};

const v1VersionHeaders = {
'Content-Type': 'application/json',
Authorization: 'Bearer testApiKey',
Accept: 'application/json',
'Intercom-Version': '2.10',
'User-Agent': 'RudderLabs',
'User-Agent': 'RudderStack',
};

const userPayload = {
Expand Down Expand Up @@ -532,7 +532,7 @@ const deliveryCallsData = [
Authorization: 'Bearer invalidApiKey',
Accept: 'application/json',
'Intercom-Version': '1.4',
'User-Agent': 'RudderLabs',
'User-Agent': 'RudderStack',
},
method: 'POST',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ const v1Headers = {
Authorization: 'Bearer abcd=',
Accept: 'application/json',
'Intercom-Version': '1.4',
'User-Agent': 'RudderStack',
};

const v2Headers = {
Accept: 'application/json',
Authorization: 'Bearer testApiKey',
'Content-Type': 'application/json',
'Intercom-Version': '2.10',
'User-Agent': 'RudderStack',
};

const destination: Destination = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ const v2Headers = {
Authorization: 'Bearer testApiKey',
'Content-Type': 'application/json',
'Intercom-Version': '2.10',
'User-Agent': 'RudderStack',
};

const v1Headers = {
'Content-Type': 'application/json',
Authorization: 'Bearer intercomApiKey',
Accept: 'application/json',
'Intercom-Version': '1.4',
'User-Agent': 'RudderStack',
};

const destination: Destination = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ const v1Headers = {
Authorization: 'Bearer intercomApiKey',
Accept: 'application/json',
'Intercom-Version': '1.4',
'User-Agent': 'RudderStack',
};

const v2Headers = {
Accept: 'application/json',
Authorization: 'Bearer testApiKey',
'Content-Type': 'application/json',
'Intercom-Version': '2.10',
'User-Agent': 'RudderStack',
};

const destination: Destination = {
Expand Down
Loading

0 comments on commit 2b5cf4f

Please sign in to comment.