Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dailymotion Bid Adaptor: initial release #10970

Merged
merged 27 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5b534be
Dailymotion Bid Adaptor: initial release
Jan 11, 2024
807c75b
.md file lint issue resolved
Aditi0101 Jan 22, 2024
9eb2277
Merge pull request #3 from dailymotion-oss/feat/dailymotion-adaptor
sebmil-daily Jan 22, 2024
3b3878e
Merge branch 'prebid:master' into master
kvnsw Feb 1, 2024
6c25624
Dailymotion Bid Adaptor: build bidder request based on param with fal…
Jan 31, 2024
9aab2ea
Dailymotion Bid Adaptor: support video metadata
Aditi0101 Feb 16, 2024
7ee40c4
Merge branch 'prebid:master' into master
kvnsw Mar 1, 2024
32d6391
Dailymotion Bid Adaptor: add support for sending adUnitCode
Mar 5, 2024
d5542db
Merge branch 'prebid:master' into master
kvnsw Mar 6, 2024
ce0536c
Dailymotion Bid Adaptor: add support for sending startDelay
Mar 6, 2024
9a97052
Merge branch 'prebid:master' into master
kvnsw Mar 6, 2024
3092928
feat(LEO-528): Allow multiple IAB categories in video metadata
sebmil-daily Mar 19, 2024
4b78d35
Merge pull request #10 from dailymotion-oss/LEO-528_multiple_iabcat2
sebmil-daily Mar 20, 2024
09f8e16
Dailymotion bid adapter: Clarify the video metadata to provide in eac…
sebmil-daily Mar 27, 2024
44b88d1
Merge pull request #11 from dailymotion-oss/LEO-528_fix_metadata_doc
sebmil-daily Mar 27, 2024
898d8bb
Dailymotion bid adapter: Move API key to bid params
sebmil-daily Apr 3, 2024
673f831
Dailymotion bid adapter: Verify API key is string
kvnsw Apr 3, 2024
53bd3df
Merge branch 'prebid:master' into master
kvnsw Apr 3, 2024
fbd456d
Dailymotion bid adapter: Move API key to bid params (fix tests)
sebmil-daily Apr 4, 2024
2bfbc13
Merge pull request #13 from dailymotion-oss/dailymotion_move_api_key_…
sebmil-daily Apr 4, 2024
b908269
Merge branch 'prebid:master' into master
sebmil-daily Apr 4, 2024
cc0c1bc
Dailymotion Bid Adaptor: add gpp support and get coppa from request
Apr 18, 2024
cc5f6ff
Merge branch 'prebid:master' into master
kvnsw Apr 18, 2024
fa56a41
Dailymotion Bid Adaptor: fix lint error
Apr 18, 2024
36637e0
Dailymotion Bid Adaptor: add iabcat1 and fallback to ortb2 for iabcat2
Apr 18, 2024
cff7c34
Merge pull request #16 from dailymotion-oss/dailymotion_iabcat
sebmil-daily Apr 18, 2024
50dda1f
Dailymotion Bid Adaptor: get iabcats from ortb2.site.content.data
Apr 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 139 additions & 0 deletions modules/dailymotionBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { VIDEO } from '../src/mediaTypes.js';
import { deepAccess } from '../src/utils.js';

/**
* Get video metadata from bid request
*
* @param {BidRequest} bidRequest A valid bid requests that should be sent to the Server.
* @return video metadata
*/
function getVideoMetadata(bidRequest, bidderRequest) {
const videoAdUnit = deepAccess(bidRequest, 'mediaTypes.video', {});
const videoBidderParams = deepAccess(bidRequest, 'params.video', {});

const videoParams = {
...videoAdUnit,
...videoBidderParams, // Bidder Specific overrides
};

// Store as object keys to ensure uniqueness
const iabcat1 = {};
const iabcat2 = {};

deepAccess(bidderRequest, 'ortb2.site.content.data', []).forEach((data) => {
if ([4, 5, 6, 7].includes(data?.ext?.segtax)) {
(Array.isArray(data.segment) ? data.segment : []).forEach((segment) => {
if (typeof segment.id === 'string') {
// See https://docs.prebid.org/features/firstPartyData.html#segments-and-taxonomy
// Only take IAB cats of taxonomy V1
if (data.ext.segtax === 4) iabcat1[segment.id] = 1;
// Only take IAB cats of taxonomy V2 or higher
if ([5, 6, 7].includes(data.ext.segtax)) iabcat2[segment.id] = 1;
}
});
}
});

const videoMetadata = {
description: videoParams.description || '',
duration: videoParams.duration || 0,
iabcat1: Object.keys(iabcat1),
iabcat2: Array.isArray(videoParams.iabcat2)
? videoParams.iabcat2
: Object.keys(iabcat2),
id: videoParams.id || '',
lang: videoParams.lang || '',
private: videoParams.private || false,
tags: videoParams.tags || '',
title: videoParams.title || '',
topics: videoParams.topics || '',
xid: videoParams.xid || '',
};

return videoMetadata;
}

