Skip to content

Commit cecb69c

Browse files
authored
chore: cut release (#1122)
2 parents 96b5987 + cd05411 commit cecb69c

File tree

8 files changed

+8
-107
lines changed

8 files changed

+8
-107
lines changed

globals.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const PORT = process.env.PORT || 8080;
88
module.exports = (env = { TARGET: 'sdk' }) => ({
99
__DISABLE_SET_COOKIE__: false,
1010
__PAYPAL_DOMAIN__: 'https://www.paypal.com',
11-
__PAYPAL_API_DOMAIN__: 'https://api.paypal.com',
1211
__ZOID__: {
1312
...zoidGlobals.__ZOID__,
1413
__DEFAULT_CONTAINER__: true,
@@ -36,16 +35,11 @@ module.exports = (env = { TARGET: 'sdk' }) => ({
3635
__SANDBOX__: 'https://www.sandbox.paypal.com',
3736
__PRODUCTION__: 'https://www.paypal.com'
3837
},
39-
__API_DOMAIN__: {
40-
__LOCAL__: `https://localhost.paypal.com:${PORT}`,
41-
__SANDBOX__: 'https://api.sandbox.paypal.com',
42-
__PRODUCTION__: 'https://api.paypal.com'
43-
},
4438
__URI__: {
4539
__MESSAGE__: '/credit-presentment/smart/message',
4640
__TREATMENTS__: '/credit-presentment/experiments/local',
4741
__MODAL__: '/credit-presentment/smart/modal',
48-
__LOGGER__: '/v1/credit/upstream-messaging-events',
42+
__LOGGER__: '/credit-presentment/glog',
4943
__CREDIT_APPLY__: '/ppcreditapply/da/us'
5044
}
5145
}

src/utils/global.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import {
1010
getPageType,
1111
getPartnerAccount,
1212
getPayPalDomain,
13-
getScript,
14-
getPayPalAPIDomain
13+
getScript
1514
} from './sdk';
1615
import { createState } from './miscellaneous';
1716
import { ppDebug } from './debug';
@@ -75,16 +74,6 @@ export const createTitleGenerator = () => {
7574
export function getGlobalUrl(type) {
7675
return `${getPayPalDomain()}${__MESSAGES__.__URI__[`__${type.toUpperCase()}__`]}`;
7776
}
78-
79-
/**
80-
* Create an API URL of the requested type from Webpack global variables
81-
* @param {String} type URL type
82-
* @returns {String} URL of requested type
83-
*/
84-
export function getGlobalAPIUrl(type) {
85-
return `${getPayPalAPIDomain()}${__MESSAGES__.__URI__[`__${type.toUpperCase()}__`]}`;
86-
}
87-
8877
// Return a getter function as opposed to the value itself so that it can be lazy loaded within
8978
// the SDK lifecycle to guard against unintentionally using state from previous SDK instances
9079
export const createGlobalVariableGetter = (variable, fn) => () => {

src/utils/logger.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import arrayIncludes from 'core-js-pure/stable/array/includes';
55
import { Logger, LOG_LEVEL } from '@krakenjs/beaver-logger/src';
66
import { ZalgoPromise } from '@krakenjs/zalgo-promise/src';
77

8-
import { getGlobalAPIUrl } from './global';
8+
import { getGlobalUrl } from './global';
99
import { request } from './miscellaneous';
1010

1111
import { getLibraryVersion, getDisableSetCookie } from './sdk';
@@ -105,7 +105,7 @@ function generateLogPayload(account, { meta, events: bizEvents, tracking }) {
105105

106106
/**
107107
* Translate the meta, events, and tracking into payloads for the
108-
* endpoint `/v1/credit/upstream-messaging-events`
108+
* endpoint `/credit-presentment/glog`
109109
* @param {Object} data - the data the logger wishes to send
110110
* @param {Object} data.meta - the data the logger wishes to send
111111
* @param {Object[]} data.events - the data captured by logger.{debug|info|warn|error} calls
@@ -130,7 +130,7 @@ function translateLogData({ meta, events, tracking }) {
130130

131131
export const logger = Logger({
132132
// Url to send logs to
133-
url: getGlobalAPIUrl('LOGGER'),
133+
url: getGlobalUrl('LOGGER'),
134134
// Prefix to prepend to all events
135135
prefix: 'paypal_messages',
136136
// Log level to display in the browser console

src/utils/sdk.js

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -210,51 +210,6 @@ export const isScriptBeingDestroyed = () => {
210210
}
211211
};
212212

213-
export function getPayPalAPIDomain() {
214-
if (getEnv() !== 'production' && getEnv() !== 'sandbox') {
215-
const testEnviroment = window.__TEST_ENV__ ?? __MESSAGES__.__TEST_ENV__;
216-
217-
if (testEnviroment) {
218-
try {
219-
const url = new URL(testEnviroment);
220-
221-
// Check if the hostname starts with 'www.' and replace it with 'api.'
222-
if (url.hostname.startsWith('www.')) {
223-
url.hostname = url.hostname.replace('www.', 'api.');
224-
} else {
225-
// If 'www' is not part of the domain, prepend 'api.' directly
226-
url.hostname = `api.${url.hostname}`;
227-
}
228-
return url.pathname === '/' && !url.search ? url.origin : url.href;
229-
} catch (error) {
230-
return testEnviroment;
231-
}
232-
}
233-
234-
// eslint-disable-next-line security/detect-unsafe-regex
235-
if (window.location.origin.match(/\.paypal\.com(:\d+)?$/)) {
236-
return window.location.origin;
237-
}
238-
}
239-
240-
// Not using `getPayPalAPIDomain` function call here because it outputs 'cors.api.paypal.com'
241-
// The domain with prefixed 'cors' does not route to logging application.
242-
if (__MESSAGES__.__TARGET__ === 'SDK') {
243-
if (getEnv() === 'sandbox') {
244-
return 'https://api.sandbox.paypal.com';
245-
}
246-
return 'https://api.paypal.com';
247-
} else {
248-
const domain = __MESSAGES__.__API_DOMAIN__[`__${getEnv().toUpperCase()}__`];
249-
250-
if (domain) {
251-
return domain;
252-
}
253-
254-
throw new Error('Missing PayPal Domain');
255-
}
256-
}
257-
258213
export function getPayPalDomain() {
259214
if (getEnv() !== 'production' && getEnv() !== 'sandbox') {
260215
const testEnviroment = window.__TEST_ENV__ ?? __MESSAGES__.__TEST_ENV__;

tests/functional/spec/non-snapshot-tests/payload.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const createSpy = async () => {
1010
page.on('request', request => {
1111
const url = request.url();
1212
const postDataString = request.postData();
13-
if (url.includes('upstream-messaging-events') && postDataString) {
13+
if (url.includes('glog') && postDataString) {
1414
const postData = JSON.parse(postDataString);
1515

1616
const events = postData.data?.components.reduce((acc, component) => {

tests/unit/spec/src/utils/sdk.test.js

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getPayPalDomain, getPayPalAPIDomain, getDevTouchpoint, getFeatures } from '../../../../../src/utils/sdk';
1+
import { getPayPalDomain, getDevTouchpoint, getFeatures } from '../../../../../src/utils/sdk';
22

33
describe('getPayPalDomain', () => {
44
beforeEach(() => {
@@ -36,42 +36,6 @@ describe('getPayPalDomain', () => {
3636
});
3737
});
3838

39-
describe('getPayPalAPIDomain', () => {
40-
beforeEach(() => {
41-
// reset test variables
42-
window.__TEST_ENV__ = undefined;
43-
__ENV__ = 'stage';
44-
__MESSAGES__ = {
45-
__TEST_ENV__: undefined,
46-
__API_DOMAIN__: { __SANDBOX__: 'https://api.sandbox.com' }
47-
};
48-
});
49-
test('returns message test environment if window test environment is not set', () => {
50-
__MESSAGES__.__TEST_ENV__ = 'https://www.test-env.com';
51-
expect(getPayPalAPIDomain()).toBe('https://api.test-env.com');
52-
});
53-
test('returns window test environment if it is set', () => {
54-
__MESSAGES__.__TEST_ENV__ = 'https://www.test-env.com';
55-
window.__TEST_ENV__ = 'https://www.window-test-env.com';
56-
expect(getPayPalAPIDomain()).toBe('https://api.window-test-env.com');
57-
});
58-
test('returns sandbox domain if no test environment is set and env is sandbox', () => {
59-
__MESSAGES__.__TEST_ENV__ = 'https://www.test-env.com';
60-
window.__TEST_ENV__ = 'https://www.window-test-env.com';
61-
__ENV__ = 'sandbox';
62-
expect(getPayPalAPIDomain()).toBe('https://api.sandbox.com');
63-
});
64-
test('returns error if no test environment is set', () => {
65-
expect(() => getPayPalAPIDomain()).toThrow(Error);
66-
});
67-
test('returns stage domain if set via window test env global and env is stage', () => {
68-
__MESSAGES__.__TEST_ENV__ = 'https://www.stage.com';
69-
window.__TEST_ENV__ = 'https://www.stage.com';
70-
__ENV__ = 'stage';
71-
expect(getPayPalAPIDomain()).toBe('https://api.stage.com');
72-
});
73-
});
74-
7539
describe('getDevTouchpoint', () => {
7640
beforeEach(() => {
7741
// reset test variables

tests/unit/utils/setup.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const standaloneGlobals = globals({
77
});
88

99
standaloneGlobals.__MESSAGES__.__DOMAIN__.__TEST__ = 'http://localhost.paypal.com:8080';
10-
standaloneGlobals.__MESSAGES__.__API_DOMAIN__.__TEST__ = 'http://localhost.paypal.com:8080';
1110

1211
Object.assign(window, {
1312
__ENV__: 'test',

utils/devServerProxy/proxy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default (app, server, compiler) => {
55
createMessageRoutes(app, server, compiler);
66
createModalRoutes(app, server, compiler);
77

8-
app.post('/v1/credit/upstream-messaging-events', (req, res) => res.send(''));
8+
app.post('/credit-presentment/glog', (req, res) => res.send(''));
99

1010
app.get('/credit-presentment/experiments/hash', (req, res) => res.send('1daf92517fb7620b02add6943517ae0a5ca8f0a0'));
1111

0 commit comments

Comments
 (0)