|
29 | 29 | // content.p = promise rejection |
30 | 30 | // content.f = function call the Sentry |
31 | 31 | if ( |
32 | | - (content.e || |
33 | | - content.p || |
| 32 | + ('e' in content || |
| 33 | + 'p' in content || |
34 | 34 | (content.f && content.f.indexOf('capture') > -1) || |
35 | 35 | (content.f && content.f.indexOf('showReportDialog') > -1)) && |
36 | 36 | lazy |
|
56 | 56 | // come out in the wrong order. Because of that we don't need async=1 as GA does. |
57 | 57 | // it was probably(?) a legacy behavior that they left to not modify few years old snippet |
58 | 58 | // https://www.html5rocks.com/en/tutorials/speed/script-loading/ |
59 | | - var _currentScriptTag = _document.getElementsByTagName(_script)[0]; |
| 59 | + var _currentScriptTag = _document.scripts[0]; |
60 | 60 | var _newScriptTag = _document.createElement(_script); |
61 | 61 | _newScriptTag.src = _sdkBundleUrl; |
62 | 62 | _newScriptTag.crossOrigin = 'anonymous'; |
|
68 | 68 | _window[_onerror] = _oldOnerror; |
69 | 69 | _window[_onunhandledrejection] = _oldOnunhandledrejection; |
70 | 70 |
|
| 71 | + // Add loader as SDK source |
| 72 | + _window.SENTRY_SDK_SOURCE = 'loader'; |
| 73 | + |
71 | 74 | var SDK = _window[_namespace]; |
72 | 75 |
|
73 | 76 | var oldInit = SDK.init; |
|
137 | 140 |
|
138 | 141 | // And now capture all previously caught exceptions |
139 | 142 | for (var i = 0; i < data.length; i++) { |
140 | | - if (data[i].e && tracekitErrorHandler) { |
| 143 | + if ('e' in data[i] && tracekitErrorHandler) { |
141 | 144 | tracekitErrorHandler.apply(_window, data[i].e); |
142 | | - } else if (data[i].p && tracekitUnhandledRejectionHandler) { |
| 145 | + } else if ('p' in data[i] && tracekitUnhandledRejectionHandler) { |
143 | 146 | tracekitUnhandledRejectionHandler.apply(_window, [data[i].p]); |
144 | 147 | } |
145 | 148 | } |
|
198 | 201 |
|
199 | 202 | // Do the same store/queue/call operations for `onunhandledrejection` event |
200 | 203 | var _oldOnunhandledrejection = _window[_onunhandledrejection]; |
201 | | - _window[_onunhandledrejection] = function(exception) { |
| 204 | + _window[_onunhandledrejection] = function(e) { |
202 | 205 | queue({ |
203 | | - p: exception.reason |
| 206 | + p: 'reason' in e ? e.reason : 'detail' in e && 'reason' in e.detail ? e.detail.reason : e |
204 | 207 | }); |
205 | 208 | if (_oldOnunhandledrejection) _oldOnunhandledrejection.apply(_window, arguments); |
206 | 209 | }; |
|
0 commit comments