Skip to content

Commit

Permalink
GrowthCode ID Module: update the user module to expire old user infor…
Browse files Browse the repository at this point in the history
…mation (prebid#9170)

* Initial check-in ofthe GrowthCode Adaptor

* Growthcode ID System

* Working on test module

* Tests for the growthCode Id System

* Clean up tests for GrowthCode

* Fixed the default values for shareID

* Remove Test HTML Page

* Remove file

* Updated MD file to switch client ID to partner ID

* Will now expire LocalStore data

* Remove Test Files
  • Loading branch information
southern-growthcode authored and jorgeluisrocha committed May 18, 2023
1 parent 874fc25 commit d73ddc2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions modules/growthCodeIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {ajax} from '../src/ajax.js';
import { submodule } from '../src/hook.js'
import { getStorageManager } from '../src/storageManager.js';

const GCID_EXPIRY = 45;
const GCID_EXPIRY = 7;
const MODULE_NAME = 'growthCodeId';
const GC_DATA_KEY = '_gc_data';
const ENDPOINT_URL = 'https://p2.gcprivacy.com/v1/pb?'
Expand All @@ -24,11 +24,15 @@ export const storage = getStorageManager({ gvlid: undefined, moduleName: MODULE_
*/
export function readData(key) {
try {
let payload
if (storage.cookiesAreEnabled()) {
payload = tryParse(storage.getCookie(key))
}
if (storage.hasLocalStorage()) {
return storage.getDataFromLocalStorage(key);
payload = tryParse(storage.getDataFromLocalStorage(key))
}
if (storage.cookiesAreEnabled()) {
return storage.getCookie(key);
if ((payload.expire_at !== undefined) && (payload.expire_at > (Date.now() / 1000))) {
return payload
}
} catch (error) {
logError(error);
Expand Down Expand Up @@ -122,7 +126,7 @@ export const growthCodeIdSubmodule = {
}

const resp = function(callback) {
let gcData = tryParse(readData(GC_DATA_KEY));
let gcData = readData(GC_DATA_KEY);
if (gcData) {
callback(gcData);
} else {
Expand Down

0 comments on commit d73ddc2

Please sign in to comment.