-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathpersistence.interfaces.ts
More file actions
142 lines (133 loc) · 4.46 KB
/
Copy pathpersistence.interfaces.ts
File metadata and controls
142 lines (133 loc) · 4.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import { Context } from '@mparticle/event-models';
import {
IdentityApiData,
MPID,
Product,
UserIdentities,
} from '@mparticle/web-sdk';
import { IForwardingStatsData } from './apiClient';
import {
IntegrationAttributes,
ServerSettings,
SessionAttributes,
LocalSessionAttributes,
} from './store';
import { Dictionary } from './utils';
import { IMinifiedConsentJSONObject } from './consent';
import { UserAttributes } from './identity-user-interfaces';
import { CookieSyncDates } from './cookieSyncManager';
export type UploadsTable = Dictionary<any>;
export interface iForwardingStatsBatches {
uploadsTable: UploadsTable;
forwardingStatsEventQueue: IForwardingStatsData[];
}
export interface IGlobalStoreV2MinifiedKeys {
sid: string; // Session ID
ie: boolean; // Is Enabled
sa: SessionAttributes;
lsa?: LocalSessionAttributes;
ss: ServerSettings;
dt: string; // Dev Token
av: string; // App Version
cgid: string; // Client Generated ID
das: string; // Device ID/ Device Application String
ia: IntegrationAttributes;
c: Context;
csm: MPID[]; // Current Session MPIDs
les: number; // Last Event Sent Timestamp
ssd: number; // Session Start Date
}
export interface IPersistenceMinified extends Dictionary {
cu: MPID; // Current User MPID
gs: IGlobalStoreV2MinifiedKeys;
l: boolean; // IsLoggedIn
// Persistence Minified can also store optional dictionaries with
// an idex of MPID
// [mpid: MPID]: Dictionary<IUserPersistenceMinified>;
// For Example:
// {
// cu: '123345',
// gs: {
// sid: '123',
// ie: false,
// sa: {},
// ss: {},
// dt: '',
// av: '',
// cgid: '123',
// das: 'das',
// ia: {},
// c: null,
// csm: ['123'],
// les: 0,
// ssd: 0,
// },
// l: false,
// MPID1: {
// csd: {
// [moduleid]: 1234567890,
// },
// ui: {
// customerid: '12346',
// },
// ua: {
// age '42',
// },
// },
// };
}
export interface IUserPersistenceMinified extends Dictionary {
csd: CookieSyncDates; // list of timestamps for last cookie sync per module
con: IMinifiedConsentJSONObject; // Consent State
ui: UserIdentities; // User Identities
ua: UserAttributes; // User Attributes
// https://go.mparticle.com/work/SQDSDKS-6048
cp: Product[]; // Cart Products
fst: number; // First Seen Time
lst: number; // Last Seen Time
}
export interface IPersistence {
useLocalStorage(): boolean;
initializeStorage(): void;
update(): void;
storeProductsInMemory(products: Product[], mpid: MPID): void;
storeDataInMemory(obj: IPersistenceMinified, currentMPID: MPID): void;
determineLocalStorageAvailability(storage: Storage): boolean;
getUserProductsFromLS(mpid: MPID): Product[];
getAllUserProductsFromLS(): Product[];
setLocalStorage(): void;
setProductStorage(): void;
getLocalStorage(): IPersistenceMinified | null;
expireCookies(cookieName: string): void;
getCookie(): IPersistenceMinified | null;
setCookie(): void;
reduceAndEncodePersistence(
persistence: IPersistenceMinified,
expires: string,
domain: string,
maxCookieSize: number
): string;
findPrevCookiesBasedOnUI(identityApiData: IdentityApiData): void;
encodePersistence(persistence: IPersistenceMinified): string;
decodePersistence(persistenceString: string): string;
getCookieDomain(): string;
getDomain(doc: string, locationHostname: string): string;
getCartProducts(mpid: MPID): Product[];
setCartProducts(allProducts: Product[]): void;
saveUserCookieSyncDatesToPersistence(mpid: MPID, csd: CookieSyncDates): void;
savePersistence(persistance: IPersistenceMinified): void;
getPersistence(): IPersistenceMinified;
getFirstSeenTime(mpid: MPID): string | null;
setFirstSeenTime(mpid: MPID, time: number): void;
getLastSeenTime(mpid: MPID): number | null;
setLastSeenTime(mpid: MPID, time: number): void;
getDeviceId(): string;
setDeviceId(guid: string): void;
resetPersistence(): void;
swapCurrentUser(
previousMPID: MPID,
currentMPID: MPID,
currentSessionMPIDs?: MPID[]
): void;
forwardingStatsBatches: iForwardingStatsBatches;
}