export const spec = {
code: 'dailymotion',
gvlid: 573,
supportedMediaTypes: [VIDEO],

/**
* Determines whether or not the given bid request is valid.
* The only mandatory parameter for a bid to be valid is the API key.
* Other parameters are optional.
*
* @return boolean True if this is a valid bid, and false otherwise.
*/
isBidRequestValid: function (bid) {
return typeof bid?.params?.apiKey === 'string' && bid.params.apiKey.length > 10;
},

/**
* Make a server request from the list of valid BidRequests (that already passed the isBidRequestValid call)
*
* @param {BidRequest[]} validBidRequests A non-empty list of valid bid requests that should be sent to the Server.
* @param {BidderRequest} bidderRequest
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: (validBidRequests = [], bidderRequest) => validBidRequests.map(bid => ({
method: 'POST',
url: 'https://pb.dmxleo.com',
data: {
bidder_request: {
gdprConsent: {
apiVersion: bidderRequest?.gdprConsent?.apiVersion || 1,
consentString: bidderRequest?.gdprConsent?.consentString || '',
// Cast boolean in any case (eg: if value is int) to ensure type
gdprApplies: !!bidderRequest?.gdprConsent?.gdprApplies,
},
refererInfo: {
page: bidderRequest?.refererInfo?.page || '',
},
uspConsent: bidderRequest?.uspConsent || '',
patmmccann marked this conversation as resolved.
Show resolved Hide resolved
gppConsent: {
gppString: deepAccess(bidderRequest, 'gppConsent.gppString') ||
deepAccess(bidderRequest, 'ortb2.regs.gpp', ''),
applicableSections: deepAccess(bidderRequest, 'gppConsent.applicableSections') ||
deepAccess(bidderRequest, 'ortb2.regs.gpp_sid', []),
},
},
config: {
api_key: bid.params.apiKey
},
// Cast boolean in any case (value should be 0 or 1) to ensure type
coppa: !!deepAccess(bidderRequest, 'ortb2.regs.coppa'),
request: {
patmmccann marked this conversation as resolved.
Show resolved Hide resolved
adUnitCode: bid.adUnitCode || '',
auctionId: bid.auctionId || '',
bidId: bid.bidId || '',
mediaTypes: {
video: {
playerSize: bid.mediaTypes?.[VIDEO]?.playerSize || [],
api: bid.mediaTypes?.[VIDEO]?.api || [],
startDelay: bid.mediaTypes?.[VIDEO]?.startdelay || 0,
},
},
sizes: bid.sizes || [],
},
video_metadata: getVideoMetadata(bid, bidderRequest),
},
options: {
withCredentials: true,
crossOrigin: true,
},
})),

/**
* Map the response from the server into a list of bids.
* As dailymotion prebid server returns an entry with the correct Prebid structure,
* we directly include it as the only bid in the response.
*
* @param {*} serverResponse A successful response from the server.
* @return {Bid[]} An array of bids which were nested inside the server.
*/
interpretResponse: serverResponse => serverResponse?.body ? [serverResponse.body] : [],
};

registerBidder(spec);
140 changes: 140 additions & 0 deletions modules/dailymotionBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Overview

```
Module Name: Dailymotion Bid Adapter
Module Type: Bidder Adapter
Maintainer: [email protected]
```

# Description

Dailymotion prebid adapter.

# Configuration options

Before calling this adapter, you need to set at least the API key in the bid parameters:

```javascript
const adUnits = [
{
bids: [{
bidder: 'dailymotion',
params: {
apiKey: 'fake_api_key'
}
}]
}
];
```

`apiKey` is your publisher API key. For testing purpose, you can use "dailymotion-testing".

# Test Parameters

By setting the following bid parameters, you'll get a constant response to any request, to validate your adapter integration:

```javascript
const adUnits = [
{
bids: [{
bidder: 'dailymotion',
params: {
apiKey: 'dailymotion-testing'
}
}]
}
];
```

Please note that failing to set these will result in the adapter not bidding at all.

# Sample video AdUnit

To allow better targeting, you should provide as much context about the video as possible.
There are two ways of doing this depending on if you're using Dailymotion player or a third party one.

If you are using the Dailymotion player, you should only provide the video `xid` in your ad unit, example:

```javascript
const adUnits = [
{
bids: [{
bidder: 'dailymotion',
params: {
apiKey: 'dailymotion-testing'
}
}],
code: 'test-ad-unit',
mediaTypes: {
video: {
api: [2, 7],
context: 'instream',
playerSize: [ [1280, 720] ],
startDelay: 0,
xid: 'x123456' // Dailymotion infrastructure unique video ID
},
}
}
];
```

This will automatically fetch the most up-to-date information about the video.
If you provide any other metadata in addition to the `xid`, they will be ignored.

If you are using a third party video player, you should not provide any `xid` and instead fill the following members:

```javascript
const adUnits = [
{
bids: [{
bidder: 'dailymotion',
params: {
apiKey: 'dailymotion-testing',
video: {
description: 'overriden video description'
}
}
}],
code: 'test-ad-unit',
mediaTypes: {
video: {
api: [2, 7],
context: 'instream',
description: 'this is a video description',
duration: 556,
iabcat2: ['6', '17'],
id: '54321',
lang: 'FR',
playerSize: [ [1280, 720] ],
private: false,
startDelay: 0,
tags: 'tag_1,tag_2,tag_3',
title: 'test video',
topics: 'topic_1, topic_2',
},
}
}
];
```

Each of the following video metadata fields can be added in mediaTypes.video or bids.params.video.
If a field exists in both places, it will be overridden by bids.params.video.

* `description` - Video description
* `duration` - Video duration in seconds
* `iabcat2` - List of IAB category IDs from the [2.0 taxonomy](https://github.com/InteractiveAdvertisingBureau/Taxonomies/blob/main/Content%20Taxonomies/Content%20Taxonomy%202.0.tsv)
* `id` - Video unique ID in host video infrastructure
* `lang` - ISO 639-1 code for main language used in the video
* `private` - True if video is not publicly available
* `tags` - Tags for the video, comma separated
* `title` - Video title
* `topics` - Main topics for the video, comma separated
* `xid` - Dailymotion video identifier (only applicable if using the Dailymotion player)

# Integrating the adapter

To use the adapter with any non-test request, you first need to ask an API key from Dailymotion. Please contact us through **[email protected]**.

You will then be able to use it within the bid parameters before making a bid request.

This API key will ensure proper identification of your inventory and allow you to get real bids.
Loading
Loading