Skip to content

Commit 458d1a5

Browse files
ruifcnunesjoaoprcosta
authored andcommitted
feat(react): expose Vitorino network option
1 parent 075a1d4 commit 458d1a5

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

packages/react/src/analytics/integrations/Vitorino/Vitorino.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import isArray from 'lodash/isArray';
3939
*/
4040
export default class Vitorino extends integrations.Integration {
4141
/**
42-
* This integration is required, so it must be loaded indenpendently of user consent.
42+
* This integration is required, so it must be loaded independently of user consent.
4343
*
4444
* @returns {boolean} If the integration should load or not.
4545
*/
@@ -220,7 +220,7 @@ export default class Vitorino extends integrations.Integration {
220220
customerId: getCustomerIdFromUser(data.user),
221221
environment: getEnvironmentFromOptions(this.options),
222222
fields: this.getFieldsFromOptions(this.options),
223-
network: {
223+
network: this.options.network || {
224224
proxy: origin,
225225
path: `${MARKETING_API_PREFIX}${POST_TRACKINGS_PATHNAME}`,
226226
},
@@ -259,11 +259,11 @@ export default class Vitorino extends integrations.Integration {
259259
}
260260

261261
/**
262-
* Returns the correspondant Vitorino page type for the event.
262+
* Returns the correspondent Vitorino page type for the event.
263263
*
264264
* @param {string} event - The analytics event to filter by.
265-
266-
* @returns {string | Array} - The correspondant Vitorino's page view(s).
265+
266+
* @returns {string | Array} - The correspondent Vitorino's page view(s).
267267
*/
268268
getPageTypeFromEvent(event) {
269269
const mapper = this.getEventsMapper();

packages/react/src/analytics/integrations/Vitorino/__tests__/Vitorino.test.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,23 @@ describe('Vitorino', () => {
189189
});
190190
});
191191

192+
describe('Network option', () => {
193+
it('Should allow to pass a "network" object to pass a custom proxy to Vitorino', async () => {
194+
const customNetworkProxy = {
195+
proxy: 'https://johndoe.com',
196+
path: '/api',
197+
};
198+
await getIntegrationInstance({
199+
network: customNetworkProxy,
200+
});
201+
202+
expect(window.Vitorino.track).toHaveBeenCalledWith({
203+
...generateMockVitorinoPayload(),
204+
network: customNetworkProxy,
205+
});
206+
});
207+
});
208+
192209
describe('Script', () => {
193210
it('Should log an error if the development script is not present if the environment is dev', async () => {
194211
try {
@@ -220,7 +237,7 @@ describe('Vitorino', () => {
220237
// clean the body
221238
document.body.innerHTML = '';
222239

223-
// test the dev script with the implicit environment option without relying on the default behaviour
240+
// test the dev script with the implicit environment option without relying on the default behavior
224241
const devScriptSource = 'https://google.com/';
225242

226243
await getIntegrationInstance({

0 commit comments

Comments
 (0)