Skip to content

Commit

Permalink
Metrics fixes (#530)
Browse files Browse the repository at this point in the history
* fix: added event listeners

* fix: styling
  • Loading branch information
0xcadams committed Apr 8, 2024
1 parent 8a4b1dc commit adbd11b
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 111 deletions.
8 changes: 8 additions & 0 deletions .changeset/late-jeans-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@livepeer/core": patch
"@livepeer/core-react": patch
"@livepeer/core-web": patch
"@livepeer/react": patch
---

**Fix:** fix for metrics using `disableProgressListener` where the metrics does not register a `playing` event.
19 changes: 4 additions & 15 deletions packages/core-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"files": ["dist"],
"exports": {
"./package.json": "./package.json",
".": {
Expand All @@ -31,12 +29,8 @@
},
"typesVersions": {
"*": {
"crypto": [
"./dist/crypto/index.d.ts"
],
"*": [
"./dist/index.d.ts"
]
"crypto": ["./dist/crypto/index.d.ts"],
"*": ["./dist/index.d.ts"]
}
},
"scripts": {
Expand All @@ -61,10 +55,5 @@
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"keywords": [
"livepeer",
"video",
"streaming",
"livestream"
]
"keywords": ["livepeer", "video", "streaming", "livestream"]
}
39 changes: 9 additions & 30 deletions packages/core-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"files": ["dist"],
"exports": {
"./package.json": "./package.json",
".": {
Expand Down Expand Up @@ -56,27 +54,13 @@
},
"typesVersions": {
"*": {
"broadcast": [
"./dist/broadcast/index.d.ts"
],
"browser": [
"./dist/browser/index.d.ts"
],
"external": [
"./dist/external/index.d.ts"
],
"hls": [
"./dist/hls/index.d.ts"
],
"media": [
"./dist/media/index.d.ts"
],
"webrtc": [
"./dist/webrtc/index.d.ts"
],
"*": [
"./dist/index.d.ts"
]
"broadcast": ["./dist/broadcast/index.d.ts"],
"browser": ["./dist/browser/index.d.ts"],
"external": ["./dist/external/index.d.ts"],
"hls": ["./dist/hls/index.d.ts"],
"media": ["./dist/media/index.d.ts"],
"webrtc": ["./dist/webrtc/index.d.ts"],
"*": ["./dist/index.d.ts"]
}
},
"scripts": {
Expand All @@ -90,10 +74,5 @@
"hls.js": "^1.5.2",
"zustand": "^4.5.0"
},
"keywords": [
"livepeer",
"video",
"streaming",
"livestream"
]
"keywords": ["livepeer", "video", "streaming", "livestream"]
}
39 changes: 9 additions & 30 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"files": ["dist"],
"exports": {
"./package.json": "./package.json",
".": {
Expand Down Expand Up @@ -56,27 +54,13 @@
},
"typesVersions": {
"*": {
"crypto": [
"./dist/crypto/index.d.ts"
],
"errors": [
"./dist/errors/index.d.ts"
],
"media": [
"./dist/media/index.d.ts"
],
"storage": [
"./dist/storage/index.d.ts"
],
"utils": [
"./dist/utils/index.d.ts"
],
"version": [
"./dist/version/index.d.ts"
],
"*": [
"./dist/index.d.ts"
]
"crypto": ["./dist/crypto/index.d.ts"],
"errors": ["./dist/errors/index.d.ts"],
"media": ["./dist/media/index.d.ts"],
"storage": ["./dist/storage/index.d.ts"],
"utils": ["./dist/utils/index.d.ts"],
"version": ["./dist/version/index.d.ts"],
"*": ["./dist/index.d.ts"]
}
},
"scripts": {
Expand All @@ -92,10 +76,5 @@
"devDependencies": {
"jose": "^5.2.3"
},
"keywords": [
"livepeer",
"video",
"streaming",
"livestream"
]
"keywords": ["livepeer", "video", "streaming", "livestream"]
}
28 changes: 22 additions & 6 deletions packages/core/src/media/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ export class MetricsStatus {
this.timeUnpaused.start();
} else {
this.timeUnpaused.stop();
this.timeStalled.stop();
this.timeWaiting.stop();
}
}

Expand All @@ -301,13 +303,27 @@ export class MetricsStatus {
this.timeUnpaused.start();
}

if (state.stalled !== prevState.stalled && state.stalled) {
this.timeStalled.start();
this.timeUnpaused.stop();
if (state.stalled !== prevState.stalled) {
if (state.stalled) {
this.timeStalled.start();
this.timeUnpaused.stop();
} else if (state.playing) {
this.timeStalled.stop();
this.timeWaiting.stop();

this.timeUnpaused.start();
}
}
if (state.waiting !== prevState.waiting && state.waiting) {
this.timeWaiting.start();
this.timeUnpaused.stop();
if (state.waiting !== prevState.waiting) {
if (state.waiting) {
this.timeWaiting.start();
this.timeUnpaused.stop();
} else if (state.playing) {
this.timeStalled.stop();
this.timeWaiting.stop();

this.timeUnpaused.start();
}
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/version.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const core = "@livepeer/core@3.1.13";
const react = "@livepeer/react@4.1.13";
const core = "@livepeer/core@3.1.14";
const react = "@livepeer/react@4.1.14";

export const version = {
core,
Expand Down
36 changes: 8 additions & 28 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"files": ["dist"],
"exports": {
"./package.json": "./package.json",
".": {
Expand Down Expand Up @@ -51,24 +49,12 @@
},
"typesVersions": {
"*": {
"assets": [
"./dist/assets/index.d.ts"
],
"broadcast": [
"./dist/broadcast/index.d.ts"
],
"crypto": [
"./dist/crypto/index.d.ts"
],
"external": [
"./dist/external/index.d.ts"
],
"player": [
"./dist/player/index.d.ts"
],
"*": [
"./dist/index.d.ts"
]
"assets": ["./dist/assets/index.d.ts"],
"broadcast": ["./dist/broadcast/index.d.ts"],
"crypto": ["./dist/crypto/index.d.ts"],
"external": ["./dist/external/index.d.ts"],
"player": ["./dist/player/index.d.ts"],
"*": ["./dist/index.d.ts"]
}
},
"scripts": {
Expand Down Expand Up @@ -114,11 +100,5 @@
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"keywords": [
"livepeer",
"react",
"video",
"streaming",
"livestream"
]
"keywords": ["livepeer", "react", "video", "streaming", "livestream"]
}

0 comments on commit adbd11b

Please sign in to comment.