prebid.js 5.18.0 → 5.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/browsers.json +1 -0
  2. package/integrationExamples/gpt/akamaidap_segments_example.html +132 -0
  3. package/modules/.submodules.json +1 -0
  4. package/modules/adfBidAdapter.js +21 -16
  5. package/modules/adtelligentBidAdapter.js +2 -1
  6. package/modules/adxcgBidAdapter.js +311 -359
  7. package/modules/airgridRtdProvider.js +1 -1
  8. package/modules/akamaiDapRtdProvider.js +474 -0
  9. package/modules/akamaiDapRtdProvider.md +47 -0
  10. package/modules/appnexusBidAdapter.js +9 -3
  11. package/modules/atsAnalyticsAdapter.js +67 -46
  12. package/modules/atsAnalyticsAdapter.md +1 -0
  13. package/modules/betweenBidAdapter.js +20 -3
  14. package/modules/browsiRtdProvider.js +106 -18
  15. package/modules/cleanioRtdProvider.js +192 -0
  16. package/modules/cleanioRtdProvider.md +59 -0
  17. package/modules/codefuelBidAdapter.js +183 -0
  18. package/modules/codefuelBidAdapter.md +111 -0
  19. package/modules/connectIdSystem.js +104 -0
  20. package/modules/connectIdSystem.md +33 -0
  21. package/modules/deepintentBidAdapter.js +106 -9
  22. package/modules/deepintentBidAdapter.md +36 -1
  23. package/modules/deltaprojectsBidAdapter.js +252 -0
  24. package/modules/deltaprojectsBidAdapter.md +32 -0
  25. package/modules/engageyaBidAdapter.js +157 -0
  26. package/modules/gridBidAdapter.js +1 -0
  27. package/modules/gumgumBidAdapter.js +8 -0
  28. package/modules/inskinBidAdapter.js +7 -3
  29. package/modules/ipromBidAdapter.js +79 -0
  30. package/modules/ixBidAdapter.js +8 -1
  31. package/modules/jixieBidAdapter.js +8 -2
  32. package/modules/justpremiumBidAdapter.js +6 -1
  33. package/modules/kinessoIdSystem.js +1 -1
  34. package/modules/limelightDigitalBidAdapter.js +22 -2
  35. package/modules/livewrappedAnalyticsAdapter.js +49 -1
  36. package/modules/multibid/index.js +3 -3
  37. package/modules/nativoBidAdapter.js +5 -1
  38. package/modules/nextMillenniumBidAdapter.js +12 -3
  39. package/modules/oguryBidAdapter.js +14 -1
  40. package/modules/openxBidAdapter.js +34 -22
  41. package/modules/operaadsBidAdapter.js +21 -1
  42. package/modules/otmBidAdapter.js +146 -0
  43. package/modules/otmBidAdapter.md +27 -26
  44. package/modules/outbrainBidAdapter.js +5 -0
  45. package/modules/playwireBidAdapter.md +61 -0
  46. package/modules/publinkIdSystem.js +11 -6
  47. package/modules/rtdModule/index.js +2 -2
  48. package/modules/sonobiBidAdapter.js +7 -0
  49. package/modules/sortableBidAdapter.js +1 -0
  50. package/modules/teadsBidAdapter.js +3 -0
  51. package/modules/tripleliftBidAdapter.js +22 -5
  52. package/modules/trustxBidAdapter.js +8 -6
  53. package/modules/undertoneBidAdapter.js +9 -5
  54. package/modules/undertoneBidAdapter.md +5 -1
  55. package/modules/userId/eids.js +18 -0
  56. package/modules/userId/eids.md +7 -0
  57. package/modules/userId/userId.md +12 -0
  58. package/modules/ventesBidAdapter.js +370 -0
  59. package/modules/ventesBidAdapter.md +94 -0
  60. package/modules/videobyteBidAdapter.js +13 -6
  61. package/modules/videobyteBidAdapter.md +49 -0
  62. package/modules/yahoosspBidAdapter.js +6 -6
  63. package/modules/yieldmoSyntheticInventoryModule.js +46 -0
  64. package/modules/yieldmoSyntheticInventoryModule.md +68 -0
  65. package/package.json +1 -1
  66. package/src/adapterManager.js +5 -0
  67. package/src/adapters/bidderFactory.js +4 -3
  68. package/src/auction.js +11 -11
  69. package/src/constants.json +1 -0
  70. package/src/secureCreatives.js +6 -7
  71. package/src/targeting.js +11 -9
  72. package/test/spec/modules/adfBidAdapter_spec.js +83 -29
  73. package/test/spec/modules/adtelligentBidAdapter_spec.js +1 -0
  74. package/test/spec/modules/adxcgBidAdapter_spec.js +827 -571
  75. package/test/spec/modules/akamaiDapRtdProvider_spec.js +246 -0
  76. package/test/spec/modules/appnexusBidAdapter_spec.js +16 -1
  77. package/test/spec/modules/atsAnalyticsAdapter_spec.js +42 -9
  78. package/test/spec/modules/betweenBidAdapter_spec.js +41 -0
  79. package/test/spec/modules/browsiRtdProvider_spec.js +62 -7
  80. package/test/spec/modules/cleanioRtdProvider_spec.js +188 -0
  81. package/test/spec/modules/codefuelBidAdapter_spec.js +316 -0
  82. package/test/spec/modules/connectIdSystem_spec.js +189 -0
  83. package/test/spec/modules/deepintentBidAdapter_spec.js +153 -3
  84. package/test/spec/modules/deltaprojectsBidAdapter_spec.js +399 -0
  85. package/test/spec/modules/engageyaBidAdapter_spec.js +286 -0
  86. package/test/spec/modules/eplanningBidAdapter_spec.js +8 -8
  87. package/test/spec/modules/gumgumBidAdapter_spec.js +5 -1
  88. package/test/spec/modules/ipromBidAdapter_spec.js +195 -0
  89. package/test/spec/modules/ixBidAdapter_spec.js +13 -3
  90. package/test/spec/modules/jixieBidAdapter_spec.js +13 -11
  91. package/test/spec/modules/justpremiumBidAdapter_spec.js +9 -2
  92. package/test/spec/modules/limelightDigitalBidAdapter_spec.js +155 -1
  93. package/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +52 -7
  94. package/test/spec/modules/multibid_spec.js +31 -31
  95. package/test/spec/modules/nextMillenniumBidAdapter_spec.js +13 -1
  96. package/test/spec/modules/oguryBidAdapter_spec.js +53 -12
  97. package/test/spec/modules/openxBidAdapter_spec.js +85 -13
  98. package/test/spec/modules/operaadsBidAdapter_spec.js +38 -6
  99. package/test/spec/modules/otmBidAdapter_spec.js +67 -0
  100. package/test/spec/modules/outbrainBidAdapter_spec.js +18 -0
  101. package/test/spec/modules/publinkIdSystem_spec.js +6 -6
  102. package/test/spec/modules/sonobiBidAdapter_spec.js +34 -1
  103. package/test/spec/modules/sortableBidAdapter_spec.js +11 -0
  104. package/test/spec/modules/teadsBidAdapter_spec.js +132 -0
  105. package/test/spec/modules/tripleliftBidAdapter_spec.js +128 -0
  106. package/test/spec/modules/trustxBidAdapter_spec.js +3 -3
  107. package/test/spec/modules/undertoneBidAdapter_spec.js +52 -0
  108. package/test/spec/modules/ventesBidAdapter_spec.js +845 -0
  109. package/test/spec/modules/videobyteBidAdapter_spec.js +2 -2
  110. package/test/spec/modules/yieldmoSyntheticInventoryModule_spec.js +89 -0
  111. package/test/spec/unit/core/adapterManager_spec.js +37 -2
  112. package/test/spec/unit/core/bidderFactory_spec.js +61 -1
  113. package/test/spec/unit/pbjs_api_spec.js +37 -2
  114. package/test/spec/unit/secureCreatives_spec.js +54 -25
