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

RPO-2012: Update local storage name-spacing for c_uid #8

Merged
merged 3 commits into from
Oct 27, 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
12 changes: 10 additions & 2 deletions modules/concertBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export const spec = {

registerBidder(spec);

const storage = getStorageManager({bidderCode: BIDDER_CODE});
export const storage = getStorageManager({bidderCode: BIDDER_CODE});

/**
* Check or generate a UID for the current user.
Expand All @@ -188,10 +188,18 @@ function getUid(bidderRequest) {
return false;
}

const CONCERT_UID_KEY = 'c_uid';
const LEGACY_CONCERT_UID_KEY = 'c_uid';
const CONCERT_UID_KEY = 'vmconcert_uid';

const legacyUid = storage.getDataFromLocalStorage(LEGACY_CONCERT_UID_KEY);
let uid = storage.getDataFromLocalStorage(CONCERT_UID_KEY);

if (legacyUid) {
uid = legacyUid;
storage.setDataInLocalStorage(CONCERT_UID_KEY, uid);
storage.removeDataFromLocalStorage(LEGACY_CONCERT_UID_KEY);
}

if (!uid) {
uid = generateUUID();
storage.setDataInLocalStorage(CONCERT_UID_KEY, uid);
Expand Down
25 changes: 11 additions & 14 deletions test/spec/modules/concertBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import sinon from 'sinon';
import { spec } from 'modules/concertBidAdapter.js';
import { getStorageManager } from '../../../src/storageManager.js'
import { spec, storage } from 'modules/concertBidAdapter.js';
import { hook } from 'src/hook.js';

describe('ConcertAdapter', function () {
let bidRequests;
Expand All @@ -10,9 +10,8 @@ describe('ConcertAdapter', function () {
let element;
let sandbox;

afterEach(function () {
$$PREBID_GLOBAL$$.bidderSettings = {};
sandbox.restore();
before(function () {
hook.ready();
});

beforeEach(function () {
Expand All @@ -39,6 +38,7 @@ describe('ConcertAdapter', function () {
storageAllowed: true
}
};

bidRequests = [
{
bidder: 'concert',
Expand Down Expand Up @@ -83,6 +83,11 @@ describe('ConcertAdapter', function () {
sandbox.stub(document, 'getElementById').withArgs('desktop_leaderboard_variable').returns(element)
});

afterEach(function () {
$$PREBID_GLOBAL$$.bidderSettings = {};
sandbox.restore();
});

describe('spec.isBidRequestValid', function() {
it('should return when it recieved all the required params', function() {
const bid = bidRequests[0];
Expand Down Expand Up @@ -118,7 +123,6 @@ describe('ConcertAdapter', function () {
});

it('should not generate uid if the user has opted out', function() {
const storage = getStorageManager();
storage.setDataInLocalStorage('c_nap', 'true');
const request = spec.buildRequests(bidRequests, bidRequest);
const payload = JSON.parse(request.data);
Expand All @@ -127,7 +131,6 @@ describe('ConcertAdapter', function () {
});

it('should generate uid if the user has not opted out', function() {
const storage = getStorageManager();
storage.removeDataFromLocalStorage('c_nap');
const request = spec.buildRequests(bidRequests, bidRequest);
const payload = JSON.parse(request.data);
Expand All @@ -136,8 +139,7 @@ describe('ConcertAdapter', function () {
});

it('should grab uid from local storage if it exists', function() {
const storage = getStorageManager();
storage.setDataInLocalStorage('c_uid', 'foo');
storage.setDataInLocalStorage('vmconcert_uid', 'foo');
storage.removeDataFromLocalStorage('c_nap');
const request = spec.buildRequests(bidRequests, bidRequest);
const payload = JSON.parse(request.data);
Expand Down Expand Up @@ -211,7 +213,6 @@ describe('ConcertAdapter', function () {
const opts = {
iframeEnabled: true
};
const storage = getStorageManager();
storage.setDataInLocalStorage('c_nap', 'true');

const sync = spec.getUserSyncs(opts, [], bidRequest.gdprConsent, bidRequest.uspConsent);
Expand All @@ -222,7 +223,6 @@ describe('ConcertAdapter', function () {
const opts = {
iframeEnabled: true
};
const storage = getStorageManager();
storage.removeDataFromLocalStorage('c_nap');

bidRequest.gdprConsent = {
Expand All @@ -237,7 +237,6 @@ describe('ConcertAdapter', function () {
const opts = {
iframeEnabled: true
};
const storage = getStorageManager();
storage.removeDataFromLocalStorage('c_nap');

bidRequest.gdprConsent = {
Expand All @@ -252,7 +251,6 @@ describe('ConcertAdapter', function () {
const opts = {
iframeEnabled: true
};
const storage = getStorageManager();
storage.removeDataFromLocalStorage('c_nap');

bidRequest.gdprConsent = {
Expand All @@ -268,7 +266,6 @@ describe('ConcertAdapter', function () {
const opts = {
iframeEnabled: true
};
const storage = getStorageManager();
storage.removeDataFromLocalStorage('c_nap');

bidRequest.gdprConsent = {
Expand Down