• 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

32.93
/modules/videoModule/videoImpressionVerifier.js
1
import { vastXmlEditorFactory } from '../../libraries/video/shared/vastXmlEditor.js';
2
import { generateUUID } from '../../src/utils.js';
3

4
export const PB_PREFIX = 'pb_';
2✔
5
export const UUID_MARKER = PB_PREFIX + 'uuid';
2✔
6

7
/**
8
 * Video Impression Verifier interface. All implementations of a Video Impression Verifier must comply with this interface.
9
 * @description adds tracking markers to an ad and extracts the bid identifiers from ad event information.
10
 * @typedef {Object} VideoImpressionVerifier
11
 * @function trackBid - requests that a bid's ad be tracked for impression verification.
12
 * @function getBidIdentifiers - requests information from the ad event data that can be used to match the ad to a tracked bid.
13
 */
14

15
/**
16
 * @function VideoImpressionVerifier#trackBid
17
 * @param {Object} bid - Bid that should be tracked.
18
 * @return {String} - Identifier for the bid being tracked.
19
 */
20

21
/**
22
 * @function VideoImpressionVerifier#getBidIdentifiers
23
 * @param {String} adId - In the VAST tag, this value is present in the Ad element's id property.
24
 * @param {String} adTagUrl - The ad tag url that was loaded into the player.
25
 * @param {[String]} adWrapperIds - List of ad id's that were obtained from the different wrappers. Each redirect points to an ad wrapper.
26
 * @return {bidIdentifier} - Object allowing the bid matching the ad event to be identified.
27
 */
28

29
/**
30
 * @typedef {Object} bidIdentifier
31
 * @property {String} adId - Bid identifier.
32
 * @property {String} adUnitCode - Identifier for the Ad Unit for which the bid was made.
33
 * @property {String} auctionId - Id of the auction in which the bid was made.
34
 * @property {String} requestId - Id of the bid request which resulted in the bid.
35
 */
36

37
/**
38
 * Factory function for obtaining a Video Impression Verifier.
39
 * @param {Boolean} isCacheUsed - wether Prebid is configured to use a cache.
40
 * @return {VideoImpressionVerifier}
41
 */
42
export function videoImpressionVerifierFactory(isCacheUsed) {
43
  const vastXmlEditor = vastXmlEditorFactory();
1✔
44
  const bidTracker = tracker();
1✔
45
  if (isCacheUsed) {
1!
46
    return cachedVideoImpressionVerifier(vastXmlEditor, bidTracker);
×
47
  }
48

49
  return videoImpressionVerifier(vastXmlEditor, bidTracker);
1✔
50
}
51

52
export function videoImpressionVerifier(vastXmlEditor_, bidTracker_) {
53
  const verifier = baseImpressionVerifier(bidTracker_);
1✔
54
  const superTrackBid = verifier.trackBid;
1✔
55
  const vastXmlEditor = vastXmlEditor_;
1✔
56

57
  verifier.trackBid = function(bid) {
1✔
UNCOV
58
    const { vastXml, vastUrl } = bid;
×
UNCOV
59
    if (!vastXml && !vastUrl) {
×
UNCOV
60
      return;
×
61
    }
62

UNCOV
63
    const uuid = superTrackBid(bid);
×
64

UNCOV
65
    if (vastUrl) {
×
UNCOV
66
      const url = new URL(vastUrl);
×
67
      url.searchParams.append(UUID_MARKER, uuid);
×
68
      bid.vastUrl = url.toString();
×
69
    } else if (vastXml) {
×
70
      bid.vastXml = vastXmlEditor.getVastXmlWithTracking(vastXml, uuid);
×
71
    }
72

73
    return uuid;
×
74
  }
75

76
  return verifier;
1✔
77
}
78

