-
Notifications
You must be signed in to change notification settings - Fork 368
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
change: [M3-8390] - Initialize Pendo on Cloud Manager #10982
Conversation
// Adapted Pendo install script for readability: | ||
|
||
// Set up Pendo namespace and queue | ||
const pendo = (window['pendo'] = window['pendo'] || {}); | ||
pendo._q = pendo._q || []; | ||
|
||
// Define the methods Pendo uses in a queue | ||
const methodNames = [ | ||
'initialize', | ||
'identify', | ||
'updateOptions', | ||
'pageLoad', | ||
'track', | ||
]; | ||
|
||
// Enqueue methods and their arguments on the Pendo object | ||
methodNames.forEach((_, index) => { | ||
(function (method) { | ||
pendo[method] = | ||
pendo[method] || | ||
function () { | ||
pendo._q[method === methodNames[0] ? 'unshift' : 'push']( | ||
// eslint-disable-next-line prefer-rest-params | ||
[method].concat([].slice.call(arguments, 0)) | ||
); | ||
}; | ||
})(methodNames[index]); | ||
}); |
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.
All this stuff is a slightly more readable version of the Pendo install script: https://support.pendo.io/hc/en-us/articles/21362607464987-Components-of-the-install-script.
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.
would we need to cite this in our code?
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 don't think we need to as far as Pendo is concerned, but it's good context to have, since we set this up in a way that is consistent with our repo, deconstructing a bit to make use of our loadScript function. I added a link to the Pendo doc in a comment in the code so it's not just ephemerally in this PR - good call out.
loadScript(PENDO_URL, { | ||
location: 'head', | ||
}).then(() => { | ||
window.pendo.initialize({ |
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 left the commented-out sections for reference.
|
||
declare global { | ||
interface Window { | ||
pendo: any; |
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.
Unfortunately, Pendo docs recommend typing this as any
.
Coverage Report: ❌ |
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.
Script initialization looks good. Didn't 👁️ any issues
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.
✅ confirmed pendo.validateEnvironment()
✅ confirmed no sensitive data is sent to Pendo
thanks Mariah! 🎉
Going to go ahead and merge this because CI was passing last week and today's updates shouldn't have impacted that; CI is just having known issues today. |
* Save work * Adapt install script and get usePendo hook working * Clean up logging * Add sha256 hashing for ids * Clean up for readability * Sanitize the URLs * Add env var to .env.example * Added changeset: Add Pendo to Cloud Manager * Make IDs unique in multiple environments * Address feedback: add auth matching to regex * Address feedback: reference link in code comment for context
Description 📝
This PR adds Pendo to Cloud Manager by adding the Pendo agent script from the CDN and initializing Pendo with some custom configurations.
Changes 🔄
js-sha256
usePendo
hookloadScript
App.tsx
with the rest of the GlobalListenersTarget release date 🗓️
10/14/24
How to test 🧪
Prerequisites
(How to setup test environment)
.env
, add the Pendo API Key. This is not a secret key; it will be visible in the browser dev tools, but we also want to be able to stop Pendo from running using an environment variable, which will live elsewhere with our env var configurations. See the internal repo (PR 167) for that change and the API key.Verification steps
(How to verify changes)
pendo.validateEnvironment()
. This should output some data, including your hashed visitor and account id.pendo
in the Network tab of the browser dev tools.normalizedUrl
of the requests:linodes/123
should be truncated tolinodes/
)Example:
![image](https://private-user-images.githubusercontent.com/114685994/369549003-f03dc759-9a1e-486c-84fc-f36d47dd6789.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMjY3NzksIm5iZiI6MTczOTMyNjQ3OSwicGF0aCI6Ii8xMTQ2ODU5OTQvMzY5NTQ5MDAzLWYwM2RjNzU5LTlhMWUtNDg2Yy04NGZjLWYzNmQ0N2RkNjc4OS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMlQwMjE0MzlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04Y2NkYjM0MDNmMDk3MDlhMDRmMmExNTBkZWNkM2NmZGU5NTI1NGE2MjY1YmQzMWM5N2Q3M2UyY2M1ZDU5MmMyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.efEqPl-ybc-0eRY7oB8j_8xEJvbhUg1jO0V9PPX2XU8)
As an Author I have considered 🤔
Check all that apply