-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Added global function for refreshing user id's #5752
Conversation
this is a good start, but it doesn't take into account the fact that the user id modules will likely need to call their servers again to get a fresh ID. here's a use case:
In fact, in step 4 the userId module actually needs to issue a |
To address @smenzer's points, that refresh flag would need to be passed down into I would also like if there were a way to only refresh specific submodules. In my particular case, the effect of being logged in only effects a handful of submodules, so it would be better for me to trigger just the ones I know will benefit from the new information instead of having to update them all. I think two reasonable ways to do this would be:
I would probably prefer |
i like that approach and something i was thinking about too. if you specify a list of submodules, then it's clear which ones are getting refreshed and having that passed in as a condition to call |
Refactored for individual submodule refresh. I've done some initial testing and the submodule's getId method is called on refresh. I may still be missing something though (I'm not super familiar with this code). Please let me know if there's more I need to do. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few comments/questions, but overall I like this approach
I added submodule initialization to the refresh function, so that it won't quit early if they aren't initialized. I think this will work correctly based on both your comments above. |
this is looking good. when you add tests, can you make sure that in addition to just calling |
Refactored refresh user id's parameter to be optional where an empty list will result in all modules being refreshed.
Made the submodule name list parameter optional, and if absent all modules will be refreshed. Also, added a unit test, and verified that the most recently updated config will be read when refreshing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests feel a bit light, can we add some about which submodules get refreshed based on what you pass in, etc.?
|
||
if (!storedId || refreshNeeded || !!forceRefresh || !storedConsentDataMatchesConsentData(storedConsentData, consentData)) { | ||
// No id previously saved, or a refresh is needed, or consent has changed. Request a new id from the submodule. | ||
response = submodule.submodule.getId(submodule.config.params, consentData, storedId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do folks think about passing forceRefresh
into this function so if a submodule wants to treat a refresh differently for some reason, they can?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@icflournoy do you have thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've created a new issue to track interest in this: #5818
@TLadd could you add a test (or edit one of the existing ones) to cover the |
@TLadd @coryhammon1 The CI build is failing in Edge with this message ... can you look into it and see if you can find anything that broke the Zeotap adapter and attempt to fix, too, please?
|
Added that here: #5815. Am currently using that branch to try and figure out what's going on with the failing test as well. Pushed up some logs and seeing some odd behavior. Notice here Edge 17 fails, but here and here it's Edge 18, so it's not entirely deterministic. In the build where I added logs, I get this output:
Compared to one of the browsers that succeeds:
So it fails because somehow the cookie isn't set properly in the Edit, after significantly more logging, it seems that the cookie is set properly (it shows up in |
* Test callback in refreshUserIds test * Remove zeotapIdPlus expiration on cookie in test because it caused it to intermittently fail
it looks like you've been working on an outdated version of master that has an old version of the zeotap test. if you look at the version in this PR compared to what is in master (https://github.com/prebid/Prebid.js/blob/master/test/spec/modules/zeotapIdPlusIdSystem_spec.js) you'll see that several of these cookie calls have been removed per #5758. Make sure you do a full merge of master and resolve the conflicts, then this should be working properly. This may have been due to #5815 I'm not sure |
@smenzer Yep, sure enough, the same failures were happening on master before that PR that mocked writing to cookies: https://app.circleci.com/pipelines/github/prebid/Prebid.js/2130/workflows/efbe4e02-8090-41ea-a517-adef33a6410a/jobs/9900. I've created #5819 that merged the latest master and removes the mocking, as it is no longer necessary after removing the expiration time on the cookie. I'm generally of the philosophy that mocking should be avoided unless they make tests easier to write/maintain and don't diminish the value of the test significantly. In this case, the tests aren't easier to write and assuming cookies work in the tests, I think that does provide some value to the tests. There are a lot things that can go wrong with cookies. Trying to write a unit test suite for cookie storage that covers every possible thing that could go wrong within Prebid would be really hard. Even if you did have such a suite, mocks can be set incorrectly and behave differently than reality. Part of the reason to bother running these tests in multiple browsers I assume is to catch browser-specific behavior, which you don't get when mocking browser API's. Just my 2 cents on the matter; as I said in #5819, I can easily go back to the mocking solution if that's preferred. |
closing in favor of #5819 |
Type of change
Description of change
Added a global function to refresh user id's after initialization on page load. This seems to be the simplest way to get this functionality without adding more complexity into the user id module itself. Essentially, the function triggers a reinitialization of all user id modules, so if there were any changes to the stored values after page load, those new values will be included in the any bid requests.
Be sure to test the integration with your adserver using the Hello World sample page.
For any changes that affect user-facing APIs or example code documented on http://prebid.org, please provide:
Other information
#5683