-
Notifications
You must be signed in to change notification settings - Fork 44
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
Added crossOrigin
, onLoad
, and onLoadFailed
config options
#675
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: e7954c5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Big thanks for all the work you did.
I've already quickly gone through your code. At this moment I can't tell yet when I'll do a thorough sweep and release it.
Can you also provide me some reference(s) where the (official) Intercom docs/forum mentions setting the crossorigin
attribute?
@@ -91,6 +91,9 @@ Place the `IntercomProvider` as high as possible in your application. This will | |||
| apiBase | string | If you need to route your Messenger requests through a different endpoint than the default. Generally speaking, this is not needed.<br/> Format: `https://${INTERCOM_APP_ID}.intercom-messenger.com` (See: [https://github.com/devrnt/react-use-intercom/pull/96](https://github.com/devrnt/react-use-intercom/pull/96)) | false | | |
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.
Can you also copy and paste this in the other README?
@@ -26,9 +35,21 @@ const initialize = (appId: string, timeout = 0) => { | |||
var l = function () { | |||
setTimeout(function () { | |||
var s = d.createElement('script'); | |||
s.crossOrigin = crossOrigin; |
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.
s.crossOrigin = crossOrigin; | |
s.crossorigin = crossOrigin; |
s.type = 'text/javascript'; | ||
s.async = true; | ||
s.src = 'https://widget.intercom.io/widget/' + appId; | ||
if (onLoad) { | ||
s.addEventListener('load', () => { | ||
onLoad(); |
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.
This can be undefined
right?
if (onLoadFailed) { | ||
s.addEventListener('error', () => { | ||
// No need to pass any information from the ErrorEvent because it will contain no information about the error. | ||
onLoadFailed(); |
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.
This can be also be undefined
right?
crossOrigin: "anonymous"
forces CORS when loading the Messenger script (<script crossOrigin="anonymous" …>
). That in turn allows the website/app to receive full error information if the Messenger script throws an error. That's important for error logging and follow-ups with Intercom's own support.onLoad
andonLoadFailed
are called when the Messenger script is loaded successfully or not loaded successfully. That allows for