From c5c87407324bf912ef4a48f50e9a7777cb683ccd Mon Sep 17 00:00:00 2001 From: kyoya-takei Date: Thu, 24 Feb 2022 15:57:26 +0900 Subject: [PATCH 1/3] Add dacid user id module --- integrationExamples/gpt/userId_example.html | 3 ++ modules/.submodules.json | 1 + modules/dacIdSystem.js | 57 +++++++++++++++++++++ modules/dacIdSystem.md | 25 +++++++++ modules/userId/eids.js | 6 +++ modules/userId/userId.md | 3 ++ test/spec/modules/dacIdSystem_spec.js | 51 ++++++++++++++++++ 7 files changed, 146 insertions(+) create mode 100644 modules/dacIdSystem.js create mode 100644 modules/dacIdSystem.md create mode 100644 test/spec/modules/dacIdSystem_spec.js diff --git a/integrationExamples/gpt/userId_example.html b/integrationExamples/gpt/userId_example.html index 585bb1c97ae..e11a0b626c9 100644 --- a/integrationExamples/gpt/userId_example.html +++ b/integrationExamples/gpt/userId_example.html @@ -252,6 +252,9 @@ "params": { "cid": 5126 // Set your Intimate Merger Customer ID here for production } + }, + { + "name": "dacId" } ], "syncDelay": 5000, diff --git a/modules/.submodules.json b/modules/.submodules.json index 2fb46377a64..4177646ec38 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -7,6 +7,7 @@ "britepoolIdSystem", "connectIdSystem", "criteoIdSystem", + "dacIdSystem", "deepintentDpesIdSystem", "dmdIdSystem", "fabrickIdSystem", diff --git a/modules/dacIdSystem.js b/modules/dacIdSystem.js new file mode 100644 index 00000000000..73b5c7420cf --- /dev/null +++ b/modules/dacIdSystem.js @@ -0,0 +1,57 @@ +/** + * This module adds dacId to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/dacIdSystem + * @requires module:modules/userId + */ + +import { submodule } from '../src/hook.js'; +import { getStorageManager } from '../src/storageManager.js'; + +export const storage = getStorageManager(); + +export const cookieKey = '_a1_f'; + +export const dacIdSystemSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: 'dacId', + + /** + * performs action to obtain id + * @function + * @returns { {id: {dacId: string}} | undefined } + */ + getId: function() { + const newId = storage.getCookie(cookieKey); + if (!newId) { + return undefined; + } + const result = { + dacId: newId + } + return {id: result}; + }, + + /** + * decode the stored id value for passing to bid requests + * @function + * @param { {dacId: string} } value + * @returns { {dacId: {id: string} } | undefined } + */ + decode: function(value) { + if (value && typeof value === 'object') { + const result = {}; + if (value.dacId) { + result.id = value.dacId + } + return {dacId: result}; + } + return undefined; + }, + +} + +submodule('userId', dacIdSystemSubmodule); diff --git a/modules/dacIdSystem.md b/modules/dacIdSystem.md new file mode 100644 index 00000000000..871bce003db --- /dev/null +++ b/modules/dacIdSystem.md @@ -0,0 +1,25 @@ +## DAC User ID Submodule + +## Building Prebid with DAC ID Support + +First, make sure to add the DAC ID submodule to your Prebid.js package with: + +``` +gulp build --modules=dacIdSystem +``` + +The following configuration parameters are available: + +```javascript +pbjs.setConfig({ + userSync: { + userIds: [{ + name: 'dacId' + }] + } +}); +``` + +| Param under userSync.userIds[] | Scope | Type | Description | Example | +| --- | --- | --- | --- | --- | +| name | Required | String | The name of this module. | `"dacId"` | diff --git a/modules/userId/eids.js b/modules/userId/eids.js index e78cffdcbac..7ec9c398b2e 100644 --- a/modules/userId/eids.js +++ b/modules/userId/eids.js @@ -285,6 +285,12 @@ const USER_IDS_CONFIG = { source: 'adquery.io', atype: 1 }, + + // DAC ID + 'dacId': { + source: 'dac.co.jp', + atype: 1 + }, }; // this function will create an eid object for the given UserId sub-module diff --git a/modules/userId/userId.md b/modules/userId/userId.md index 44ed7003f0c..93edc21bb66 100644 --- a/modules/userId/userId.md +++ b/modules/userId/userId.md @@ -140,6 +140,9 @@ pbjs.setConfig({ name: "knssoId", expires: 30 }, + { + name: "dacId" + } ], syncDelay: 5000, auctionDelay: 1000 diff --git a/test/spec/modules/dacIdSystem_spec.js b/test/spec/modules/dacIdSystem_spec.js new file mode 100644 index 00000000000..d78b4a69000 --- /dev/null +++ b/test/spec/modules/dacIdSystem_spec.js @@ -0,0 +1,51 @@ +import { dacIdSystemSubmodule, storage, cookieKey } from 'modules/dacIdSystem.js'; + +const DACID_DUMMY_VALUE = 'dacIdTest'; +const DACID_DUMMY_OBJ = { + dacId: DACID_DUMMY_VALUE +}; + +describe('dacId module', function () { + let getCookieStub; + + beforeEach(function (done) { + getCookieStub = sinon.stub(storage, 'getCookie'); + done(); + }); + + afterEach(function () { + getCookieStub.restore(); + }); + + const cookieTestCasesForEmpty = [ + undefined, + null, + '' + ] + + describe('getId()', function () { + it('should return the uid when it exists in cookie', function () { + getCookieStub.withArgs(cookieKey).returns(DACID_DUMMY_VALUE); + const id = dacIdSystemSubmodule.getId(); + expect(id).to.be.deep.equal({id: {dacId: DACID_DUMMY_VALUE}}); + }); + + cookieTestCasesForEmpty.forEach(testCase => it('should return the uid when it not exists in cookie', function () { + getCookieStub.withArgs(cookieKey).returns(testCase); + const id = dacIdSystemSubmodule.getId(); + expect(id).to.be.deep.equal(undefined); + })); + }); + + describe('decode()', function () { + it('should return the uid when it exists in cookie', function () { + const decoded = dacIdSystemSubmodule.decode(DACID_DUMMY_OBJ); + expect(decoded).to.be.deep.equal({dacId: {id: DACID_DUMMY_VALUE}}); + }); + + it('should return the undefined when decode id is not "string"', function () { + const decoded = dacIdSystemSubmodule.decode(1); + expect(decoded).to.equal(undefined); + }); + }); +}); From b9242735a2e746a41f331e9153e2199b86fc56e7 Mon Sep 17 00:00:00 2001 From: kyoya-takei Date: Thu, 17 Mar 2022 12:39:21 +0900 Subject: [PATCH 2/3] Fix source domain --- modules/userId/eids.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/userId/eids.js b/modules/userId/eids.js index 7ec9c398b2e..0f5feca4f67 100644 --- a/modules/userId/eids.js +++ b/modules/userId/eids.js @@ -288,7 +288,7 @@ const USER_IDS_CONFIG = { // DAC ID 'dacId': { - source: 'dac.co.jp', + source: 'impact-ad.jp', atype: 1 }, }; From d51896369feef17d6b2c87e2e30e0d1bc4e3725d Mon Sep 17 00:00:00 2001 From: kyoya-takei Date: Thu, 17 Mar 2022 13:13:33 +0900 Subject: [PATCH 3/3] Add document to explain dac ID --- modules/dacIdSystem.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/dacIdSystem.md b/modules/dacIdSystem.md index 871bce003db..b422d0a536d 100644 --- a/modules/dacIdSystem.md +++ b/modules/dacIdSystem.md @@ -1,5 +1,8 @@ ## DAC User ID Submodule +DAC ID, provided by [D.A.Consortium Inc.](https://www.dac.co.jp/), is ID for ad targeting by using 1st party cookie. +Please contact D.A.Consortium Inc. before using this ID. + ## Building Prebid with DAC ID Support First, make sure to add the DAC ID submodule to your Prebid.js package with: