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

Shared #3

Merged
merged 3 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
106 changes: 91 additions & 15 deletions modules/novatiqIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ import { submodule } from '../src/hook.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 +33,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 +47,94 @@ 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;
},

getFromLocalStorage(cookieOrStorageID) {
return window.localStorage.getItem(cookieOrStorageID);
},

getFromSessionStorage(cookieOrStorageID) {
return window.sessionStorage.getItem(cookieOrStorageID);
},

// 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);
}

// Check local storage first
sharedId = this.getFromLocalStorage(cookieOrStorageID);
if (sharedId == null) {
// next check session storage
sharedId = this.getFromSessionStorage(cookieOrStorageID);

// OK check cookies
if (sharedId == null) {
sharedId = this.getCookieValue(cookieOrStorageID);
logInfo('NOVATIQ retrieved sharedID from cookies: ' + sharedId);
} else {
logInfo('NOVATIQ retrieved sharedID from sessionstorage: ' + sharedId);
}
} else {
logInfo('NOVATIQ retrieved sharedID from localstorage: ' + sharedId);
}

// sanity check
if (sharedId == undefined || sharedId == null || sharedId == '') {
logInfo('NOVATIQ invalid sharedID, resetting to null');
sharedId = null;
}
}

return sharedId;
},

getCookieValue(name) {
let res = document.cookie.match('(^|;)\\s*' + name + '\\s*=\\s*([^;]+)');
if (res != undefined) {
return res.pop();
} else {
return null;
}
},

getSrcId(configParams) {
Expand Down
100 changes: 93 additions & 7 deletions modules/novatiqIdSystem.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# 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 +20,103 @@ 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"` |

&nbsp;

### Parameters for the SharedID Module
| Param | Scope | Type | Description | Example |
| --- | --- | --- | --- | --- |
| name | Required | String | Module identification: `"pubCommonId"` | `"pubCommonId"` |
| params | Required | Object | Configuration specifications for the SharedID module. | | |
| params.storage | Required | Object | | |
| params.storage.type | Required | String | Storage type, Set to `"cookie"` | `"cookie"` |
| params.storage.name | Optional | String | Storage cookie name. If this is changed must match sharedIdName <br /> in the Novatiq module | `"demo_pubcid"` ||
| params.storage.expires | Required | integer | Time to expire | `365` |


&nbsp;

If you have any questions, please reach out to us at [email protected].
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