Skip to content

Commit

Permalink
Utiq ID submodule: Update submodule name and parameters (#10587)
Browse files Browse the repository at this point in the history
Co-authored-by: Tomasz Januszek <tomasz@teavaro.com>
  • Loading branch information
jkthomas and Tomasz Januszek authored Oct 12, 2023
1 parent de82bae commit 86736ac
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
2 changes: 1 addition & 1 deletion modules/.submodules.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"tapadIdSystem",
"teadsIdSystem",
"tncIdSystem",
"utiqSystem",
"utiqIdSystem",
"uid2IdSystem",
"euidIdSystem",
"unifiedIdSystem",
Expand Down
8 changes: 4 additions & 4 deletions modules/utiqSystem.js → modules/utiqIdSystem.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/**
* This module adds Utiq provided by Utiq SA/NV to the User ID module
* The {@link module:modules/userId} module is required
* @module modules/utiqSystem
* @module modules/utiqIdSystem
* @requires module:modules/userId
*/
import { logInfo } from '../src/utils.js';
import { submodule } from '../src/hook.js';
import { getStorageManager } from '../src/storageManager.js';
import { MODULE_TYPE_UID } from '../src/activities/modules.js';

const MODULE_NAME = 'utiq';
const MODULE_NAME = 'utiqId';
const LOG_PREFIX = 'Utiq module';

export const storage = getStorageManager({
Expand Down Expand Up @@ -56,7 +56,7 @@ function getUtiqFromStorage() {
}

/** @type {Submodule} */
export const utiqSubmodule = {
export const utiqIdSubmodule = {
/**
* Used to link submodule with config
* @type {string}
Expand Down Expand Up @@ -135,4 +135,4 @@ export const utiqSubmodule = {
}
};

submodule('userId', utiqSubmodule);
submodule('userId', utiqIdSubmodule);
7 changes: 1 addition & 6 deletions modules/utiqSystem.md → modules/utiqIdSystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Utiq ID Module.
First, make sure to add the utiq submodule to your Prebid.js package with:

```
gulp build --modules=userId,adfBidAdapter,ixBidAdapter,prebidServerBidAdapter,utiqSystem
gulp build --modules=userId,adfBidAdapter,ixBidAdapter,prebidServerBidAdapter,utiqIdSystem
```

## Parameter Descriptions
Expand All @@ -15,8 +15,3 @@ gulp build --modules=userId,adfBidAdapter,ixBidAdapter,prebidServerBidAdapter,ut
| name | String | The name of the module | `"utiq"` |
| params | Object | Object with configuration parameters for utiq User Id submodule | - |
| params.maxDelayTime | Integer | Max amount of time (in seconds) before looking into storage for data | 2500 |
| bidders | Array of Strings | An array of bidder codes to which this user ID may be sent. Currently required and supporting AdformOpenRTB | [`"adf"`, `"adformPBS"`, `"ix"`] |
| storage | Object | Local storage configuration object | - |
| storage.type | String | Type of the storage that would be used to store user ID. Must be `"html5"` to utilise HTML5 local storage. | `"html5"` |
| storage.name | String | The name of the key in local storage where the user ID will be stored. | `"utiq"` |
| storage.expires | Integer | How long (in days) the user ID information will be stored. For safety reasons, this information is required. | `1` |
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect } from 'chai';
import { utiqSubmodule } from 'modules/utiqSystem.js';
import { storage } from 'modules/utiqSystem.js';
import { utiqIdSubmodule } from 'modules/utiqIdSystem.js';
import { storage } from 'modules/utiqIdSystem.js';

describe('utiqSystem', () => {
describe('utiqIdSystem', () => {
const utiqPassKey = 'utiqPass';

const getStorageData = (idGraph) => {
Expand All @@ -17,7 +17,7 @@ describe('utiqSystem', () => {
};

it('should have the correct module name declared', () => {
expect(utiqSubmodule.name).to.equal('utiq');
expect(utiqIdSubmodule.name).to.equal('utiqId');
});

describe('utiq getId()', () => {
Expand All @@ -26,13 +26,13 @@ describe('utiqSystem', () => {
});

it('it should return object with key callback', () => {
expect(utiqSubmodule.getId()).to.have.property('callback');
expect(utiqIdSubmodule.getId()).to.have.property('callback');
});

it('should return object with key callback with value type - function', () => {
storage.setDataInLocalStorage(utiqPassKey, JSON.stringify(getStorageData()));
expect(utiqSubmodule.getId()).to.have.property('callback');
expect(typeof utiqSubmodule.getId().callback).to.be.equal('function');
expect(utiqIdSubmodule.getId()).to.have.property('callback');
expect(typeof utiqIdSubmodule.getId().callback).to.be.equal('function');
});

it('tests if localstorage & JSON works properly ', () => {
Expand All @@ -50,7 +50,7 @@ describe('utiqSystem', () => {
'atid': 'atidValue',
};
storage.setDataInLocalStorage(utiqPassKey, JSON.stringify(getStorageData(idGraph)));
const response = utiqSubmodule.getId();
const response = utiqIdSubmodule.getId();
expect(response).to.have.property('id');
expect(response.id).to.have.property('utiq');
expect(response.id.utiq).to.be.equal('atidValue');
Expand All @@ -61,7 +61,7 @@ describe('utiqSystem', () => {
'domain': 'test.domain',
'atid': 'atidValue',
};
const response = utiqSubmodule.getId();
const response = utiqIdSubmodule.getId();
expect(response).to.have.property('callback');
expect(response.callback.toString()).contain('result(callback)');

Expand All @@ -82,7 +82,7 @@ describe('utiqSystem', () => {
'atid': 'atidValue',
};

const response = utiqSubmodule.getId();
const response = utiqIdSubmodule.getId();
expect(response).to.have.property('callback');
expect(response.callback.toString()).contain('result(callback)');

Expand All @@ -105,7 +105,7 @@ describe('utiqSystem', () => {
'atid': 'atidValue',
};

const response = utiqSubmodule.getId({params: {maxDelayTime: 200}});
const response = utiqIdSubmodule.getId({params: {maxDelayTime: 200}});
expect(response).to.have.property('callback');
expect(response.callback.toString()).contain('result(callback)');

Expand Down Expand Up @@ -138,15 +138,15 @@ describe('utiqSystem', () => {
];
VALID_API_RESPONSES.forEach(responseData => {
it('should return a newly constructed object with the utiq for a payload with {utiq: value}', () => {
expect(utiqSubmodule.decode(responseData.payload)).to.deep.equal(
expect(utiqIdSubmodule.decode(responseData.payload)).to.deep.equal(
{utiq: responseData.expected}
);
});
});

[{}, '', {foo: 'bar'}].forEach((response) => {
it(`should return null for an invalid response "${JSON.stringify(response)}"`, () => {
expect(utiqSubmodule.decode(response)).to.be.null;
expect(utiqIdSubmodule.decode(response)).to.be.null;
});
});
});
Expand Down Expand Up @@ -177,7 +177,7 @@ describe('utiqSystem', () => {

window.dispatchEvent(new MessageEvent('message', eventData));

const response = utiqSubmodule.getId();
const response = utiqIdSubmodule.getId();
expect(response).to.have.property('id');
expect(response.id).to.have.property('utiq');
expect(response.id.utiq).to.be.equal('atidValue');
Expand Down

0 comments on commit 86736ac

Please sign in to comment.