@@ -26,12 +26,14 @@ Add this line in your HTML code, before `</head>` and replace `<my-api-key>` and
2626
2727``` HTML
2828<!-- 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 >
3030<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+ });
3537});
3638 </script >
3739```
@@ -60,17 +62,19 @@ Here are all the initialization options available:
6062
6163``` HTML
6264<!-- 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 >
6466<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+ });
7478});
7579 </script >
7680```
0 commit comments