-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinject.js
25 lines (21 loc) · 913 Bytes
/
inject.js
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
window.addEventListener('rhAnalyticsTimespanChanged', async function(event) {
var days = event.detail.days;
var element = document.getElementsByTagName('redhat-container-analytics')[0];
var baseUrl = 'https://pyxis.stage.engineering.redhat.com/v1' +
'/repositories/registry/registry.access.redhat.com' +
'/repository/ubi8/analytics/';
var pullCountUrl = baseUrl + 'pull-counts?delta=' + days;
var pageViewUrl = baseUrl + 'pageviews?delta=' + days;
var pullCountRsp = await fetch(pullCountUrl, {cache: 'no-store'});
var pageViewRsp = await fetch(pageViewUrl, {cache: 'no-store'});
if (pullCountRsp.ok) {
element.pullCountStats = await pullCountRsp.json();
} else {
console.error(await pullCountRsp.text());
}
if (pageViewRsp.ok) {
element.pageViewStats = await pageViewRsp.json();
} else {
console.error(await pageViewRsp.text());
}
});