Skip to content

Commit

Permalink
Skip the cookie check when running localhost
Browse files Browse the repository at this point in the history
  • Loading branch information
mjac0bs committed Jan 24, 2025
1 parent 625ea0b commit 9a7d51d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/manager/src/hooks/usePendo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,20 @@ export const usePendo = () => {
const visitorId = hashUniquePendoId(profile?.uid.toString());

const optanonCookie = getCookie('OptanonConsent');
const hasCookieConsent = checkOptanonConsent(
optanonCookie,
ONE_TRUST_COOKIE_CATEGORIES['Performance Cookies']
);
// Since OptanonConsent cookie always has a .linode.com domain, only check for consent in dev/staging/prod envs.
// When running the app locally, do not try to check for OneTrust cookie consent, just enable Pendo.
const hasConsentEnabled = !APP_ROOT.includes('localhost')
? checkOptanonConsent(
optanonCookie,
ONE_TRUST_COOKIE_CATEGORIES['Performance Cookies']
)
: true;

// This URL uses a Pendo-configured CNAME (M3-8742).
const PENDO_URL = `https://content.psp.cloud.linode.com/agent/static/${PENDO_API_KEY}/pendo.js`;

React.useEffect(() => {
if (PENDO_API_KEY && hasCookieConsent) {
if (PENDO_API_KEY && hasConsentEnabled) {
// Adapted Pendo install script for readability
// Refer to: https://support.pendo.io/hc/en-us/articles/21362607464987-Components-of-the-install-script#01H6S2EXET8C9FGSHP08XZAE4F

Expand Down Expand Up @@ -164,5 +168,5 @@ export const usePendo = () => {
});
});
}
}, [PENDO_URL, accountId, hasCookieConsent, visitorId]);
}, [PENDO_URL, accountId, hasConsentEnabled, visitorId]);
};

0 comments on commit 9a7d51d

Please sign in to comment.