Skip to content

Commit

Permalink
DTPPSDK-1216: Add cookie disabling flag to logger call 🍪 (#156)
Browse files Browse the repository at this point in the history
* add disableSetCookie global variable

* add globals

* remove dist

* add query to logger

* make test global variable boolean

* change to camel case

---------

Co-authored-by: Spencer Sablan <[email protected]>
  • Loading branch information
spencersablan and Spencer Sablan authored Jun 12, 2023
1 parent dec994b commit db81201
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ module.exports = {
__FUNDING_ELIGIBILITY__: true,
__PAYPAL_DOMAIN__: true,
__PAYPAL_API_DOMAIN__: true,

// Experiment Variable
__DISABLE_SET_COOKIE__: true,
},
};
3 changes: 3 additions & 0 deletions src/declarations.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ declare var __COMPONENTS__: $ReadOnlyArray<$Values<typeof COMPONENTS>>;

// $FlowFixMe[value-as-type]
declare var __FUNDING_ELIGIBILITY__: FundingEligibilityType;

// Experiment Variable
declare var __DISABLE_SET_COOKIE__: boolean;
5 changes: 5 additions & 0 deletions src/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,8 @@ export function getFundingEligibility(): FundingEligibilityType {
export function getPlatform(): $Values<typeof PLATFORM> {
return isDevice() ? PLATFORM.MOBILE : PLATFORM.DESKTOP;
}

// Experiment Variable
export function getDisableSetCookie(): boolean {
return __DISABLE_SET_COOKIE__;
}
9 changes: 8 additions & 1 deletion src/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@
import { Logger, type LoggerType } from "@krakenjs/beaver-logger/src";
import { memoize } from "@krakenjs/belter/src";

import { getDisableSetCookie } from "./global";
import { getPayPalLoggerUrl } from "./domains";

type GetLogger = () => LoggerType;

const disableSetCookieQuery = "disableSetCookie=true";

const loggerUrl = getDisableSetCookie()
? `${getPayPalLoggerUrl()}?${disableSetCookieQuery}`
: getPayPalLoggerUrl();

export const getLogger: GetLogger = memoize(() => {
return Logger({
url: getPayPalLoggerUrl(),
url: loggerUrl,
});
});
3 changes: 2 additions & 1 deletion test/globals.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* @flow */

type TestGlobals = {|
[string]: string | number | (() => string | (() => number)),
[string]: string | number | boolean | (() => string | (() => number)),
__COMPONENTS__: $ReadOnlyArray<string>,
|};

Expand All @@ -19,4 +19,5 @@ export const sdkClientTestGlobals: TestGlobals = {
__PAYPAL_DOMAIN__: "mock://www.paypal.com",
__PAYPAL_API_DOMAIN__: "mock://msmaster.qa.paypal.com",
__COMPONENTS__: ["buttons"],
__DISABLE_SET_COOKIE__: true,
};

0 comments on commit db81201

Please sign in to comment.