Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/anonymisedRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down
1 change: 0 additions & 1 deletion modules/anonymisedRtdProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
23 changes: 6 additions & 17 deletions test/spec/modules/anonymisedRtdProvider_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down Expand Up @@ -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',
Expand All @@ -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() {
Expand Down
Loading