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

prebid / Prebid.js / 16446452813

22 Jul 2025 01:57PM UTC coverage: 96.256% (+0.003%) from 96.253%
16446452813

push

github

08c83b
web-flow
Mobkoi Adapter: bug: getUserSyncs no need to check gdprConsent (#13599)

* getUserSyncs no need to check gdprConsent

* removed invalid test

* automatic cleanup event listener

39340 of 48364 branches covered (81.34%)

3 of 5 new or added lines in 2 files covered. (60.0%)

3 existing lines in 2 files now uncovered.

194323 of 201881 relevant lines covered (96.26%)

83.02 hits per line

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

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

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 { logError, logInfo, deepAccess, insertUserSyncIframe } from '../src/utils.js';
12

13
const GVL_ID = 898;
1✔
14
const MODULE_NAME = 'mobkoiId';
1✔
15
export const PROD_AD_SERVER_BASE_URL = 'https://adserver.maximus.mobkoi.com';
1✔
16
export const EQUATIV_BASE_URL = 'https://sync.smartadserver.com';
1✔
17
export const EQUATIV_NETWORK_ID = '5290';
1✔
18
/**
19
 * !IMPORTANT: This value must match the value in mobkoiAnalyticsAdapter.js
20
 * The name of the parameter that the publisher can use to specify the ad server endpoint.
21
 */
22
const PARAM_NAME_AD_SERVER_BASE_URL = 'adServerBaseUrl';
1✔
23

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

26
export const mobkoiIdSubmodule = {
1✔
27
  name: MODULE_NAME,
28
  gvlid: GVL_ID,
29

30
  decode(value) {
31
    return value ? { [MODULE_NAME]: value } : undefined;
2✔
32
  },
33

34
  getId(userSyncOptions, consentObject) {
35
    logInfo('Getting Equativ SAS ID.');
4✔
36

37
    if (!storage.cookiesAreEnabled()) {
4✔
38
      logError('Cookies are not enabled. Module will not work.');
1✔
39
      return {
1✔
40
        id: null
41
      };
42
    }
43

44
    const storageName = userSyncOptions && userSyncOptions.storage && userSyncOptions.storage.name;
3✔
45
    if (!storageName) {
3!
46
      logError('Storage name is not defined. Module will not work.');
×
47
      return {
×
48
        id: null
49
      };
50
    }
51

52
    const existingId = storage.getCookie(storageName);
3✔
53

54
    if (existingId) {
3✔
55
      logInfo(`Found "${storageName}" from local cookie: "${existingId}"`);
1✔
56
      return { id: existingId };
1✔
57
    }
58

59
    logInfo(`Cannot found "${storageName}" in local cookie with name.`);
2✔
60
    return {
2✔
61
      callback: () => {
62
        return new Promise((resolve, _reject) => {
1✔
63
          utils.requestEquativSasId(
1✔
64
            userSyncOptions,
65
            consentObject,
66
            (sasId) => {
67
              if (!sasId) {
1!
68
                logError('Equativ SAS ID is empty');
×
69
                resolve({ id: null });
×
70
                return;
×
71
              }
72

73
              logInfo(`Fetched Equativ SAS ID: "${sasId}"`);
1✔
74
              storage.setCookie(storageName, sasId, userSyncOptions.storage.expires);
1✔
75
              logInfo(`Stored Equativ SAS ID in local cookie with name: "${storageName}"`);
1✔
76
              resolve({ id: sasId });
1✔
77
            }
78
          );
79
        });
80
      }
81
    };
82
  },
83
  eids: {
84
    'mobkoiId': {
85
      source: 'mobkoi.com',
86
      atype: 1
87
    },
88
  }
89
};
90

91
submodule('userId', mobkoiIdSubmodule);
1✔
92

93
export const utils = {
1✔
94
  requestEquativSasId(syncUserOptions, consentObject, onCompleteCallback) {
95
    logInfo('Start requesting Equativ SAS ID');
1✔
96
    const adServerBaseUrl = deepAccess(
1✔
97
      syncUserOptions,
98
      `params.${PARAM_NAME_AD_SERVER_BASE_URL}`) || PROD_AD_SERVER_BASE_URL;
99

100
    const equativPixelUrl = utils.buildEquativPixelUrl(syncUserOptions, consentObject);
1✔
101
    logInfo('Equativ SAS ID request URL:', equativPixelUrl);
1✔
102

103
    const url = adServerBaseUrl + '/pixeliframe?' +
1✔
104
      'pixelUrl=' + encodeURIComponent(equativPixelUrl) +
105
      '&cookieName=sas_uid';
106

107
    /**
108
     * Listen for messages from the iframe with automatic cleanup
109
     */
110
    const messageHandler = function(event) {
1✔
111
      switch (event.data.type) {
8!
112
        case 'MOBKOI_PIXEL_SYNC_COMPLETE':
113
          const sasUid = event.data.syncData;
×
114
          logInfo('Parent window Sync completed. SAS ID:', sasUid);
×
NEW
115
          window.removeEventListener('message', messageHandler);
×
116
          onCompleteCallback(sasUid);
×
117
          break;
×
118
        case 'MOBKOI_PIXEL_SYNC_ERROR':
119
          logError('Parent window Sync failed:', event.data.error);
×
NEW
120
          window.removeEventListener('message', messageHandler);
×
121
          onCompleteCallback(null);
×
122
          break;
×
123
      }
124
    };
125

126
    window.addEventListener('message', messageHandler);
1✔
127

128
    insertUserSyncIframe(url, () => {
1✔
129
      logInfo('insertUserSyncIframe loaded');
×
130
    });
131

132
    // Return the URL for testing purposes
133
    return url;
1✔
134
  },
135

136
  /**
137
   * Build a pixel URL that will be placed in an iframe to fetch the Equativ SAS ID
138
   */
139
  buildEquativPixelUrl(syncUserOptions, consentObject) {
140
    logInfo('Generating Equativ SAS ID request URL');
6✔
141
    const adServerBaseUrl =
142
      deepAccess(
6✔
143
        syncUserOptions,
144
        `params.${PARAM_NAME_AD_SERVER_BASE_URL}`) || PROD_AD_SERVER_BASE_URL;
145

146
    const gdprConsentString = consentObject && consentObject.gdpr && consentObject.gdpr.consentString ? consentObject.gdpr.consentString : '';
6✔
147
    const smartServerUrl = EQUATIV_BASE_URL + '/getuid?' +
6✔
148
      `url=` + encodeURIComponent(`${adServerBaseUrl}/getPixel?value=`) + '[sas_uid]' +
149
      `&gdpr_consent=${gdprConsentString}` +
150
      `&nwid=${EQUATIV_NETWORK_ID}`;
151

152
    return smartServerUrl;
6✔
153
  }
154
};
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