77import { logError , formatQS } from '../src/utils.js' ;
88import { submodule } from '../src/hook.js' ;
99import { ajax } from '../src/ajax.js' ;
10- import { getStorageManager } from '../src/storageManager.js' ;
11- import { MODULE_TYPE_UID } from '../src/activities/modules.js' ;
1210import { getUserSyncParams } from '../libraries/userSyncUtils/userSyncUtils.js' ;
1311
1412const MODULE_NAME = 'startioId' ;
13+ const GVLID = 1216 ;
1514const DEFAULT_ENDPOINT = 'https://cs.startappnetwork.com/get-uid-obj?p=m4b8b3y4' ;
1615
17- const storage = getStorageManager ( { moduleType : MODULE_TYPE_UID , moduleName : MODULE_NAME } ) ;
18-
19- function getCachedId ( ) {
20- let cachedId ;
21-
22- if ( storage . cookiesAreEnabled ( ) ) {
23- cachedId = storage . getCookie ( MODULE_NAME ) ;
24- }
25-
26- if ( ! cachedId && storage . hasLocalStorage ( ) ) {
27- const expirationStr = storage . getDataFromLocalStorage ( `${ MODULE_NAME } _exp` ) ;
28- if ( expirationStr ) {
29- const expirationDate = new Date ( expirationStr ) ;
30- if ( expirationDate > new Date ( ) ) {
31- cachedId = storage . getDataFromLocalStorage ( MODULE_NAME ) ;
32- }
33- }
34- }
35-
36- return cachedId || null ;
37- }
38-
39- function storeId ( id , expiresInDays ) {
40- expiresInDays = expiresInDays || 90 ;
41- const expirationDate = new Date ( Date . now ( ) + expiresInDays * 24 * 60 * 60 * 1000 ) . toUTCString ( ) ;
42-
43- if ( storage . cookiesAreEnabled ( ) ) {
44- storage . setCookie ( MODULE_NAME , id , expirationDate , 'None' ) ;
45- }
46-
47- if ( storage . hasLocalStorage ( ) ) {
48- storage . setDataInLocalStorage ( `${ MODULE_NAME } _exp` , expirationDate ) ;
49- storage . setDataInLocalStorage ( MODULE_NAME , id ) ;
50- }
51- }
52-
53- function fetchIdFromServer ( callback , expiresInDays , consentData ) {
16+ function fetchIdFromServer ( callback , consentData ) {
5417 const consentParams = getUserSyncParams (
5518 consentData ?. gdpr ,
5619 consentData ?. usp ,
@@ -66,7 +29,6 @@ function fetchIdFromServer(callback, expiresInDays, consentData) {
6629 const responseObj = JSON . parse ( response ) ;
6730 if ( responseObj && responseObj . uid ) {
6831 responseId = responseObj . uid ;
69- storeId ( responseId , expiresInDays ) ;
7032 } else {
7133 logError ( `${ MODULE_NAME } : Server response missing 'uid' field` ) ;
7234 }
@@ -85,6 +47,7 @@ function fetchIdFromServer(callback, expiresInDays, consentData) {
8547
8648export const startioIdSubmodule = {
8749 name : MODULE_NAME ,
50+ gvlid : GVLID ,
8851 decode ( value ) {
8952 return value && typeof value === 'string'
9053 ? { 'startioId' : value }
@@ -94,14 +57,10 @@ export const startioIdSubmodule = {
9457 if ( storedId ) {
9558 return { id : storedId } ;
9659 }
97-
98- const cachedId = getCachedId ( ) ;
99- if ( cachedId ) {
100- return { id : cachedId } ;
60+ if ( config . storage && config . storage . expires == null ) {
61+ config . storage . expires = 90 ;
10162 }
102- const storageConfig = config && config . storage ;
103- const expiresInDays = storageConfig && storageConfig . expires ;
104- return { callback : ( cb ) => fetchIdFromServer ( cb , expiresInDays , consentData ) } ;
63+ return { callback : ( cb ) => fetchIdFromServer ( cb , consentData ) } ;
10564 } ,
10665
10766 eids : {
0 commit comments