-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathexercise-metrics.php
42 lines (34 loc) · 1.76 KB
/
exercise-metrics.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
require_once(__DIR__ . '/../assert.php');
require_once 'vendor/autoload.php';
// Exercises all metrics operations.
// Authentication Setup
$config = MuxPhp\Configuration::getDefaultConfiguration()
->setUsername(getenv('MUX_TOKEN_ID'))
->setPassword(getenv('MUX_TOKEN_SECRET'));
// API Client Initialization
$metricsApi = new MuxPhp\Api\MetricsApi(
new GuzzleHttp\Client(),
$config
);
// ========== list-breakdown-values ==========
$breakdown = $metricsApi->listBreakdownValues("video_startup_time", ["group_by" => "browser", "timeframe" => ["7:days"]]);
assert($breakdown->getData() !== null);
print("list-breakdown-values OK ✅\n");
// ========== get-overall-values ==========
$overall = $metricsApi->getOverallValues("video_startup_time", ["timeframe" => ["7:days"]]);
// Alternatively specify an array of epoch timestamps e.g.: $overall = $metricsApi->getOverallValues("video_startup_time", ["timeframe" => [1498867200, 1498953600]]);
assert($overall->getData() !== null);
print("get-overall-values OK ✅\n");
// ========== list-insights ==========
$insights = $metricsApi->listInsights("video_startup_time", ["timeframe" => ["7:days"]]);
assert($insights->getData() !== null);
print("list-insights OK ✅\n");
// ========== get-metric-timeseries-data ==========
$timeseries = $metricsApi->getMetricTimeseriesData("video_startup_time", ["timeframe" => ["7:days"]]);
assert($timeseries->getData() !== null);
print("get-metric-timeseries-data OK ✅\n");
// ========== list-all-metric-values ==========
$allValues = $metricsApi->listAllMetricValues();
assert($allValues->getData() !== null);
print("list-all-metric-values OK ✅\n");