videojs / videojs-contrib-ads

A Tool for Building Video.js Ad Plugins
http://videojs.github.io/videojs-contrib-ads/
Other
379 stars 257 forks source link

feat: Add support for US Privacy macro for CCPA compliance #551

Closed alex-barstow closed 1 year ago

alex-barstow commented 1 year ago

Description

This PR adds support for a {usp.uspString} macro that is replaced with the US Privacy consent string, which is acquired using the IAB's USP API if it is available. The implementation follows the reference code from IAB-- the API is invoked directly if it is available in the same window as the player, or via postMessage() if in a parent window. This also follows the same basic pattern as our implementation of TCF in this plugin, with a key difference. TCF triggers an event whenever the consent string changes, which lets us easily keep the string updated. The USP API does not, and manual asynchronous API calls are necessary to update it.

Test pages with reference USP API implementation:

Open the pages and select different options from the "Do Not Sell My Data" menu.