|
1 | 1 | // https://github.com/umdjs/umd/blob/master/templates/returnExportsGlobal.js
|
2 | 2 |
|
3 |
| -(function (root, factory) { |
| 3 | +(function(root, factory) { |
4 | 4 | if (typeof define === 'function' && define.amd) {
|
5 | 5 | // AMD. Register as an anonymous module.
|
6 |
| - define('raygun4js', function () { |
| 6 | + define('raygun4js', function() { |
7 | 7 | return (root.Raygun = factory());
|
8 | 8 | });
|
9 | 9 | } else if (typeof module === 'object' && module.exports) {
|
|
15 | 15 | // Browser globals
|
16 | 16 | root.Raygun = factory();
|
17 | 17 | }
|
18 |
| -}(this, function () { |
| 18 | +}(this, function() { |
19 | 19 |
|
20 |
| - var windw = this || window || global; |
21 |
| - var originalOnError = windw.onerror; |
22 |
| - windw.onerror = function (msg, url, line, col, err) { |
23 |
| - if (originalOnError) { |
24 |
| - originalOnError(msg, url, line, col, err); |
25 |
| - } |
| 20 | + var windw = this || window || global; |
| 21 | + var originalOnError = windw.onerror; |
| 22 | + windw.onerror = function(msg, url, line, col, err) { |
| 23 | + if (originalOnError) { |
| 24 | + originalOnError(msg, url, line, col, err); |
| 25 | + } |
26 | 26 |
|
27 |
| - if (!err) { |
28 |
| - err = new Error(msg); |
29 |
| - } |
| 27 | + if (!err) { |
| 28 | + err = new Error(msg); |
| 29 | + } |
| 30 | + |
| 31 | + windw['rg4js'].q = windw['rg4js'].q || []; |
| 32 | + windw['rg4js'].q.push({ e: err }); |
| 33 | + }; |
| 34 | + let isWindowLoaded = false; |
30 | 35 |
|
31 |
| - windw['rg4js'].q = windw['rg4js'].q || []; |
32 |
| - windw['rg4js'].q.push({e: err}); |
33 |
| - }; |
| 36 | + window.onload = function() { |
| 37 | + isWindowLoaded = true; |
| 38 | + }; |
| 39 | + // Similar approach as the snippet, creates the rg4js proxy function, which is exported in umd.outro.js once the |
| 40 | + // script is executed, and later overwritten by the loader once it's finished |
| 41 | + (function(wind) { |
| 42 | + wind['RaygunObject'] = 'rg4js'; |
| 43 | + wind[wind['RaygunObject']] = wind[wind['RaygunObject']] || function() { |
| 44 | + if (wind && typeof wind['Raygun'] === 'undefined' || |
| 45 | + (typeof document === 'undefined' || document.readyState !== 'complete') || (wind['RaygunInitialized'] || false) === false) { |
| 46 | + // onload hasn't been called, cache the commands just like the snippet |
| 47 | + (wind[wind['RaygunObject']].o = wind[wind['RaygunObject']].o || []).push(arguments) |
| 48 | + } else { |
| 49 | + // onload has been called and provider has executed, call the executor proxy function |
| 50 | + var test = wind[wind['RaygunObject']]; |
| 51 | + console.log(test); |
| 52 | + return wind[wind['RaygunObject']](arguments[0], arguments[1]); |
| 53 | + } |
34 | 54 |
|
35 |
| - // Similar approach as the snippet, creates the rg4js proxy function, which is exported in umd.outro.js once the |
36 |
| - // script is executed, and later overwritten by the loader once it's finished |
37 |
| - (function(wind) { wind['RaygunObject'] = 'rg4js'; |
38 |
| - wind[wind['RaygunObject']] = wind[wind['RaygunObject']] || function() { |
39 |
| - if (wind && typeof wind['Raygun'] === 'undefined' || |
40 |
| - (typeof document === 'undefined' || document.readyState !== 'complete')) { |
41 |
| - // onload hasn't been called, cache the commands just like the snippet |
42 |
| - (wind[wind['RaygunObject']].o = wind[wind['RaygunObject']].o || []).push(arguments) |
43 |
| - } else { |
44 |
| - // onload has been called and provider has executed, call the executor proxy function |
45 |
| - return wind[wind['RaygunObject']](arguments[0], arguments[1]); |
46 |
| - } |
47 |
| - |
48 |
| - }})(windw); |
| 55 | + } |
| 56 | + })(windw); |
0 commit comments