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

prebid / Prebid.js / 19437775255

17 Nov 2025 05:00PM UTC coverage: 96.213% (-0.02%) from 96.231%
19437775255

push

github

web-flow
sevioBidAdapter_bugfix: Send all sizes instead of just maxSize (#14133)

* Send all sizes instead of just maxSize

* Added tests to cover modifs in the sizes that we are sending

53222 of 65234 branches covered (81.59%)

10 of 10 new or added lines in 2 files covered. (100.0%)

304 existing lines in 58 files now uncovered.

202715 of 210693 relevant lines covered (96.21%)

71.77 hits per line

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

73.85
/modules/eightPodAnalyticsAdapter.js
1
import {logError, logInfo, logMessage} from '../src/utils.js';
1✔
2
import {ajax} from '../src/ajax.js';
3
import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js';
4
import { EVENTS } from '../src/constants.js';
5
import adapterManager from '../src/adapterManager.js';
6
import {MODULE_TYPE_ANALYTICS} from '../src/activities/modules.js'
7
import {getStorageManager} from '../src/storageManager.js';
8

9
const analyticsType = 'endpoint';
1✔
10
const MODULE_NAME = `eightPod`;
1✔
11
const MODULE = `${MODULE_NAME}AnalyticProvider`;
1✔
12

13
/**
14
 * Custom tracking server that gets internal events from EightPod's ad unit
15
 */
16
const trackerUrl = 'https://demo.8pod.com/tracker/track';
1✔
17
export const storage = getStorageManager({moduleType: MODULE_TYPE_ANALYTICS, moduleName: MODULE_NAME})
1✔
18

19
const {
20
  BID_WON
21
} = EVENTS;
1✔
22

23
export let queue = [];
1✔
24
let context = {};
1✔
25

26
/**
27
 * Create eightPod Analytic adapter
28
 */
29
const eightPodAnalytics = Object.assign(adapter({url: trackerUrl, analyticsType}), {
1✔
30
  /**
31
   * Execute on bid won - setup basic settings, save context about EightPod's bid. We will send it with our events later
32
   */
33
  track({ eventType, args }) {
2✔
34
    switch (eventType) {
2✔
35
      case BID_WON:
36
        if (args.bidder === 'eightPod') {
1✔
37
          context[args.adUnitCode] = makeContext(args);
1✔
38

39
          eightPodAnalytics.setupPage(args);
1✔
40
          break;
1✔
41
        }
42
    }
43
  },
44

45
  /**
46
   * Execute on bid won upload events from local storage
47
   */
48
  setupPage() {
49
    queue = this.getEventFromLocalStorage();
2✔
50
  },
51

52
  /**
53
   * Subscribe on internal ad unit tracking events
54
   */
55
  eventSubscribe() {
56
    window.addEventListener('message', async (event) => {
5✔
UNCOV
57
      const data = event.data;
×
58

UNCOV
59
      const frameElement = event.source?.frameElement;
×
UNCOV
60
      const parentElement = frameElement?.parentElement;
×
UNCOV
61
      const adUnitCode = parentElement?.id;
×
62

UNCOV
63
      trackEvent(data, adUnitCode);
×
64
    });
65

66
    if (!this._interval) {
5✔
67
      this._interval = setInterval(sendEvents, 10_000);
5✔
68
    }
69
  },
70
  resetQueue() {
71
    queue = [];
1✔
72
  },
73
  getContext() {
74
    return context;
2✔
75
  },
76
  resetContext() {
77
    context = {};
3✔
78
  },
79
  getEventFromLocalStorage,
80
});
81

82
/**
83
 * Create context of event, who emits it
84
 */
85
function makeContext(args) {
86
  const params = args?.params?.[0];
1!
87
  return {
1✔
88
    bidId: args.seatBidId,
89
    variantId: args.creativeId || '',
1!
90
    campaignId: args.cid || '',
1!
91
    publisherId: params.publisherId,
92
    placementId: params.placementId,
93
  };
94
}
95

96
/**
97
 * Create event, add context and push it to queue
98
 */
99
export function trackEvent(event, adUnitCode) {
100
  if (!event.detail) {
2!
UNCOV
101
    return;
×
102
  }
103

104
  const fullEvent = {
2✔
105
    context: eightPodAnalytics.getContext()[adUnitCode],
106
    eventType: event.detail.type,
107
    eventClass: 'adunit',
108
    timestamp: new Date().getTime(),
109
    eventName: event.detail.name,
110
    payload: event.detail.payload
111
  };
112

113
  logMessage(fullEvent);
2✔
114
  addEvent(fullEvent);
2✔
115
}
116

117
/**
118
 * Push event to queue, save event list in local storage
119
 */
120
function addEvent(eventPayload) {
121
  queue.push(eventPayload);
2✔
122
  storage.setDataInLocalStorage(`EIGHT_POD_EVENTS`, JSON.stringify(queue), null);
2✔
123
}
124

125
/**
126
 * Gets previously saved event that has not been sent
127
 */
128
function getEventFromLocalStorage() {
129
  const storedEvents = storage.localStorageIsEnabled() ? storage.getDataFromLocalStorage('EIGHT_POD_EVENTS') : null;
2!
130

131
  if (storedEvents) {
2!
132
    return JSON.parse(storedEvents);
2✔
133
  } else {
134
    return [];
×
135
  }
136
}
137

138
/**
139
 * Send event to our custom tracking server and reset queue
140
 */
141
function sendEvents() {
142
  eightPodAnalytics.eventsStorage = queue;
×
143

144
  if (queue.length) {
×
145
    try {
×
146
      sendEventsApi(queue, {
×
147
        success: () => {
148
          resetLocalStorage();
×
149
          eightPodAnalytics.resetQueue();
×
150
        },
151
        error: (e) => {
152
          logError(MODULE, 'Cant send events', e);
×
153
        }
154
      })
155
    } catch (e) {
156
      logError(MODULE, 'Cant send events', e);
×
157
    }
158
  }
159
}
160

161
/**
162
 * Send event to our custom tracking server
163
 */
164
function sendEventsApi(eventList, callbacks) {
165
  ajax(trackerUrl, callbacks, JSON.stringify(eventList), {keepalive: true});
×
166
}
167

168
/**
169
 * Remove saved events in success scenario
170
 */
171
const resetLocalStorage = () => {
1✔
172
  storage.setDataInLocalStorage(`EIGHT_POD_EVENTS`, JSON.stringify([]), null);
×
173
}
174

175
// save the base class function
176
eightPodAnalytics.originEnableAnalytics = eightPodAnalytics.enableAnalytics;
1✔
177
eightPodAnalytics.eventsStorage = [];
1✔
178

179
// override enableAnalytics so we can get access to the config passed in from the page
180
// Subscribe on events from adUnit
181
eightPodAnalytics.enableAnalytics = function (config) {
1✔
182
  eightPodAnalytics.originEnableAnalytics(config);
5✔
183
  logInfo(MODULE, 'init', config);
5✔
184
  eightPodAnalytics.eventSubscribe();
5✔
185
};
186

187
eightPodAnalytics.disableAnalytics = ((orig) => {
1✔
188
  return function () {
1✔
189
    if (this._interval) {
5✔
190
      clearInterval(this._interval);
5✔
191
      this._interval = null;
5✔
192
    }
193
    return orig.apply(this, arguments);
5✔
194
  }
195
})(eightPodAnalytics.disableAnalytics)
196

197
/**
198
 * Register Analytics Adapter
199
 */
200
adapterManager.registerAnalyticsAdapter({
1✔
201
  adapter: eightPodAnalytics,
202
  code: MODULE_NAME
203
});
204

205
export default eightPodAnalytics;
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