• 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.5
/modules/utiqMtpIdSystem.js
1
/**
1✔
2
 * This module adds Utiq MTP provided by Utiq SA/NV to the User ID module
3
 * The {@link module:modules/userId} module is required
4
 * @module modules/utiqMtpIdSystem
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 = 'utiqMtpId';
1✔
17
const LOG_PREFIX = 'Utiq MTP module';
1✔
18

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

24
/**
25
 * Get the "mtid" from html5 local storage to make it available to the UserId module.
26
 * @returns {{utiqMtp: (*|string)}}
27
 */
28
function getUtiqFromStorage() {
29
  let utiqPass;
30
  let utiqPassStorage = JSON.parse(
28✔
31
    storage.getDataFromLocalStorage('utiqPass')
32
  );
33
  logInfo(
28✔
34
    `${LOG_PREFIX}: Local storage utiqPass: ${JSON.stringify(
35
      utiqPassStorage
36
    )}`
37
  );
38

39
  if (
28✔
40
    utiqPassStorage &&
67✔
41
    utiqPassStorage.connectId &&
42
    Array.isArray(utiqPassStorage.connectId.idGraph) &&
43
    utiqPassStorage.connectId.idGraph.length > 0
44
  ) {
45
    utiqPass = utiqPassStorage.connectId.idGraph[0];
13✔
46
  }
47
  logInfo(
28✔
48
    `${LOG_PREFIX}: Graph of utiqPass: ${JSON.stringify(
49
      utiqPass
50
    )}`
51
  );
52

53
  return {
28✔
54
    utiqMtp:
55
      utiqPass && utiqPass.mtid
69✔
56
        ? utiqPass.mtid
57
        : null,
58
  };
59
}
60

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

141
submodule('userId', utiqMtpIdSubmodule);
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