@@ -0,0 +1,59 @@
1
+ # Overview
2
+
3
+ ```
4
+ Module Name: clean.io Rtd provider
5
+ Module Type: Rtd Provider
6
+ Maintainer: nick@clean.io
7
+ ```
8
+
9
+ The clean.io Realtime module provides effective anti-malvertising solution for publishers, including, but not limited to,
10
+ blocking unwanted 0- and 1-click redirects, deceptive ads or those with malicious landing pages, and various types of affiliate fraud.
11
+
12
+ Using this module requires prior agreement with [clean.io](https://clean.io) to obtain the necessary distribution key.
13
+
14
+
15
+ # Integration
16
+
17
+ clean.io Realtime module can be built just like any other prebid module:
18
+
19
+ ```
20
+ gulp build --modules=cleanioRtdProvider,...
21
+ ```
22
+
23
+
24
+ # Configuration
25
+
26
+ When built into prebid.js, this module can be configured through the following `pbjs.setConfig` call:
27
+
28
+ ```javascript
29
+ pbjs.setConfig({
30
+ realTimeData: {
31
+ dataProviders: [{
32
+ name: 'clean.io',
33
+ params: {
34
+ cdnUrl: 'https://abc1234567890.cloudfront.net/script.js', ///< Contact clean.io to get your own CDN URL
35
+ protectionMode: 'full', ///< Supported modes are 'full', 'bids' and 'bids-nowait', see below.
36
+ }
37
+ }]
38
+ }
39
+ });
40
+ ```
41
+
42
+
43
+ ## Configuration parameters
44
+
45
+ {: .table .table-bordered .table-striped }
46
+ | Name | Type | Scope | Description |
47
+ | :------------ | :------------ | :------------ |:------------ |
48
+ | ``cdnUrl`` | ``string`` | Required | CDN URL of the script, which is to be used for protection. |
49
+ | ``protectionMode`` | ``'full' \| 'bids' \| 'bids-nowait'`` | Required | Integration mode. Please refer to the "Integration modes" section for details. |
50
+
51
+
52
+ ## Integration modes
53
+
54
+ {: .table .table-bordered .table-striped }
55
+ | Integration Mode | Parameter Value | Description |
56
+ | :------------ | :------------ | :------------ |
57
+ | Full page protection | ``'full'`` | Preferred mode. The module will add the protector agent script directly to the page, and it will protect all placements. This mode will make the most out of various behavioral detection mechanisms, and will also prevent typical malicious behaviors. Please note that in this mode, depending on Prebid library naming, Chrome may mistakenly tag non-ad-related content as ads: https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/ad_tagging.md. |
58
+ | Bids-only protection | ``'bids'`` | The module will protect specific bid responses, more specifically, the HTML representing ad payload, by wrapping it into the agent script. Please note that in this mode, ads delivered directly, outside of Prebid integration, will not be protected, since the module can only access the ads coming through Prebid. |
59
+ | Bids-only protection with no delay on bid rendering | ``'bids-nowait'`` | Same as above, but in this mode, the script will also *not* wrap those bid responses, which arrived prior to successful preloading of agent script. |
@@ -0,0 +1,183 @@
1
+ import { deepAccess, isArray } from '../src/utils.js';
2
+ import { config } from '../src/config.js';
3
+ import {registerBidder} from '../src/adapters/bidderFactory.js';
4
+ import { BANNER } from '../src/mediaTypes.js';
5
+ const BIDDER_CODE = 'codefuel';
6
+ const CURRENCY = 'USD';
7
+
8
+ export const spec = {
9
+ code: BIDDER_CODE,
10
+ supportedMediaTypes: [ BANNER ],
11
+ aliases: ['ex'], // short code
12
+ /**
13
+ * Determines whether or not the given bid request is valid.
14
+ *
15
+ * @param {BidRequest} bid The bid params to validate.
16
+ * @return boolean True if this is a valid bid, and false otherwise.
17
+ */
18
+ isBidRequestValid: function(bid) {
19
+ if (bid.nativeParams) {
20
+ return false;
21
+ }
22
+ return !!(bid.params.placementId || (bid.params.member && bid.params.invCode));
23
+ },
24
+ /**
25
+ * Make a server request from the list of BidRequests.
26
+ *
27
+ * @param {validBidRequests[]} - an array of bids
28
+ * @return ServerRequest Info describing the request to the server.
29
+ */
30
+ buildRequests: function(validBidRequests, bidderRequest) {
31
+ const page = bidderRequest.refererInfo.referer;
32
+ const domain = getDomainFromURL(page)
33
+ const ua = navigator.userAgent;
34
+ const devicetype = getDeviceType()
35
+ const publisher = setOnAny(validBidRequests, 'params.publisher');
36
+ const cur = CURRENCY;
37
+ // const endpointUrl = 'http://localhost:5000/prebid'
38
+ const endpointUrl = config.getConfig('codefuel.bidderUrl');
39
+ const timeout = bidderRequest.timeout;
40
+
41
+ validBidRequests.forEach(bid => bid.netRevenue = 'net');
42
+
43
+ const imps = validBidRequests.map((bid, idx) => {
44
+ const imp = {
45
+ id: idx + 1 + ''
46
+ }
47
+
48
+ if (bid.params.tagid) {
49
+ imp.tagid = bid.params.tagid
50
+ }
51
+
52
+ if (bid.sizes) {
53
+ imp.banner = {
54
+ format: transformSizes(bid.sizes)
55
+ }
56
+ }
57
+
58
+ return imp;
59
+ });
60
+
61
+ const request = {
62
+ id: bidderRequest.auctionId,
63
+ site: { page, domain, publisher },
64
+ device: { ua, devicetype },
65
+ source: { fd: 1 },
66
+ cur: [cur],
67
+ tmax: timeout,
68
+ imp: imps,
69
+ };
70
+
71
+ return {
72
+ method: 'POST',
73
+ url: endpointUrl,
74
+ data: request,
75
+ bids: validBidRequests,
76
+ options: {
77
+ withCredentials: false
78
+ }
79
+ };
80
+ },
81
+ /**
82
+ * Unpack the response from the server into a list of bids.
83
+ *
84
+ * @param {ServerResponse} serverResponse A successful response from the server.
85
+ * @return {Bid[]} An array of bids which were nested inside the server.
86
+ */
87
+ interpretResponse: (serverResponse, { bids }) => {
88
+ if (!serverResponse.body) {
89
+ return [];
90
+ }
91
+ const { seatbid, cur } = serverResponse.body;
92
+
93
+ const bidResponses = flatten(seatbid.map(seat => seat.bid)).reduce((result, bid) => {
94
+ result[bid.impid - 1] = bid;
95
+ return result;
96
+ }, []);
97
+
98
+ return bids.map((bid, id) => {
99
+ const bidResponse = bidResponses[id];
100
+ if (bidResponse) {
101
+ const bidObject = {
102
+ requestId: bid.bidId,
103
+ cpm: bidResponse.price,
104
+ creativeId: bidResponse.crid,
105
+ ttl: 360,
106
+ netRevenue: true,
107
+ currency: cur,
108
+ mediaType: BANNER,
109
+ ad: bidResponse.adm,
110
+ width: bidResponse.w,
111
+ height: bidResponse.h,
112
+ meta: { advertiserDomains: bid.adomain ? bid.adomain : [] }
113
+ };
114
+ return bidObject;
115
+ }
116
+ }).filter(Boolean);
117
+ },
118
+
119
+ /**
120
+ * Register the user sync pixels which should be dropped after the auction.
121
+ *
122
+ * @param {SyncOptions} syncOptions Which user syncs are allowed?
123
+ * @param {ServerResponse[]} serverResponses List of server's responses.
124
+ * @return {UserSync[]} The user syncs which should be dropped.
125
+ */
126
+ getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) {
127
+ return [];
128
+ }
129
+
130
+ }
131
+ registerBidder(spec);
132
+
133
+ function getDomainFromURL(url) {
134
+ let anchor = document.createElement('a');
135
+ anchor.href = url;
136
+ return anchor.hostname;
137
+ }
138
+
139
+ function getDeviceType() {
140
+ if ((/ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase()))) {
141
+ return 5; // 'tablet'
142
+ }
143
+ if ((/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(navigator.userAgent.toLowerCase()))) {
144
+ return 4; // 'mobile'
145
+ }
146
+ return 2; // 'desktop'
147
+ }
148
+
149
+ function setOnAny(collection, key) {
150
+ for (let i = 0, result; i < collection.length; i++) {
151
+ result = deepAccess(collection[i], key);
152
+ if (result) {
153
+ return result;
154
+ }
155
+ }
156
+ }
157
+
158
+ function flatten(arr) {
159
+ return [].concat(...arr);
160
+ }
161
+
162
+ /* Turn bid request sizes into ut-compatible format */
163
+ function transformSizes(requestSizes) {
164
+ if (!isArray(requestSizes)) {
165
+ return [];
166
+ }
167
+
168
+ if (requestSizes.length === 2 && !isArray(requestSizes[0])) {
169
+ return [{
170
+ w: parseInt(requestSizes[0], 10),
171
+ h: parseInt(requestSizes[1], 10)
172
+ }];
173
+ } else if (isArray(requestSizes[0])) {
174
+ return requestSizes.map(item =>
175
+ ({
176
+ w: parseInt(item[0], 10),
177
+ h: parseInt(item[1], 10)
178
+ })
179
+ );
180
+ }
181
+
182
+ return [];
183
+ }
@@ -0,0 +1,111 @@
1
+ # Overview
2
+
3
+ ```
4
+ Module Name: Codefuel Adapter
5
+ Module Type: Bidder Adapter
6
+ Maintainer: hayimm@codefuel.com
7
+ ```
8
+
9
+ # Description
10
+
11
+ Module that connects to Codefuel bidder to fetch bids.
12
+ Display format is supported but not native format. Using OpenRTB standard.
13
+
14
+ # Configuration
15
+
16
+ ## Bidder and usersync URLs
17
+
18
+ The Codefuel adapter does not work without setting the correct bidder.
19
+ You will receive the URLs when contacting us.
20
+
21
+ ```
22
+ pbjs.setConfig({
23
+ codefuel: {
24
+ bidderUrl: 'https://ai-i-codefuel-ds-rtb-us-east-1-k8s-internal.seccint.com/prebid',
25
+ usersyncUrl: 'https://usersync-url.com'
26
+ }
27
+ });
28
+ ```
29
+
30
+
31
+ # Test Native Parameters
32
+ ```
33
+ var adUnits = [
34
+ code: '/19968336/prebid_native_example_1',
35
+ mediaTypes: {
36
+ native: {
37
+ image: {
38
+ required: false,
39
+ sizes: [100, 50]
40
+ },
41
+ title: {
42
+ required: false,
43
+ len: 140
44
+ },
45
+ sponsoredBy: {
46
+ required: false
47
+ },
48
+ clickUrl: {
49
+ required: false
50
+ },
51
+ body: {
52
+ required: false
53
+ },
54
+ icon: {
55
+ required: false,
56
+ sizes: [50, 50]
57
+ }
58
+ }
59
+ },
60
+ bids: [{
61
+ bidder: 'codefuel',
62
+ params: {
63
+ publisher: {
64
+ id: '2706', // required
65
+ name: 'Publishers Name',
66
+ domain: 'publisher.com'
67
+ },
68
+ tagid: 'tag-id',
69
+ bcat: ['IAB1-1'],
70
+ badv: ['example.com']
71
+ }
72
+ }]
73
+ ];
74
+
75
+ pbjs.setConfig({
76
+ codefuel: {
77
+ bidderUrl: 'https://prebidtest.zemanta.com/api/bidder/prebidtest/bid/'
78
+ }
79
+ });
80
+ ```
81
+
82
+ # Test Display Parameters
83
+ ```
84
+ var adUnits = [
85
+ code: '/19968336/prebid_display_example_1',
86
+ mediaTypes: {
87
+ banner: {
88
+ sizes: [[300, 250]]
89
+ }
90
+ },
91
+ bids: [{
92
+ bidder: 'codefuel',
93
+ params: {
94
+ publisher: {
95
+ id: '2706', // required
96
+ name: 'Publishers Name',
97
+ domain: 'publisher.com'
98
+ },
99
+ tagid: 'tag-id',
100
+ bcat: ['IAB1-1'],
101
+ badv: ['example.com']
102
+ },
103
+ }]
104
+ ];
105
+
106
+ pbjs.setConfig({
107
+ codefuel: {
108
+ bidderUrl: 'https://prebidtest.zemanta.com/api/bidder/prebidtest/bid/'
109
+ }
110
+ });
111
+ ```
@@ -0,0 +1,104 @@
1
+ /**
2
+ * This module adds support for Yahoo ConnectID to the user ID module system.
3
+ * The {@link module:modules/userId} module is required
4
+ * @module modules/connectIdSystem
5
+ * @requires module:modules/userId
6
+ */
7
+
8
+ import {ajax} from '../src/ajax.js';
9
+ import {submodule} from '../src/hook.js';
10
+ import {logError, formatQS} from '../src/utils.js';
11
+ import includes from 'core-js-pure/features/array/includes.js';
12
+
13
+ const MODULE_NAME = 'connectId';
14
+ const VENDOR_ID = 25;
15
+ const PLACEHOLDER = '__PIXEL_ID__';
16
+ const UPS_ENDPOINT = `https://ups.analytics.yahoo.com/ups/${PLACEHOLDER}/fed`;
17
+
18
+ function isEUConsentRequired(consentData) {
19
+ return !!(consentData && consentData.gdpr && consentData.gdpr.gdprApplies);
20
+ }
21
+
22
+ /** @type {Submodule} */
23
+ export const connectIdSubmodule = {
24
+ /**
25
+ * used to link submodule with config
26
+ * @type {string}
27
+ */
28
+ name: MODULE_NAME,
29
+ /**
30
+ * @type {Number}
31
+ */
32
+ gvlid: VENDOR_ID,
33
+ /**
34
+ * decode the stored id value for passing to bid requests
35
+ * @function
36
+ * @returns {{connectId: string} | undefined}
37
+ */
38
+ decode(value) {
39
+ return (typeof value === 'object' && value.connectid)
40
+ ? {connectId: value.connectid} : undefined;
41
+ },
42
+ /**
43
+ * Gets the Yahoo ConnectID
44
+ * @function
45
+ * @param {SubmoduleConfig} [config]
46
+ * @param {ConsentData} [consentData]
47
+ * @returns {IdResponse|undefined}
48
+ */
49
+ getId(config, consentData) {
50
+ const params = config.params || {};
51
+ if (!params || typeof params.he !== 'string' ||
52
+ (typeof params.pixelId === 'undefined' && typeof params.endpoint === 'undefined')) {
53
+ logError('The connectId submodule requires the \'he\' and \'pixelId\' parameters to be defined.');
54
+ return;
55
+ }
56
+
57
+ const data = {
58
+ '1p': includes([1, '1', true], params['1p']) ? '1' : '0',
59
+ he: params.he,
60
+ gdpr: isEUConsentRequired(consentData) ? '1' : '0',
61
+ gdpr_consent: isEUConsentRequired(consentData) ? consentData.gdpr.consentString : '',
62
+ us_privacy: consentData && consentData.uspConsent ? consentData.uspConsent : ''
63
+ };
64
+
65
+ if (params.pixelId) {
66
+ data.pixelId = params.pixelId
67
+ }
68
+
69
+ const resp = function (callback) {
70
+ const callbacks = {
71
+ success: response => {
72
+ let responseObj;
73
+ if (response) {
74
+ try {
75
+ responseObj = JSON.parse(response);
76
+ } catch (error) {
77
+ logError(error);
78
+ }
79
+ }
80
+ callback(responseObj);
81
+ },
82
+ error: error => {
83
+ logError(`${MODULE_NAME}: ID fetch encountered an error`, error);
84
+ callback();
85
+ }
86
+ };
87
+ const endpoint = UPS_ENDPOINT.replace(PLACEHOLDER, params.pixelId);
88
+ let url = `${params.endpoint || endpoint}?${formatQS(data)}`;
89
+ connectIdSubmodule.getAjaxFn()(url, callbacks, null, {method: 'GET', withCredentials: true});
90
+ };
91
+ return {callback: resp};
92
+ },
93
+
94
+ /**
95
+ * Return the function used to perform XHR calls.
96
+ * Utilised for each of testing.
97
+ * @returns {Function}
98
+ */
99
+ getAjaxFn() {
100
+ return ajax;
101
+ }
102
+ };
103
+
104
+ submodule('userId', connectIdSubmodule);
@@ -0,0 +1,33 @@
1
+ ## Yahoo ConnectID User ID Submodule
2
+
3
+ Yahoo ConnectID user ID Module.
4
+
5
+ ### Prebid Params
6
+
7
+ ```
8
+ pbjs.setConfig({
9
+ userSync: {
10
+ userIds: [{
11
+ name: 'connectId',
12
+ storage: {
13
+ name: 'connectId',
14
+ type: 'html5',
15
+ expires: 15
16
+ },
17
+ params: {
18
+ pixelId: 58776,
19
+ he: '0bef996248d63cea1529cb86de31e9547a712d9f380146e98bbd39beec70355a'
20
+ }
21
+ }]
22
+ }
23
+ });
24
+ ```
25
+ ## Parameter Descriptions for the `usersync` Configuration Section
26
+ The below parameters apply only to the Yahoo ConnectID user ID Module.
27
+
28
+ | Param under usersync.userIds[] | Scope | Type | Description | Example |
29
+ | --- | --- | --- | --- | --- |
30
+ | name | Required | String | ID value for the Yahoo ConnectID module - `"connectId"` | `"connectId"` |
31
+ | params | Required | Object | Data for Yahoo ConnectID initialization. | |
32
+ | params.pixelId | Required | Number | The Yahoo supplied publisher specific pixel Id | `8976` |
33
+ | params.he | Required | String | The SHA-256 hashed user email address | `"529cb86de31e9547a712d9f380146e98bbd39beec"` |
@@ -1,13 +1,38 @@
1
- import { generateUUID, deepSetValue, deepAccess, isArray } from '../src/utils.js';
1
+ import { generateUUID, deepSetValue, deepAccess, isArray, isInteger, logError, logWarn } from '../src/utils.js';
2
2
  import {registerBidder} from '../src/adapters/bidderFactory.js';
