-
Notifications
You must be signed in to change notification settings - Fork 380
change: [M3-9347] - Switch to self hosting Pendo agent in Adobe Launch #12203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5a37c91
a3bda2e
1872663
717de14
c67870a
c152e98
ac82434
51ae005
3ecafeb
6b29c12
5905509
240384c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Changed | ||
--- | ||
|
||
Switch to self-hosting the Pendo agent with Adobe Launch ([#12203](https://github.com/linode/manager/pull/12203)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Fixed | ||
--- | ||
|
||
Bug in loadScript function not resolving promise if script already existed ([#12203](https://github.com/linode/manager/pull/12203)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Fixed | ||
--- | ||
|
||
Bug where first pageview of landing page was not fired in Adobe Analytics ([#12203](https://github.com/linode/manager/pull/12203)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,8 @@ import { useAccount, useProfile } from '@linode/queries'; | |
import { loadScript } from '@linode/utilities'; // `loadScript` from `useScript` hook | ||
import React from 'react'; | ||
|
||
import { APP_ROOT, PENDO_API_KEY } from 'src/constants'; | ||
import { | ||
checkOptanonConsent, | ||
getCookie, | ||
ONE_TRUST_COOKIE_CATEGORIES, | ||
} from 'src/utilities/analytics/utils'; | ||
import { ADOBE_ANALYTICS_URL, APP_ROOT, PENDO_API_KEY } from 'src/constants'; | ||
import { reportException } from 'src/exceptionReporting'; | ||
|
||
declare global { | ||
interface Window { | ||
|
@@ -70,21 +66,8 @@ export const usePendo = () => { | |
const accountId = getUniquePendoId(account?.euuid); | ||
const visitorId = getUniquePendoId(profile?.uid.toString()); | ||
|
||
const optanonCookie = getCookie('OptanonConsent'); | ||
// 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'] | ||
); | ||
|
||
// 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 && hasConsentEnabled) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's an explanation of why PR preview links aren't initializing Pendo correctly before this PR's changes:
|
||
if (PENDO_API_KEY && ADOBE_ANALYTICS_URL) { | ||
// Adapted Pendo install script for readability | ||
// Refer to: https://support.pendo.io/hc/en-us/articles/21362607464987-Components-of-the-install-script#01H6S2EXET8C9FGSHP08XZAE4F | ||
|
||
|
@@ -115,54 +98,61 @@ export const usePendo = () => { | |
})(methodNames[index]); | ||
}); | ||
|
||
// Load Pendo script into the head HTML tag, then initialize Pendo with metadata | ||
loadScript(PENDO_URL, { | ||
// Ensure the Adobe Launch script is loaded, then initialize Pendo with metadata | ||
loadScript(ADOBE_ANALYTICS_URL, { | ||
location: 'head', | ||
}).then(() => { | ||
window.pendo.initialize({ | ||
account: { | ||
id: accountId, // Highly recommended, required if using Pendo Feedback | ||
// name: // Optional | ||
// is_paying: // Recommended if using Pendo Feedback | ||
// monthly_value:// Recommended if using Pendo Feedback | ||
// planLevel: // Optional | ||
// planPrice: // Optional | ||
// creationDate: // Optional | ||
|
||
// You can add any additional account level key-values here, | ||
// as long as it's not one of the above reserved names. | ||
}, | ||
// Controls what URLs we send to Pendo. Refer to: https://agent.pendo.io/advanced/location/. | ||
location: { | ||
transforms: [ | ||
{ | ||
action: 'Clear', | ||
attr: 'hash', | ||
}, | ||
{ | ||
action: 'Clear', | ||
attr: 'search', | ||
}, | ||
{ | ||
action: 'Replace', | ||
attr: 'pathname', | ||
data(url: string) { | ||
return transformUrl(url); | ||
try { | ||
window.pendo.initialize({ | ||
account: { | ||
id: accountId, // Highly recommended, required if using Pendo Feedback | ||
// name: // Optional | ||
// is_paying: // Recommended if using Pendo Feedback | ||
// monthly_value:// Recommended if using Pendo Feedback | ||
// planLevel: // Optional | ||
// planPrice: // Optional | ||
// creationDate: // Optional | ||
|
||
// You can add any additional account level key-values here, | ||
// as long as it's not one of the above reserved names. | ||
}, | ||
// Controls what URLs we send to Pendo. Refer to: https://agent.pendo.io/advanced/location/. | ||
location: { | ||
transforms: [ | ||
{ | ||
action: 'Clear', | ||
attr: 'hash', | ||
}, | ||
{ | ||
action: 'Clear', | ||
attr: 'search', | ||
}, | ||
{ | ||
action: 'Replace', | ||
attr: 'pathname', | ||
data(url: string) { | ||
return transformUrl(url); | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
visitor: { | ||
id: visitorId, // Required if user is logged in | ||
// email: // Recommended if using Pendo Feedback, or NPS Email | ||
// full_name: // Recommended if using Pendo Feedback | ||
// role: // Optional | ||
|
||
// You can add any additional visitor level key-values here, | ||
// as long as it's not one of the above reserved names. | ||
}, | ||
}); | ||
], | ||
}, | ||
visitor: { | ||
id: visitorId, // Required if user is logged in | ||
// email: // Recommended if using Pendo Feedback, or NPS Email | ||
// full_name: // Recommended if using Pendo Feedback | ||
// role: // Optional | ||
|
||
// You can add any additional visitor level key-values here, | ||
// as long as it's not one of the above reserved names. | ||
}, | ||
}); | ||
} catch (error) { | ||
reportException( | ||
'An error occurred when trying to initialize Pendo.', | ||
{ error } | ||
); | ||
} | ||
}); | ||
} | ||
}, [PENDO_URL, accountId, hasConsentEnabled, visitorId]); | ||
}, [accountId, visitorId]); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious as to why the first page view was not being sent through the useEffect below this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, good question. history.listen only fires when the location changes, and when the user first loads the app, the location hasn't changed.