Skip to content

Commit 0dbd6e2

Browse files
clean up console.logs and excess comments
1 parent 6941e26 commit 0dbd6e2

File tree

1 file changed

+8
-33
lines changed
  • web-integrations/prebid-integrations/client-side-deferred

1 file changed

+8
-33
lines changed

web-integrations/prebid-integrations/client-side-deferred/index.html

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,17 @@
88
<script async src="../prebid.js"></script>
99
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
1010
<script>
11-
console.log('Initializing deferred ${IDENTITY_NAME} + Prebid example.');
12-
13-
const identityName = '${IDENTITY_NAME}'; // 'UID2' or 'EUID'
11+
const identityName = '${IDENTITY_NAME}';
1412
const apiBaseKey = identityName === 'EUID' ? 'euidApiBase' : 'uid2ApiBase';
15-
const userIdName = identityName.toLowerCase(); // 'uid2' or 'euid'
13+
const userIdName = identityName.toLowerCase();
1614
const storageKey = '${UID_STORAGE_KEY}';
1715

18-
// Track the current state
1916
let uidConfigured = false;
2017

2118
function updateGuiElements() {
22-
console.log('Updating displayed values.');
23-
24-
// Try to get identity from Prebid
2519
let identity = pbjs.getUserIds ? pbjs.getUserIds()[userIdName] : null;
2620
let advertisingToken = identity ? identity.id : null;
2721

28-
// Check localStorage for token data
2922
let isOptedOut = false;
3023
const storedToken = localStorage.getItem(storageKey);
3124
if (storedToken) {
@@ -35,14 +28,11 @@
3528
if (!advertisingToken && tokenData.latestToken && tokenData.latestToken.advertising_token) {
3629
advertisingToken = tokenData.latestToken.advertising_token;
3730
}
38-
} catch (e) {
39-
console.log('Could not parse stored token');
40-
}
31+
} catch (e) {}
4132
}
4233

4334
const hasValidToken = !!advertisingToken;
4435

45-
// Update token status
4636
$('#targeted_advertising_ready').text(hasValidToken ? 'yes' : 'no');
4737
$('#login_required').text(hasValidToken ? 'no' : 'yes');
4838
$('#has_opted_out').text(isOptedOut ? 'yes' : 'no');
@@ -70,7 +60,6 @@
7060
}
7161
}
7262

73-
// Update UI visibility
7463
updateFormVisibility(hasValidToken, isOptedOut);
7564
}
7665

@@ -79,7 +68,6 @@
7968
$('#login_form').hide();
8069
$('#clear_storage_form').show();
8170
} else if (uidConfigured) {
82-
// UID is configured but no token yet - might be loading
8371
$('#login_form').hide();
8472
$('#clear_storage_form').show();
8573
} else {
@@ -88,17 +76,14 @@
8876
}
8977
}
9078

91-
// This is called when user clicks "Configure UID with mergeConfig()"
9279
async function handleDeferredLogin() {
9380
const email = $('#email').val();
9481
if (!email) {
9582
alert('Please enter an email address');
9683
return;
9784
}
9885

99-
console.log('=== DEFERRED LOGIN: Using mergeConfig() to add UID configuration ===');
100-
101-
// Build the UID config to merge
86+
// Build UID config to merge - this adds UID AFTER page load
10287
const uidConfig = {
10388
userSync: {
10489
userIds: [
@@ -115,44 +100,36 @@
115100
},
116101
};
117102

118-
// Add consent management for EUID
119103
if (identityName === 'EUID') {
120104
uidConfig.consentManagement = consentManagementObj;
121105
}
122106

123-
// Show what we're merging
124-
console.log('Calling pbjs.mergeConfig() with:', JSON.stringify(uidConfig, null, 2));
125107
$('#merged_config').text(JSON.stringify(uidConfig, null, 2));
126108
$('#merge_config_display').show();
127109

128-
// *** KEY STEP 1: Use mergeConfig() to add UID configuration ***
110+
// Use mergeConfig() to add UID configuration after page load
129111
pbjs.mergeConfig(uidConfig);
130112

131-
// *** KEY STEP 2: Call refreshUserIds() to trigger token generation ***
132-
console.log('Calling pbjs.refreshUserIds() to generate token...');
113+
// Call refreshUserIds() to trigger token generation
133114
await pbjs.refreshUserIds();
134115

135116
uidConfigured = true;
136117

137-
// Wait a moment for token to be generated
138118
setTimeout(() => {
139119
updateGuiElements();
140120
}, 2000);
141121
}
142122

143123
function handleClearStorage() {
144-
console.log('Clearing storage and resetting state.');
145124
localStorage.removeItem(storageKey);
146125
uidConfigured = false;
147126
location.reload();
148127
}
149128

150129
function onDocumentReady() {
151-
console.log('Setting up interface handlers.');
152130
$('#configure_uid').click(handleDeferredLogin);
153131
$('#clear_storage').click(handleClearStorage);
154132

155-
// Display initial config immediately
156133
displayInitialConfig();
157134

158135
pbjs.que.push(function() {
@@ -161,7 +138,7 @@
161138
});
162139
}
163140

164-
// Initial Prebid config - WITHOUT UID
141+
// Initial Prebid config - WITHOUT UID (deferred pattern)
165142
const initialPrebidConfig = {
166143
debug: true,
167144
userSync: {
@@ -170,12 +147,10 @@
170147
},
171148
};
172149

173-
// Display the initial config (called on document ready)
174150
function displayInitialConfig() {
175151
$('#initial_config').text(JSON.stringify(initialPrebidConfig, null, 2));
176152
}
177153

178-
// Apply the initial Prebid config
179154
function setInitialConfig() {
180155
pbjs.setConfig(initialPrebidConfig);
181156
}
@@ -226,7 +201,7 @@
226201
var pbjs = pbjs || {};
227202
pbjs.que = pbjs.que || [];
228203
pbjs.que.push(function () {
229-
// Set initial config WITHOUT UID - this is the deferred pattern!
204+
// Initial config WITHOUT UID - UID is added later via mergeConfig()
230205
setInitialConfig();
231206
pbjs.addAdUnits(adUnits);
232207
pbjs.requestBids();

0 commit comments

Comments
 (0)