Skip to content

Commit 0ee4b54

Browse files
replace uid2 references with generic naming
1 parent 9f5f9bf commit 0ee4b54

File tree

1 file changed

+13
-13
lines changed
  • web-integrations/javascript-sdk/server-side

1 file changed

+13
-13
lines changed

web-integrations/javascript-sdk/server-side/server.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const docsBaseUrl = process.env.DOCS_BASE_URL;
2727

2828
// Initialize UID JavaScript SDK in a simulated browser environment using jsdom
2929
// This demonstrates that the client-side SDK works in Node.js with jsdom
30-
let uid2Sdk = null;
30+
let uidSdk = null;
3131
let dom = null;
3232

3333
async function initializeSDK() {
@@ -59,7 +59,7 @@ async function initializeSDK() {
5959
dom.window.TextEncoder = util.TextEncoder;
6060
dom.window.TextDecoder = util.TextDecoder;
6161

62-
// Load the UID2 SDK script from CDN
62+
// Load the UID SDK script from CDN
6363
try {
6464
const response = await axios.get(uidJsSdkUrl);
6565

@@ -72,15 +72,15 @@ async function initializeSDK() {
7272
await new Promise(resolve => setTimeout(resolve, 100));
7373

7474
// Get reference to the SDK
75-
uid2Sdk = dom.window[uidJsSdkName];
76-
if (!uid2Sdk) {
75+
uidSdk = dom.window[uidJsSdkName];
76+
if (!uidSdk) {
7777
throw new Error(`SDK not found at window.${uidJsSdkName}`);
7878
}
7979

8080
// Initialize the SDK
81-
uid2Sdk.init({ baseUrl: uidBaseUrl });
81+
uidSdk.init({ baseUrl: uidBaseUrl });
8282

83-
return uid2Sdk;
83+
return uidSdk;
8484
} catch (error) {
8585
console.error('Failed to initialize SDK:', error);
8686
throw error;
@@ -119,7 +119,7 @@ app.get('/', (req, res) => {
119119
* Uses the JavaScript SDK's setIdentityFromEmail method on the server
120120
*/
121121
app.post('/login', async (req, res) => {
122-
if (!uid2Sdk) {
122+
if (!uidSdk) {
123123
return res.render('error', {
124124
error: 'SDK not initialized. Server may still be starting up.',
125125
response: null,
@@ -138,20 +138,20 @@ app.post('/login', async (req, res) => {
138138
const callbackHandler = (eventType, payload) => {
139139
if ((eventType === 'InitCompleted' || eventType === 'IdentityUpdated') && payload?.identity) {
140140
clearTimeout(timeout);
141-
uid2Sdk.callbacks.splice(uid2Sdk.callbacks.indexOf(callbackHandler), 1);
141+
uidSdk.callbacks.splice(uidSdk.callbacks.indexOf(callbackHandler), 1);
142142
resolve(payload.identity);
143143
}
144144

145145
if (eventType === 'OptoutReceived') {
146146
clearTimeout(timeout);
147-
uid2Sdk.callbacks.splice(uid2Sdk.callbacks.indexOf(callbackHandler), 1);
147+
uidSdk.callbacks.splice(uidSdk.callbacks.indexOf(callbackHandler), 1);
148148
reject(new Error('Got unexpected token generate status: optout'));
149149
}
150150
};
151151

152-
uid2Sdk.callbacks.push(callbackHandler);
152+
uidSdk.callbacks.push(callbackHandler);
153153

154-
uid2Sdk.setIdentityFromEmail(
154+
uidSdk.setIdentityFromEmail(
155155
req.body.email,
156156
{
157157
subscriptionId: subscriptionId,
@@ -186,8 +186,8 @@ app.post('/login', async (req, res) => {
186186
* Logout endpoint - clears session and returns to main page
187187
*/
188188
app.get('/logout', (req, res) => {
189-
if (uid2Sdk && uid2Sdk.disconnect) {
190-
uid2Sdk.disconnect();
189+
if (uidSdk && uidSdk.disconnect) {
190+
uidSdk.disconnect();
191191
}
192192
req.session = null;
193193
res.redirect('/');

0 commit comments

Comments
 (0)