@@ -184,14 +184,14 @@ export interface IStore {
184
184
185
185
persistenceData ?: IPersistenceMinified ;
186
186
187
- getConsentState ?( mpid : MPID ) : ConsentState | null ;
188
- setConsentState ?( mpid : MPID , consentState : ConsentState ) : void ;
189
-
190
187
_getFromPersistence ?< T > ( mpid : MPID , key : string ) : T ;
191
188
_setPersistence ?< T > ( mpid : MPID , key : string , value : T ) : void ;
192
189
190
+ getConsentState ?( mpid : MPID ) : ConsentState | null ;
191
+ setConsentState ?( mpid : MPID , consentState : ConsentState ) : void ;
193
192
getDeviceId ?( ) : string ;
194
193
setDeviceId ?( deviceId : string ) : void ;
194
+ getGlobalStorageAttributes ?( ) : IGlobalStoreV2MinifiedKeys ;
195
195
getFirstSeenTime ?( mpid : MPID ) : number ;
196
196
setFirstSeenTime ?( mpid : MPID , time ?: number ) : void ;
197
197
getLastSeenTime ?( mpid : MPID ) : number ;
@@ -202,7 +202,6 @@ export interface IStore {
202
202
setUserIdentities ?( mpid : MPID , userIdentities : UserIdentities ) : void ;
203
203
204
204
addMpidToSessionHistory ?( mpid : MPID , previousMpid ?: MPID ) : void ;
205
- getGlobalStorageAttributes ?( ) : IGlobalStoreV2MinifiedKeys ;
206
205
hasInvalidIdentifyRequest ?: ( ) => boolean ;
207
206
nullifySession ?: ( ) => void ;
208
207
processConfig ( config : SDKInitConfig ) : void ;
@@ -526,33 +525,6 @@ export default function Store(
526
525
}
527
526
} ;
528
527
529
- this . getGlobalStorageAttributes = ( ) => ( {
530
- sid : this . sessionId ,
531
- ie : this . isEnabled ,
532
- sa : this . sessionAttributes ,
533
- ss : this . serverSettings ,
534
- dt : this . devToken ,
535
- les : this . dateLastEventSent ? this . dateLastEventSent . getTime ( ) : null ,
536
- av : this . SDKConfig . appVersion ,
537
- cgid : this . clientId ,
538
- das : this . deviceId ,
539
- c : this . context ,
540
- ssd : this . sessionStartDate ? this . sessionStartDate . getTime ( ) : 0 ,
541
- ia : this . integrationAttributes ,
542
-
543
- csm : this . sessionId ? this . currentSessionMPIDs : undefined ,
544
- } ) ;
545
-
546
- this . hasInvalidIdentifyRequest = ( ) : boolean => {
547
- const { identifyRequest } = this . SDKConfig ;
548
- return (
549
- ( isObject ( identifyRequest ) &&
550
- isObject ( identifyRequest . userIdentities ) &&
551
- isEmpty ( identifyRequest . userIdentities ) ) ||
552
- ! identifyRequest
553
- ) ;
554
- } ;
555
-
556
528
this . getConsentState = ( mpid : MPID ) : ConsentState => {
557
529
const {
558
530
fromMinifiedJsonObject,
@@ -576,23 +548,49 @@ export default function Store(
576
548
577
549
// If ConsentState is null, we assume the intent is to clear out the consent state
578
550
if ( consentState || consentState === null ) {
579
- this . _setPersistence (
551
+ this . _setPersistence < IMinifiedConsentJSONObject > (
580
552
mpid ,
581
553
'con' ,
582
554
toMinifiedJsonObject ( consentState )
583
555
) ;
584
556
}
585
557
} ;
586
558
587
- this . getDeviceId = ( ) => this . deviceId ;
588
- this . setDeviceId = ( deviceId : string ) => {
559
+ this . getGlobalStorageAttributes = ( ) : IGlobalStoreV2MinifiedKeys => ( {
560
+ sid : this . sessionId ,
561
+ ie : this . isEnabled ,
562
+ sa : this . sessionAttributes ,
563
+ ss : this . serverSettings ,
564
+ dt : this . devToken ,
565
+ les : this . dateLastEventSent ? this . dateLastEventSent . getTime ( ) : null ,
566
+ av : this . SDKConfig . appVersion ,
567
+ cgid : this . clientId ,
568
+ das : this . deviceId ,
569
+ c : this . context ,
570
+ ssd : this . sessionStartDate ? this . sessionStartDate . getTime ( ) : 0 ,
571
+ ia : this . integrationAttributes ,
572
+
573
+ csm : this . sessionId ? this . currentSessionMPIDs : undefined ,
574
+ } ) ;
575
+
576
+ this . hasInvalidIdentifyRequest = ( ) : boolean => {
577
+ const { identifyRequest } = this . SDKConfig ;
578
+ return (
579
+ ( isObject ( identifyRequest ) &&
580
+ isObject ( identifyRequest . userIdentities ) &&
581
+ isEmpty ( identifyRequest . userIdentities ) ) ||
582
+ ! identifyRequest
583
+ ) ;
584
+ } ;
585
+
586
+ this . getDeviceId = ( ) : string => this . deviceId ;
587
+ this . setDeviceId = ( deviceId : string ) : void => {
589
588
this . deviceId = deviceId ;
590
589
this . persistenceData . gs . das = deviceId ;
591
590
mpInstance . _Persistence . update ( ) ;
592
591
} ;
593
592
594
-
595
- this . getFirstSeenTime = ( mpid : MPID ) =>
593
+ this . getFirstSeenTime = ( mpid : MPID ) : number =>
596
594
this . _getFromPersistence < number > ( mpid , 'fst' ) ;
597
595
598
596
this . setFirstSeenTime = ( mpid : MPID , _time ?: number ) => {
@@ -602,7 +600,7 @@ export default function Store(
602
600
603
601
const time = _time || new Date ( ) . getTime ( ) ;
604
602
605
- this . _setPersistence ( mpid , 'fst' , time ) ;
603
+ this . _setPersistence < number > ( mpid , 'fst' , time ) ;
606
604
} ;
607
605
608
606
this . getLastSeenTime = ( mpid : MPID ) : number => {
@@ -618,40 +616,30 @@ export default function Store(
618
616
return this . _getFromPersistence < number > ( mpid , 'lst' ) ;
619
617
} ;
620
618
621
- this . setLastSeenTime = ( mpid : MPID , _time ?: number ) => {
619
+ this . setLastSeenTime = ( mpid : MPID , _time ?: number ) : void => {
622
620
if ( ! mpid ) {
623
621
return ;
624
622
}
625
623
626
624
const time = _time || new Date ( ) . getTime ( ) ;
627
625
628
- this . _setPersistence ( mpid , 'lst' , time ) ;
629
- } ;
630
-
631
- this . syncPersistenceData = ( ) => {
632
- const persistenceData = mpInstance . _Persistence . getPersistence ( ) ;
633
-
634
- this . persistenceData = mpInstance . _Helpers . extend (
635
- { } ,
636
- this . persistenceData ,
637
- persistenceData ,
638
- ) ;
626
+ this . _setPersistence < number > ( mpid , 'lst' , time ) ;
639
627
} ;
640
628
641
- this . getUserIdentities = ( mpid : MPID ) : UserIdentities =>
642
- this . _getFromPersistence ( mpid , 'ui' ) || { } ;
643
-
644
- this . setUserIdentities = ( mpid : MPID , userIdentities : UserIdentities ) => {
645
- this . _setPersistence ( mpid , 'ui' , userIdentities ) ;
646
- }
647
-
648
629
this . getUserAttributes = ( mpid : MPID ) : UserAttributes =>
649
630
this . _getFromPersistence ( mpid , 'ua' ) || { } ;
650
631
651
632
this . setUserAttributes = (
652
633
mpid : MPID ,
653
634
userAttributes : UserAttributes
654
- ) : void => this . _setPersistence ( mpid , 'ua' , userAttributes ) ;
635
+ ) : void => this . _setPersistence < UserAttributes > ( mpid , 'ua' , userAttributes ) ;
636
+
637
+ this . getUserIdentities = ( mpid : MPID ) : UserIdentities =>
638
+ this . _getFromPersistence < UserIdentities > ( mpid , 'ui' ) || { } ;
639
+
640
+ this . setUserIdentities = ( mpid : MPID , userIdentities : UserIdentities ) => {
641
+ this . _setPersistence < UserIdentities > ( mpid , 'ui' , userIdentities ) ;
642
+ } ;
655
643
656
644
this . addMpidToSessionHistory = ( mpid : MPID , previousMPID ?: MPID ) : void => {
657
645
const indexOfMPID = this . currentSessionMPIDs . indexOf ( mpid ) ;
@@ -705,6 +693,16 @@ export default function Store(
705
693
706
694
this . configurationLoaded = true ;
707
695
} ;
696
+
697
+ this . syncPersistenceData = ( ) => {
698
+ const persistenceData = mpInstance . _Persistence . getPersistence ( ) ;
699
+
700
+ this . persistenceData = mpInstance . _Helpers . extend (
701
+ { } ,
702
+ this . persistenceData ,
703
+ persistenceData
704
+ ) ;
705
+ } ;
708
706
}
709
707
710
708
// https://go.mparticle.com/work/SQDSDKS-6317
0 commit comments