Skip to content

Commit

Permalink
Relaido Bid Adapter: Add params for hashed canonical url. (#8743)
Browse files Browse the repository at this point in the history
* add relaido adapter

* remove event listener

* fixed UserSyncs and e.data

* fix conflicts

* Add params for hashed canonical url.

* Add params for hashed canonical url.

removed review comment.

Co-authored-by: ishigami_shingo <[email protected]>
Co-authored-by: cmertv-sishigami <[email protected]>
Co-authored-by: t_bun <[email protected]>
Co-authored-by: n.maeura <[email protected]>
  • Loading branch information
5 people authored Jul 28, 2022
1 parent 95ee493 commit 45c3312
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 12 additions & 3 deletions modules/relaidoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { Renderer } from '../src/Renderer.js';
import { getStorageManager } from '../src/storageManager.js';
import sha1 from 'crypto-js/sha1';

const BIDDER_CODE = 'relaido';
const BIDDER_DOMAIN = 'api.relaido.jp';
const ADAPTER_VERSION = '1.0.8';
const ADAPTER_VERSION = '1.0.9';
const DEFAULT_TTL = 300;
const UUID_KEY = 'relaido_uuid';

Expand Down Expand Up @@ -104,9 +105,9 @@ function buildRequests(validBidRequests, bidderRequest) {
uuid: getUuid(),
pv: '$prebid.version$',
imuid: imuid,
// TODO: is 'page' the right value here?
canonical_url_hash: getCanonicalUrlHash(bidderRequest.refererInfo),
ref: bidderRequest.refererInfo.page
})
});

return {
method: 'POST',
Expand Down Expand Up @@ -277,6 +278,14 @@ function getUuid() {
return newId;
}

function getCanonicalUrlHash(refererInfo) {
const canonicalUrl = refererInfo.canonicalUrl || null;
if (!canonicalUrl) {
return null;
}
return sha1(canonicalUrl).toString();
}

export function isMobile() {
const ua = navigator.userAgent;
if (ua.indexOf('iPhone') > -1 || ua.indexOf('iPod') > -1 || (ua.indexOf('Android') > -1 && ua.indexOf('Tablet') == -1)) {
Expand Down
4 changes: 3 additions & 1 deletion test/spec/modules/relaidoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ describe('RelaidoAdapter', function () {
bidderRequest = {
timeout: 1000,
refererInfo: {
page: 'https://publisher.com/home'
page: 'https://publisher.com/home?aaa=test1&bbb=test2',
canonicalUrl: 'https://publisher.com/home'
}
};
serverResponse = {
Expand Down Expand Up @@ -238,6 +239,7 @@ describe('RelaidoAdapter', function () {
const request = data.bids[0];
expect(bidRequests.method).to.equal('POST');
expect(bidRequests.url).to.equal('https://api.relaido.jp/bid/v1/sprebid');
expect(data.canonical_url_hash).to.equal('e6092f44a0044903ae3764126eedd6187c1d9f04');
expect(data.ref).to.equal(bidderRequest.refererInfo.page);
expect(data.timeout_ms).to.equal(bidderRequest.timeout);
expect(request.ad_unit_code).to.equal(bidRequest.adUnitCode);
Expand Down

0 comments on commit 45c3312

Please sign in to comment.