• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

prebid / Prebid.js / 22873923570

09 Mar 2026 08:44PM UTC coverage: 96.327% (-0.001%) from 96.328%
22873923570

push

github

web-flow
MediaEyes Bid Adapter : Support Video Type (#14565)

* MediaEyes Bid Adapter : Update Support Video Type

* fix eslint

* modifications as suggested

* improve code as suggested

56971 of 69697 branches covered (81.74%)

50 of 51 new or added lines in 2 files covered. (98.04%)

465 existing lines in 60 files now uncovered.

217514 of 225807 relevant lines covered (96.33%)

70.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/modules/novatiqIdSystem.js
1
/**
1✔
2
 * This module adds novatiqId to the User ID module
3
 * The {@link module:modules/userId} module is required
4
 * @module modules/novatiqIdSystem
5
 * @requires module:modules/userId
6
 */
7

8
import { logInfo, getWindowLocation } from '../src/utils.js';
9
import { ajax } from '../src/ajax.js';
10
import { submodule } from '../src/hook.js';
11
import { getStorageManager } from '../src/storageManager.js';
12
import { MODULE_TYPE_UID } from '../src/activities/modules.js';
13

14
/**
15
 * @typedef {import('../modules/userId/index.js').Submodule} Submodule
16
 * @typedef {import('../modules/userId/index.js').SubmoduleConfig} SubmoduleConfig
17
 */
18

19
const MODULE_NAME = 'novatiq';
1✔
20

21
/** @type {Submodule} */
22
export const novatiqIdSubmodule = {
1✔
23

24
  /**
25
   * used to link submodule with config
26
   * @type {string}
27
   */
28
  name: MODULE_NAME,
29
  /**
30
   * used to specify vendor id
31
   * @type {number}
32
   */
33
  gvlid: 1119,
34

35
  /**
36
   * decode the stored id value for passing to bid requests
37
   * @function
38
   * @returns {{novatiq: {snowflake: string}}}
39
   */
40
  decode(novatiqId, config) {
41
    const responseObj = {
3✔
42
      novatiq: {
43
        snowflake: novatiqId
44
      }
45
    };
46

47
    if (novatiqId.syncResponse !== undefined) {
3✔
48
      responseObj.novatiq.ext = {};
2✔
49
      responseObj.novatiq.ext.syncResponse = novatiqId.syncResponse;
2✔
50
    }
51

52
    if (typeof config !== 'undefined' && typeof config.params !== 'undefined' && typeof config.params.removeAdditionalInfo !== 'undefined' && config.params.removeAdditionalInfo === true) {
3✔
53
      delete responseObj.novatiq.snowflake.syncResponse;
1✔
54
    }
55

56
    return responseObj;
3✔
57
  },
58

59
  /**
60
   * performs action to obtain id and return a value in the callback's response argument
61
   * @function
62
   * @param {SubmoduleConfig} config
63
   * @returns {string}
64
   */
65
  getId(config) {
66
    const configParams = config.params || {};
5!
67
    const urlParams = this.getUrlParams(configParams);
5✔
68
    const srcId = this.getSrcId(configParams, urlParams);
5✔
69
    const sharedId = this.getSharedId(configParams);
5✔
70
    const useCallbacks = this.useCallbacks(configParams);
5✔
71

72
    logInfo('NOVATIQ config params: ' + JSON.stringify(configParams));
5✔
73
    logInfo('NOVATIQ Sync request used sourceid param: ' + srcId);
5✔
74
    logInfo('NOVATIQ Sync request Shared ID: ' + sharedId);
5✔
75

76
    return this.sendSyncRequest(useCallbacks, sharedId, srcId, urlParams);
5✔
77
  },
78

79
  sendSyncRequest(useCallbacks, sharedId, sspid, urlParams) {
80
    const syncUrl = this.getSyncUrl(sharedId, sspid, urlParams);
5✔
81
    const url = syncUrl.url;
5✔
82
    const novatiqId = syncUrl.novatiqId;
5✔
83

84
    // for testing
85
    const sharedStatus = (sharedId !== null && sharedId !== undefined && sharedId !== false) ? 'Found' : 'Not Found';
5✔
86

87
    if (useCallbacks) {
5✔
88
      const res = this.sendAsyncSyncRequest(novatiqId, url); ;
1✔
89
      res.sharedStatus = sharedStatus;
1✔
90

91
      return res;
1✔
92
    } else {
93
      this.sendSimpleSyncRequest(novatiqId, url);
4✔
94

95
      return {
4✔
96
        'id': novatiqId,
97
        'sharedStatus': sharedStatus
98
      }
99
    }
100
  },
101

102
  sendAsyncSyncRequest(novatiqId, url) {
103
    logInfo('NOVATIQ Setting up ASYNC sync request');
2✔
104

105
    const resp = function (callback) {
2✔
UNCOV
106
      logInfo('NOVATIQ *** Calling ASYNC sync request');
×
107

108
      function onSuccess(response, responseObj) {
109
        let syncrc;
110
        var novatiqIdJson = { syncResponse: 0 };
×
111
        syncrc = responseObj.status;
×
112
        logInfo('NOVATIQ Sync Response Code:' + syncrc);
×
113
        logInfo('NOVATIQ *** ASYNC request returned ' + syncrc);
×
UNCOV
114
        if (syncrc === 200) {
×
115
          novatiqIdJson = { 'id': novatiqId, syncResponse: 1 };
×
116
        } else {
UNCOV
117
          if (syncrc === 204) {
×
UNCOV
118
            novatiqIdJson = { 'id': novatiqId, syncResponse: 2 };
×
119
          }
120
        }
UNCOV
121
        callback(novatiqIdJson);
×
122
      }
123

UNCOV
124
      ajax(url,
×
125
        { success: onSuccess },
126
        undefined, { method: 'GET', withCredentials: false });
127
    }
128

129
    return { callback: resp };
2✔
130
  },
131

132
  sendSimpleSyncRequest(novatiqId, url) {
133
    logInfo('NOVATIQ Sending SIMPLE sync request');
4✔
134

135
    ajax(url, undefined, undefined, { method: 'GET', withCredentials: false });
4✔
136

137
    logInfo('NOVATIQ snowflake: ' + novatiqId);
4✔
138
  },
139

140
  getNovatiqId(urlParams) {
141
    // standard uuid format
142
    let uuidFormat = [1e7] + -1e3 + -4e3 + -8e3 + -1e11;
6✔
143
    if (urlParams.useStandardUuid === false) {
6✔
144
      // novatiq standard uuid(like) format
145
      uuidFormat = uuidFormat + 1e3;
6✔
146
    }
147

148
    return (uuidFormat).replace(/[018]/g, c =>
6✔
149
      (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
210✔
150
    );
151
  },
152

153
  getSyncUrl(sharedId, sspid, urlParams) {
154
    const novatiqId = this.getNovatiqId(urlParams);
6✔
155

156
    let url = 'https://spadsync.com/sync?' + urlParams.novatiqId + '=' + novatiqId;
6✔
157

158
    if (urlParams.useSspId) {
6✔
159
      url = url + '&sspid=' + sspid;
6✔
160
    }
161

162
    if (urlParams.useSspHost) {
6✔
163
      const ssphost = getWindowLocation().hostname;
6✔
164
      logInfo('NOVATIQ partner hostname: ' + ssphost);
6✔
165

166
      url = url + '&ssphost=' + ssphost;
6✔
167
    }
168

169
    // append on the shared ID if we have one
170
    if (sharedId !== null && sharedId !== undefined) {
6✔
171
      url = url + '&sharedId=' + sharedId;
3✔
172
    }
173

174
    return {
6✔
175
      url: url,
176
      novatiqId: novatiqId
177
    }
178
  },
179

180
  getUrlParams(configParams) {
181
    const urlParams = {
7✔
182
      novatiqId: 'snowflake',
183
      useStandardUuid: false,
184
      useSspId: true,
185
      useSspHost: true
186
    }
187

188
    if (typeof configParams.urlParams !== 'undefined') {
7✔
189
      if (configParams.urlParams.novatiqId !== undefined) {
1✔
190
        urlParams.novatiqId = configParams.urlParams.novatiqId;
1✔
191
      }
192
      if (configParams.urlParams.useStandardUuid !== undefined) {
1✔
193
        urlParams.useStandardUuid = configParams.urlParams.useStandardUuid;
1✔
194
      }
195
      if (configParams.urlParams.useSspId !== undefined) {
1✔
196
        urlParams.useSspId = configParams.urlParams.useSspId;
1✔
197
      }
198
      if (configParams.urlParams.useSspHost !== undefined) {
1✔
199
        urlParams.useSspHost = configParams.urlParams.useSspHost;
1✔
200
      }
201
    }
202

203
    return urlParams;
7✔
204
  },
205

206
  useCallbacks(configParams) {
207
    return typeof configParams.useCallbacks !== 'undefined' && configParams.useCallbacks === true;
5✔
208
  },
209

210
  useSharedId(configParams) {
211
    return typeof configParams.useSharedId !== 'undefined' && configParams.useSharedId === true;
3✔
212
  },
213

214
  getCookieOrStorageID(configParams) {
215
    let cookieOrStorageID = '_pubcid';
1✔
216

217
    if (typeof configParams.sharedIdName !== 'undefined' && configParams.sharedIdName !== null && configParams.sharedIdName !== '') {
1!
UNCOV
218
      cookieOrStorageID = configParams.sharedIdName;
×
UNCOV
219
      logInfo('NOVATIQ sharedID name redefined: ' + cookieOrStorageID);
×
220
    }
221

222
    return cookieOrStorageID;
1✔
223
  },
224

225
  // return null if we aren't supposed to use one or we are but there isn't one present
226
  getSharedId(configParams) {
227
    let sharedId = null;
3✔
228
    if (this.useSharedId(configParams)) {
3✔
229
      const cookieOrStorageID = this.getCookieOrStorageID(configParams);
1✔
230
      const storage = getStorageManager({ moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME });
1✔
231

232
      // first check local storage
233
      if (storage.hasLocalStorage()) {
1✔
234
        sharedId = storage.getDataFromLocalStorage(cookieOrStorageID);
1✔
235
        logInfo('NOVATIQ sharedID retrieved from local storage:' + sharedId);
1✔
236
      }
237

238
      // if nothing check the local cookies
239
      if (sharedId === null || sharedId === undefined) {
1!
240
        sharedId = storage.getCookie(cookieOrStorageID);
1✔
241
        logInfo('NOVATIQ sharedID retrieved from cookies:' + sharedId);
1✔
242
      }
243
    }
244

245
    logInfo('NOVATIQ sharedID returning: ' + sharedId);
3✔
246

247
    return sharedId;
3✔
248
  },
249

250
  getSrcId(configParams, urlParams) {
251
    if (urlParams.useSspId === false) {
9!
UNCOV
252
      logInfo('NOVATIQ Configured to NOT use sspid');
×
UNCOV
253
      return '';
×
254
    }
255

256
    logInfo('NOVATIQ Configured sourceid param: ' + configParams.sourceid);
9✔
257

258
    let srcId;
259
    if (typeof configParams.sourceid === 'undefined' || configParams.sourceid === null || configParams.sourceid === '') {
9✔
260
      srcId = '000';
3✔
261
      logInfo('NOVATIQ sourceid param set to value 000 due to undefined parameter or missing value in config section');
3✔
262
    } else if (configParams.sourceid.length < 3 || configParams.sourceid.length > 3) {
6✔
263
      srcId = '001';
1✔
264
      logInfo('NOVATIQ sourceid param set to value 001 due to wrong size in config section 3 chars max e.g. 1ab');
1✔
265
    } else {
266
      srcId = configParams.sourceid;
5✔
267
    }
268
    return srcId;
9✔
269
  },
270
  eids: {
271
    'novatiq': {
272
      getValue: function(data) {
UNCOV
273
        if (data.snowflake.id === undefined) {
×
UNCOV
274
          return data.snowflake;
×
275
        }
276

UNCOV
277
        return data.snowflake.id;
×
278
      },
279
      source: 'novatiq.com',
280
    },
281
  }
282
};
283
submodule('userId', novatiqIdSubmodule);
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc