Skip to content

Commit

Permalink
Novatiq ID module: sharedID changes (#7994)
Browse files Browse the repository at this point in the history
* Novatiq snowflake userId submodule

Novatiq snowflake userId submodule initial release

* change request updates

added novatiq info /modules/userId/userId.md
added novatiq info /modules/userId/eids.md
added novatiq eids /modules/userId/eids.js
added novatiq module in /modules/.submodules.json
removed unnecessary value from getId response

* Update novatiqIdSystem_spec.js

removed unnecessary srcid value

* Update novatiqIdSystem.md

Novatiq ID System: updated novatiq snowflake ID description

* use the sharedId if available and configured

* updated docs

* test changes

* defensive code not required

* Use the prebid storage manager instead of using native functions

* doc changes

* trailing spaces

Co-authored-by: novatiq <79258366+novatiq@users.noreply.github.com>
  • Loading branch information
rajsidhunovatiq and novatiq authored Feb 10, 2022
1 parent 40ebe8d commit 4f05f95
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 22 deletions.
83 changes: 68 additions & 15 deletions modules/novatiqIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@
import { logInfo } from '../src/utils.js';
import { ajax } from '../src/ajax.js';
import { submodule } from '../src/hook.js';
import {getStorageManager} from '../src/storageManager.js';

/** @type {Submodule} */
export const novatiqIdSubmodule = {

/**
* used to link submodule with config
* @type {string}
*/
/**
* used to link submodule with config
* @type {string}
*/
name: 'novatiq',

/**
* decode the stored id value for passing to bid requests
* @function
* @returns {novatiq: {snowflake: string}}
*/
* decode the stored id value for passing to bid requests
* @function
* @returns {novatiq: {snowflake: string}}
*/
decode(novatiqId, config) {
let responseObj = {
novatiq: {
Expand All @@ -33,11 +34,11 @@ export const novatiqIdSubmodule = {
},

/**
* performs action to obtain id and return a value in the callback's response argument
* @function
* @param {SubmoduleConfig} config
* @returns {id: string}
*/
* performs action to obtain id and return a value in the callback's response argument
* @function
* @param {SubmoduleConfig} config
* @returns {id: string}
*/
getId(config) {
function snowflakeId(placeholder) {
return placeholder
Expand All @@ -47,18 +48,70 @@ export const novatiqIdSubmodule = {

const configParams = config.params || {};
const srcId = this.getSrcId(configParams);
const sharedId = this.getSharedId(configParams);

logInfo('NOVATIQ config params: ' + JSON.stringify(configParams));
logInfo('NOVATIQ Sync request used sourceid param: ' + srcId);
logInfo('NOVATIQ Sync request Shared ID: ' + sharedId);

let partnerhost;
partnerhost = window.location.hostname;
logInfo('NOVATIQ partner hostname: ' + partnerhost);

const novatiqId = snowflakeId();
const url = 'https://spadsync.com/sync?sptoken=' + novatiqId + '&sspid=' + srcId + '&ssphost=' + partnerhost;

let url = 'https://spadsync.com/sync?sptoken=' + novatiqId + '&sspid=' + srcId + '&ssphost=' + partnerhost;

// for testing
let sharedStatus = 'Not Found';

// append on the shared ID if we have one
if (sharedId != null) {
url = url + '&sharedId=' + sharedId;
sharedStatus = 'Found';
}

ajax(url, undefined, undefined, { method: 'GET', withCredentials: false });

logInfo('NOVATIQ snowflake: ' + novatiqId);
return { 'id': novatiqId }
return { 'id': novatiqId,
'sharedStatus': sharedStatus }
},

useSharedId(configParams) {
return typeof configParams.useSharedId != 'undefined' && configParams.useSharedId === true;
},

// return null if we aren't supposed to use one or we are but there isn't one present
getSharedId(configParams) {
let sharedId = null;
if (this.useSharedId(configParams)) {
let cookieOrStorageID = '_pubcid';

// Has the cookieOrStorageID been redefined?
if (typeof configParams.sharedIdName != 'undefined' && configParams.sharedIdName != null && configParams.sharedIdName != '') {
cookieOrStorageID = configParams.sharedIdName;
logInfo('NOVATIQ sharedID name redefined: ' + cookieOrStorageID);
}

const storage = getStorageManager('', 'pubCommonId');

// first check local storage
if (storage.hasLocalStorage()) {
sharedId = storage.getDataFromLocalStorage(cookieOrStorageID);
logInfo('NOVATIQ sharedID retrieved from local storage:' + sharedId);
}

// if nothing check the local cookies
if (sharedId == null) {
sharedId = storage.getCookie(cookieOrStorageID);
logInfo('NOVATIQ sharedID retrieved from cookies:' + sharedId);
}
}

logInfo('NOVATIQ sharedID returning: ' + sharedId);

return sharedId;
},

getSrcId(configParams) {
Expand Down
76 changes: 69 additions & 7 deletions modules/novatiqIdSystem.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Novatiq Snowflake ID
# Novatiq Hyper ID

Novatiq proprietary dynamic snowflake ID is a unique, non sequential and single use identifier for marketing activation. Our in network solution matches verification requests to telco network IDs, safely and securely inside telecom infrastructure. Novatiq snowflake ID can be used for identity validation and as a secured 1st party data delivery mechanism.
The Novatiq proprietary dynamic Hyper ID is a unique, non sequential and single use identifier for marketing activation. Our in network solution matches verification requests to telco network IDs safely and securely inside telecom infrastructure. The Novatiq Hyper ID can be used for identity validation and as a secured 1st party data delivery mechanism.

## Novatiq Snowflake ID Configuration
## Novatiq Hyper ID Configuration

Enable by adding the Novatiq submodule to your Prebid.js package with:

Expand All @@ -18,19 +18,81 @@ pbjs.setConfig({
userIds: [{
name: 'novatiq',
params: {
sourceid '1a3', // change to the Partner Number you received from Novatiq
// change to the Partner Number you received from Novatiq
sourceid '1a3'
}
}
}],
auctionDelay: 50 // 50ms maximum auction delay, applies to all userId modules
// 50ms maximum auction delay, applies to all userId modules
auctionDelay: 50
}
});
```
```

| Param under userSync.userIds[] | Scope | Type | Description | Example |
### Parameters for the Novatiq Module
| Param | Scope | Type | Description | Example |
| --- | --- | --- | --- | --- |
| name | Required | String | Module identification: `"novatiq"` | `"novatiq"` |
| params | Required | Object | Configuration specifications for the Novatiq module. | |
| params.sourceid | Required | String | This is the Novatiq Partner Number obtained via Novatiq registration. | `1a3` |

# Novatiq Hyper ID with Prebid SharedID support
You can make use of the Prebid.js SharedId module as follows.

## Novatiq Hyper ID Configuration

Enable by adding the Novatiq and SharedId submodule to your Prebid.js package with:

```
gulp build --modules=novatiqIdSystem,userId,pubCommonId
```

Module activation and configuration:

```javascript
pbjs.setConfig({
userSync: {
userIds: [
{
name: "pubCommonId",
storage: {
type: "cookie",
// optional: will default to _pubcid if left blank
name: "demo_pubcid",

// expires in 1 years
expires: 365
},
bidders: [ 'adtarget' ]
},
{
name: 'novatiq',
params: {
// change to the Partner Number you received from Novatiq
sourceid '1a3',

// Use the sharedID module
useSharedId: true,

// optional: will default to _pubcid if left blank.
// If not left blank must match "name" in the the module above
sharedIdName: 'demo_pubcid'
}
}
}],
// 50ms maximum auction delay, applies to all userId modules
auctionDelay: 50
}
});
```

### Parameters for the Novatiq Module
| Param | Scope | Type | Description | Example |
| --- | --- | --- | --- | --- |
| name | Required | String | Module identification: `"novatiq"` | `"novatiq"` |
| params | Required | Object | Configuration specifications for the Novatiq module. | |
| params.sourceid | Required | String | The Novatiq Partner Number obtained via Novatiq | `1a3` |
| params.useSharedId | Optional | Boolean | Use the sharedID module if it's activated. | `true` |
| params.sharedIdName | Optional | String | Same as the SharedID "name" parameter <br /> Defaults to "_pubcid" | `"demo_pubcid"` |

If you have any questions, please reach out to us at prebid@novatiq.com.
18 changes: 18 additions & 0 deletions test/spec/modules/novatiqIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,24 @@ describe('novatiqIdSystem', function () {
const response = novatiqIdSubmodule.getId(config);
expect(response.id).should.be.not.empty;
});

it('should set sharedStatus if sharedID is configured but returned null', function() {
const config = { params: { sourceid: '123', useSharedId: true } };
const response = novatiqIdSubmodule.getId(config);
expect(response.sharedStatus).to.equal('Not Found');
});

it('should set sharedStatus if sharedID is configured and is valid', function() {
const config = { params: { sourceid: '123', useSharedId: true } };

let stub = sinon.stub(novatiqIdSubmodule, 'getSharedId').returns('fakeId');

const response = novatiqIdSubmodule.getId(config);

stub.restore();

expect(response.sharedStatus).to.equal('Found');
});
});

describe('decode', function() {
Expand Down

0 comments on commit 4f05f95

Please sign in to comment.