Skip to content

Commit

Permalink
Merge pull request #59 from THEOplayer/disable-hesp
Browse files Browse the repository at this point in the history
Disable connector for HESP requests
  • Loading branch information
cTopher authored Nov 12, 2024
2 parents cc129b4 + 93296bb commit 35c06f0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/sixty-knives-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@theoplayer/cmcd-connector-web": minor
---

Disable CMCD for HESP requests
10 changes: 7 additions & 3 deletions cmcd/src/CMCDCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class CMCDCollector {
*/
private handleCurrentSourceChange_ = (event: CurrentSourceChangeEvent) => {
const currentSource = event.currentSource;
if (!currentSource) {
if (!currentSource || currentSource.type === 'application/vnd.theo.hesp+json') {
this._streamingFormat = undefined;
} else {
this._streamingFormat = getStreamingFormatFromTypedSource(currentSource);
Expand Down Expand Up @@ -138,9 +138,13 @@ export class CMCDCollector {
/**
* Collects all the CMCD parameters as supported by the connector depending on the provided {@link Request}.
* @param request The request for which CMCD parameters should be collected.
* @returns A payload object containing keys for the provided request.
* @returns A payload object containing keys for the provided request or `undefined` if CMCD is not applicable for
* this request
*/
collect(request: Request): CMCDPayload {
collect(request: Request): CMCDPayload | undefined {
if (this._streamingFormat === undefined) {
return;
}
const sessionKeys = this.collectSessionKeys();
const requestKeys = this._config.sendRequestID
? {
Expand Down
3 changes: 3 additions & 0 deletions cmcd/src/CMCDConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export class CMCDConnector {
}

let payload = this._collector.collect(request);
if (payload === undefined) {
return;
}
if (this._processor) {
payload = this._processor(payload, request);
}
Expand Down

0 comments on commit 35c06f0

Please sign in to comment.