@washingtonpost/wp-uspapi

5.0.2 • Public • Published

USPAPI

Getting started

npm install

Run unit tests: npm run test

Production build: npm run build

Validating it works in a browser:

__uspapi('getUSPData', 1, (uspData, success) => {
    if (success) { console.debug(uspData, success) }
    else { console.error('no') }
});

What is this?

This provides window.__uspapi which is needed by ad systems, third party trackers, and any operation that touches user data for CCPA for California residents and CDPA for Virginia residents.

The US Privacy API is our control mechanism for allowing users to opt out of tracking under the California CCPA and Virginia CDPA regulations. Users are eligible for use of the US Privacy API and the Do Not Sell mode if they are California or Virginia residents (as determined by their billing address) or have a California or Virginia geolocation.

Because the California law is strong and protects users outside of the CA Geo, we also use it to grant EU users the ability to opt-out of tracking under the promise we make them when they encounter our TCF banner in the EU and European Economic Area. We call this “EEA Ad Consent” mode, or “EAC”.

Finally, CA and VA residents are also eligible to use the Global Privacy Control. Normally users who wish to opt out do so using the Do Not Sell link in our footer (only available to VA & CA-residents or Geo). However, they can also do so using a signal at the browser level. GPC is that signal and can be activated in Chrome or Edge using a plugin or using a custom configuration for Firefox.

This package is intended to be a one stop shop for implementing the API which, to resolve race conditions, may need to be implimented more than once on the page. It is set up in order to support that approach.

Unit tests cover the functionality of this package under CA, VA and EAC settings.

Using this package

Including this package in your library will not automatically activate the USP API. You have to initiate it like so:

try {
	new Uspapi({
		log() {},
		debug: console.debug,
	});
} catch (e) {
	console.error('USP API attachment may have failed.');
}

Initiating Arguments

This class takes an object that emulates the structure of console. You can pass console directly in on browser-facing software. You can also use this structure to pass in your own logging objects or NOOP functions. The USPAPI library makes use of log for verbose console logging to understand program flow. It makes use of debug to message the console about errors and issues that might disrupt its proper functioning.

The Window Object

On class initiation the USP API library will attach itself to the window object along with any necessary other objects. You do not need to attach it to the window object yourself.

How to test

Use The Washington Post Confluence pages under Washington Post Data Privacy > Technical Guidance to find and leverage testing instructions.

Release Process

Make sure you are up to date

git pull git status npm ci npm test

Prepare the Release

npm run build

Update version numbers

Either use npm version or manually update the version in package.json & package-lock.json.

git tag 2.0.0

Publish

npm publish git push git push --tags

Readme

Keywords

none

Package Sidebar

Install

npm i @washingtonpost/wp-uspapi

Weekly Downloads

457

Version

5.0.2

License

ISC

Unpacked Size

91.4 kB

Total Files

27

Last publish

