Skip to content

Commit 5c68a85

Browse files
committed
πŸ”– v1.4.0
1 parent 24a926b commit 5c68a85

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

β€Žsourcelink.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žsourcelink.js.LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
*
33
* Copyright (c) 2025 Praba Ponnambalam
4-
* Version: 1.3.0
4+
* Version: 1.4.0
55
* Released under the MIT License.
66
*
77
*/

β€Žsourcelinkdev.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,21 @@ const cloudFunctionUrl = "https://us-west1-ms-source-tracking-tool-dev.cloudfunc
4242

4343
// Get client ID from script tag
4444
const scriptTag = document.currentScript;
45-
const clientId = scriptTag.getAttribute('data-client-id');
45+
const scriptUrl = scriptTag.src;
46+
47+
// Parse query string manually
48+
const getClientId = (url) => {
49+
const queryString = url.split('?')[1];
50+
if (!queryString) return null;
51+
52+
const params = new URLSearchParams(queryString);
53+
return params.get('clientId');
54+
};
55+
56+
const clientId = getClientId(scriptUrl);
4657

4758
if (!clientId) {
48-
console.error('Client ID is required');
59+
console.error('Pixel ID is required');
4960
return;
5061
}
5162

@@ -93,7 +104,7 @@ const cloudFunctionUrl = "https://us-west1-ms-source-tracking-tool-dev.cloudfunc
93104
if (!response.ok) {
94105
if (response.status === 403) {
95106
console.warn(
96-
`🚫 SourceLink disabled - Client ${CLIENT_ID} is inactive`,
107+
`🚫 SourceLink disabled - Pixel ${CLIENT_ID} is inactive`,
97108
);
98109
} else {
99110
console.warn(`⚠️ Source tracking error - Status: ${response.status}`);
@@ -149,7 +160,7 @@ const cloudFunctionUrl = "https://us-west1-ms-source-tracking-tool-dev.cloudfunc
149160
sessionStorage.setItem(SESSION_KEY, isActive.toString());
150161
return isActive;
151162
} catch (error) {
152-
console.error('Error validating client:', error);
163+
console.error('Error validating pixel:', error);
153164
return false;
154165
}
155166
};
@@ -318,7 +329,7 @@ const cloudFunctionUrl = "https://us-west1-ms-source-tracking-tool-dev.cloudfunc
318329
const init = async () => {
319330
const isActive = await validateClient();
320331
if (!isActive) {
321-
console.warn(`🚫 SourceLink disabled - Client ${CLIENT_ID} is inactive`);
332+
console.warn(`🚫 SourceLink disabled - Pixel ${CLIENT_ID} is inactive`);
322333
return;
323334
}
324335

0 commit comments

Comments
Β (0)