`tracing._export({ path })` exports current tracing state into a file
and does not require tracing to be stopped.
`tracing._reset()` resets current tracing state, but keeps resources
around so they can be referenced in the future snapshots. Does not stop.
The usage pattern is:
```js
await tracing.start({ screenshots: true, snapshots: true });
// ...
await tracing._reset();
// Do stuff, it will all be in the export below.
await tracing._export({ path });
// ...
await tracing.stop();
```
65 lines
1.7 KiB
TypeScript
65 lines
1.7 KiB
TypeScript
/**
|
|
* Copyright (c) Microsoft Corporation.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import { CallMetadata } from '../../instrumentation';
|
|
import { FrameSnapshot, ResourceSnapshot } from '../../snapshot/snapshotTypes';
|
|
import { BrowserContextOptions } from '../../types';
|
|
|
|
export type ContextCreatedTraceEvent = {
|
|
version: number,
|
|
type: 'context-options',
|
|
browserName: string,
|
|
options: BrowserContextOptions
|
|
};
|
|
|
|
export type ScreencastFrameTraceEvent = {
|
|
type: 'screencast-frame',
|
|
pageId: string,
|
|
sha1: string,
|
|
width: number,
|
|
height: number,
|
|
timestamp: number,
|
|
};
|
|
|
|
export type ActionTraceEvent = {
|
|
type: 'action' | 'event',
|
|
hasSnapshot: boolean,
|
|
metadata: CallMetadata,
|
|
};
|
|
|
|
export type ResourceSnapshotTraceEvent = {
|
|
type: 'resource-snapshot',
|
|
snapshot: ResourceSnapshot,
|
|
};
|
|
|
|
export type FrameSnapshotTraceEvent = {
|
|
type: 'frame-snapshot',
|
|
snapshot: FrameSnapshot,
|
|
};
|
|
|
|
export type MarkerTraceEvent = {
|
|
type: 'marker',
|
|
resetIndex?: number,
|
|
};
|
|
|
|
export type TraceEvent =
|
|
ContextCreatedTraceEvent |
|
|
ScreencastFrameTraceEvent |
|
|
ActionTraceEvent |
|
|
ResourceSnapshotTraceEvent |
|
|
FrameSnapshotTraceEvent |
|
|
MarkerTraceEvent;
|