Collaborators

  • vladimirjv
  • catherine1234
  • mfernanda-sosa
  • dev-javu
  • vviswa
  • netolm-wp
  • yeswapo
  • harmanwapo
  • lpadillac4s
  • rjaya
  • granadoslopez
  • cashack
  • courtneybeesch
  • joshhoegen
  • thiago_srpt
  • alefkow
  • michelle_mark
  • ysmilde
  • shrddhawashpost
  • hanj.washpost
  • karenwang
  • carsonology
  • yuyanlei
  • dbnapp
  • colemanc4
  • vpenney
  • stevethedev
  • dkao
  • elenalacey
  • zhoyoyo
  • dwuandjune
  • fransandi
  • ashendruk
  • michaeldomine
  • mark-a-wapo
  • lenacohen
  • chris93007
  • sabrinamochi
  • jorgemhc-dev
  • carlyn
  • dgreen19
  • josephjames
  • niko_kom
  • nicrocs
  • avalbuena
  • sotojl
  • haileyhaymond
  • lukaskeelwapo
  • timborisenko
  • bantupallik
  • kt-prry
  • jesse.post.washpo
  • threeteaspoons
  • emilycsabens
  • luciovilla
  • tam.steph
  • agillespie
  • ani512
  • vonoehsene
  • emmakumer
  • aggyjlee
  • lavanderoi
  • emily.eng
  • lmelgar
  • sadbumblebee
  • janicekchen
  • jamelhendricks
  • ryanpicou
  • crunchwrap78
  • welchk
  • val-l-hosler
  • nick.mourtoupalas
  • benjaki
  • battand
  • jon.rosado
  • jacknugent27
  • asamireissa
  • courth
  • mahig
  • jchaskell
  • lorenzog
  • ln-washpost
  • stericson
  • talpert022
  • gengel
  • tuckabelle
  • nauticaharvin
  • aadittambe
  • natalievineberg
  • krbrooks
  • katty-huertas
  • mariaalconadabrooks
  • juniorh28
  • atomictangerine
  • emlorraine
  • helmsc
  • tritico
  • pranavganore
  • danacasidy
  • terrywp
  • ksemanur8
  • dreyvitser
  • mvonesh
  • chelseaconrad
  • arnolda-wp
  • hermionewy
  • wp-aberg
  • sheamus-hei
  • haysstephanie
  • broadwaterne
  • andrevinc
  • kat-alo
  • daniellersaul
  • stevefuenteswp
  • rekha26
  • marcnahed
  • amiemunoz
  • chloelangston
  • martinezy
  • seanwapo
  • ducroquet
  • jakekara
  • jtotoole
  • mjperales
  • arturgalocha
  • ebgranger
  • ramyalamati
  • adamsrobw
  • luke.connors
  • wrneff
  • mcdoh
  • floresa
  • taliatrackim
  • lennybronner
  • bitsoglass
  • it_procurement
  • davidchaiwapo
  • maddoxnelson
  • juliebacon
  • stephanie.clark
  • jasonvuong
  • jkoo87
  • kankelcr
  • gregoryauld2014
  • uncompiled
  • jbrown4
  • scarothers
  • khan.salauddin
  • rowhawn
  • subs-npm-builder
  • nealhumphreywapo
  • ashlynstill
  • ptnielsen
  • leslie-s
  • courtney-kan
  • kevin.schaul
  • jakecrump
  • macallah
  • jmuyskens
  • madisonwalls
  • brianaa
  • dsantamarina
  • artmsilva
  • ashtol
  • sberhanu
  • jjalcantara
  • alyssa.fowers
  • joemfox
  • reubenfb
  • calcantara
  • adrianblanco
  • chiquiesteban
  • iuraizee
  • bdgross
  • ulmonica
  • bmferrill
  • dankeating
  • emamd
  • timmeko
  • kevinuhrmacher
  • shellytan
  • harrystevens
  • chrisrukan
  • allisonnmann
  • aaronsteckelberg
  • shruthagandla
  • braforda
  • hannahmahon
  • adityajain15
  • linorabolini
  • anthonyjpesce
  • 1313davidlee
  • kate.rabinowitz
  • fontc
  • cecepascual
  • vsingarayar
  • aramzs
  • ruxk
  • nader_heidari
  • thompsond3
  • tylerremmel
  • tmac0201
  • joemoore-post
  • ealvarez79
  • hdormido
  • sgpotts
  • yutaochen
  • nwalker_wp
  • apbest
  • briannaschroer
  • shikha-sub
  • naema
  • chloemeister
  • julia.ledur
  • solomonsscott
  • betchavarria
  • eewright
  • nickkirkpatrick
  • trann_wapo
  • tobefrankhj
  • tierneyl
  • essiekim
  • sergio.pecanha
  • meganwalter
  • alyssabartuch
  • alexisbarnes
  • dmoriarty6
  • mokhtar.ali
  • dpham5
  • klimenkovd
  • davisshaver
  • aaronbrezel
  • moodypaige.e
  • kastningj