-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathconstants.ts
More file actions
235 lines (229 loc) · 11.2 KB
/
constants.ts
File metadata and controls
235 lines (229 loc) · 11.2 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
import { version } from '../package.json';
const Constants = {
sdkVersion: version,
sdkVendor: 'mparticle',
platform: 'web',
Messages: {
DeprecationMessages: {
MethodHasBeenDeprecated: 'has been deprecated.',
MethodMarkedForDeprecationPostfix:
'is a deprecated method and will be removed in future releases.',
AlternativeMethodPrefix: 'Please use the alternate method:',
},
ErrorMessages: {
NoToken: 'A token must be specified.',
EventNameInvalidType: 'Event name must be a valid string value.',
EventDataInvalidType: 'Event data must be a valid object hash.',
LoggingDisabled: 'Event logging is currently disabled.',
CookieParseError: 'Could not parse cookie',
EventEmpty: 'Event object is null or undefined, cancelling send',
APIRequestEmpty: 'APIRequest is null or undefined, cancelling send',
NoEventType: 'Event type must be specified.',
TransactionIdRequired: 'Transaction ID is required',
TransactionRequired: 'A transaction attributes object is required',
PromotionIdRequired: 'Promotion ID is required',
BadAttribute: 'Attribute value cannot be object or array',
BadKey: 'Key value cannot be object or array',
BadLogPurchase:
'Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions',
AudienceAPINotEnabled:
'Your workspace is not enabled to retrieve user audiences.',
},
InformationMessages: {
CookieSearch: 'Searching for cookie',
CookieFound: 'Cookie found, parsing values',
CookieNotFound: 'Cookies not found',
CookieSet: 'Setting cookie',
CookieSync: 'Performing cookie sync',
SendBegin: 'Starting to send event',
SendIdentityBegin: 'Starting to send event to identity server',
SendWindowsPhone: 'Sending event to Windows Phone container',
SendIOS: 'Calling iOS path: ',
SendAndroid: 'Calling Android JS interface method: ',
SendHttp: 'Sending event to mParticle HTTP service',
SendAliasHttp: 'Sending alias request to mParticle HTTP service',
SendIdentityHttp: 'Sending event to mParticle HTTP service',
StartingNewSession: 'Starting new Session',
StartingLogEvent: 'Starting to log event',
StartingLogOptOut: 'Starting to log user opt in/out',
StartingEndSession: 'Starting to end session',
StartingInitialization: 'Starting to initialize',
StartingLogCommerceEvent: 'Starting to log commerce event',
StartingAliasRequest: 'Starting to Alias MPIDs',
LoadingConfig: 'Loading configuration options',
AbandonLogEvent:
'Cannot log event, logging disabled or developer token not set',
AbandonAliasUsers:
'Cannot Alias Users, logging disabled or developer token not set',
AbandonStartSession:
'Cannot start session, logging disabled or developer token not set',
AbandonEndSession:
'Cannot end session, logging disabled or developer token not set',
NoSessionToEnd: 'Cannot end session, no active session found',
},
ValidationMessages: {
ModifyIdentityRequestUserIdentitiesPresent:
'identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again',
IdentityRequesetInvalidKey:
'There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.',
OnUserAliasType: 'The onUserAlias value must be a function.',
UserIdentities:
'The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.',
UserIdentitiesInvalidKey:
'There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.',
UserIdentitiesInvalidValues:
'All user identity values must be strings or null. Request not sent to server. Please fix and try again.',
AliasMissingMpid:
'Alias Request must contain both a destinationMpid and a sourceMpid',
AliasNonUniqueMpid:
"Alias Request's destinationMpid and sourceMpid must be unique",
AliasMissingTime:
'Alias Request must have both a startTime and an endTime',
AliasStartBeforeEndTime:
"Alias Request's endTime must be later than its startTime",
},
},
NativeSdkPaths: {
LogEvent: 'logEvent',
SetUserTag: 'setUserTag',
RemoveUserTag: 'removeUserTag',
SetUserAttribute: 'setUserAttribute',
RemoveUserAttribute: 'removeUserAttribute',
SetSessionAttribute: 'setSessionAttribute',
AddToCart: 'addToCart',
RemoveFromCart: 'removeFromCart',
ClearCart: 'clearCart',
LogOut: 'logOut',
SetUserAttributeList: 'setUserAttributeList',
RemoveAllUserAttributes: 'removeAllUserAttributes',
GetUserAttributesLists: 'getUserAttributesLists',
GetAllUserAttributes: 'getAllUserAttributes',
Identify: 'identify',
Logout: 'logout',
Login: 'login',
Modify: 'modify',
Alias: 'aliasUsers',
Upload: 'upload',
},
StorageNames: {
localStorageName: 'mprtcl-api', // Name of the mP localstorage, had cp and pb even if cookies were used, skipped v2
localStorageNameV3: 'mprtcl-v3', // v3 Name of the mP localstorage, final version on SDKv1
cookieName: 'mprtcl-api', // v1 Name of the cookie stored on the user's machine
cookieNameV2: 'mprtcl-v2', // v2 Name of the cookie stored on the user's machine. Removed keys with no values, moved cartProducts and productBags to localStorage.
cookieNameV3: 'mprtcl-v3', // v3 Name of the cookie stored on the user's machine. Base64 encoded keys in Base64CookieKeys object, final version on SDKv1
localStorageNameV4: 'mprtcl-v4', // v4 Name of the mP localstorage, Current Version
localStorageProductsV4: 'mprtcl-prodv4', // The name for mP localstorage that contains products for cartProducs and productBags
cookieNameV4: 'mprtcl-v4', // v4 Name of the cookie stored on the user's machine. Base64 encoded keys in Base64CookieKeys object, current version on SDK v2
currentStorageName: 'mprtcl-v4',
currentStorageProductsName: 'mprtcl-prodv4',
},
DefaultConfig: {
cookieDomain: null, // If null, defaults to current location.host
cookieExpiration: 365, // Cookie expiration time in days
logLevel: null, // What logging will be provided in the console
timeout: 300, // timeout in milliseconds for logging functions
sessionTimeout: 30, // Session timeout in minutes
maxProducts: 20, // Number of products persisted in cartProducts and productBags
forwarderStatsTimeout: 5000, // Milliseconds for forwarderStats timeout
integrationDelayTimeout: 5000, // Milliseconds for forcing the integration delay to un-suspend event queueing due to integration partner errors
maxCookieSize: 3000, // Number of bytes for cookie size to not exceed
aliasMaxWindow: 90, // Max age of Alias request startTime, in days
uploadInterval: 0, // Maximum milliseconds in between batch uploads, below 500 will mean immediate upload. The server returns this as a string, but we are using it as a number internally
},
DefaultBaseUrls: {
v1SecureServiceUrl: 'jssdks.mparticle.com/v1/JS/',
v2SecureServiceUrl: 'jssdks.mparticle.com/v2/JS/',
v3SecureServiceUrl: 'jssdks.mparticle.com/v3/JS/',
configUrl: 'jssdkcdns.mparticle.com/JS/v2/',
identityUrl: 'identity.mparticle.com/v1/',
aliasUrl: 'jssdks.mparticle.com/v1/identity/',
userAudienceUrl: 'nativesdks.mparticle.com/v1/',
},
// These are the paths that are used to construct the CNAME urls
CNAMEUrlPaths: {
v1SecureServiceUrl: '/webevents/v1/JS/',
v2SecureServiceUrl: '/webevents/v2/JS/',
v3SecureServiceUrl: '/webevents/v3/JS/',
configUrl: '/tags/JS/v2/',
identityUrl: '/identity/v1/',
aliasUrl: '/webevents/v1/identity/',
},
Base64CookieKeys: {
csm: 1,
sa: 1,
ss: 1,
lsa: 1,
ua: 1,
ui: 1,
csd: 1,
ia: 1,
con: 1,
},
// https://go.mparticle.com/work/SQDSDKS-6039
SDKv2NonMPIDCookieKeys: {
gs: 1,
cu: 1,
l: 1,
globalSettings: 1,
currentUserMPID: 1,
},
HTTPCodes: {
noHttpCoverage: -1,
activeIdentityRequest: -2,
activeSession: -3,
validationIssue: -4,
nativeIdentityRequest: -5,
loggingDisabledOrMissingAPIKey: -6,
tooManyRequests: 429,
},
FeatureFlags: {
ReportBatching: 'reportBatching',
EventBatchingIntervalMillis: 'eventBatchingIntervalMillis',
OfflineStorage: 'offlineStorage',
DirectUrlRouting: 'directURLRouting',
CacheIdentity: 'cacheIdentity',
AudienceAPI: 'audienceAPI',
// CaptureIntegrationSpecificIds (legacy): boolean flag from server/UI
// - 'True' → capture all integration-specific IDs
// - 'False' → capture none
CaptureIntegrationSpecificIds: 'captureIntegrationSpecificIds',
// CaptureIntegrationSpecificIdsV2 (new): string mode from server
// - 'all' → capture all IDs
// - 'none' → capture none
// - 'roktonly' → capture only Rokt-related IDs
CaptureIntegrationSpecificIdsV2: 'captureIntegrationSpecificIdsV2',
AstBackgroundEvents: 'astBackgroundEvents',
},
DefaultInstance: 'default_instance',
CCPAPurpose: 'data_sale_opt_out',
IdentityMethods: {
Modify: 'modify',
Logout: 'logout',
Login: 'login',
Identify: 'identify',
},
Environment: {
Development: 'development',
Production: 'production',
},
CaptureIntegrationSpecificIdsV2Modes: {
All: 'all',
None: 'none',
RoktOnly: 'roktonly',
},
Rokt: {
LauncherInstanceGuidKey: '__rokt_li_guid__',
},
} as const;
export default Constants;
// https://go.mparticle.com/work/SQDSDKS-6080
export const ONE_DAY_IN_SECONDS = 60 * 60 * 24;
export const MILLIS_IN_ONE_SEC = 1000;
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
export const HTTP_OK = 200 as const;
export const HTTP_ACCEPTED = 202 as const;
export const HTTP_BAD_REQUEST = 400 as const;
export const HTTP_UNAUTHORIZED = 401 as const;
export const HTTP_FORBIDDEN = 403 as const;
export const HTTP_NOT_FOUND = 404 as const;
export const HTTP_SERVER_ERROR = 500 as const;