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

prebid / Prebid.js / #298

29 May 2025 11:21AM UTC coverage: 82.464% (-7.7%) from 90.144%
#298

push

travis-ci

prebidjs-release
Prebid 9.45.0 release

12606 of 17518 branches covered (71.96%)

18622 of 22582 relevant lines covered (82.46%)

157.38 hits per line

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

97.73
/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

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

16
const MODULE_NAME = 'utiqId';
1✔
17
const LOG_PREFIX = 'Utiq module';
1✔
18

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

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

34
  const netIdAdtechpass = storage.getDataFromLocalStorage('netid_utiq_adtechpass');
30✔
35

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

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

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

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

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

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

154
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