Skip to content

Commit b2d9cd7

Browse files
author
Eiman Eltigani
committed
Revert Secure Signals UI detection changes (moved to separate PR)
1 parent 507f00b commit b2d9cd7

3 files changed

Lines changed: 25 additions & 25 deletions

File tree

web-integrations/google-secure-signals/client-server/server.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const uidJsSdkName = process.env.UID_JS_SDK_NAME || '__uid2';
1919

2020
// Secure Signals configuration
2121
const secureSignalsSdkUrl = process.env.UID_SECURE_SIGNALS_SDK_URL || 'https://cdn.integ.uidapi.com/uid2SecureSignal.js';
22-
const secureSignalsStorageKey = process.env.UID_SECURE_SIGNALS_STORAGE_KEY || '_GESPSK-uidapi.com';
2322

2423
// UI/Display configuration
2524
const identityName = process.env.IDENTITY_NAME;
@@ -49,7 +48,7 @@ app.get('/', (req, res) => {
4948
uidJsSdkUrl,
5049
uidJsSdkName,
5150
secureSignalsSdkUrl,
52-
secureSignalsStorageKey,
51+
secureSignalsStorageKey: process.env.UID_SECURE_SIGNALS_STORAGE_KEY,
5352
identityName,
5453
docsBaseUrl
5554
});
@@ -148,7 +147,7 @@ app.post('/login', async (req, res) => {
148147
uidJsSdkUrl,
149148
uidJsSdkName,
150149
secureSignalsSdkUrl,
151-
secureSignalsStorageKey,
150+
secureSignalsStorageKey: process.env.UID_SECURE_SIGNALS_STORAGE_KEY,
152151
identityName,
153152
docsBaseUrl
154153
});
@@ -174,7 +173,7 @@ app.post('/login', async (req, res) => {
174173
uidJsSdkUrl,
175174
uidJsSdkName,
176175
secureSignalsSdkUrl,
177-
secureSignalsStorageKey,
176+
secureSignalsStorageKey: process.env.UID_SECURE_SIGNALS_STORAGE_KEY,
178177
identityName,
179178
docsBaseUrl
180179
});

web-integrations/google-secure-signals/client-server/views/index.html

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@
2525
$("#login_required").html(sdk.isLoginRequired() ? "yes" : "no");
2626
$("#identity_state").html(String(JSON.stringify(payload, null, 2)));
2727

28+
// Update Secure Signals values displayed in the GUI
2829
updateSecureSignals();
29-
if (sdk.getAdvertisingToken()) {
30-
setTimeout(updateSecureSignals, 1000);
31-
}
3230

