Skip to content

Commit e723f11

Browse files
rajsidhunovatiqnovatiq
authored andcommitted
NovatiqidSystem UserId Module: Fix async json response (prebid#9601)
* 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 * Allow configuration of the sync URL and to allow callbacks for specific custom partner integrations * update documentation * attempt to fix firefox test timeout * include the AIB Vendor Id * fix async response --------- Co-authored-by: novatiq <[email protected]>
1 parent d4974b1 commit e723f11

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

modules/novatiqIdSystem.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ export const novatiqIdSubmodule = {
3535
snowflake: novatiqId
3636
}
3737
};
38+
39+
if (novatiqId.syncResponse !== undefined) {
40+
responseObj.novatiq.ext = {};
41+
responseObj.novatiq.ext.syncResponse = novatiqId.syncResponse;
42+
}
43+
44+
if (typeof config != 'undefined' && typeof config.params !== 'undefined' && typeof config.params.removeAdditionalInfo !== 'undefined' && config.params.removeAdditionalInfo === true) {
45+
delete responseObj.novatiq.snowflake.syncResponse;
46+
}
47+
3848
return responseObj;
3949
},
4050

@@ -120,7 +130,7 @@ export const novatiqIdSubmodule = {
120130
getNovatiqId(urlParams) {
121131
// standard uuid format
122132
let uuidFormat = [1e7] + -1e3 + -4e3 + -8e3 + -1e11;
123-
if (urlParams.useStandardUuid == false) {
133+
if (urlParams.useStandardUuid === false) {
124134
// novatiq standard uuid(like) format
125135
uuidFormat = uuidFormat + 1e3;
126136
}

modules/userId/eids.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,13 @@ export const USER_IDS_CONFIG = {
250250
// Novatiq Snowflake
251251
'novatiq': {
252252
getValue: function(data) {
253-
return data.snowflake
253+
if (data.snowflake.id === undefined) {
254+
return data.snowflake;
255+
}
256+
257+
return data.snowflake.id;
254258
},
255259
source: 'novatiq.com',
256-
atype: 1
257260
},
258261

259262
'uid2': {

test/spec/modules/novatiqIdSystem_spec.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,31 @@ describe('novatiqIdSystem', function () {
138138
});
139139

140140
describe('decode', function() {
141-
it('should log message if novatiqId has wrong format', function() {
141+
it('should return the same novatiqId as passed in if not async', function() {
142142
const novatiqId = '81b001ec-8914-488c-a96e-8c220d4ee08895ef';
143143
const response = novatiqIdSubmodule.decode(novatiqId);
144144
expect(response.novatiq.snowflake).to.have.length(40);
145145
});
146146

147-
it('should log message if novatiqId has wrong format', function() {
148-
const novatiqId = '81b001ec-8914-488c-a96e-8c220d4ee08895ef';
147+
it('should change the result format if async', function() {
148+
let novatiqId = {};
149+
novatiqId.id = '81b001ec-8914-488c-a96e-8c220d4ee08895ef';
150+
novatiqId.syncResponse = 2;
149151
const response = novatiqIdSubmodule.decode(novatiqId);
150-
expect(response.novatiq.snowflake).should.be.not.empty;
152+
expect(response.novatiq.ext.syncResponse).should.be.not.empty;
153+
expect(response.novatiq.snowflake.id).should.be.not.empty;
154+
expect(response.novatiq.snowflake.syncResponse).should.be.not.empty;
155+
});
156+
157+
it('should remove syncResponse if removeAdditionalInfo true', function() {
158+
let novatiqId = {};
159+
novatiqId.id = '81b001ec-8914-488c-a96e-8c220d4ee08895ef';
160+
novatiqId.syncResponse = 2;
161+
var config = {params: {removeAdditionalInfo: true}};
162+
const response = novatiqIdSubmodule.decode(novatiqId, config);
163+
expect(response.novatiq.ext.syncResponse).should.be.not.empty;
164+
expect(response.novatiq.snowflake.id).should.be.not.empty;
165+
should.equal(response.novatiq.snowflake.syncResponse, undefined);
151166
});
152167
});
153168
})

0 commit comments

Comments
 (0)