Skip to content

Commit

Permalink
airgridRtdProvider: use provided tag insertion method `loadExternalSc…
Browse files Browse the repository at this point in the history
…ript` (prebid#9901)

* chore: update `getAudiencesAsBidderOrtb2` implementation and test

* chore: use provided tag insertion method

* fix: add `airgrid` to `_approvedLoadExternalJSList`

* fix: use 'sdk' path if no publisherId is provided

* fix: use accountId as path param for script url

* fix: assign edktInitializor props before `loadExternalScript` call

* fix: set `edktInitializor.invoked` before calling `loadExternalScript`

* fix: restore method for setting `user.ext.data`
feat: extend module data setting using `user.keywords` for appnexus

* fix: rollback changes to data setting method
  • Loading branch information
naripok authored and Michele Nasti committed Aug 25, 2023
1 parent f29f4d8 commit 964ee0d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
23 changes: 11 additions & 12 deletions modules/airgridRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import {
deepAccess,
} from '../src/utils.js';
import { getGlobal } from '../src/prebidGlobal.js';
import {getStorageManager} from '../src/storageManager.js';
import {MODULE_TYPE_RTD} from '../src/activities/modules.js';
import { getStorageManager } from '../src/storageManager.js';
import { loadExternalScript } from '../src/adloader.js';
import { MODULE_TYPE_RTD } from '../src/activities/modules.js';

const MODULE_NAME = 'realTimeData';
const SUBMODULE_NAME = 'airgrid';
Expand All @@ -25,6 +26,11 @@ export const storage = getStorageManager({
moduleName: SUBMODULE_NAME,
});

function getModuleUrl(accountId) {
const path = accountId ?? 'sdk';
return `https://cdn.edkt.io/${path}/edgekit.min.js`;
}

/**
* Attach script tag to DOM
* @param {Object} rtdConfig
Expand All @@ -33,19 +39,12 @@ export const storage = getStorageManager({
export function attachScriptTagToDOM(rtdConfig) {
var edktInitializor = (window.edktInitializor = window.edktInitializor || {});
if (!edktInitializor.invoked) {
edktInitializor.invoked = true;
edktInitializor.accountId = rtdConfig.params.accountId;
edktInitializor.publisherId = rtdConfig.params.publisherId;
edktInitializor.apiKey = rtdConfig.params.apiKey;
edktInitializor.load = function (e) {
var p = e || 'sdk';
var n = document.createElement('script');
n.type = 'module';
n.async = true;
n.src = 'https://cdn.edkt.io/' + p + '/edgekit.min.js';
document.getElementsByTagName('head')[0].appendChild(n);
};
edktInitializor.load(edktInitializor.accountId);
edktInitializor.invoked = true;
const moduleSrc = getModuleUrl(rtdConfig.params.accountId);
loadExternalScript(moduleSrc, SUBMODULE_NAME);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/adloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const _approvedLoadExternalJSList = [
'aaxBlockmeter',
'confiant',
'arcspan',
'airgrid',
'clean.io'
]

Expand Down
2 changes: 2 additions & 0 deletions test/spec/modules/airgridRtdProvider_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { config } from 'src/config.js';
import { deepAccess } from 'src/utils.js';
import { getAdUnits } from '../../fixtures/fixtures.js';
import * as agRTD from 'modules/airgridRtdProvider.js';
import { loadExternalScript } from '../../../src/adloader.js';

const MATCHED_AUDIENCES = ['travel', 'sport'];
const RTD_CONFIG = {
Expand Down Expand Up @@ -40,6 +41,7 @@ describe('airgrid RTD Submodule', function () {
expect(agRTD.airgridSubmodule.init(RTD_CONFIG.dataProviders[0])).to.equal(
true
);
expect(loadExternalScript.called).to.be.true
});

it('should attach script to DOM with correct config', function () {
Expand Down

0 comments on commit 964ee0d

Please sign in to comment.