From 5afc68ddba7f92d0b2cf526efe984e5910f3d632 Mon Sep 17 00:00:00 2001 From: Pavlo Date: Thu, 2 Apr 2026 14:51:47 +0300 Subject: [PATCH 1/3] removed obsolete tagUrl setting --- modules/anonymisedRtdProvider.js | 4 ++-- modules/anonymisedRtdProvider.md | 1 - .../modules/anonymisedRtdProvider_spec.js | 23 +++++-------------- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/modules/anonymisedRtdProvider.js b/modules/anonymisedRtdProvider.js index dd8b563d254..43d3d653bef 100644 --- a/modules/anonymisedRtdProvider.js +++ b/modules/anonymisedRtdProvider.js @@ -56,14 +56,14 @@ export function createRtdProvider(moduleName) { } logMessage(`${SUBMODULE_NAME}RtdProvider: Loading Marketing Tag`); // Check if the script is already loaded - if (document.querySelector(`script[src*="${config.params.tagUrl ?? MARKETING_TAG_URL}"]`)) { + if (document.querySelector(`script[src*="${MARKETING_TAG_URL}"]`)) { logMessage(`${SUBMODULE_NAME}RtdProvider: Marketing Tag already loaded`); return; } const tagConfig = config.params?.tagConfig ? { ...config.params.tagConfig, idw_client_id: config.params.tagConfig.clientId } : {}; delete tagConfig.clientId; - const tagUrl = config.params.tagUrl ? config.params.tagUrl : `${MARKETING_TAG_URL}?ref=prebid&d=${window.location.hostname}`; + const tagUrl = `${MARKETING_TAG_URL}?ref=prebid&d=${window.location.hostname}`; loadExternalScript(tagUrl, MODULE_TYPE_RTD, SUBMODULE_NAME, () => { logMessage(`${SUBMODULE_NAME}RtdProvider: Marketing Tag loaded successfully`); diff --git a/modules/anonymisedRtdProvider.md b/modules/anonymisedRtdProvider.md index 0541eeae746..b1abe866b69 100644 --- a/modules/anonymisedRtdProvider.md +++ b/modules/anonymisedRtdProvider.md @@ -46,7 +46,6 @@ Anonymised’s Real-time Data Provider automatically obtains segment IDs from th | params.bidders | `Array` | Bidders with which to share segment information | Optional | | params.segtax | `Integer` | The taxonomy for Anonymised | '1000' always | | params.tagConfig | `Object` | Configuration for the Anonymised Marketing Tag | Optional. Defaults to `{}`. | -| params.tagUrl | `String` | The URL of the Anonymised Marketing Tag script | Optional. Defaults to `https://static.anonymised.io/light/loader.js`. | The `anonymisedRtdProvider` must be integrated into the publisher's website along with the [Anonymised Marketing Tag](https://support.anonymised.io/integrate/marketing-tag?t=LPukVCXzSIcRoal5jggyeg). One way to install the Marketing Tag is through `anonymisedRtdProvider` by specifying the required [parameters](https://support.anonymised.io/integrate/optional-anonymised-tag-parameters?t=LPukVCXzSIcRoal5jggyeg) in the `tagConfig` object. diff --git a/test/spec/modules/anonymisedRtdProvider_spec.js b/test/spec/modules/anonymisedRtdProvider_spec.js index 6345515931d..6cc09a89297 100644 --- a/test/spec/modules/anonymisedRtdProvider_spec.js +++ b/test/spec/modules/anonymisedRtdProvider_spec.js @@ -32,6 +32,10 @@ describe('anonymisedRtdProvider', function() { }); describe('anonymisedRtdSubmodule', function() { + afterEach(function () { + document.querySelectorAll('script[src*="static.anonymised.io"]').forEach(s => s.parentNode.removeChild(s)); + }); + it('successfully instantiates', function () { expect(anonymisedRtdSubmodule.init()).to.equal(true); }); @@ -115,7 +119,7 @@ describe('anonymisedRtdProvider', function() { anonymisedRtdSubmodule.init(rtdConfig, {}); expect(loadExternalScriptStub.called).to.be.false; }); - it('should load external script from tagUrl when it is set', function () { + it('should load external script from the default URL even if the outdated tagUrl is set', function () { const rtdConfig = { params: { tagUrl: 'https://example.io/loader.js', @@ -125,25 +129,10 @@ describe('anonymisedRtdProvider', function() { } }; anonymisedRtdSubmodule.init(rtdConfig, {}); - const expected = 'https://example.io/loader.js'; + const expected = `https://static.anonymised.io/light/loader.js?ref=prebid&d=${window.location.hostname}`; expect(loadExternalScriptStub.args[0][0]).to.deep.equal(expected); }); - it('should not load external script from tagUrl when it is already loaded', function () { - const rtdConfig = { - params: { - tagUrl: 'https://example.io/loader.js', - tagConfig: { - clientId: 'testId' - } - } - }; - const script = document.createElement('script'); - script.src = 'https://example.io/loader.js'; - document.body.appendChild(script); - anonymisedRtdSubmodule.init(rtdConfig, {}); - expect(loadExternalScriptStub.called).to.be.false; - }); }); describe('Get Real-Time Data', function() { From 525b5bd89ea9010aedb6ab12e8e8e79c99dfeea9 Mon Sep 17 00:00:00 2001 From: Pavlo Date: Thu, 2 Apr 2026 15:48:06 +0300 Subject: [PATCH 2/3] strip the protocol from MARKETING_TAG_URL when building the querySelector selector, so it matches http://, https://, and protocol-relative (//) src values. --- modules/anonymisedRtdProvider.js | 4 +-- .../modules/anonymisedRtdProvider_spec.js | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/modules/anonymisedRtdProvider.js b/modules/anonymisedRtdProvider.js index 43d3d653bef..90153ee6c65 100644 --- a/modules/anonymisedRtdProvider.js +++ b/modules/anonymisedRtdProvider.js @@ -55,8 +55,8 @@ export function createRtdProvider(moduleName) { return; } logMessage(`${SUBMODULE_NAME}RtdProvider: Loading Marketing Tag`); - // Check if the script is already loaded - if (document.querySelector(`script[src*="${MARKETING_TAG_URL}"]`)) { + // Check if the script is already loaded (match on host/path only to handle http://, https://, and protocol-relative URLs) + if (document.querySelector(`script[src*="${MARKETING_TAG_URL.replace(/^https?:\/\//, '')}"]`)) { logMessage(`${SUBMODULE_NAME}RtdProvider: Marketing Tag already loaded`); return; } diff --git a/test/spec/modules/anonymisedRtdProvider_spec.js b/test/spec/modules/anonymisedRtdProvider_spec.js index 6cc09a89297..627b6003278 100644 --- a/test/spec/modules/anonymisedRtdProvider_spec.js +++ b/test/spec/modules/anonymisedRtdProvider_spec.js @@ -119,6 +119,34 @@ describe('anonymisedRtdProvider', function() { anonymisedRtdSubmodule.init(rtdConfig, {}); expect(loadExternalScriptStub.called).to.be.false; }); + it('should not load external script when it is already loaded via http://', function () { + const rtdConfig = { + params: { + tagConfig: { + clientId: 'testId' + } + } + }; + const script = document.createElement('script'); + script.src = 'http://static.anonymised.io/light/loader.js'; + document.body.appendChild(script); + anonymisedRtdSubmodule.init(rtdConfig, {}); + expect(loadExternalScriptStub.called).to.be.false; + }); + it('should not load external script when it is already loaded via protocol-relative URL', function () { + const rtdConfig = { + params: { + tagConfig: { + clientId: 'testId' + } + } + }; + const script = document.createElement('script'); + script.src = '//static.anonymised.io/light/loader.js'; + document.body.appendChild(script); + anonymisedRtdSubmodule.init(rtdConfig, {}); + expect(loadExternalScriptStub.called).to.be.false; + }); it('should load external script from the default URL even if the outdated tagUrl is set', function () { const rtdConfig = { params: { From cb23f5a73db169c4929aa3ec286eb8aadb486a68 Mon Sep 17 00:00:00 2001 From: Pavlo Date: Fri, 3 Apr 2026 12:32:37 +0300 Subject: [PATCH 3/3] logs a deprecation warning when tagUrl is set --- modules/anonymisedRtdProvider.js | 9 +++++-- modules/anonymisedRtdProvider.md | 1 + .../modules/anonymisedRtdProvider_spec.js | 27 ++++++++++++++++--- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/modules/anonymisedRtdProvider.js b/modules/anonymisedRtdProvider.js index 90153ee6c65..da894df0149 100644 --- a/modules/anonymisedRtdProvider.js +++ b/modules/anonymisedRtdProvider.js @@ -55,15 +55,20 @@ export function createRtdProvider(moduleName) { return; } logMessage(`${SUBMODULE_NAME}RtdProvider: Loading Marketing Tag`); + let tagBaseUrl = MARKETING_TAG_URL; + if (config.params?.tagUrl) { + logWarn(`${SUBMODULE_NAME}RtdProvider: params.tagUrl is deprecated and will be removed in a future release.`); + tagBaseUrl = config.params.tagUrl; + } // Check if the script is already loaded (match on host/path only to handle http://, https://, and protocol-relative URLs) - if (document.querySelector(`script[src*="${MARKETING_TAG_URL.replace(/^https?:\/\//, '')}"]`)) { + if (document.querySelector(`script[src*="${tagBaseUrl.replace(/^https?:\/\//, '')}"]`)) { logMessage(`${SUBMODULE_NAME}RtdProvider: Marketing Tag already loaded`); return; } const tagConfig = config.params?.tagConfig ? { ...config.params.tagConfig, idw_client_id: config.params.tagConfig.clientId } : {}; delete tagConfig.clientId; - const tagUrl = `${MARKETING_TAG_URL}?ref=prebid&d=${window.location.hostname}`; + const tagUrl = `${tagBaseUrl}?ref=prebid&d=${window.location.hostname}`; loadExternalScript(tagUrl, MODULE_TYPE_RTD, SUBMODULE_NAME, () => { logMessage(`${SUBMODULE_NAME}RtdProvider: Marketing Tag loaded successfully`); diff --git a/modules/anonymisedRtdProvider.md b/modules/anonymisedRtdProvider.md index b1abe866b69..b5830dd864a 100644 --- a/modules/anonymisedRtdProvider.md +++ b/modules/anonymisedRtdProvider.md @@ -46,6 +46,7 @@ Anonymised’s Real-time Data Provider automatically obtains segment IDs from th | params.bidders | `Array` | Bidders with which to share segment information | Optional | | params.segtax | `Integer` | The taxonomy for Anonymised | '1000' always | | params.tagConfig | `Object` | Configuration for the Anonymised Marketing Tag | Optional. Defaults to `{}`. | +| params.tagUrl | `String` | The URL of the Anonymised Marketing Tag script | **Deprecated.** Will be removed in a future release. Defaults to `https://static.anonymised.io/light/loader.js`. | The `anonymisedRtdProvider` must be integrated into the publisher's website along with the [Anonymised Marketing Tag](https://support.anonymised.io/integrate/marketing-tag?t=LPukVCXzSIcRoal5jggyeg). One way to install the Marketing Tag is through `anonymisedRtdProvider` by specifying the required [parameters](https://support.anonymised.io/integrate/optional-anonymised-tag-parameters?t=LPukVCXzSIcRoal5jggyeg) in the `tagConfig` object. diff --git a/test/spec/modules/anonymisedRtdProvider_spec.js b/test/spec/modules/anonymisedRtdProvider_spec.js index 627b6003278..f975ce2351f 100644 --- a/test/spec/modules/anonymisedRtdProvider_spec.js +++ b/test/spec/modules/anonymisedRtdProvider_spec.js @@ -32,8 +32,13 @@ describe('anonymisedRtdProvider', function() { }); describe('anonymisedRtdSubmodule', function() { + let logWarnStub; + beforeEach(function () { + logWarnStub = sinon.stub(require('src/utils.js'), 'logWarn'); + }); afterEach(function () { - document.querySelectorAll('script[src*="static.anonymised.io"]').forEach(s => s.parentNode.removeChild(s)); + logWarnStub.restore(); + document.querySelectorAll('script[src*="static.anonymised.io"], script[src*="example.io"]').forEach(s => s.parentNode.removeChild(s)); }); it('successfully instantiates', function () { @@ -147,7 +152,7 @@ describe('anonymisedRtdProvider', function() { anonymisedRtdSubmodule.init(rtdConfig, {}); expect(loadExternalScriptStub.called).to.be.false; }); - it('should load external script from the default URL even if the outdated tagUrl is set', function () { + it('should load external script from tagUrl when set and log a deprecation warning', function () { const rtdConfig = { params: { tagUrl: 'https://example.io/loader.js', @@ -157,9 +162,25 @@ describe('anonymisedRtdProvider', function() { } }; anonymisedRtdSubmodule.init(rtdConfig, {}); - const expected = `https://static.anonymised.io/light/loader.js?ref=prebid&d=${window.location.hostname}`; + const expected = `https://example.io/loader.js?ref=prebid&d=${window.location.hostname}`; expect(loadExternalScriptStub.args[0][0]).to.deep.equal(expected); + expect(logWarnStub.calledWithMatch('params.tagUrl is deprecated')).to.be.true; + }); + it('should not load external script from tagUrl when it is already loaded', function () { + const rtdConfig = { + params: { + tagUrl: 'https://example.io/loader.js', + tagConfig: { + clientId: 'testId' + } + } + }; + const script = document.createElement('script'); + script.src = 'https://example.io/loader.js'; + document.body.appendChild(script); + anonymisedRtdSubmodule.init(rtdConfig, {}); + expect(loadExternalScriptStub.called).to.be.false; }); });