|
110 | 110 | // Use mergeConfig() to add UID configuration after page load |
111 | 111 | pbjs.mergeConfig(uidConfig); |
112 | 112 |
|
113 | | - // Call refreshUserIds() to trigger token generation |
114 | | - await pbjs.refreshUserIds(); |
| 113 | + console.log(`[${identityName}] Config merged. Calling refreshUserIds for ${userIdName} only...`); |
| 114 | + |
| 115 | + // Call refreshUserIds() with submoduleNames to only refresh UID2/EUID specifically |
| 116 | + await pbjs.refreshUserIds({ submoduleNames: [userIdName] }); |
| 117 | + |
| 118 | + console.log(`[${identityName}] refreshUserIds complete. Current getUserIds():`, pbjs.getUserIds()); |
115 | 119 |
|
116 | 120 | uidConfigured = true; |
117 | 121 |
|
|
121 | 125 | } |
122 | 126 |
|
123 | 127 | function handleClearStorage() { |
| 128 | + // Clear UID2 identity from browser storage |
124 | 129 | localStorage.removeItem(storageKey); |
125 | | - uidConfigured = false; |
| 130 | + |
| 131 | + // Page reload is required to clear Prebid's in-memory cache. |
| 132 | + // Unlike the UID2 SDK which has disconnect(), Prebid's UID2 module |
| 133 | + // doesn't expose a method to clear just UID2 without affecting other ID modules. |
126 | 134 | location.reload(); |
127 | 135 | } |
128 | 136 |
|
@@ -247,11 +255,17 @@ <h3>📄 Initial Prebid Config (on page load)</h3> |
247 | 255 |
|
248 | 256 | <!-- Instructions --> |
249 | 257 | <div id="merge_instructions" class="merge-instructions"> |
250 | | - <p><strong>What happens when you click:</strong></p> |
| 258 | + <p><strong>What happens when you click "Configure":</strong></p> |
251 | 259 | <ol> |
252 | 260 | <li><code>pbjs.mergeConfig(uidConfig)</code> - Merges ${IDENTITY_NAME} user ID module configuration into the existing Prebid config without overwriting other settings. This allows adding ${IDENTITY_NAME} after the page has already loaded.</li> |
253 | | - <li><code>pbjs.refreshUserIds()</code> - Triggers Prebid to re-fetch all configured user IDs, including the newly added ${IDENTITY_NAME} module, which initiates token generation using the provided email and CSTG credentials.</li> |
| 261 | + <li><code>pbjs.refreshUserIds({ submoduleNames: ['${IDENTITY_NAME_LOWER}'] })</code> - Triggers Prebid to re-fetch the ${IDENTITY_NAME} user ID specifically, which initiates token generation using the provided email and CSTG credentials.</li> |
| 262 | + </ol> |
| 263 | + <p><strong>What happens when you click "Clear":</strong></p> |
| 264 | + <ol> |
| 265 | + <li><code>localStorage.removeItem(storageKey)</code> - Clears the ${IDENTITY_NAME} identity from browser storage.</li> |
| 266 | + <li><code>location.reload()</code> - Reloads the page to clear Prebid's in-memory cache, preventing future bid requests from using the old token.</li> |
254 | 267 | </ol> |
| 268 | + <p class="config-note"><strong>Why reload?</strong> ${IDENTITY_NAME} state lives in browser storage and Prebid's memory. Prebid only reads the token—it doesn't provide a method to clear just ${IDENTITY_NAME} without affecting other ID modules. Page reload ensures a clean state.</p> |
255 | 269 | </div> |
256 | 270 |
|
257 | 271 | <!-- UID Token Status Section --> |
|
0 commit comments