79
export function cachedVideoImpressionVerifier(vastXmlEditor_, bidTracker_) {
80
  const verifier = baseImpressionVerifier(bidTracker_);
×
81
  const superTrackBid = verifier.trackBid;
×
82
  const superGetBidIdentifiers = verifier.getBidIdentifiers;
×
83
  const vastXmlEditor = vastXmlEditor_;
×
84

85
  verifier.trackBid = function (bid, globalAdUnits) {
×
86
    const adIdOverride = superTrackBid(bid);
×
87
    let { vastXml, vastUrl, adId, adUnitCode } = bid;
×
88
    const adUnit = ((globalAdUnits) || []).find(adUnit => adUnitCode === adUnit.code);
×
89
    const videoConfig = adUnit && adUnit.video;
×
90
    const adServerConfig = videoConfig && videoConfig.adServer;
×
91
    const trackingConfig = adServerConfig && adServerConfig.tracking;
×
92
    let impressionUrl;
93
    let impressionId;
94
    let errorUrl;
95
    const impressionTracking = trackingConfig.impression;
×
96
    const errorTracking = trackingConfig.error;
×
97

98
    if (impressionTracking) {
×
99
      impressionUrl = getTrackingUrl(impressionTracking.getUrl, bid);
×
100
      impressionId = impressionTracking.id || adId + '-impression';
×
101
    }
102

103
    if (errorTracking) {
×
104
      errorUrl = getTrackingUrl(errorTracking.getUrl, bid);
×
105
    }
106

107
    if (vastXml) {
×
108
      vastXml = vastXmlEditor.getVastXmlWithTracking(vastXml, adIdOverride, impressionUrl, impressionId, errorUrl);
×
109
    } else if (vastUrl) {
×
110
      vastXml = vastXmlEditor.buildVastWrapper(adIdOverride, vastUrl, impressionUrl, impressionId, errorUrl);
×
111
    }
112

113
    bid.vastXml = vastXml;
×
114
    return adIdOverride;
×
115
  }
116

117
  verifier.getBidIdentifiers = function (adId, adTagUrl, adWrapperIds) {
×
118
    // When the video is cached, the ad tag loaded into the player is a parent wrapper of the cache url.
119
    // As a result, the ad tag Url cannot include identifiers.
120
    return superGetBidIdentifiers(adId, null, adWrapperIds);
×
121
  }
122

123
  return verifier;
×
124

125
  function getTrackingUrl(getUrl, bid) {
126
    if (!getUrl || typeof getUrl !== 'function') {
×
127
      return;
×
128
    }
129

130
    return getUrl(bid);
×
131
  }
132
}
133

134
export function baseImpressionVerifier(bidTracker_) {
135
  const bidTracker = bidTracker_;
4✔
136

137
  function trackBid(bid) {
138
    const { adId, adUnitCode, requestId, auctionId } = bid;
3✔
139
    const trackingId = PB_PREFIX + generateUUID(10 ** 13);
3✔
140
    bidTracker.store(trackingId, { adId, adUnitCode, requestId, auctionId });
3✔
141
    return trackingId;
3✔
142
  }
143

144
  function getBidIdentifiers(adId, adTagUrl, adWrapperIds) {
145
    return bidTracker.remove(adId) || getBidForAdTagUrl(adTagUrl) || getBidForAdWrappers(adWrapperIds);
2✔
146
  }
147

148
  return {
4✔
149
    trackBid,
150
    getBidIdentifiers
151
  };
152

153
  function getBidForAdTagUrl(adTagUrl) {
154
    if (!adTagUrl) {
1✔
155
      return;
1✔
156
    }
157

158
    let url;
159
    try {
×
160
      url = new URL(adTagUrl);
×
161
    } catch (e) {
162
      return;
×
163
    }
164

165
    const queryParams = url.searchParams;
×
166
    const uuid = queryParams.get(UUID_MARKER);
×
167
    return uuid && bidTracker.remove(uuid);
×
168
  }
169

170
  function getBidForAdWrappers(adWrapperIds) {
171
    if (!adWrapperIds || !adWrapperIds.length) {
1!
172
      return;
×
173
    }
174

175
    for (const wrapperId of adWrapperIds) {
1✔
176
      const bidInfo = bidTracker.remove(wrapperId);
1✔
177
      if (bidInfo) {
1✔
178
        return bidInfo;
1✔
179
      }
180
    }
181
  }
182
}
183

184
export function tracker() {
185
  const model = {};
1✔
186

187
  function store(key, value) {
UNCOV
188
    model[key] = value;
×
189
  }
190

191
  function remove(key) {
192
    const value = model[key];
×
193
    if (!value) {
×
194
      return;
×
195
    }
196

197
    delete model[key];
×
198
    return value;
×
199
  }
200

201
  return {
1✔
202
    store,
203
    remove
204
  }
205
}
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