3331
<% if (isOptout) { %>
3432
$("#login_form").hide();
@@ -37,13 +35,15 @@
3735
$("#optout_banner").show();
3836
$('#googleAdContainer').hide();
3937
<% } else { %>
38+
// before token generation, show login form
4039
if (sdk.isLoginRequired()) {
4140
$("#login_form").show();
4241
$("#logout_form").hide();
4342
$("#optout_form").hide();
4443
$("#optout_banner").hide();
4544
$('#googleAdContainer').hide();
4645
} else {
46+
// Success case - token generated, show logout form
4747
$("#login_form").hide();
4848
$("#logout_form").show();
4949
$("#optout_form").hide();
@@ -55,14 +55,12 @@
5555

5656
function updateSecureSignals() {
5757
try {
58+
// Read from localStorage
5859
const secureSignalsStorageKey = '<%- secureSignalsStorageKey %>';
5960
const secureSignalsStorage = localStorage[secureSignalsStorageKey];
60-
const token = sdk.getAdvertisingToken();
61-
if (token && !secureSignalsStorage) {
62-
location.reload();
63-
return;
64-
}
61+
6562
const secureSignalsStorageJson = secureSignalsStorage && JSON.parse(secureSignalsStorage);
63+
6664
if (secureSignalsStorageJson && secureSignalsStorageJson[1]) {
6765
$("#secure_signals_loaded").html("yes");
6866
$("#secure_signals_value").html(JSON.stringify(secureSignalsStorageJson, null, 2));
@@ -85,14 +83,12 @@
8583
$("#logout").click(() => {
8684
window.googletag.secureSignalProviders.clearAllCache();
8785
sdk.disconnect();
88-
localStorage.removeItem('<%- secureSignalsStorageKey %>');
8986
window.location.href = '/';
9087
});
9188

9289
$("#try_another").click(() => {
9390
window.googletag.secureSignalProviders.clearAllCache();
9491
sdk.disconnect();
95-
localStorage.removeItem('<%- secureSignalsStorageKey %>');
9692
window.location.href = '/';
9793
});
9894

@@ -107,12 +103,16 @@
107103
sdk.callbacks.push((eventType, payload) => {
108104
if (eventType === 'InitCompleted') {
109105
<% if (identity !== null && typeof identity !== 'undefined') { %>
106+
// Server provided an identity, set it
110107
if (sdk.isLoginRequired()) {
111108
sdk.setIdentity(<%- JSON.stringify(identity) %>);
112109
} else {
110+
// Identity already exists, just update GUI
113111
updateGuiElements(payload);
114112
}
115113
<% } else { %>
114+
// No identity from server (including opt-out case)
115+
// SDK will naturally remain in "login required" state
116116
updateGuiElements(payload);
117117
<% if (isOptout) { %>
118118
$("#optout_banner").show();
@@ -160,7 +160,6 @@
160160

161161
<!-- UID2 Integration Status Section -->
162162
<h2><%- identityName %> Integration Status</h2>
163-
<p class="section-summary"><strong>Note:</strong> This is a test-only integration environment—it does not collect data or generate production-level tokens.</p>
164163

165164
<table id="uid_state">
166165
<tr>
@@ -238,7 +237,7 @@ <h2 class="section-teal">Google Secure Signals Status</h2>
238237
</div>
239238
</div>
240239
</td>
241-
<td class="value"><pre id="secure_signals_loaded">no</pre></td>
240+
<td class="value"><pre id="secure_signals_loaded"></pre></td>
242241
</tr>
243242
<tr>
244243
<td class="label">
@@ -252,7 +251,7 @@ <h2 class="section-teal">Google Secure Signals Status</h2>
252251
</div>
253252
</div>
254253
</td>
255-
<td class="value"><pre id="secure_signals_value">undefined</pre></td>
254+
<td class="value"><pre id="secure_signals_value"></pre></td>
256255
</tr>
257256
</table>
258257

web-integrations/google-secure-signals/server-side/views/index.html

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,24 @@
77
<link rel="stylesheet" type="text/css" href="/stylesheets/style.css" />
88
<link rel="shortcut icon" href="/images/favicon.png" />
99
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
10+
<script async src="<%- secureSignalsSdkUrl %>"></script>
11+
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
12+
1013
<script type="text/javascript">
1114
const getUid2AdvertisingToken = async () => {
1215
const response = await fetch('/getFreshToken');
13-
if (!response.ok) return undefined;
1416
const result = await response.json();
15-
return result && result.advertising_token;
17+
console.log(result);
18+
return result.advertising_token;
1619
};
20+
1721
window.getUid2AdvertisingToken = getUid2AdvertisingToken;
18-
</script>
19-
<script src="<%- secureSignalsSdkUrl %>"></script>
20-
<script type="text/javascript">
22+
23+
// If uid2SecureSignalProvider is initialized before getUid2AdvertisingToken is assigned, call registerSecureSignalProvider
2124
if (window.__uid2SecureSignalProvider) {
2225
window.__uid2SecureSignalProvider.registerSecureSignalProvider();
2326
}
2427
</script>
25-
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
2628
<script>
2729
$(document).ready(() => {
2830
const secureSignalsStorageKey = '<%- secureSignalsStorageKey %>';
@@ -46,7 +48,8 @@
4648
}
4749
}
4850

49-
[1000, 2000, 3000].forEach((ms) => setTimeout(updateSecureSignals, ms));
51+
// Update Secure Signals display after SDK has time to load and fetch token
52+
setTimeout(updateSecureSignals, 1000);
5053

5154
$('#logout').click(() => {
5255
if (window.googletag && window.googletag.secureSignalProviders) {
@@ -104,7 +107,6 @@ <h1>Server-Side <%- identityName %> Integration Example with Google Secure Signa
104107

105108
<!-- UID2 Integration Status Section -->
106109
<h2><%- identityName %> Integration Status</h2>
107-
<p class="section-summary"><strong>Note:</strong> This is a test-only integration environment—it does not collect data or generate production-level tokens.</p>
108110

109111
<table id="uid_state">
110112
<tr>

0 commit comments

Comments
 (0)