Skip to content

CP-12559 - Add Pendo integration partial#67

Merged
bernardodsanderson merged 2 commits into
mainfrom
CP-12559
Jun 2, 2026
Merged

CP-12559 - Add Pendo integration partial#67
bernardodsanderson merged 2 commits into
mainfrom
CP-12559

Conversation

@bernardodsanderson

Copy link
Copy Markdown
Collaborator

CP-12559

Overview

Add a new shared partial _pendo.html.erb that loads the Pendo agent script and initializes it with visitor and account data for signed-in users, or empty initialization for anonymous sessions.
The partial is conditionally rendered in the application layout when the PENDO_API_KEY environment variable is set.

Add a new shared partial `_pendo.html.erb` that loads the Pendo agent script
and initializes it with visitor and account data for signed-in users,
or empty initialization for anonymous sessions.
The partial is conditionally rendered in the application layout when
the `PENDO_API_KEY` environment variable is set.
Simplify the call to `generate_document_preview_images` by removing
unnecessary parentheses around the range literal. Also remove a trailing
blank line at the end of the file for consistent formatting.
o[m]=o[m]||function(){o._q[m===v[0]?'unshift':'push']([m].concat([].slice.call(arguments,0)));};})(v[w]);
y=e.createElement(n);y.async=!0;y.src='https://cdn.pendo.io/agent/static/'+apiKey+'/pendo.js';
z=e.getElementsByTagName(n)[0];z.parentNode.insertBefore(y,z);})(window,document,'script','pendo');
<% if signed_in? %>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we actually sign_in to Docuseal? Full disclosure: I am wholly ignorant here.

But since we iframe in everything and ping the app via API calls + tokens I assumed we didn't go through the regular auth process for Docuseal.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good question! Yeah they do, just not via the usual email/password.

When ATS iframes DocuSeal, it passes an auth_token in the URL. DocuSeal validates that token and signs the user in via Devise before any view renders, so by the time the layout loads, current_user and current_account are populated and signed_in? returns true.

The external_user_id and external_account_id fields on those records are how the ATS→DocuSeal mapping works (ATS user id and ATS account id respectively), which is what we use for the Pendo visitor/account ids so sessions stitch.

The else branch (pendo.initialize({})) is just a safety net for the edge case of someone hitting DocuSeal directly without going through the iframe. It lets Pendo still track anonymous sessions instead of erroring out when current_user is nil.

end

generate_document_preview_images(attachment, data, (0..number_of_pages - 1))
generate_document_preview_images(attachment, data, 0..number_of_pages - 1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Was including this change intentional?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I was fixing a rubocop that was annoying me.

@bernardodsanderson bernardodsanderson merged commit 2bac5bb into main Jun 2, 2026
4 of 5 checks passed
@bernardodsanderson bernardodsanderson deleted the CP-12559 branch June 2, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants