Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMP API (@iabgpp/cmpapi) will not import existing event listeners from a stub using the "Example stub code" from the GPP CMP API Specification #60

Open
NevilleS opened this issue Aug 12, 2024 · 0 comments

Comments

@NevilleS
Copy link

Overview

Hello all!

We were testing some edge cases for the interaction between a __gpp CMP stub implementation and then subsequently loading the CmpApi and ran into a very subtle issue.

When CmpApi is created, it creates a new EventListenerQueue that gets existing queued commands from any existing window.__gpp implementation:

let events = window["__gpp"]("events") || [];

However, there's a subtle issue here: this relies on an "events" command, e.g. __gpp("events") which returns the internal event queue from the stub. This is implemented by the official stub here:

if (b.length == 1 && b[0] == "events") {

The issue is that the "events" command isn't part of the GPP specification, so it's not guaranteed to exist in a stub! In particular, the example stub implementation in the GPP standard doesn't include this command: https://github.com/InteractiveAdvertisingBureau/Global-Privacy-Platform/blob/main/Core/CMP%20API%20Specification.md#examples

To summarize:

  1. Publisher implements a stub following the GPP specification using the example here: https://github.com/InteractiveAdvertisingBureau/Global-Privacy-Platform/blob/main/Core/CMP%20API%20Specification.md#examples
  2. Publisher uses their stub to call __gpp("addEventListener", () => ...) to register an event listener with the GPP API
  3. Publisher initializes a CMP implementation that uses the @iabgpp/cmpapi library to implement the API
  4. CmpApi initializes and does not import the existing event listener (from step tcfcav2 unit tests #2), causing that listener to never receive GPP events

Possible Solutions

  1. This can be avoided by ensuring publishers avoid using the "example" GPP stub from the specification, and instead use the published stub from @iabgpp/stub. This is probably what 99% of implementations do anyways! In this scenario, I'd recommend updating the GPP specification to recommend this and link to the @iabgpp/stub implementation instead
  2. Alternatively, the CmpApi implementation could be updated to detect if the "example" GPP stub is being used and, if so, fallback to importing the __gpp.events array instead of trying to call __gpp("events") if it doesn't exist. This might have it's own issues, but...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant