Browse Source

Use content tracing after app ready

Kevin Sawicki 8 years ago
parent
commit
7b3e998cc6
1 changed files with 20 additions and 14 deletions
  1. 20 14
      docs/api/content-tracing.md

+ 20 - 14
docs/api/content-tracing.md

@@ -9,22 +9,28 @@ This module does not include a web interface so you need to open
 `chrome://tracing/` in a Chrome browser and load the generated file to view the
 result.
 
-```javascript
-const {contentTracing} = require('electron')
-
-const options = {
-  categoryFilter: '*',
-  traceOptions: 'record-until-full,enable-sampling'
-}
+**Note:** You should not use this module until the `ready` event of the app
+module is emitted.
 
-contentTracing.startRecording(options, () => {
-  console.log('Tracing started')
 
-  setTimeout(() => {
-    contentTracing.stopRecording('', (path) => {
-      console.log('Tracing data recorded to ' + path)
-    })
-  }, 5000)
+```javascript
+const {app, contentTracing} = require('electron')
+
+app.on('ready', () => {
+  const options = {
+    categoryFilter: '*',
+    traceOptions: 'record-until-full,enable-sampling'
+  }
+
+  contentTracing.startRecording(options, () => {
+    console.log('Tracing started')
+
+    setTimeout(() => {
+      contentTracing.stopRecording('', (path) => {
+        console.log('Tracing data recorded to ' + path)
+      })
+    }, 5000)
+  })
 })
 ```