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

GrowthCode ID Module: update the user module to expire old user information #9170

Merged
merged 16 commits into from
Oct 31, 2022
Merged
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
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