Skip to content

Commit bb656b7

Browse files
committed
collect jank test-app metrics with sentry included
1 parent 55f0a1e commit bb656b7

File tree

6 files changed

+66
-7
lines changed

6 files changed

+66
-7
lines changed

packages/replay/metrics/configs/dev/collect.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { Metrics, MetricsCollector } from '../../src/collector.js';
2-
import { JankTestScenario, LoadPageScenario } from '../../src/scenarios.js';
2+
import { JankTestScenario } from '../../src/scenarios.js';
33
import { latestResultFile } from './env.js';
44

55
const collector = new MetricsCollector();
66
const result = await collector.execute({
77
name: 'dummy',
8-
a: new JankTestScenario(),
9-
b: new LoadPageScenario('https://developers.google.com/web/'),
8+
a: new JankTestScenario(false),
9+
b: new JankTestScenario(true),
1010
runs: 1,
1111
tries: 1,
1212
async test(_aResults: Metrics[], _bResults: Metrics[]) {

packages/replay/metrics/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"type": "module",
88
"scripts": {
99
"build": "tsc",
10+
"deps": "yarn --cwd ../ build:bundle && yarn --cwd ../../tracing/ build:bundle",
1011
"dev:collect": "ts-node-esm ./configs/dev/collect.ts",
1112
"dev:process": "ts-node-esm ./configs/dev/process.ts"
1213
},

packages/replay/metrics/src/scenarios.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ export class LoadPageScenario implements Scenario {
3333

3434
// Loads test-apps/jank/ as a page source & waits for a short time before quitting.
3535
export class JankTestScenario implements Scenario {
36+
public constructor(private withSentry: boolean) { }
37+
3638
public async run(_: puppeteer.Browser, page: puppeteer.Page): Promise<void> {
37-
const url = path.resolve('./test-apps/jank/index.html');
39+
const url = path.resolve('./test-apps/jank/' + (this.withSentry ? 'with-sentry' : 'index') + '.html');
3840
assert(fs.existsSync(url));
3941
await page.goto(url, { waitUntil: 'load', timeout: 60000 });
4042
await new Promise(resolve => setTimeout(resolve, 5000));

packages/replay/metrics/test-apps/jank/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* See the License for the specific language governing permissions and
1313
* limitations under the License. */
1414

15-
(function(window) {
15+
document.addEventListener("DOMContentLoaded", function() {
1616
'use strict';
1717

1818
var app = {},
@@ -168,4 +168,4 @@
168168
window.app = app;
169169
frame = window.requestAnimationFrame(app.update);
170170

171-
})(window);
171+
});

packages/replay/metrics/test-apps/jank/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<title>Janky Animation</title>
2525
<meta name="viewport" content="width=device-width, initial-scale=1">
2626
<link rel="stylesheet" type="text/css" href="styles.css" />
27-
<script src="app.js" async></script>
27+
<script src="app.js"></script>
2828
</head>
2929

3030
<body>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!--
2+
Copyright 2016 Google Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<!-- referenced in: https://developers.google.com/web/tools/chrome-devtools/evaluate-performance/ -->
18+
19+
<!doctype html>
20+
<html>
21+
22+
<head>
23+
<link rel="shortcut icon" href="favicon-96x96.png" />
24+
<title>Janky Animation</title>
25+
<meta name="viewport" content="width=device-width, initial-scale=1">
26+
<link rel="stylesheet" type="text/css" href="styles.css" />
27+
28+
<script src="app.js"></script>
29+
<script src="../../../../tracing/build/bundles/bundle.tracing.min.js"></script>
30+
<script src="../../../build/bundles/replay.min.js"></script>
31+
<script type="text/javascript">
32+
Sentry.init({
33+
dsn: "https://[email protected]/5429213",
34+
replaysSessionSampleRate: 1.0,
35+
replaysOnErrorSampleRate: 1.0,
36+
integrations: [
37+
new Sentry.Integrations.Replay({}),
38+
],
39+
});
40+
</script>
41+
</head>
42+
43+
<body>
44+
<img class="proto mover" src="logo-1024px.png" />
45+
<div class="controls">
46+
<button class="add"></button>
47+
<button class="subtract" disabled></button>
48+
<button class="stop">Stop</button>
49+
<button class="optimize">Un-Optimize</button>
50+
<a href="https://developers.google.com/web/tools/chrome-devtools/evaluate-performance/" target="_blank">
51+
<button class="optimize">Help</button>
52+
</a>
53+
</div>
54+
</body>
55+
56+
</html>

0 commit comments

Comments
 (0)