docs(new): Adds TSDoc to Tracing class (#6088)
* Adds tsdoc to Tracing class * Updates tsdocs Co-authored-by: martinsplitt <martin@geekonaut.de>
This commit is contained in:
parent
60904da4cd
commit
a46c78fc91
@ -34,7 +34,7 @@
|
||||
| [Target](./puppeteer.target.md) | |
|
||||
| [TimeoutError](./puppeteer.timeouterror.md) | TimeoutError is emitted whenever certain operations are terminated due to timeout. |
|
||||
| [Touchscreen](./puppeteer.touchscreen.md) | The Touchscreen class exposes touchscreen events. |
|
||||
| [Tracing](./puppeteer.tracing.md) | |
|
||||
| [Tracing](./puppeteer.tracing.md) | The Tracing class exposes the tracing audit interface. |
|
||||
| [WebWorker](./puppeteer.webworker.md) | The WebWorker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API)<!-- -->. |
|
||||
|
||||
## Enumerations
|
||||
|
@ -1,20 +0,0 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [Tracing](./puppeteer.tracing.md) > [(constructor)](./puppeteer.tracing._constructor_.md)
|
||||
|
||||
## Tracing.(constructor)
|
||||
|
||||
Constructs a new instance of the `Tracing` class
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
constructor(client: CDPSession);
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| client | [CDPSession](./puppeteer.cdpsession.md) | |
|
||||
|
@ -4,17 +4,29 @@
|
||||
|
||||
## Tracing class
|
||||
|
||||
The Tracing class exposes the tracing audit interface.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare class Tracing
|
||||
```
|
||||
|
||||
## Constructors
|
||||
## Remarks
|
||||
|
||||
| Constructor | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [(constructor)(client)](./puppeteer.tracing._constructor_.md) | | Constructs a new instance of the <code>Tracing</code> class |
|
||||
You can use `tracing.start` and `tracing.stop` to create a trace file which can be opened in Chrome DevTools or [timeline viewer](https://chromedevtools.github.io/timeline-viewer/)<!-- -->.
|
||||
|
||||
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `Tracing` class.
|
||||
|
||||
## Example
|
||||
|
||||
|
||||
```js
|
||||
await page.tracing.start({path: 'trace.json'});
|
||||
await page.goto('https://www.google.com');
|
||||
await page.tracing.stop();
|
||||
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
@ -28,6 +40,6 @@ export declare class Tracing
|
||||
|
||||
| Method | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [start(options)](./puppeteer.tracing.start.md) | | |
|
||||
| [stop()](./puppeteer.tracing.stop.md) | | |
|
||||
| [start(options)](./puppeteer.tracing.start.md) | | Starts a trace for the current page. |
|
||||
| [stop()](./puppeteer.tracing.stop.md) | | Stops a trace started with the <code>start</code> method. |
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
## Tracing.start() method
|
||||
|
||||
Starts a trace for the current page.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
@ -14,9 +16,13 @@ start(options?: TracingOptions): Promise<void>;
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| options | TracingOptions | |
|
||||
| options | TracingOptions | Optional <code>TracingOptions</code>. |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
Promise<void>
|
||||
|
||||
## Remarks
|
||||
|
||||
Only one trace can be active at a time per browser.
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
## Tracing.stop() method
|
||||
|
||||
Stops a trace started with the `start` method.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
@ -13,3 +15,5 @@ stop(): Promise<Buffer>;
|
||||
|
||||
Promise<Buffer>
|
||||
|
||||
Promise which resolves to buffer with trace data.
|
||||
|
||||
|
@ -23,15 +23,37 @@ interface TracingOptions {
|
||||
categories?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* The Tracing class exposes the tracing audit interface.
|
||||
* @remarks
|
||||
* You can use `tracing.start` and `tracing.stop` to create a trace file
|
||||
* which can be opened in Chrome DevTools or {@link https://chromedevtools.github.io/timeline-viewer/ | timeline viewer}.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* await page.tracing.start({path: 'trace.json'});
|
||||
* await page.goto('https://www.google.com');
|
||||
* await page.tracing.stop();
|
||||
* ```
|
||||
*/
|
||||
export class Tracing {
|
||||
_client: CDPSession;
|
||||
_recording = false;
|
||||
_path = '';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor(client: CDPSession) {
|
||||
this._client = client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a trace for the current page.
|
||||
* @remarks
|
||||
* Only one trace can be active at a time per browser.
|
||||
* @param options - Optional `TracingOptions`.
|
||||
*/
|
||||
async start(options: TracingOptions = {}): Promise<void> {
|
||||
assert(
|
||||
!this._recording,
|
||||
@ -68,6 +90,10 @@ export class Tracing {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops a trace started with the `start` method.
|
||||
* @returns Promise which resolves to buffer with trace data.
|
||||
*/
|
||||
async stop(): Promise<Buffer> {
|
||||
let fulfill: (value: Buffer) => void;
|
||||
const contentPromise = new Promise<Buffer>((x) => (fulfill = x));
|
||||
|
Loading…
Reference in New Issue
Block a user