Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/trackers/PillarboxMonitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class PillarboxMonitoring {
log: JSON
.stringify(error.metadata || pillarbox.log.history().slice(-15)),
message: error.message,
name: error.code,
name: PillarboxMonitoring.errorKeyCode(error.code),
...playbackPosition,
url
});
Expand Down Expand Up @@ -815,6 +815,25 @@ class PillarboxMonitoring {
};
}

/**
* Returns a string representing the error key combined with its error code.
*
* If the error code doesn't exist the error key undefined.
*
* @param {number} code The error code
*
* @returns {string} The error key combined with its error code
*/
static errorKeyCode(code) {
const error = [
'MEDIA_ERR_CUSTOM',
...Object.keys(window.MediaError),
'MEDIA_ERR_ENCRYPTED'
];

return `${error[code]}: ${code}`;
}

/**
* Generates a new session ID.
*
Expand Down
1 change: 1 addition & 0 deletions test/trackers/pillarbox-monitoring.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ describe('PillarboxMonitoring', () => {
let monitoring;

global.navigator.sendBeacon = jest.fn();
global.window.MediaError = jest.fn().mockReturnValue({ });

beforeEach(() => {
player = playerMock();
Expand Down
Loading