Skip to content
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

fix: Conditionally check for PENDO_API_KEY before Pendo set up #11089

Merged

Conversation

mjac0bs
Copy link
Contributor

@mjac0bs mjac0bs commented Oct 10, 2024

Description 📝

We use an environment variable PENDO_API_KEY to load the Pendo agent. Without that API key present, we should not do any set up or loading of Pendo. (We handle Adobe Analytics in the same way -my mistake for missing it here.)

Changes 🔄

  • Adds a conditional check for PENDO_API_KEY in the usePendo hook to confirm the env var exists before attempting to load the pendo object on the window or make a request to the CDN for the Pendo agent
  • Gets rid of a console error

Target release date 🗓️

10/14/24 - this is pointed at the release branch because it needs to be included in the release.

Preview 📷

Before After
Screenshot 2024-10-10 at 3 39 44 PM Screenshot 2024-10-10 at 3 41 52 PM

How to test 🧪

Prerequisites

(How to setup test environment)

  • Comment out PENDO_API_KEY from your .env file.

Reproduction steps

(How to reproduce the issue, if applicable)

  • Check out the develop branch locally and, with the PENDO_API_KEY commented out in your .env, go to http://localhost:3000. Observe the browser console error above. In the Network tab, filter on "All" requests and keyword "pendo". Observe that a request was made to get the Pendo CDN, but it returned a 403 Unauthorized without the API key.

Verification steps

(How to verify changes)

  • Check out this branch and, with the PENDO_API_KEY commented out in your .env, go to http://localhost:3000.
  • Clear your Application storage. (If you don't do this, the API KEY can be cached there and the request to the CDN will still succeed.)
  • Observe there is no pendo-related browser console error (note: the visible console error in the screenshot is unrelated and preexisting). In the Network tab, observe that no request is made to the Pendo CDN. The usePendo.js requests are the only Pendo requests that should be visible.
  • Uncomment your commented out PENDO_API_KEY. Observe Pendo loads from the CDN as expected.

As an Author I have considered 🤔

Check all that apply

  • 👀 Doing a self review
  • ❔ Our contribution guidelines
  • 🤏 Splitting feature into small PRs
  • ➕ Adding a changeset - Note: not adding a changeset or update to the changelog for this one.
  • 🧪 Providing/Improving test coverage
  • 🔐 Removing all sensitive information from the code and PR description
  • 🚩 Using a feature flag to protect the release
  • 👣 Providing comprehensive reproduction steps
  • 📑 Providing or updating our documentation
  • 🕛 Scheduling a pair reviewing session
  • 📱 Providing mobile support
  • ♿ Providing accessibility support

@mjac0bs mjac0bs added Ready for Review Analytics Relating to Analytics migration project or Adobe Analytics labels Oct 10, 2024
@mjac0bs mjac0bs self-assigned this Oct 10, 2024
@mjac0bs mjac0bs requested a review from a team as a code owner October 10, 2024 22:58
@mjac0bs mjac0bs requested review from carrillo-erik and abailly-akamai and removed request for a team October 10, 2024 22:58
Copy link

Coverage Report:
Base Coverage: 86.97%
Current Coverage: 86.96%

@jdamore-linode
Copy link
Contributor

Nice, thanks @mjac0bs! Confirmed that the console errors no longer appear when the Pendo env var is absent at build time.

Copy link
Contributor

@abailly-akamai abailly-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

confirmed the fix toggling the env var ✅

Do we need a changeset for this?

@mjac0bs
Copy link
Contributor Author

mjac0bs commented Oct 11, 2024

Do we need a changeset for this?

Left a note in the PR description checklist but no, I don't think we need a changeset for this one, since it is essentially a one-line fix that should have been included in #10982 and is testable in the same way we test that PR.

@mjac0bs mjac0bs merged commit ab132d0 into linode:release-v1.130.0 Oct 11, 2024
23 checks passed
@mjac0bs mjac0bs added Approved Multiple approvals and ready to merge! and removed Ready for Review labels Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Analytics Relating to Analytics migration project or Adobe Analytics Approved Multiple approvals and ready to merge!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants