@bitmovin/player-web-integration-cmcd 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -3
- package/README.md +6 -8
- package/dist/js/bitmovin-player-integration-cmcd.js +1 -1
- package/package.json +3 -3
- package/test/ts/Cmcd.test.ts +51 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.4.0] - 2025-12-01
|
|
11
|
+
### Changed
|
|
12
|
+
- Dependency versions
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- Custom keys were not sorted alphabetically using the prefix due to an initial ambiguity in the specification
|
|
16
|
+
|
|
10
17
|
## [0.3.0] - 2025-03-26
|
|
11
18
|
### Added
|
|
12
19
|
- Description in package.json for the project
|
|
@@ -15,17 +22,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
15
22
|
### Fixed
|
|
16
23
|
- DASH loading failure when SegmentTimeline with $number format is used (#6)
|
|
17
24
|
- Duplicate CMCD query parameters for Live manifest (#5)
|
|
18
|
-
- Add `main` property to
|
|
25
|
+
- Add `main` property to package.json to enable usage in Jest tests
|
|
19
26
|
|
|
20
27
|
## [0.2.0] - 2023-10-13
|
|
21
28
|
### Added
|
|
22
|
-
- Support for adding Custom Keys statically in the
|
|
29
|
+
- Support for adding Custom Keys statically in the configuration
|
|
23
30
|
|
|
24
31
|
## 0.1.0 - 2023-05-05
|
|
25
32
|
### Added
|
|
26
33
|
- Initial CMCD release (Beta)
|
|
27
34
|
|
|
28
|
-
[Unreleased]: https://github.com/bitmovin/bitmovin-player-web-integration-cmcd/compare/v0.
|
|
35
|
+
[Unreleased]: https://github.com/bitmovin/bitmovin-player-web-integration-cmcd/compare/v0.4.0...HEAD
|
|
36
|
+
[0.4.0]: https://github.com/bitmovin/bitmovin-player-web-integration-cmcd/compare/v0.3.0...v0.4.0
|
|
29
37
|
[0.3.0]: https://github.com/bitmovin/bitmovin-player-web-integration-cmcd/compare/v0.2.1...v0.3.0
|
|
30
38
|
[0.2.1]: https://github.com/bitmovin/bitmovin-player-web-integration-cmcd/compare/v0.2.0...v0.2.1
|
|
31
39
|
[0.2.0]: https://github.com/bitmovin/bitmovin-player-web-integration-cmcd/compare/v0.1.0...v0.2.0
|
package/README.md
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
This project adds support for the Common Media Client Data (CMCD) plugin. Please find more information about the Consumer Technology Association (CTA) Specification in https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5004-final.pdf
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
|
-
Install with npm
|
|
6
|
+
Install with npm:
|
|
7
7
|
```
|
|
8
|
-
npm install --save
|
|
8
|
+
npm install --save @bitmovin/player-web-integration-cmcd
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
@@ -45,7 +45,7 @@ After that, you create a Bitmovin Player instance as usual, then pass the player
|
|
|
45
45
|
cmcdIntegration.setPlayer(player);
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
It is
|
|
48
|
+
It is recommended to set the CMCD Session ID to the Analytics Impression ID as this enables you to connect CDN logs with CMCD data to Analytics sessions:
|
|
49
49
|
```js
|
|
50
50
|
cmcdIntegration.setSessionId(player.analytics.getCurrentImpressionId());
|
|
51
51
|
```
|
|
@@ -64,12 +64,10 @@ player.load(source);
|
|
|
64
64
|
- Run `npm run format` to format all files in the `src/` and `test/` folders
|
|
65
65
|
|
|
66
66
|
### Preparing a release
|
|
67
|
-
1.
|
|
68
|
-
2. Use
|
|
69
|
-
3. Run `npm run build`
|
|
70
|
-
4. Commit all the above changes, including the `dist/` folder
|
|
71
|
-
5. Tag the commit of the release (which contains the changes of the `dist/` folder), e.g. with `1.0.0`
|
|
67
|
+
1. Make sure all relevant changes were merged into the `main` branch, and there is an entry for each change in `CHANGELOG.md`
|
|
68
|
+
2. Use the [Release New Version](https://github.com/bitmovin/bitmovin-player-web-integration-cmcd/actions/workflows/release.yml) Github Action Workflow and run it on the `main` branch
|
|
72
69
|
|
|
70
|
+
That's it! The workflow will take care of bumping the version (based on Changelog entries), updating the `CHANGELOG.md` file with release date and version, committing and tagging in this repository, and publishing the package to [NPM](https://www.npmjs.com/package/@bitmovin/player-web-integration-cmcd).
|
|
73
71
|
|
|
74
72
|
## Principles
|
|
75
73
|
- The Bitmovin Player shall not be packaged into the JS file created by the build of this integration. To achieve this, types can be imported and used, but no code must be imported/used (including string enums!)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.BitmovinPlayerIntegrationCmcd=e():(t.bitmovin=t.bitmovin||{},t.bitmovin.player=t.bitmovin.player||{},t.bitmovin.player.integration=t.bitmovin.player.integration||{},t.bitmovin.player.integration.Cmcd=e())}(self,(function(){return function(){"use strict";var t={247:function(t,e,n){n.d(e,{Ao:function(){return E},Dh:function(){return a},I3:function(){return R},J3:function(){return M},M:function(){return h},O5:function(){return b},Ph:function(){return I},QU:function(){return u},RE:function(){return s},RF:function(){return A},RZ:function(){return y},T8:function(){return m},TS:function(){return k},Vf:function(){return x},Vq:function(){return q},ZH:function(){return v},be:function(){return T},dg:function(){return O},gu:function(){return D},hq:function(){return P},mP:function(){return g},mc:function(){return i},nf:function(){return o},oI:function(){return S},x9:function(){return V}});var r,i,u,o,s,a,c,p=(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});function l(t){return t.sort((function(t,e){var n=t.key.substring(t.key.lastIndexOf("-")+1),r=e.key.substring(e.key.lastIndexOf("-")+1);return n.localeCompare(r)})).filter((function(t){return t.keyValuePairToString()}))}function h(t){var e=l(t),n=e.filter((function(t){return t.type===c.Request})).map((function(t){return t.keyValuePairToString()})).join(","),r=e.filter((function(t){return t.type===c.Object})).map((function(t){return t.keyValuePairToString()})).join(","),i=e.filter((function(t){return t.type===c.Status})).map((function(t){return t.keyValuePairToString()})).join(","),u=e.filter((function(t){return t.type===c.Session})).map((function(t){return t.keyValuePairToString()})).join(","),o={};return n&&(o[c.Request]=n),r&&(o[c.Object]=r),i&&(o[c.Status]=i),u&&(o[c.Session]=u),o}function y(t){var e=l(t).map((function(t){return t.keyValuePairToString()})).join(",");return"CMCD=".concat(encodeURIComponent(e))}!function(t){t.AudioOnly="a",t.VideoOnly="v",t.MuxedVideoAudio="av",t.ManifestOrPlaylistTextFile="m",t.InitSegment="i",t.CaptionOrSubtitle="c",t.TimedTextTrack="tt",t.CryptographicKeyOrLicenseOrCertificate="k",t.Other="o"}(i||(i={})),function(t){t.MpegDash="d",t.Hls="h",t.Smooth="s",t.Other="o"}(u||(u={})),function(t){t.Vod="v",t.Live="l"}(o||(o={})),function(t){t[t.v1=1]="v1"}(s||(s={})),function(t){t.EncodedBitrate="br",t.BufferLength="bl",t.BufferStarvation="bs",t.ContentId="cid",t.ObjectDuration="d",t.Deadline="dl",t.MeasuredThroughput="mtp",t.NextObjectRequest="nor",t.NextRangeRequest="nrr",t.ObjectType="ot",t.PlaybackRate="pr",t.RequestedMaximumThroughput="rtp",t.StreamingFormat="sf",t.SessionId="sid",t.StreamType="st",t.Startup="su",t.TopBitrate="tb",t.CmcdVersion="v"}(a||(a={})),function(t){t.Object="CMCD-Object",t.Request="CMCD-Request",t.Status="CMCD-Status",t.Session="CMCD-Session"}(c||(c={}));var f,d=function(){function t(t){this.value=t}return t.prototype.keyValuePairToString=function(){return"string"==typeof this.value?this.value?"".concat(this.key,"=").concat((t=this.value,e=/"/g,n=/\\/g,'"'.concat(t.replace(n,"\\\\").replace(e,'\\"'),'"'))):"":"boolean"==typeof this.value&&!0===this.value?"".concat(this.key):"".concat(this.key,"=").concat(this.value);var t,e,n},t}(),v=function(t){function e(e){var n=t.call(this,e)||this;return n.key=a.EncodedBitrate,n.type=c.Object,n}return p(e,t),e}(d),S=function(t){function e(e){var n=t.call(this,100*Math.round(e/100))||this;return n.key=a.BufferLength,n.type=c.Request,n}return p(e,t),e}(d),g=function(t){function e(e){var n=t.call(this,e)||this;return n.key=a.BufferStarvation,n.type=c.Status,n}return p(e,t),e}(d),T=function(t){function e(e){var n=t.call(this,e)||this;return n.key=a.ContentId,n.type=c.Session,n}return p(e,t),e}(d),m=function(t){function e(e){var n=t.call(this,e)||this;return n.key=a.ObjectDuration,n.type=c.Object,n}return p(e,t),e}(d),b=function(t){function e(e){var n=t.call(this,100*Math.round(e/100))||this;return n.key=a.Deadline,n.type=c.Request,n}return p(e,t),e}(d),O=function(t){function e(e){var n=t.call(this,100*Math.round(e/100))||this;return n.key=a.MeasuredThroughput,n.type=c.Request,n}return p(e,t),e}(d),R=function(t){function e(e){var n=t.call(this,e)||this;return n.key=a.NextObjectRequest,n.type=c.Request,n}return p(e,t),e}(d),k=(p((function(t){var e=f.call(this,t)||this;return e.key=a.NextRangeRequest,e.type=c.Request,e}),f=d),function(t){function e(e){var n=t.call(this,e)||this;return n.key=a.ObjectType,n.type=c.Object,n}return p(e,t),e.prototype.keyValuePairToString=function(){return"".concat(this.key,"=").concat(this.value)},e}(d)),A=function(t){function e(e){var n=t.call(this,e)||this;return n.key=a.PlaybackRate,n.type=c.Session,n}return p(e,t),e.prototype.keyValuePairToString=function(){return 1===this.value?"":"".concat(this.key,"=").concat(this.value)},e}(d),M=function(t){function e(e){var n=t.call(this,e)||this;return n.key=a.RequestedMaximumThroughput,n.type=c.Status,n}return p(e,t),e}(d),x=function(t){function e(e){var n=t.call(this,e)||this;return n.key=a.StreamingFormat,n.type=c.Session,n}return p(e,t),e.prototype.keyValuePairToString=function(){return"".concat(this.key,"=").concat(this.value)},e}(d),I=function(t){function e(e){var n=t.call(this,e)||this;return n.key=a.SessionId,n.type=c.Session,n}return p(e,t),e}(d),D=function(t){function e(e){var n=t.call(this,e)||this;return n.key=a.StreamType,n.type=c.Session,n}return p(e,t),e.prototype.keyValuePairToString=function(){return"".concat(this.key,"=").concat(this.value)},e}(d),E=function(t){function e(e){var n=t.call(this,e)||this;return n.key=a.Startup,n.type=c.Request,n}return p(e,t),e.prototype.keyValuePairToString=function(){return!0===this.value?"".concat(this.key):""},e}(d),q=function(t){function e(e){var n=t.call(this,e)||this;return n.key=a.TopBitrate,n.type=c.Object,n}return p(e,t),e}(d),V=function(t){function e(e){var n=t.call(this,e)||this;return n.key=a.CmcdVersion,n.type=c.Session,n}return p(e,t),e.prototype.keyValuePairToString=function(){return this.value===s.v1?"":"".concat(this.key,"=").concat(this.value)},e}(d),P=function(t){function e(e,n){var r=t.call(this,n)||this;r.type=c.Session;var i=e.match(/^(.*-)(.*)$/);if(!i||!i[2])throw new Error("Custom key names MUST carry a hyphenated prefix (and SHOULD use a reverse-DNS syntax)");return r.key=e,r}return p(e,t),e}(d)},498:function(t,e,n){n.r(e),n.d(e,{CmcdIntegration:function(){return u},CustomKey:function(){return r.hq}});var r=n(247),i=function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},i.apply(this,arguments)},u=function(){function t(t){var e=this;this.onVideoAdaptation=function(t){return e.currentVideoQuality=t.representations.filter((function(e){return e.id===t.suggested}))[0],t.suggested},this.onAudioAdaptation=function(t){return e.currentAudioQuality=t.representations.filter((function(e){return e.id===t.suggested}))[0],t.suggested},this.preprocessHttpRequest=function(t,n){var u=e.gatherCmcdData(t,n);if(e.useQueryArgs){var o=new URL(n.url);o.searchParams.delete("CMCD");var s=(0,r.RZ)(u),a=o.toString().includes("?")?"&":"?";n.url="".concat(o.toString()).concat(a).concat(s)}else{var c=(0,r.M)(u);n.headers=i(i({},n.headers),c)}return Promise.resolve(n)},this.preprocessHttpResponse=function(t,n){var r,i,u=n.elapsedTime,o=n.length;if(!u||!o)return Promise.resolve(n);var s=o/u/1e3;return t===((null===(r=e.player)||void 0===r?void 0:r.exports.HttpRequestType.MEDIA_AUDIO)||"media/audio")&&(e.lastMeasuredThroughputAudio=Math.round(100*s)/100),t===((null===(i=e.player)||void 0===i?void 0:i.exports.HttpRequestType.MEDIA_VIDEO)||"media/video")&&(e.lastMeasuredThroughputVideo=Math.round(100*s)/100),Promise.resolve(n)},this.useQueryArgs=t.useQueryArgs||!1,this.sessionId=t.sessionId||"",this.contentId=t.contentId||"",this.customKeys=t.customKeys||[],this.stalledSinceLastRequest=!1,this.currentVideoQuality=null,this.currentAudioQuality=null,this.isSeekingOrTimeshiftingOrStartup=!0,this.lastMeasuredThroughputAudio=0,this.lastMeasuredThroughputVideo=0,this.manifestType=null}return t.prototype.setPlayer=function(t){var e=this;this.player=t,this.player.on(t.exports.PlayerEvent.StallStarted,(function(){e.stalledSinceLastRequest=!0,e.isSeekingOrTimeshiftingOrStartup=!0})),this.player.on(t.exports.PlayerEvent.StallEnded,(function(){return e.isSeekingOrTimeshiftingOrStartup=!1})),this.player.on(t.exports.PlayerEvent.Seek,(function(){return e.isSeekingOrTimeshiftingOrStartup=!0})),this.player.on(t.exports.PlayerEvent.Seeked,(function(){return e.isSeekingOrTimeshiftingOrStartup=!1})),this.player.on(t.exports.PlayerEvent.TimeShift,(function(){return e.isSeekingOrTimeshiftingOrStartup=!0})),this.player.on(t.exports.PlayerEvent.TimeShifted,(function(){return e.isSeekingOrTimeshiftingOrStartup=!1}))},t.prototype.setSessionId=function(t){this.sessionId=t},t.prototype.setContentId=function(t){this.contentId=t},t.prototype.gatherCmcdData=function(t,e){var n,i;if(!this.player)throw new Error("Bitmovin Player not provided!");var u=[];u.push(new r.x9(r.RE.v1)),u.push(new r.gu(this.player.isLive()?r.nf.Live:r.nf.Vod)),u.push(new r.RF(this.player.getPlaybackSpeed())),u.push(this.getObjectType(t)),u.push(this.getStreamingType(t)),this.contentId&&u.push(new r.be(this.contentId)),this.sessionId&&u.push(new r.Ph(this.sessionId)),this.isSeekingOrTimeshiftingOrStartup&&u.push(new r.Ao(!0)),(this.stalledSinceLastRequest||this.player.isStalled())&&(u.push(new r.mP(!0)),this.stalledSinceLastRequest=!1),t===(null===(n=this.player)||void 0===n?void 0:n.exports.HttpRequestType.MEDIA_AUDIO)?u=u.concat(this.getAudioSegmentRequestSpecificData(e)):t===(null===(i=this.player)||void 0===i?void 0:i.exports.HttpRequestType.MEDIA_VIDEO)&&(u=u.concat(this.getVideoSegmentRequestSpecificData(e))),u.concat(this.getRequestedMaximumThroughput(u));for(var o=0,s=this.customKeys;o<s.length;o++){var a=s[o];u.push(a)}return u},t.prototype.getRequestedMaximumThroughput=function(t){var e=t.find((function(t){return t.key===r.Dh.EncodedBitrate})),n=t.find((function(t){return t.key===r.Dh.ObjectDuration})),i=Boolean(t.find((function(t){return t.key===r.Dh.ObjectDuration}))),u=t.find((function(t){return t.key===r.Dh.Startup})),o=u&&!u.value;if(e&&n&&!i&&!o){var s=1e3*Number(n.value),a=Number(e.value)*(s/2);return[new r.J3(a)]}return[]},t.prototype.getStreamingType=function(t){var e,n,i;return this.manifestType||(t===(null===(e=this.player)||void 0===e?void 0:e.exports.HttpRequestType.MANIFEST_DASH)?this.manifestType=r.QU.MpegDash:t===(null===(n=this.player)||void 0===n?void 0:n.exports.HttpRequestType.MANIFEST_HLS_MASTER)?this.manifestType=r.QU.Hls:t===(null===(i=this.player)||void 0===i?void 0:i.exports.HttpRequestType.MANIFEST_SMOOTH)?this.manifestType=r.QU.Smooth:this.manifestType=r.QU.Other),new r.Vf(this.manifestType)},t.prototype.getObjectType=function(t){var e,n,i,u,o,s,a,c,p,l,h,y,f,d,v,S;switch(t){case null===(e=this.player)||void 0===e?void 0:e.exports.HttpRequestType.MEDIA_AUDIO:S=new r.TS(r.mc.AudioOnly);break;case null===(n=this.player)||void 0===n?void 0:n.exports.HttpRequestType.MEDIA_VIDEO:S=new r.TS(r.mc.VideoOnly);break;case null===(i=this.player)||void 0===i?void 0:i.exports.HttpRequestType.DRM_CERTIFICATE_FAIRPLAY:case null===(u=this.player)||void 0===u?void 0:u.exports.HttpRequestType.DRM_LICENSE_CLEARKEY:case null===(o=this.player)||void 0===o?void 0:o.exports.HttpRequestType.DRM_LICENSE_FAIRPLAY:case null===(s=this.player)||void 0===s?void 0:s.exports.HttpRequestType.DRM_LICENSE_PLAYREADY:case null===(a=this.player)||void 0===a?void 0:a.exports.HttpRequestType.DRM_LICENSE_WIDEVINE:case null===(c=this.player)||void 0===c?void 0:c.exports.HttpRequestType.KEY_HLS_AES:S=new r.TS(r.mc.CryptographicKeyOrLicenseOrCertificate);break;case null===(p=this.player)||void 0===p?void 0:p.exports.HttpRequestType.MANIFEST_ADS:case null===(l=this.player)||void 0===l?void 0:l.exports.HttpRequestType.MANIFEST_DASH:case null===(h=this.player)||void 0===h?void 0:h.exports.HttpRequestType.MANIFEST_HLS_MASTER:case null===(y=this.player)||void 0===y?void 0:y.exports.HttpRequestType.MANIFEST_HLS_VARIANT:case null===(f=this.player)||void 0===f?void 0:f.exports.HttpRequestType.MANIFEST_SMOOTH:S=new r.TS(r.mc.ManifestOrPlaylistTextFile);break;case null===(d=this.player)||void 0===d?void 0:d.exports.HttpRequestType.MEDIA_SEGMENTINDEX:S=new r.TS(r.mc.InitSegment);break;case null===(v=this.player)||void 0===v?void 0:v.exports.HttpRequestType.MEDIA_SUBTITLES:S=new r.TS(r.mc.CaptionOrSubtitle);break;default:S=new r.TS(r.mc.Other)}return S},t.prototype.getAudioSegmentRequestSpecificData=function(t){var e,n=[];if(this.currentAudioQuality&&this.currentAudioQuality.bandwidth&&n.push(new r.ZH(Math.round(this.currentAudioQuality.bandwidth/1e3))),this.lastMeasuredThroughputAudio&&n.push(new r.dg(this.lastMeasuredThroughputAudio)),!this.player)return n;var i=this.player.buffer.getLevel(this.player.exports.BufferType.ForwardDuration,this.player.exports.MediaType.Audio);if(i.targetLevel>0){n.push(new r.oI(1e3*i.level));var u=i.level/(null===(e=this.player)||void 0===e?void 0:e.getPlaybackSpeed());n.push(new r.O5(1e3*u))}var o=this.player.getAvailableAudioQualities().reduce((function(t,e){return Math.max(t,e.bitrate)}),0)/1e3;if(o>0&&n.push(new r.Vq(o)),this.currentVideoQuality)try{var s=this.player.getAvailableSegments();for(var a in s)if(a.startsWith("video/")){var c=s[a][this.currentVideoQuality.id];n=n.concat(this.getNextObjectAndObjectDurationCmcdData(c,t.url))}}catch(t){console.error("Error processing audio segments:",t)}return n},t.prototype.getVideoSegmentRequestSpecificData=function(t){var e,n=[];if(this.currentVideoQuality&&this.currentVideoQuality.bandwidth&&n.push(new r.ZH(Math.round(this.currentVideoQuality.bandwidth/1e3))),this.lastMeasuredThroughputVideo&&n.push(new r.dg(this.lastMeasuredThroughputVideo)),!this.player)return n;var i=this.player.buffer.getLevel(this.player.exports.BufferType.ForwardDuration,this.player.exports.MediaType.Video);if(i.targetLevel>0){n.push(new r.oI(1e3*i.level));var u=i.level/(null===(e=this.player)||void 0===e?void 0:e.getPlaybackSpeed());n.push(new r.O5(1e3*u))}var o=this.player.getAvailableVideoQualities().reduce((function(t,e){return Math.max(t,e.bitrate)}),0)/1e3;if(o>0&&n.push(new r.Vq(o)),this.currentVideoQuality)try{var s=this.player.getAvailableSegments();for(var a in s)if(a.startsWith("video/")){var c=s[a][this.currentVideoQuality.id];n=n.concat(this.getNextObjectAndObjectDurationCmcdData(c,t.url))}}catch(t){console.error("Error processing video segments:",t)}return n},t.prototype.getNextObjectAndObjectDurationCmcdData=function(t,e){var n=[],i=t.findIndex((function(t){return t.url===e}));if(i>-1){var u=t[i];if(Number.isNaN(u.duration)||n.push(new r.T8(1e3*Number(u.duration))),i+1<t.length){var o=t[i+1];o.url&&n.push(new r.I3(o.url))}}return n},t}()}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var u=e[r]={exports:{}};return t[r](u,u.exports,n),u.exports}return n.d=function(t,e){for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n(247),n(498)}()}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.BitmovinPlayerIntegrationCmcd=e():(t.bitmovin=t.bitmovin||{},t.bitmovin.player=t.bitmovin.player||{},t.bitmovin.player.integration=t.bitmovin.player.integration||{},t.bitmovin.player.integration.Cmcd=e())}(self,(function(){return function(){"use strict";var t={247:function(t,e,r){r.d(e,{Ao:function(){return E},Dh:function(){return a},I3:function(){return R},J3:function(){return M},M:function(){return h},O5:function(){return b},Ph:function(){return I},QU:function(){return u},RE:function(){return s},RF:function(){return A},RZ:function(){return y},T8:function(){return m},TS:function(){return k},Vf:function(){return x},Vq:function(){return q},ZH:function(){return v},be:function(){return T},dg:function(){return O},gu:function(){return D},hq:function(){return P},mP:function(){return g},mc:function(){return i},nf:function(){return o},oI:function(){return S},x9:function(){return V}});var n,i,u,o,s,a,c,p=(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});function l(t){return t.sort((function(t,e){return t.key.localeCompare(e.key)})).filter((function(t){return t.keyValuePairToString()}))}function h(t){var e=l(t),r=e.filter((function(t){return t.type===c.Request})).map((function(t){return t.keyValuePairToString()})).join(","),n=e.filter((function(t){return t.type===c.Object})).map((function(t){return t.keyValuePairToString()})).join(","),i=e.filter((function(t){return t.type===c.Status})).map((function(t){return t.keyValuePairToString()})).join(","),u=e.filter((function(t){return t.type===c.Session})).map((function(t){return t.keyValuePairToString()})).join(","),o={};return r&&(o[c.Request]=r),n&&(o[c.Object]=n),i&&(o[c.Status]=i),u&&(o[c.Session]=u),o}function y(t){var e=l(t).map((function(t){return t.keyValuePairToString()})).join(",");return"CMCD=".concat(encodeURIComponent(e))}!function(t){t.AudioOnly="a",t.VideoOnly="v",t.MuxedVideoAudio="av",t.ManifestOrPlaylistTextFile="m",t.InitSegment="i",t.CaptionOrSubtitle="c",t.TimedTextTrack="tt",t.CryptographicKeyOrLicenseOrCertificate="k",t.Other="o"}(i||(i={})),function(t){t.MpegDash="d",t.Hls="h",t.Smooth="s",t.Other="o"}(u||(u={})),function(t){t.Vod="v",t.Live="l"}(o||(o={})),function(t){t[t.v1=1]="v1"}(s||(s={})),function(t){t.EncodedBitrate="br",t.BufferLength="bl",t.BufferStarvation="bs",t.ContentId="cid",t.ObjectDuration="d",t.Deadline="dl",t.MeasuredThroughput="mtp",t.NextObjectRequest="nor",t.NextRangeRequest="nrr",t.ObjectType="ot",t.PlaybackRate="pr",t.RequestedMaximumThroughput="rtp",t.StreamingFormat="sf",t.SessionId="sid",t.StreamType="st",t.Startup="su",t.TopBitrate="tb",t.CmcdVersion="v"}(a||(a={})),function(t){t.Object="CMCD-Object",t.Request="CMCD-Request",t.Status="CMCD-Status",t.Session="CMCD-Session"}(c||(c={}));var f,d=function(){function t(t){this.value=t}return t.prototype.keyValuePairToString=function(){return"string"==typeof this.value?this.value?"".concat(this.key,"=").concat((t=this.value,e=/"/g,r=/\\/g,'"'.concat(t.replace(r,"\\\\").replace(e,'\\"'),'"'))):"":"boolean"==typeof this.value&&!0===this.value?"".concat(this.key):"".concat(this.key,"=").concat(this.value);var t,e,r},t}(),v=function(t){function e(e){var r=t.call(this,e)||this;return r.key=a.EncodedBitrate,r.type=c.Object,r}return p(e,t),e}(d),S=function(t){function e(e){var r=t.call(this,100*Math.round(e/100))||this;return r.key=a.BufferLength,r.type=c.Request,r}return p(e,t),e}(d),g=function(t){function e(e){var r=t.call(this,e)||this;return r.key=a.BufferStarvation,r.type=c.Status,r}return p(e,t),e}(d),T=function(t){function e(e){var r=t.call(this,e)||this;return r.key=a.ContentId,r.type=c.Session,r}return p(e,t),e}(d),m=function(t){function e(e){var r=t.call(this,e)||this;return r.key=a.ObjectDuration,r.type=c.Object,r}return p(e,t),e}(d),b=function(t){function e(e){var r=t.call(this,100*Math.round(e/100))||this;return r.key=a.Deadline,r.type=c.Request,r}return p(e,t),e}(d),O=function(t){function e(e){var r=t.call(this,100*Math.round(e/100))||this;return r.key=a.MeasuredThroughput,r.type=c.Request,r}return p(e,t),e}(d),R=function(t){function e(e){var r=t.call(this,e)||this;return r.key=a.NextObjectRequest,r.type=c.Request,r}return p(e,t),e}(d),k=(p((function(t){var e=f.call(this,t)||this;return e.key=a.NextRangeRequest,e.type=c.Request,e}),f=d),function(t){function e(e){var r=t.call(this,e)||this;return r.key=a.ObjectType,r.type=c.Object,r}return p(e,t),e.prototype.keyValuePairToString=function(){return"".concat(this.key,"=").concat(this.value)},e}(d)),A=function(t){function e(e){var r=t.call(this,e)||this;return r.key=a.PlaybackRate,r.type=c.Session,r}return p(e,t),e.prototype.keyValuePairToString=function(){return 1===this.value?"":"".concat(this.key,"=").concat(this.value)},e}(d),M=function(t){function e(e){var r=t.call(this,e)||this;return r.key=a.RequestedMaximumThroughput,r.type=c.Status,r}return p(e,t),e}(d),x=function(t){function e(e){var r=t.call(this,e)||this;return r.key=a.StreamingFormat,r.type=c.Session,r}return p(e,t),e.prototype.keyValuePairToString=function(){return"".concat(this.key,"=").concat(this.value)},e}(d),I=function(t){function e(e){var r=t.call(this,e)||this;return r.key=a.SessionId,r.type=c.Session,r}return p(e,t),e}(d),D=function(t){function e(e){var r=t.call(this,e)||this;return r.key=a.StreamType,r.type=c.Session,r}return p(e,t),e.prototype.keyValuePairToString=function(){return"".concat(this.key,"=").concat(this.value)},e}(d),E=function(t){function e(e){var r=t.call(this,e)||this;return r.key=a.Startup,r.type=c.Request,r}return p(e,t),e.prototype.keyValuePairToString=function(){return!0===this.value?"".concat(this.key):""},e}(d),q=function(t){function e(e){var r=t.call(this,e)||this;return r.key=a.TopBitrate,r.type=c.Object,r}return p(e,t),e}(d),V=function(t){function e(e){var r=t.call(this,e)||this;return r.key=a.CmcdVersion,r.type=c.Session,r}return p(e,t),e.prototype.keyValuePairToString=function(){return this.value===s.v1?"":"".concat(this.key,"=").concat(this.value)},e}(d),P=function(t){function e(e,r){var n=t.call(this,r)||this;n.type=c.Session;var i=e.match(/^(.*-)(.*)$/);if(!i||!i[2])throw new Error("Custom key names MUST carry a hyphenated prefix (and SHOULD use a reverse-DNS syntax)");return n.key=e,n}return p(e,t),e}(d)},498:function(t,e,r){r.r(e),r.d(e,{CmcdIntegration:function(){return u},CustomKey:function(){return n.hq}});var n=r(247),i=function(){return i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},i.apply(this,arguments)},u=function(){function t(t){var e=this;this.onVideoAdaptation=function(t){return e.currentVideoQuality=t.representations.filter((function(e){return e.id===t.suggested}))[0],t.suggested},this.onAudioAdaptation=function(t){return e.currentAudioQuality=t.representations.filter((function(e){return e.id===t.suggested}))[0],t.suggested},this.preprocessHttpRequest=function(t,r){var u=e.gatherCmcdData(t,r);if(e.useQueryArgs){var o=new URL(r.url);o.searchParams.delete("CMCD");var s=(0,n.RZ)(u),a=o.toString().includes("?")?"&":"?";r.url="".concat(o.toString()).concat(a).concat(s)}else{var c=(0,n.M)(u);r.headers=i(i({},r.headers),c)}return Promise.resolve(r)},this.preprocessHttpResponse=function(t,r){var n,i,u=r.elapsedTime,o=r.length;if(!u||!o)return Promise.resolve(r);var s=o/u/1e3;return t===((null===(n=e.player)||void 0===n?void 0:n.exports.HttpRequestType.MEDIA_AUDIO)||"media/audio")&&(e.lastMeasuredThroughputAudio=Math.round(100*s)/100),t===((null===(i=e.player)||void 0===i?void 0:i.exports.HttpRequestType.MEDIA_VIDEO)||"media/video")&&(e.lastMeasuredThroughputVideo=Math.round(100*s)/100),Promise.resolve(r)},this.useQueryArgs=t.useQueryArgs||!1,this.sessionId=t.sessionId||"",this.contentId=t.contentId||"",this.customKeys=t.customKeys||[],this.stalledSinceLastRequest=!1,this.currentVideoQuality=null,this.currentAudioQuality=null,this.isSeekingOrTimeshiftingOrStartup=!0,this.lastMeasuredThroughputAudio=0,this.lastMeasuredThroughputVideo=0,this.manifestType=null}return t.prototype.setPlayer=function(t){var e=this;this.player=t,this.player.on(t.exports.PlayerEvent.StallStarted,(function(){e.stalledSinceLastRequest=!0,e.isSeekingOrTimeshiftingOrStartup=!0})),this.player.on(t.exports.PlayerEvent.StallEnded,(function(){return e.isSeekingOrTimeshiftingOrStartup=!1})),this.player.on(t.exports.PlayerEvent.Seek,(function(){return e.isSeekingOrTimeshiftingOrStartup=!0})),this.player.on(t.exports.PlayerEvent.Seeked,(function(){return e.isSeekingOrTimeshiftingOrStartup=!1})),this.player.on(t.exports.PlayerEvent.TimeShift,(function(){return e.isSeekingOrTimeshiftingOrStartup=!0})),this.player.on(t.exports.PlayerEvent.TimeShifted,(function(){return e.isSeekingOrTimeshiftingOrStartup=!1}))},t.prototype.setSessionId=function(t){this.sessionId=t},t.prototype.setContentId=function(t){this.contentId=t},t.prototype.gatherCmcdData=function(t,e){var r,i;if(!this.player)throw new Error("Bitmovin Player not provided!");var u=[];u.push(new n.x9(n.RE.v1)),u.push(new n.gu(this.player.isLive()?n.nf.Live:n.nf.Vod)),u.push(new n.RF(this.player.getPlaybackSpeed())),u.push(this.getObjectType(t)),u.push(this.getStreamingType(t)),this.contentId&&u.push(new n.be(this.contentId)),this.sessionId&&u.push(new n.Ph(this.sessionId)),this.isSeekingOrTimeshiftingOrStartup&&u.push(new n.Ao(!0)),(this.stalledSinceLastRequest||this.player.isStalled())&&(u.push(new n.mP(!0)),this.stalledSinceLastRequest=!1),t===(null===(r=this.player)||void 0===r?void 0:r.exports.HttpRequestType.MEDIA_AUDIO)?u=u.concat(this.getAudioSegmentRequestSpecificData(e)):t===(null===(i=this.player)||void 0===i?void 0:i.exports.HttpRequestType.MEDIA_VIDEO)&&(u=u.concat(this.getVideoSegmentRequestSpecificData(e))),u.concat(this.getRequestedMaximumThroughput(u));for(var o=0,s=this.customKeys;o<s.length;o++){var a=s[o];u.push(a)}return u},t.prototype.getRequestedMaximumThroughput=function(t){var e=t.find((function(t){return t.key===n.Dh.EncodedBitrate})),r=t.find((function(t){return t.key===n.Dh.ObjectDuration})),i=Boolean(t.find((function(t){return t.key===n.Dh.ObjectDuration}))),u=t.find((function(t){return t.key===n.Dh.Startup})),o=u&&!u.value;if(e&&r&&!i&&!o){var s=1e3*Number(r.value),a=Number(e.value)*(s/2);return[new n.J3(a)]}return[]},t.prototype.getStreamingType=function(t){var e,r,i;return this.manifestType||(t===(null===(e=this.player)||void 0===e?void 0:e.exports.HttpRequestType.MANIFEST_DASH)?this.manifestType=n.QU.MpegDash:t===(null===(r=this.player)||void 0===r?void 0:r.exports.HttpRequestType.MANIFEST_HLS_MASTER)?this.manifestType=n.QU.Hls:t===(null===(i=this.player)||void 0===i?void 0:i.exports.HttpRequestType.MANIFEST_SMOOTH)?this.manifestType=n.QU.Smooth:this.manifestType=n.QU.Other),new n.Vf(this.manifestType)},t.prototype.getObjectType=function(t){var e,r,i,u,o,s,a,c,p,l,h,y,f,d,v,S;switch(t){case null===(e=this.player)||void 0===e?void 0:e.exports.HttpRequestType.MEDIA_AUDIO:S=new n.TS(n.mc.AudioOnly);break;case null===(r=this.player)||void 0===r?void 0:r.exports.HttpRequestType.MEDIA_VIDEO:S=new n.TS(n.mc.VideoOnly);break;case null===(i=this.player)||void 0===i?void 0:i.exports.HttpRequestType.DRM_CERTIFICATE_FAIRPLAY:case null===(u=this.player)||void 0===u?void 0:u.exports.HttpRequestType.DRM_LICENSE_CLEARKEY:case null===(o=this.player)||void 0===o?void 0:o.exports.HttpRequestType.DRM_LICENSE_FAIRPLAY:case null===(s=this.player)||void 0===s?void 0:s.exports.HttpRequestType.DRM_LICENSE_PLAYREADY:case null===(a=this.player)||void 0===a?void 0:a.exports.HttpRequestType.DRM_LICENSE_WIDEVINE:case null===(c=this.player)||void 0===c?void 0:c.exports.HttpRequestType.KEY_HLS_AES:S=new n.TS(n.mc.CryptographicKeyOrLicenseOrCertificate);break;case null===(p=this.player)||void 0===p?void 0:p.exports.HttpRequestType.MANIFEST_ADS:case null===(l=this.player)||void 0===l?void 0:l.exports.HttpRequestType.MANIFEST_DASH:case null===(h=this.player)||void 0===h?void 0:h.exports.HttpRequestType.MANIFEST_HLS_MASTER:case null===(y=this.player)||void 0===y?void 0:y.exports.HttpRequestType.MANIFEST_HLS_VARIANT:case null===(f=this.player)||void 0===f?void 0:f.exports.HttpRequestType.MANIFEST_SMOOTH:S=new n.TS(n.mc.ManifestOrPlaylistTextFile);break;case null===(d=this.player)||void 0===d?void 0:d.exports.HttpRequestType.MEDIA_SEGMENTINDEX:S=new n.TS(n.mc.InitSegment);break;case null===(v=this.player)||void 0===v?void 0:v.exports.HttpRequestType.MEDIA_SUBTITLES:S=new n.TS(n.mc.CaptionOrSubtitle);break;default:S=new n.TS(n.mc.Other)}return S},t.prototype.getAudioSegmentRequestSpecificData=function(t){var e,r=[];if(this.currentAudioQuality&&this.currentAudioQuality.bandwidth&&r.push(new n.ZH(Math.round(this.currentAudioQuality.bandwidth/1e3))),this.lastMeasuredThroughputAudio&&r.push(new n.dg(this.lastMeasuredThroughputAudio)),!this.player)return r;var i=this.player.buffer.getLevel(this.player.exports.BufferType.ForwardDuration,this.player.exports.MediaType.Audio);if(i.targetLevel>0){r.push(new n.oI(1e3*i.level));var u=i.level/(null===(e=this.player)||void 0===e?void 0:e.getPlaybackSpeed());r.push(new n.O5(1e3*u))}var o=this.player.getAvailableAudioQualities().reduce((function(t,e){return Math.max(t,e.bitrate)}),0)/1e3;if(o>0&&r.push(new n.Vq(o)),this.currentVideoQuality)try{var s=this.player.getAvailableSegments();for(var a in s)if(a.startsWith("video/")){var c=s[a][this.currentVideoQuality.id];r=r.concat(this.getNextObjectAndObjectDurationCmcdData(c,t.url))}}catch(t){console.error("Error processing audio segments:",t)}return r},t.prototype.getVideoSegmentRequestSpecificData=function(t){var e,r=[];if(this.currentVideoQuality&&this.currentVideoQuality.bandwidth&&r.push(new n.ZH(Math.round(this.currentVideoQuality.bandwidth/1e3))),this.lastMeasuredThroughputVideo&&r.push(new n.dg(this.lastMeasuredThroughputVideo)),!this.player)return r;var i=this.player.buffer.getLevel(this.player.exports.BufferType.ForwardDuration,this.player.exports.MediaType.Video);if(i.targetLevel>0){r.push(new n.oI(1e3*i.level));var u=i.level/(null===(e=this.player)||void 0===e?void 0:e.getPlaybackSpeed());r.push(new n.O5(1e3*u))}var o=this.player.getAvailableVideoQualities().reduce((function(t,e){return Math.max(t,e.bitrate)}),0)/1e3;if(o>0&&r.push(new n.Vq(o)),this.currentVideoQuality)try{var s=this.player.getAvailableSegments();for(var a in s)if(a.startsWith("video/")){var c=s[a][this.currentVideoQuality.id];r=r.concat(this.getNextObjectAndObjectDurationCmcdData(c,t.url))}}catch(t){console.error("Error processing video segments:",t)}return r},t.prototype.getNextObjectAndObjectDurationCmcdData=function(t,e){var r=[],i=t.findIndex((function(t){return t.url===e}));if(i>-1){var u=t[i];if(Number.isNaN(u.duration)||r.push(new n.T8(1e3*Number(u.duration))),i+1<t.length){var o=t[i+1];o.url&&r.push(new n.I3(o.url))}}return r},t}()}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var u=e[n]={exports:{}};return t[n](u,u.exports,r),u.exports}return r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r(247),r(498)}()}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitmovin/player-web-integration-cmcd",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Conviva analytics integration for the Bitmovin Player",
|
|
5
5
|
"types": "dist/js/CmcdIntegration.d.ts",
|
|
6
6
|
"browser": "dist/js/bitmovin-player-integration-cmcd.js",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"ts-jest": "^29.0.5",
|
|
39
39
|
"ts-loader": "^9.4.2",
|
|
40
40
|
"typescript": "^4.9.5",
|
|
41
|
-
"webpack": "^5.
|
|
41
|
+
"webpack": "^5.76.0",
|
|
42
42
|
"webpack-cli": "^5.0.1",
|
|
43
|
-
"webpack-dev-server": "^
|
|
43
|
+
"webpack-dev-server": "^5.2.1",
|
|
44
44
|
"webpack-merge": "^5.8.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
package/test/ts/Cmcd.test.ts
CHANGED
|
@@ -79,6 +79,55 @@ describe('Cmcd', () => {
|
|
|
79
79
|
expect(cmcdUrlParams3).toEqual(cmcdUrlParams4);
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
+
it('should sort custom keys alphabetically with standard keys according to full key name', () => {
|
|
83
|
+
const cmcdObjects = [
|
|
84
|
+
new CmcdObjectDuration(4004), // key: 'd'
|
|
85
|
+
new CmcdCustomKey('com.example-myNumericKey', 500), // key: 'com.example-myNumericKey'
|
|
86
|
+
new CmcdCustomKey('com.example-myStringKey', 'myStringValue'), // key: 'com.example-myStringKey'
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
const result = cmcdDataToUrlParameter(cmcdObjects);
|
|
90
|
+
|
|
91
|
+
// Custom keys should come first alphabetically before 'd'
|
|
92
|
+
// Expected order: 'com.example-myNumericKey', 'com.example-myStringKey', 'd'
|
|
93
|
+
expect(result).toEqual('CMCD=com.example-myNumericKey%3D500%2Ccom.example-myStringKey%3D%22myStringValue%22%2Cd%3D4004');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should maintain strict alphabetical order regardless of input order with mixed custom and standard keys', () => {
|
|
97
|
+
const cmcdObjects1 = [
|
|
98
|
+
new CmcdObjectDuration(4004), // 'd'
|
|
99
|
+
new CmcdCustomKey('com.example-myKey', 500), // 'com.example-myKey'
|
|
100
|
+
new CmcdBufferLength(0), // 'bl'
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
const cmcdObjects2 = [
|
|
104
|
+
new CmcdBufferLength(0), // 'bl'
|
|
105
|
+
new CmcdCustomKey('com.example-myKey', 500), // 'com.example-myKey'
|
|
106
|
+
new CmcdObjectDuration(4004), // 'd'
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
const result1 = cmcdDataToUrlParameter(cmcdObjects1);
|
|
110
|
+
const result2 = cmcdDataToUrlParameter(cmcdObjects2);
|
|
111
|
+
|
|
112
|
+
expect(result1).toEqual(result2);
|
|
113
|
+
// Should be: bl, com.example-myKey, d
|
|
114
|
+
expect(result1).toEqual('CMCD=bl%3D0%2Ccom.example-myKey%3D500%2Cd%3D4004');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('should sort custom keys that come after standard keys alphabetically', () => {
|
|
118
|
+
const cmcdObjects = [
|
|
119
|
+
new CmcdBufferLength(100), // 'bl'
|
|
120
|
+
new CmcdCustomKey('z-custom-key', 'value'), // 'z-custom-key' - should come last
|
|
121
|
+
new CmcdObjectDuration(4004), // 'd'
|
|
122
|
+
new CmcdCustomKey('m-custom-key', 123), // 'm-custom-key' - should come between 'd' and 'z'
|
|
123
|
+
];
|
|
124
|
+
|
|
125
|
+
const result = cmcdDataToUrlParameter(cmcdObjects);
|
|
126
|
+
|
|
127
|
+
// Expected alphabetical order: bl, d, m-custom-key, z-custom-key
|
|
128
|
+
expect(result).toEqual('CMCD=bl%3D100%2Cd%3D4004%2Cm-custom-key%3D123%2Cz-custom-key%3D%22value%22');
|
|
129
|
+
});
|
|
130
|
+
|
|
82
131
|
describe('Cmcd classes', () => {
|
|
83
132
|
it('should ignore keys with empty string value', () => {
|
|
84
133
|
expect(new CmcdContentId('').keyValuePairToString()).toEqual('');
|
|
@@ -224,7 +273,7 @@ describe('Cmcd', () => {
|
|
|
224
273
|
new CmcdCustomKey('com.example-myStringKey', 'myStringValue'),
|
|
225
274
|
];
|
|
226
275
|
expect(cmcdDataToUrlParameter(cmcdObjects)).toEqual(
|
|
227
|
-
'CMCD=
|
|
276
|
+
'CMCD=com.example-myNumericKey%3D500%2Ccom.example-myStringKey%3D%22myStringValue%22%2Cd%3D4004'
|
|
228
277
|
);
|
|
229
278
|
expect(cmcdDataToHeader(cmcdObjects)).toEqual({
|
|
230
279
|
'CMCD-Object': 'd=4004',
|
|
@@ -308,4 +357,4 @@ describe('Cmcd', () => {
|
|
|
308
357
|
});
|
|
309
358
|
});
|
|
310
359
|
});
|
|
311
|
-
});
|
|
360
|
+
});
|