Skip to content

Commit 42973d3

Browse files
committed
Update example documentation & params
1 parent 0f52d13 commit 42973d3

File tree

1 file changed

+19
-12
lines changed
  • examples/nodejs/metric-budgets

1 file changed

+19
-12
lines changed

examples/nodejs/metric-budgets/list.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,29 @@
22

33
import { MetricBudget } from 'calibre'
44

5+
// Returns a list of metric budgets for a site, including:
6+
// - The budget threshold value, e.g. 2500
7+
// - Budget status, e.g. "met", "unmet", "at_risk"
8+
// - Metric, e.g. "largestContentfulPaint"
9+
// - Each page and test profile associated with the budget, with:
10+
// - Last observed value
11+
// - Whether the budget is within the threshold
512
const listMetricBudgets = async () => {
613
const site = 'calibre' // site slug
7-
const count = 20 // number of metric budgets to return, maximum 500
14+
const count = 1 // number of metric budgets to return (maximum=5)
15+
const metric = 'largestContentfulPaint' // specify a metric (default=budgets for all metrics are returned)
816

9-
// Optional
10-
const metric = 'consistently-interactive' // pass a metric to limit results
17+
try {
18+
const metricBudgets = await MetricBudget.list({
19+
site,
20+
metric,
21+
count
22+
})
1123

12-
// List the metric budgets
13-
const metricBudgets = await MetricBudget.list({
14-
site,
15-
metric,
16-
count
17-
})
18-
19-
// Output the formatted JSON response
20-
console.log(JSON.stringify(metricBudgets, null, 2))
24+
console.log(JSON.stringify(metricBudgets, null, 2))
25+
} catch (error) {
26+
console.error(error)
27+
}
2128
}
2229

2330
listMetricBudgets()

0 commit comments

Comments
 (0)