Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[FPTI_KEY.SELLER_ID]: mID && mID[0],
[FPTI_KEY.SESSION_UID]: getSessionID(),
[FPTI_KEY.REFERER]: window.location.host,
[FPTI_KEY.LOCALE]: `${ lang }_${ country }`,
[FPTI_KEY.INTEGRATION_IDENTIFIER]: getClientID(),
[FPTI_KEY.PARTNER_ATTRIBUTION_ID]: getPartnerAttributionID(),
[FPTI_KEY.SDK_NAME]: FPTI_SDK_NAME.PAYMENTS_SDK,
[FPTI_KEY.SDK_VERSION]: getVersion(),
[FPTI_KEY.USER_AGENT]: window.navigator && window.navigator.userAgent,
[FPTI_KEY.USER_ACTION]: getCommit() ? FPTI_USER_ACTION.COMMIT : FPTI_USER_ACTION.CONTINUE,
[FPTI_KEY.CONTEXT_CORRID]: getCorrelationID(),
[FPTI_KEY.SDK_INTEGRATION_SOURCE]: getSDKIntegrationSource()
};
});
ZalgoPromise.onPossiblyUnhandledException(err => {
logger.track({
[FPTI_KEY.ERROR_CODE]: 'payments_sdk_error',
[FPTI_KEY.ERROR_DESC]: stringifyErrorMessage(err)
});
logger.error('unhandled_error', {
err: stringifyError(err)
});
// eslint-disable-next-line promise/no-promise-in-callback
logger.flush().catch(noop);
});
waitForWindowReady().then(() => {
const loadTime = getResourceLoadTime(getSDKScript().src);
logger.addPayloadBuilder(function () {
return {
referer: window.location.host,
uid: getSessionID(),
env: getEnv()
};
});
logger.addTrackingBuilder(function () {
var _ref;
return _ref = {}, _ref[FPTI_KEY.FEED] = FPTI_FEED.PAYMENTS_SDK, _ref[FPTI_KEY.DATA_SOURCE] = FPTI_DATA_SOURCE.PAYMENTS_SDK, _ref[FPTI_KEY.CLIENT_ID] = getClientID(), _ref[FPTI_KEY.SELLER_ID] = getMerchantID(), _ref[FPTI_KEY.SESSION_UID] = getSessionID(), _ref[FPTI_KEY.REFERER] = window.location.host, _ref[FPTI_KEY.LOCALE] = getLang() + '_' + getCountry(), _ref[FPTI_KEY.BUYER_COUNTRY] = getCountry(), _ref[FPTI_KEY.INTEGRATION_IDENTIFIER] = getClientID(), _ref[FPTI_KEY.PARTNER_ATTRIBUTION_ID] = getPartnerAttributionID(), _ref[FPTI_KEY.SDK_NAME] = FPTI_SDK_NAME.PAYMENTS_SDK, _ref[FPTI_KEY.SDK_VERSION] = getVersion(), _ref[FPTI_KEY.USER_AGENT] = window.navigator && window.navigator.userAgent, _ref[FPTI_KEY.USER_ACTION] = getCommit() ? FPTI_USER_ACTION.COMMIT : FPTI_USER_ACTION.CONTINUE, _ref[FPTI_KEY.CONTEXT_CORRID] = getCorrelationID(), _ref;
});
ZalgoPromise.onPossiblyUnhandledException(function (err) {
var _logger$track;
logger.track((_logger$track = {}, _logger$track[FPTI_KEY.ERROR_CODE] = 'checkoutjs_error', _logger$track[FPTI_KEY.ERROR_DESC] = stringifyErrorMessage(err), _logger$track));
logger.error('unhandled_error', {
stack: stringifyError(err),
errtype: {}.toString.call(err)
});
// eslint-disable-next-line promise/no-promise-in-callback
logger.flush()['catch'](noop);
});
}
/* @flow */
import { logger, FPTI_KEY } from 'paypal-braintree-web-client/src';
import { ZalgoPromise } from 'zalgo-promise/src';
import { stringifyError, stringifyErrorMessage, once } from 'belter/src';
import { CURRENT_ENV } from './globals';
import { checkForCommonErrors, isEligible, setupLogger } from './lib';
ZalgoPromise.onPossiblyUnhandledException(err => {
logger.error('unhandled_error', {
stack: stringifyError(err),
errtype: ({}).toString.call(err)
});
logger.track({
[ FPTI_KEY.ERROR_CODE ]: 'checkoutjs_error',
[ FPTI_KEY.ERROR_DESC ]: stringifyErrorMessage(err)
});
logger.flush();
});
export let setup = once(() => {
[FPTI_KEY.SESSION_UID]: sessionID,
[FPTI_KEY.REFERER]: window.location.host,
[FPTI_KEY.MERCHANT_DOMAIN]: merchantDomain,
[FPTI_KEY.LOCALE]: `${ lang }_${ country }`,
[FPTI_KEY.INTEGRATION_IDENTIFIER]: clientID,
[FPTI_KEY.PARTNER_ATTRIBUTION_ID]: partnerAttributionID,
[FPTI_KEY.SDK_NAME]: FPTI_SDK_NAME.PAYMENTS_SDK,
[FPTI_KEY.SDK_VERSION]: version,
[FPTI_KEY.USER_AGENT]: window.navigator && window.navigator.userAgent,
[FPTI_KEY.USER_ACTION]: commit ? FPTI_USER_ACTION.COMMIT : FPTI_USER_ACTION.CONTINUE,
[FPTI_KEY.CONTEXT_CORRID]: correlationID,
[FPTI_KEY.BUTTON_VERSION]: __SMART_BUTTONS__.__MINOR_VERSION__
};
});
ZalgoPromise.onPossiblyUnhandledException(err => {
logger.track({
[FPTI_KEY.ERROR_CODE]: 'payments_sdk_error',
[FPTI_KEY.ERROR_DESC]: stringifyErrorMessage(err)
});
logger.error('unhandled_error', {
err: stringifyError(err)
});
// eslint-disable-next-line promise/no-promise-in-callback
logger.flush().catch(noop);
});
}