CP-12559 - Add Pendo integration partial#67
Conversation
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? %> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Was including this change intentional?
There was a problem hiding this comment.
Yeah, I was fixing a rubocop that was annoying me.
CP-12559
Overview
Add a new shared partial
_pendo.html.erbthat 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_KEYenvironment variable is set.