3
- import {BANNER} from '../src/mediaTypes.js';
3
+ import {BANNER, VIDEO} from '../src/mediaTypes.js';
4
4
  const BIDDER_CODE = 'deepintent';
5
5
  const BIDDER_ENDPOINT = 'https://prebid.deepintent.com/prebid';
6
6
  const USER_SYNC_URL = 'https://cdn.deepintent.com/syncpixel.html';
7
7
  const DI_M_V = '1.0.0';
8
+ export const ORTB_VIDEO_PARAMS = {
9
+ 'mimes': (value) => Array.isArray(value) && value.length > 0 && value.every(v => typeof v === 'string'),
10
+ 'minduration': (value) => isInteger(value),
11
+ 'maxduration': (value) => isInteger(value),
12
+ 'protocols': (value) => Array.isArray(value) && value.every(v => v >= 1 && v <= 10),
13
+ 'w': (value) => isInteger(value),
14
+ 'h': (value) => isInteger(value),
15
+ 'startdelay': (value) => isInteger(value),
16
+ 'placement': (value) => Array.isArray(value) && value.every(v => v >= 1 && v <= 5),
17
+ 'linearity': (value) => [1, 2].indexOf(value) !== -1,
18
+ 'skip': (value) => [0, 1].indexOf(value) !== -1,
19
+ 'skipmin': (value) => isInteger(value),
20
+ 'skipafter': (value) => isInteger(value),
21
+ 'sequence': (value) => isInteger(value),
22
+ 'battr': (value) => Array.isArray(value) && value.every(v => v >= 1 && v <= 17),
23
+ 'maxextended': (value) => isInteger(value),
24
+ 'minbitrate': (value) => isInteger(value),
25
+ 'maxbitrate': (value) => isInteger(value),
26
+ 'boxingallowed': (value) => [0, 1].indexOf(value) !== -1,
27
+ 'playbackmethod': (value) => Array.isArray(value) && value.every(v => v >= 1 && v <= 6),
28
+ 'playbackend': (value) => [1, 2, 3].indexOf(value) !== -1,
29
+ 'delivery': (value) => [1, 2, 3].indexOf(value) !== -1,
30
+ 'pos': (value) => [0, 1, 2, 3, 4, 5, 6, 7].indexOf(value) !== -1,
31
+ 'api': (value) => Array.isArray(value) && value.every(v => v >= 1 && v <= 6)
32
+ };
8
33
  export const spec = {
9
34
  code: BIDDER_CODE,
10
- supportedMediaTypes: [BANNER],
35
+ supportedMediaTypes: [BANNER, VIDEO],
11
36
  aliases: [],
12
37
 
13
38
  // tagId is mandatory param
@@ -15,16 +40,38 @@ export const spec = {
15
40
  let valid = false;
16
41
  if (bid && bid.params && bid.params.tagId) {
17
42
  if (typeof bid.params.tagId === 'string' || bid.params.tagId instanceof String) {
18
- valid = true;
43
+ if (bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty(VIDEO)) {
44
+ if (bid.mediaTypes[VIDEO].hasOwnProperty('context')) {
45
+ valid = true;
46
+ }
47
+ } else {
48
+ valid = true;
49
+ }
19
50
  }
20
51
  }
21
52
  return valid;
22
53
  },
23
- interpretResponse: function(bidResponse, request) {
54
+ interpretResponse: function(bidResponse, bidRequest) {
24
55
  let responses = [];
25
56
  if (bidResponse && bidResponse.body) {
26
- let bids = bidResponse.body.seatbid && bidResponse.body.seatbid[0] ? bidResponse.body.seatbid[0].bid : [];
27
- responses = bids.map(bid => formatResponse(bid))
57
+ try {
58
+ let bids = bidResponse.body.seatbid && bidResponse.body.seatbid[0] ? bidResponse.body.seatbid[0].bid : [];
59
+ if (bids) {
60
+ bids.forEach(bidObj => {
61
+ let newBid = formatResponse(bidObj);
62
+ let mediaType = _checkMediaType(bidObj);
63
+ if (mediaType === BANNER) {
64
+ newBid.mediaType = BANNER;
65
+ } else if (mediaType === VIDEO) {
66
+ newBid.mediaType = VIDEO;
67
+ newBid.vastXml = bidObj.adm;
68
+ }
69
+ responses.push(newBid);
70
+ });
71
+ }
72
+ } catch (err) {
73
+ logError(err);
74
+ }
28
75
  }
29
76
  return responses;
30
77
  },
@@ -73,6 +120,17 @@ export const spec = {
73
120
  }
74
121
 
75
122
  };
123
+ function _checkMediaType(bid) {
124
+ let videoRegex = new RegExp(/VAST\s+version/);
125
+ let mediaType;
126
+ if (bid.adm && bid.adm.indexOf('deepintent_wrapper') >= 0) {
127
+ mediaType = BANNER;
128
+ } else if (videoRegex.test(bid.adm)) {
129
+ mediaType = VIDEO;
130
+ }
131
+ return mediaType;
132
+ }
133
+
76
134
  function clean(obj) {
77
135
  for (let propName in obj) {
78
136
  if (obj[propName] === null || obj[propName] === undefined) {
@@ -100,16 +158,55 @@ function formatResponse(bid) {
100
158
  }
101
159
 
102
160
  function buildImpression(bid) {
103
- return {
161
+ let impression = {};
162
+ impression = {
104
163
  id: bid.bidId,
105
164
  tagid: bid.params.tagId || '',
106
165
  secure: window.location.protocol === 'https' ? 1 : 0,
107
- banner: buildBanner(bid),
108
166
  displaymanager: 'di_prebid',
109
167
  displaymanagerver: DI_M_V,
110
168
  ext: buildCustomParams(bid)
111
169
  };
170
+ if (deepAccess(bid, 'mediaTypes.banner')) {
171
+ impression['banner'] = buildBanner(bid);
172
+ }
173
+ if (deepAccess(bid, 'mediaTypes.video')) {
174
+ impression['video'] = _buildVideo(bid);
175
+ }
176
+ return impression;
112
177
  }
178
+
179
+ function _buildVideo(bid) {
180
+ const videoObj = {};
181
+ const videoAdUnitParams = deepAccess(bid, 'mediaTypes.video', {});
182
+ const videoBidderParams = deepAccess(bid, 'params.video', {});
183
+ const computedParams = {};
184
+
185
+ if (Array.isArray(videoAdUnitParams.playerSize)) {
186
+ const tempSize = (Array.isArray(videoAdUnitParams.playerSize[0])) ? videoAdUnitParams.playerSize[0] : videoAdUnitParams.playerSize;
187
+ computedParams.w = tempSize[0];
188
+ computedParams.h = tempSize[1];
189
+ }
190
+
191
+ const videoParams = {
192
+ ...computedParams,
193
+ ...videoAdUnitParams,
194
+ ...videoBidderParams
195
+ };
196
+
197
+ Object.keys(ORTB_VIDEO_PARAMS).forEach(paramName => {
198
+ if (videoParams.hasOwnProperty(paramName)) {
199
+ if (ORTB_VIDEO_PARAMS[paramName](videoParams[paramName])) {
200
+ videoObj[paramName] = videoParams[paramName];
201
+ } else {
202
+ logWarn(`The OpenRTB video param ${paramName} has been skipped due to misformating. Please refer to OpenRTB 2.5 spec.`);
203
+ }
204
+ }
205
+ });
206
+
207
+ return videoObj;
208
+ };
209
+
113
210
  function buildCustomParams(bid) {
114
211
  if (bid.params && bid.params.custom) {
115
212
  return {
@@ -8,7 +8,7 @@ Maintainer: prebid@deepintent.com
8
8
 
9
9
  # Description
10
10
 
11
- Deepintent currently supports the BANNER type ads through prebid js
11
+ Deepintent currently supports the BANNER and VIDEO type ads through prebid js
12
12
 
13
13
  Module that connects to Deepintent's demand sources.
14
14
 
@@ -40,6 +40,41 @@ Module that connects to Deepintent's demand sources.
40
40
  ];
41
41
  ```
42
42
 
43
+ # Sample Video Ad Unit
44
+ ```
45
+ var adVideoAdUnits = [
46
+ {
47
+ code: 'test-div-video',
48
+ mediaTypes: {
49
+ video: {
50
+ playerSize: [640, 480], // required
51
+ context: 'instream' //required
52
+ }
53
+ },
54
+ bids: [{
55
+ bidder: 'deepintent',
56
+ params: {
57
+ tagId: '1300', // Required parameter // required
58
+ video: {
59
+ mimes: ['video/mp4','video/x-flv'], // required
60
+ skippable: true, // optional
61
+ minduration: 5, // optional
62
+ maxduration: 30, // optional
63
+ startdelay: 5, // optional
64
+ playbackmethod: [1,3], // optional
65
+ api: [ 1, 2 ], // optional
66
+ protocols: [ 2, 3 ], // optional
67
+ battr: [ 13, 14 ], // optional
68
+ linearity: 1, // optional
69
+ placement: 2, // optional
70
+ minbitrate: 10, // optional
71
+ maxbitrate: 10 // optional
72
+ }
73
+ }
74
+ }]
75
+ }]
76
+ ```
77
+
43
78
  ###Recommended User Sync Configuration
44
79
 
45
80
  ```javascript