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

prebid / Prebid.js / 18136225893

30 Sep 2025 04:07PM UTC coverage: 96.245% (+0.006%) from 96.239%
18136225893

push

github

web-flow
Advertising Bid Adapter: Update the regex while parsing bid.impid to support the change to UUID format for bid ids (#13879)

51890 of 63472 branches covered (81.75%)

1 of 1 new or added line in 1 file covered. (100.0%)

70 existing lines in 12 files now uncovered.

198517 of 206262 relevant lines covered (96.25%)

125.12 hits per line

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

97.87
/modules/utiqIdSystem.js
1
/**
1✔
2
 * This module adds Utiq provided by Utiq SA/NV to the User ID module
3
 * The {@link module:modules/userId} module is required
4
 * @module modules/utiqIdSystem
5
 * @requires module:modules/userId
6
 */
7
import { logInfo } from '../src/utils.js';
8
import { submodule } from '../src/hook.js';
9
import { getStorageManager } from '../src/storageManager.js';
10
import { MODULE_TYPE_UID } from '../src/activities/modules.js';
11
import { findUtiqService } from "../libraries/utiqUtils/utiqUtils.ts";
12
import { getGlobal } from '../src/prebidGlobal.js';
13

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

18
const MODULE_NAME = 'utiqId';
1✔
19
const LOG_PREFIX = 'Utiq module';
1✔
20

21
export const storage = getStorageManager({
1✔
22
  moduleType: MODULE_TYPE_UID,
23
  moduleName: MODULE_NAME,
24
});
25

26
/**
27
 * Get the "atid" from html5 local storage to make it available to the UserId module.
28
 * @returns {{utiq: (*|string)}}
29
 */
30
function getUtiqFromStorage() {
31
  let utiqPass;
32
  const utiqPassStorage = JSON.parse(
30✔
33
    storage.getDataFromLocalStorage('utiqPass')
34
  );
35

36
  const netIdAdtechpass = storage.getDataFromLocalStorage('netid_utiq_adtechpass');
30✔
37

38
  if (netIdAdtechpass) {
30✔
39
    logInfo(
1✔
40
      `${LOG_PREFIX}: Local storage netid_utiq_adtechpass: ${netIdAdtechpass}`
41
    );
42
    return {
1✔
43
      utiq: netIdAdtechpass,
44
    }
45
  }
46

47
  if (
29✔
48
    utiqPassStorage &&
56✔
49
    utiqPassStorage.connectId &&
50
    Array.isArray(utiqPassStorage.connectId.idGraph) &&
51
    utiqPassStorage.connectId.idGraph.length > 0
52
  ) {
53
    utiqPass = utiqPassStorage.connectId.idGraph[0];
9✔
54

55
    logInfo(
9✔
56
      `${LOG_PREFIX}: Local storage utiqPass: ${JSON.stringify(
57
        utiqPassStorage
58
      )}`
59
    );
60

61
    logInfo(
9✔
62
      `${LOG_PREFIX}: Graph of utiqPass: ${JSON.stringify(
63
        utiqPass
64
      )}`
65
    );
66
  }
67

68
  return {
29✔
69
    utiq:
70
      utiqPass && utiqPass.atid
67✔
71
        ? utiqPass.atid
72
        : null,
73
  };
74
}
75

76
/** @type {Submodule} */
77
export const utiqIdSubmodule = {
1✔
78
  /**
79
   * Used to link submodule with config
80
   * @type {string}
81
   */
82
  name: MODULE_NAME,
83
  disclosureURL: 'local://modules/utiqDeviceStorageDisclosure.json',
84
  /**
85
   * Decodes the stored id value for passing to bid requests.
86
   * @function
87
   * @returns {{utiq: string} | null}
88
   */
89
  decode(bidId) {
90
    logInfo(`${LOG_PREFIX}: Decoded ID value ${JSON.stringify(bidId)}`);
5✔
91
    return bidId.utiq ? bidId : null;
5✔
92
  },
93
  /**
94
   * Get the id from helper function and initiate a new user sync.
95
   * @param config
96
   * @returns {{callback: Function}|{id: {utiq: string}}}
97
   */
98
  getId: function (config) {
99
    const data = getUtiqFromStorage();
12✔
100
    if (data.utiq) {
12✔
101
      logInfo(`${LOG_PREFIX}: Local storage ID value ${JSON.stringify(data)}`);
6✔
102
      return { id: { utiq: data.utiq } };
6✔
103
    } else {
104
      if (!config) {
6✔
105
        config = {};
5✔
106
      }
107
      if (!config.params) {
6✔
108
        config.params = {};
5✔
109
      }
110
      if (
6✔
111
        typeof config.params.maxDelayTime === 'undefined' ||
7✔
112
        config.params.maxDelayTime === null
113
      ) {
114
        config.params.maxDelayTime = 1000;
5✔
115
      }
116
      // Current delay and delay step in milliseconds
117
      let currentDelay = 0;
6✔
118
      const delayStep = 50;
6✔
119
      const result = (callback) => {
6✔
120
        const data = getUtiqFromStorage();
18✔
121
        if (!data.utiq) {
18✔
122
          if (currentDelay > config.params.maxDelayTime) {
16✔
123
            logInfo(
1✔
124
              `${LOG_PREFIX}: No utiq value set after ${config.params.maxDelayTime} max allowed delay time`
125
            );
126
            callback(null);
1✔
127
          } else {
128
            currentDelay += delayStep;
15✔
129
            setTimeout(() => {
15✔
130
              result(callback);
15✔
131
            }, delayStep);
132
          }
133
        } else {
134
          const dataToReturn = { utiq: data.utiq };
2✔
135
          logInfo(
2✔
136
            `${LOG_PREFIX}: Returning ID value data of ${JSON.stringify(
137
              dataToReturn
138
            )}`
139
          );
140
          callback(dataToReturn);
2✔
141
        }
142
      };
143
      return { callback: result };
6✔
144
    }
145
  },
146
  eids: {
147
    'utiq': {
148
      source: 'utiq.com',
149
      atype: 1,
150
      getValue: function (data) {
UNCOV
151
        return data;
×
152
      },
153
    },
154
  }
155
};
156

157
const pbjsGlobal = getGlobal();
1✔
158
const refreshUserIds = pbjsGlobal && typeof pbjsGlobal.refreshUserIds === 'function'
1!
159
  ? pbjsGlobal.refreshUserIds.bind(pbjsGlobal)
160
  : () => {};
161
findUtiqService(storage, refreshUserIds, LOG_PREFIX, MODULE_NAME);
1✔
162
submodule('userId', utiqIdSubmodule);
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