forked from docusealco/docuseal
-
Notifications
You must be signed in to change notification settings - Fork 0
CP-12559 - Add Pendo integration partial #67
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <script> | ||
| (function(apiKey){ | ||
| (function(p,e,n,d,o){var v,w,x,y,z;o=p[d]=p[d]||{};o._q=[]; | ||
| v=['initialize','identify','updateOptions','pageLoad'];for(w=0,x=v.length;w<x;++w)(function(m){ | ||
| 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? %> | ||
| pendo.initialize({ | ||
| visitor: { id: '<%= current_user.external_user_id || current_user.id %>' }, | ||
| account: { id: '<%= current_account.external_account_id || current_account.id %>' } | ||
| }); | ||
| <% else %> | ||
| pendo.initialize({}); | ||
| <% end %> | ||
| })('<%= ENV.fetch('PENDO_API_KEY', nil) %>'); | ||
| </script> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,7 +94,7 @@ def generate_pdf_preview_images(attachment, data, pdf = nil) | |
| attachment.save! | ||
| end | ||
|
|
||
| generate_document_preview_images(attachment, data, (0..number_of_pages - 1)) | ||
| generate_document_preview_images(attachment, data, 0..number_of_pages - 1) | ||
|
Member
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. Was including this change intentional?
Collaborator
Author
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. Yeah, I was fixing a rubocop that was annoying me. |
||
| end | ||
|
|
||
| def generate_document_preview_images(attachment, data, range, concurrency: CONCURRENCY) | ||
|
|
@@ -196,6 +196,5 @@ def normalize_attachment_fields(template, attachments = template.documents) | |
| pdf_fields | ||
| end | ||
| end | ||
|
|
||
| end | ||
| end | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we actually
sign_into 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.
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.