Skip to content

Update all commands to rely solely on callbacks #55

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

Merged
merged 10 commits into from
Apr 14, 2023

Conversation

nealrosen
Copy link
Contributor

@nealrosen nealrosen commented Jan 30, 2023

Resolves issues #23, #51, and #52

Changes in this PR include

  • Removed direct return values from all commands
  • Added callback support for all commands
  • Updated addEventHandler command to return initial EventListener response through callback instead of return value
  • Added success parameter to all callbacks
  • Fixed 2 typos in the sample stub code
  • Removed getGPPData command

@nealrosen nealrosen marked this pull request as ready for review January 30, 2023 21:18
Copy link

@janwinkler janwinkler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments :-)

@@ -234,32 +228,25 @@ The `addEventListener` command can be used to define a callback function (or a p
<tr>
<td><code>callback</code></td>
<td>function</td>
<td>function (data: EventListener)</td>
<td>function (data: <a href="https://github.com/InteractiveAdvertisingBureau/Global-Privacy-Platform/blob/main/Core/CMP%20API%20Specification.md#eventlistener-">EventListener</a>, success: boolean)</td>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do i get there? the callback for the event or the callback for the eventlistener object? what doess sucess do? (why give success = false if there is still an eventListener Object in the callback)?

proposal:

  • use callback as a callback (always). in this case, the callback would return immediatly after registering the eventListerner and gives the eventListener Object (so i can unregister it)
  • use parameter as the function that should be called when the event happens. the function will (also) get the eventLister Object (but filled with context data about the event)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I fully understand your comment here...
The callback returns the EventListener object as defined just below this section. I'm not sure what you mean by the callback fro the event vs the callback for the eventlistener object.

I've added success to the callbacks to align with both the TCF spec and the sample stub code in this GPP spec. For this command, success would be false if the CMP failed to register the listener for any reason.

Copy link
Contributor Author

@nealrosen nealrosen Jan 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After re-reading your comment, I think we're on the same page. The only change here is that instead of directly returning immediately, the callback would be used for that initial response. The callback would, of course, also continue to be used when future events are triggered. I have added more descriptive text to the text above this table

@@ -166,6 +160,12 @@ supportedAPIs : Array of string, // list of supported APIs (prefix strings), e.g

cmpId : Number, // IAB assigned CMP ID, may be 0 during stub/loading

sectionList : Array of Number, // may be empty during loading of the CMP
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this say array of integer?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we are using "Number" elsewere, it makes sence to keep it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hoping to avoid inflating this PR any bigger than it already is. Jan mentioned that Number is used in other parts of this document. I'd prefer to use Number here to be consistent. If we want to update all "Number"s that should be "Integer"s, I think that should be handled in a separate issue/pull request

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, the string specification documents say integer though

@@ -166,6 +160,12 @@ supportedAPIs : Array of string, // list of supported APIs (prefix strings), e.g

cmpId : Number, // IAB assigned CMP ID, may be 0 during stub/loading

sectionList : Array of Number, // may be empty during loading of the CMP

applicableSections: Array of Number, // Section ID considered to be in force for this transaction. In most cases, this field should have a single section ID. In rare occasions where such a single section ID can not be determined, the field may contain up to 2 values. The value can be 0 or a Section ID specified by the Publisher / Advertiser, during stub / load. When no section is applicable, the value will be -1.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be array of integer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jan and I would prefer to leave it as Number for this PR to be consistent with the rest of the documentation. If it is decided that this and other parts of the document should be changed to Integer, I feel that should be addressed in a separate issue/PR

@nealrosen nealrosen requested review from patmmccann and janwinkler and removed request for janwinkler and patmmccann February 2, 2023 16:59
@nealrosen nealrosen requested review from patmmccann and removed request for janwinkler February 7, 2023 16:34
Copy link

@janwinkler janwinkler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two tiny changes please ;-)

@@ -871,7 +773,7 @@ window.__gpp_stub = function ()
if (cmd === 'ping')
{
return {
gppVersion : '1.0', // must be “Version.Subversion”, current: “1.0
gppVersion : '1.1', // must be “Version.Subversion”, current: “1.1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the 3 "new" properties (sectionList, applicableSections, gppString) need to be added to ping, addEventListener and removeEventlisterner:

sectionList:[],
applicableSections:[-1], //or 0 or ID set by publisher
gppString:''

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@@ -1042,7 +926,7 @@ The sent message shall follow the form outlined below. The command, parameter an
__gppCall: {
command: "command",
parameter: “parameter”,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you correct the " ? we have three different quotes here (normal, cursive and single quotes) - lets stick to one ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

…tListener, and removeEventListener callbacks in example stub code
@nealrosen nealrosen requested review from janwinkler and removed request for patmmccann February 7, 2023 17:26
Copy link

@janwinkler janwinkler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-)

@lamrowena
Copy link
Collaborator

@nealrosen can you please also update the description of applicableSections to the following --
applicableSections: Array of Number, // Section ID considered to be in force for this transaction. In most cases, this field should have a single section ID. In rare occasions where such a single section ID can not be determined, the field may contain up to 2 values. During the transition period which ends on July 1, 2023, the legacy USPrivacy section may be determined as applicable along with another US section. In this case, the field may contain up to 3 values where one of the values is 6, representing the legacy USPrivacy section. The value can be 0 or a Section ID specified by the Publisher / Advertiser, during stub / load. When no section is applicable, the value will be -1.

This addresses Issue #21.

@nealrosen
Copy link
Contributor Author

@lamrowena I have updated the applicableSections description. I see there are now conflict between the PR and the develop branch. At least part of the conflict is due to a recent commit made by HeinzBaumann. I think we should review the conflicts on today's call to determine how to resolve them.

@lamrowena lamrowena merged commit 315ced5 into InteractiveAdvertisingBureau:develop Apr 14, 2023
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

Successfully merging this pull request may close these issues.

6 participants