Added crossOrigin, onLoad, and onLoadFailed config options#675
Added crossOrigin, onLoad, and onLoadFailed config options#675fluidsonic wants to merge 4 commits intodevrnt:mainfrom
crossOrigin, onLoad, and onLoadFailed config options#675Conversation
🦋 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 |
devrnt
left a comment
There was a problem hiding this comment.
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.
Can you also copy and paste this in the other README?
| var l = function () { | ||
| setTimeout(function () { | ||
| var s = d.createElement('script'); | ||
| s.crossOrigin = crossOrigin; |
There was a problem hiding this comment.
| s.crossOrigin = crossOrigin; | |
| s.crossorigin = crossOrigin; |
| s.src = 'https://widget.intercom.io/widget/' + appId; | ||
| if (onLoad) { | ||
| s.addEventListener('load', () => { | ||
| onLoad(); |
| 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.
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.onLoadandonLoadFailedare called when the Messenger script is loaded successfully or not loaded successfully. That allows for