You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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:
Publisher uses their stub to call __gpp("addEventListener", () => ...) to register an event listener with the GPP API
Publisher initializes a CMP implementation that uses the @iabgpp/cmpapi library to implement the API
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
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
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...
The text was updated successfully, but these errors were encountered:
Overview
Hello all!
We were testing some edge cases for the interaction between a
__gpp
CMP stub implementation and then subsequently loading theCmpApi
and ran into a very subtle issue.When
CmpApi
is created, it creates a newEventListenerQueue
that gets existing queued commands from any existingwindow.__gpp
implementation:iabgpp-es/modules/cmpapi/src/cmpapi/EventListenerQueue.ts
Line 21 in b03e54c
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:iabgpp-es/modules/stub/src/stub.js
Line 22 in b03e54c
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:
__gpp("addEventListener", () => ...)
to register an event listener with the GPP API@iabgpp/cmpapi
library to implement the APICmpApi
initializes and does not import the existing event listener (from step tcfcav2 unit tests #2), causing that listener to never receive GPP eventsPossible Solutions
@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 insteadCmpApi
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...The text was updated successfully, but these errors were encountered: