@@ -26,12 +26,14 @@ Add this line in your HTML code, before `</head>` and replace `<my-api-key>` and
26
26
27
27
``` HTML
28
28
<!-- Warning: This is an experimental library, do not use it on production environments -->
29
- <script src =" https://cdn.rawgit.com/GoogleCloudPlatform/stackdriver-errors-js/v0.2.0/dist/stackdriver-errors-concat.min.js" ></script >
29
+ <script defer src =" https://cdn.rawgit.com/GoogleCloudPlatform/stackdriver-errors-js/v0.2.0/dist/stackdriver-errors-concat.min.js" ></script >
30
30
<script type =" text/javascript" >
31
- var errorHandler = new StackdriverErrorReporter ();
32
- errorHandler .start ({
33
- key: ' <my-api-key>' ,
34
- projectId: ' <my-project-id>'
31
+ window .addEventListener (' DOMContentLoaded' , function () {
32
+ var errorHandler = new StackdriverErrorReporter ();
33
+ errorHandler .start ({
34
+ key: ' <my-api-key>' ,
35
+ projectId: ' <my-project-id>'
36
+ });
35
37
});
36
38
</script >
37
39
```
@@ -60,17 +62,19 @@ Here are all the initialization options available:
60
62
61
63
``` HTML
62
64
<!-- Warning: This is an experimental library -->
63
- <script src =" node_modules/stackdriver-errors-js/dist/stackdriver-errors-concat.min.js" ></script >
65
+ <script defer src =" node_modules/stackdriver-errors-js/dist/stackdriver-errors-concat.min.js" ></script >
64
66
<script type =" text/javascript" >
65
- var errorHandler = new StackdriverErrorReporter ();
66
- errorHandler .start ({
67
- key: ' <my-api-key>' ,
68
- projectId: ' <my-project-id>' ,
69
- service: ' <my-service>' , // (optional)
70
- version: ' <my-service-version>' , // (optional)
71
- // reportUncaughtExceptions: false // (optional) Set to false to stop reporting unhandled exceptions.
72
- // disabled: true // (optional) Set to true to not report errors when calling report(), this can be used when developping locally.
73
- // context: {user: 'user1'} // (optional) You can set the user later using setUser()
67
+ window .addEventListener (' DOMContentLoaded' , function () {
68
+ var errorHandler = new StackdriverErrorReporter ();
69
+ errorHandler .start ({
70
+ key: ' <my-api-key>' ,
71
+ projectId: ' <my-project-id>' ,
72
+ service: ' <my-service>' , // (optional)
73
+ version: ' <my-service-version>' , // (optional)
74
+ // reportUncaughtExceptions: false // (optional) Set to false to stop reporting unhandled exceptions.
75
+ // disabled: true // (optional) Set to true to not report errors when calling report(), this can be used when developping locally.
76
+ // context: {user: 'user1'} // (optional) You can set the user later using setUser()
77
+ });
74
78
});
75
79
</script >
76
80
```
0 commit comments