@mparticle/web-rokt-kit 1.21.0 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Rokt-Kit.common.js +282 -2
- package/dist/Rokt-Kit.iife.js +282 -2
- package/package.json +1 -1
package/dist/Rokt-Kit.common.js
CHANGED
|
@@ -262,6 +262,43 @@ var constructor = function () {
|
|
|
262
262
|
|
|
263
263
|
self.domain = domain;
|
|
264
264
|
|
|
265
|
+
// Register reporting services with the core SDK
|
|
266
|
+
var reportingConfig = {
|
|
267
|
+
loggingUrl: settings.loggingUrl,
|
|
268
|
+
errorUrl: settings.errorUrl,
|
|
269
|
+
isLoggingEnabled:
|
|
270
|
+
settings.isLoggingEnabled === 'true' ||
|
|
271
|
+
settings.isLoggingEnabled === true,
|
|
272
|
+
};
|
|
273
|
+
var errorReportingService = new ErrorReportingService(
|
|
274
|
+
reportingConfig,
|
|
275
|
+
self.integrationName,
|
|
276
|
+
window.__rokt_li_guid__,
|
|
277
|
+
settings.accountId
|
|
278
|
+
);
|
|
279
|
+
var loggingService = new LoggingService(
|
|
280
|
+
reportingConfig,
|
|
281
|
+
errorReportingService,
|
|
282
|
+
self.integrationName,
|
|
283
|
+
window.__rokt_li_guid__,
|
|
284
|
+
settings.accountId
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
self.errorReportingService = errorReportingService;
|
|
288
|
+
self.loggingService = loggingService;
|
|
289
|
+
|
|
290
|
+
if (
|
|
291
|
+
window.mParticle &&
|
|
292
|
+
window.mParticle._registerErrorReportingService
|
|
293
|
+
) {
|
|
294
|
+
window.mParticle._registerErrorReportingService(
|
|
295
|
+
errorReportingService
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
if (window.mParticle && window.mParticle._registerLoggingService) {
|
|
299
|
+
window.mParticle._registerLoggingService(loggingService);
|
|
300
|
+
}
|
|
301
|
+
|
|
265
302
|
if (testMode) {
|
|
266
303
|
self.testHelpers = {
|
|
267
304
|
generateLauncherScript: generateLauncherScript,
|
|
@@ -277,6 +314,12 @@ var constructor = function () {
|
|
|
277
314
|
setAllowedOriginHashes: function (hashes) {
|
|
278
315
|
_allowedOriginHashes = hashes;
|
|
279
316
|
},
|
|
317
|
+
ReportingTransport: ReportingTransport,
|
|
318
|
+
ErrorReportingService: ErrorReportingService,
|
|
319
|
+
LoggingService: LoggingService,
|
|
320
|
+
RateLimiter: RateLimiter,
|
|
321
|
+
ErrorCodes: ErrorCodes,
|
|
322
|
+
WSDKErrorSeverity: WSDKErrorSeverity,
|
|
280
323
|
};
|
|
281
324
|
attachLauncher(accountId, launcherOptions);
|
|
282
325
|
return;
|
|
@@ -877,7 +920,7 @@ var constructor = function () {
|
|
|
877
920
|
|
|
878
921
|
function generateIntegrationName(customIntegrationName) {
|
|
879
922
|
var coreSdkVersion = window.mParticle.getVersion();
|
|
880
|
-
var kitVersion = "1.
|
|
923
|
+
var kitVersion = "1.22.0";
|
|
881
924
|
var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
|
|
882
925
|
|
|
883
926
|
if (customIntegrationName) {
|
|
@@ -987,6 +1030,225 @@ function isString(value) {
|
|
|
987
1030
|
return typeof value === 'string';
|
|
988
1031
|
}
|
|
989
1032
|
|
|
1033
|
+
// --- Reporting Services ---
|
|
1034
|
+
|
|
1035
|
+
var ErrorCodes = {
|
|
1036
|
+
UNKNOWN_ERROR: 'UNKNOWN_ERROR',
|
|
1037
|
+
UNHANDLED_EXCEPTION: 'UNHANDLED_EXCEPTION',
|
|
1038
|
+
IDENTITY_REQUEST: 'IDENTITY_REQUEST',
|
|
1039
|
+
};
|
|
1040
|
+
|
|
1041
|
+
var WSDKErrorSeverity = {
|
|
1042
|
+
ERROR: 'ERROR',
|
|
1043
|
+
INFO: 'INFO',
|
|
1044
|
+
WARNING: 'WARNING',
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
var DEFAULT_LOGGING_URL = 'apps.rokt-api.com/v1/log';
|
|
1048
|
+
var DEFAULT_ERROR_URL = 'apps.rokt-api.com/v1/errors';
|
|
1049
|
+
var RATE_LIMIT_PER_SEVERITY = 10;
|
|
1050
|
+
|
|
1051
|
+
function RateLimiter() {
|
|
1052
|
+
this._logCount = {};
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
RateLimiter.prototype.incrementAndCheck = function (severity) {
|
|
1056
|
+
var count = this._logCount[severity] || 0;
|
|
1057
|
+
var newCount = count + 1;
|
|
1058
|
+
this._logCount[severity] = newCount;
|
|
1059
|
+
return newCount > RATE_LIMIT_PER_SEVERITY;
|
|
1060
|
+
};
|
|
1061
|
+
|
|
1062
|
+
// --- ReportingTransport: shared transport layer for reporting services ---
|
|
1063
|
+
|
|
1064
|
+
function ReportingTransport(
|
|
1065
|
+
config,
|
|
1066
|
+
integrationName,
|
|
1067
|
+
launcherInstanceGuid,
|
|
1068
|
+
accountId,
|
|
1069
|
+
rateLimiter
|
|
1070
|
+
) {
|
|
1071
|
+
var self = this;
|
|
1072
|
+
self._isLoggingEnabled = (config && config.isLoggingEnabled) || false;
|
|
1073
|
+
self._integrationName = integrationName || '';
|
|
1074
|
+
self._launcherInstanceGuid = launcherInstanceGuid;
|
|
1075
|
+
self._accountId = accountId || null;
|
|
1076
|
+
self._rateLimiter = rateLimiter || new RateLimiter();
|
|
1077
|
+
self._reporter = 'mp-wsdk';
|
|
1078
|
+
self._isEnabled = _isReportingEnabled(self);
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
ReportingTransport.prototype.send = function (
|
|
1082
|
+
url,
|
|
1083
|
+
severity,
|
|
1084
|
+
msg,
|
|
1085
|
+
code,
|
|
1086
|
+
stackTrace,
|
|
1087
|
+
onError
|
|
1088
|
+
) {
|
|
1089
|
+
if (!this._isEnabled || this._rateLimiter.incrementAndCheck(severity)) {
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
try {
|
|
1094
|
+
var logRequest = {
|
|
1095
|
+
additionalInformation: {
|
|
1096
|
+
message: msg,
|
|
1097
|
+
version: this._integrationName || '',
|
|
1098
|
+
},
|
|
1099
|
+
severity: severity,
|
|
1100
|
+
code: code || ErrorCodes.UNKNOWN_ERROR,
|
|
1101
|
+
url: _getUrl(),
|
|
1102
|
+
deviceInfo: _getUserAgent(),
|
|
1103
|
+
stackTrace: stackTrace,
|
|
1104
|
+
reporter: this._reporter,
|
|
1105
|
+
integration: this._integrationName || '',
|
|
1106
|
+
};
|
|
1107
|
+
var headers = {
|
|
1108
|
+
Accept: 'text/plain;charset=UTF-8',
|
|
1109
|
+
'Content-Type': 'application/json',
|
|
1110
|
+
'rokt-launcher-version': this._integrationName || '',
|
|
1111
|
+
'rokt-wsdk-version': 'joint',
|
|
1112
|
+
};
|
|
1113
|
+
if (this._launcherInstanceGuid) {
|
|
1114
|
+
headers['rokt-launcher-instance-guid'] = this._launcherInstanceGuid;
|
|
1115
|
+
}
|
|
1116
|
+
if (this._accountId) {
|
|
1117
|
+
headers['rokt-account-id'] = this._accountId;
|
|
1118
|
+
}
|
|
1119
|
+
var payload = {
|
|
1120
|
+
method: 'POST',
|
|
1121
|
+
headers: headers,
|
|
1122
|
+
body: JSON.stringify(logRequest),
|
|
1123
|
+
};
|
|
1124
|
+
fetch(url, payload).catch(function (error) {
|
|
1125
|
+
console.error('ReportingTransport: Failed to send log', error);
|
|
1126
|
+
if (onError) {
|
|
1127
|
+
onError(error);
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
1130
|
+
} catch (error) {
|
|
1131
|
+
console.error('ReportingTransport: Failed to send log', error);
|
|
1132
|
+
if (onError) {
|
|
1133
|
+
onError(error);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
};
|
|
1137
|
+
|
|
1138
|
+
function _isReportingEnabled(transport) {
|
|
1139
|
+
return (
|
|
1140
|
+
_isDebugModeEnabled() ||
|
|
1141
|
+
(_isRoktDomainPresent() && transport._isLoggingEnabled)
|
|
1142
|
+
);
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
function _isRoktDomainPresent() {
|
|
1146
|
+
return typeof window !== 'undefined' && Boolean(window['ROKT_DOMAIN']);
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
function _isDebugModeEnabled() {
|
|
1150
|
+
return (
|
|
1151
|
+
typeof window !== 'undefined' &&
|
|
1152
|
+
window.location &&
|
|
1153
|
+
window.location.search &&
|
|
1154
|
+
window.location.search
|
|
1155
|
+
.toLowerCase()
|
|
1156
|
+
.indexOf('mp_enable_logging=true') !== -1
|
|
1157
|
+
);
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
function _getUrl() {
|
|
1161
|
+
return typeof window !== 'undefined' && window.location
|
|
1162
|
+
? window.location.href
|
|
1163
|
+
: undefined;
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
function _getUserAgent() {
|
|
1167
|
+
return typeof window !== 'undefined' && window.navigator
|
|
1168
|
+
? window.navigator.userAgent
|
|
1169
|
+
: undefined;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
// --- ErrorReportingService: handles ERROR and WARNING severity ---
|
|
1173
|
+
|
|
1174
|
+
function ErrorReportingService(
|
|
1175
|
+
config,
|
|
1176
|
+
integrationName,
|
|
1177
|
+
launcherInstanceGuid,
|
|
1178
|
+
accountId,
|
|
1179
|
+
rateLimiter
|
|
1180
|
+
) {
|
|
1181
|
+
this._transport = new ReportingTransport(
|
|
1182
|
+
config,
|
|
1183
|
+
integrationName,
|
|
1184
|
+
launcherInstanceGuid,
|
|
1185
|
+
accountId,
|
|
1186
|
+
rateLimiter
|
|
1187
|
+
);
|
|
1188
|
+
this._errorUrl =
|
|
1189
|
+
'https://' + ((config && config.errorUrl) || DEFAULT_ERROR_URL);
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
ErrorReportingService.prototype.report = function (error) {
|
|
1193
|
+
if (!error) {
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
var severity = error.severity || WSDKErrorSeverity.ERROR;
|
|
1197
|
+
this._transport.send(
|
|
1198
|
+
this._errorUrl,
|
|
1199
|
+
severity,
|
|
1200
|
+
error.message,
|
|
1201
|
+
error.code,
|
|
1202
|
+
error.stackTrace
|
|
1203
|
+
);
|
|
1204
|
+
};
|
|
1205
|
+
|
|
1206
|
+
// --- LoggingService: handles INFO severity ---
|
|
1207
|
+
|
|
1208
|
+
function LoggingService(
|
|
1209
|
+
config,
|
|
1210
|
+
errorReportingService,
|
|
1211
|
+
integrationName,
|
|
1212
|
+
launcherInstanceGuid,
|
|
1213
|
+
accountId,
|
|
1214
|
+
rateLimiter
|
|
1215
|
+
) {
|
|
1216
|
+
this._transport = new ReportingTransport(
|
|
1217
|
+
config,
|
|
1218
|
+
integrationName,
|
|
1219
|
+
launcherInstanceGuid,
|
|
1220
|
+
accountId,
|
|
1221
|
+
rateLimiter
|
|
1222
|
+
);
|
|
1223
|
+
this._loggingUrl =
|
|
1224
|
+
'https://' + ((config && config.loggingUrl) || DEFAULT_LOGGING_URL);
|
|
1225
|
+
this._errorReportingService = errorReportingService;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
LoggingService.prototype.log = function (entry) {
|
|
1229
|
+
if (!entry) {
|
|
1230
|
+
return;
|
|
1231
|
+
}
|
|
1232
|
+
var self = this;
|
|
1233
|
+
self._transport.send(
|
|
1234
|
+
self._loggingUrl,
|
|
1235
|
+
WSDKErrorSeverity.INFO,
|
|
1236
|
+
entry.message,
|
|
1237
|
+
entry.code,
|
|
1238
|
+
undefined,
|
|
1239
|
+
function (error) {
|
|
1240
|
+
if (self._errorReportingService) {
|
|
1241
|
+
self._errorReportingService.report({
|
|
1242
|
+
message:
|
|
1243
|
+
'LoggingService: Failed to send log: ' + error.message,
|
|
1244
|
+
code: ErrorCodes.UNKNOWN_ERROR,
|
|
1245
|
+
severity: WSDKErrorSeverity.ERROR,
|
|
1246
|
+
});
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
);
|
|
1250
|
+
};
|
|
1251
|
+
|
|
990
1252
|
if (window && window.mParticle && window.mParticle.addForwarder) {
|
|
991
1253
|
window.mParticle.addForwarder({
|
|
992
1254
|
name: name,
|
|
@@ -997,8 +1259,26 @@ if (window && window.mParticle && window.mParticle.addForwarder) {
|
|
|
997
1259
|
|
|
998
1260
|
var RoktKit = {
|
|
999
1261
|
register: register,
|
|
1262
|
+
ReportingTransport: ReportingTransport,
|
|
1263
|
+
ErrorReportingService: ErrorReportingService,
|
|
1264
|
+
LoggingService: LoggingService,
|
|
1265
|
+
RateLimiter: RateLimiter,
|
|
1266
|
+
ErrorCodes: ErrorCodes,
|
|
1267
|
+
WSDKErrorSeverity: WSDKErrorSeverity,
|
|
1000
1268
|
};
|
|
1001
1269
|
var RoktKit_1 = RoktKit.register;
|
|
1002
|
-
|
|
1270
|
+
var RoktKit_2 = RoktKit.ReportingTransport;
|
|
1271
|
+
var RoktKit_3 = RoktKit.ErrorReportingService;
|
|
1272
|
+
var RoktKit_4 = RoktKit.LoggingService;
|
|
1273
|
+
var RoktKit_5 = RoktKit.RateLimiter;
|
|
1274
|
+
var RoktKit_6 = RoktKit.ErrorCodes;
|
|
1275
|
+
var RoktKit_7 = RoktKit.WSDKErrorSeverity;
|
|
1276
|
+
|
|
1277
|
+
exports.ErrorCodes = RoktKit_6;
|
|
1278
|
+
exports.ErrorReportingService = RoktKit_3;
|
|
1279
|
+
exports.LoggingService = RoktKit_4;
|
|
1280
|
+
exports.RateLimiter = RoktKit_5;
|
|
1281
|
+
exports.ReportingTransport = RoktKit_2;
|
|
1282
|
+
exports.WSDKErrorSeverity = RoktKit_7;
|
|
1003
1283
|
exports.default = RoktKit;
|
|
1004
1284
|
exports.register = RoktKit_1;
|
package/dist/Rokt-Kit.iife.js
CHANGED
|
@@ -261,6 +261,43 @@ var RoktKit = (function (exports) {
|
|
|
261
261
|
|
|
262
262
|
self.domain = domain;
|
|
263
263
|
|
|
264
|
+
// Register reporting services with the core SDK
|
|
265
|
+
var reportingConfig = {
|
|
266
|
+
loggingUrl: settings.loggingUrl,
|
|
267
|
+
errorUrl: settings.errorUrl,
|
|
268
|
+
isLoggingEnabled:
|
|
269
|
+
settings.isLoggingEnabled === 'true' ||
|
|
270
|
+
settings.isLoggingEnabled === true,
|
|
271
|
+
};
|
|
272
|
+
var errorReportingService = new ErrorReportingService(
|
|
273
|
+
reportingConfig,
|
|
274
|
+
self.integrationName,
|
|
275
|
+
window.__rokt_li_guid__,
|
|
276
|
+
settings.accountId
|
|
277
|
+
);
|
|
278
|
+
var loggingService = new LoggingService(
|
|
279
|
+
reportingConfig,
|
|
280
|
+
errorReportingService,
|
|
281
|
+
self.integrationName,
|
|
282
|
+
window.__rokt_li_guid__,
|
|
283
|
+
settings.accountId
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
self.errorReportingService = errorReportingService;
|
|
287
|
+
self.loggingService = loggingService;
|
|
288
|
+
|
|
289
|
+
if (
|
|
290
|
+
window.mParticle &&
|
|
291
|
+
window.mParticle._registerErrorReportingService
|
|
292
|
+
) {
|
|
293
|
+
window.mParticle._registerErrorReportingService(
|
|
294
|
+
errorReportingService
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
if (window.mParticle && window.mParticle._registerLoggingService) {
|
|
298
|
+
window.mParticle._registerLoggingService(loggingService);
|
|
299
|
+
}
|
|
300
|
+
|
|
264
301
|
if (testMode) {
|
|
265
302
|
self.testHelpers = {
|
|
266
303
|
generateLauncherScript: generateLauncherScript,
|
|
@@ -276,6 +313,12 @@ var RoktKit = (function (exports) {
|
|
|
276
313
|
setAllowedOriginHashes: function (hashes) {
|
|
277
314
|
_allowedOriginHashes = hashes;
|
|
278
315
|
},
|
|
316
|
+
ReportingTransport: ReportingTransport,
|
|
317
|
+
ErrorReportingService: ErrorReportingService,
|
|
318
|
+
LoggingService: LoggingService,
|
|
319
|
+
RateLimiter: RateLimiter,
|
|
320
|
+
ErrorCodes: ErrorCodes,
|
|
321
|
+
WSDKErrorSeverity: WSDKErrorSeverity,
|
|
279
322
|
};
|
|
280
323
|
attachLauncher(accountId, launcherOptions);
|
|
281
324
|
return;
|
|
@@ -876,7 +919,7 @@ var RoktKit = (function (exports) {
|
|
|
876
919
|
|
|
877
920
|
function generateIntegrationName(customIntegrationName) {
|
|
878
921
|
var coreSdkVersion = window.mParticle.getVersion();
|
|
879
|
-
var kitVersion = "1.
|
|
922
|
+
var kitVersion = "1.22.0";
|
|
880
923
|
var name = 'mParticle_' + 'wsdkv_' + coreSdkVersion + '_kitv_' + kitVersion;
|
|
881
924
|
|
|
882
925
|
if (customIntegrationName) {
|
|
@@ -986,6 +1029,225 @@ var RoktKit = (function (exports) {
|
|
|
986
1029
|
return typeof value === 'string';
|
|
987
1030
|
}
|
|
988
1031
|
|
|
1032
|
+
// --- Reporting Services ---
|
|
1033
|
+
|
|
1034
|
+
var ErrorCodes = {
|
|
1035
|
+
UNKNOWN_ERROR: 'UNKNOWN_ERROR',
|
|
1036
|
+
UNHANDLED_EXCEPTION: 'UNHANDLED_EXCEPTION',
|
|
1037
|
+
IDENTITY_REQUEST: 'IDENTITY_REQUEST',
|
|
1038
|
+
};
|
|
1039
|
+
|
|
1040
|
+
var WSDKErrorSeverity = {
|
|
1041
|
+
ERROR: 'ERROR',
|
|
1042
|
+
INFO: 'INFO',
|
|
1043
|
+
WARNING: 'WARNING',
|
|
1044
|
+
};
|
|
1045
|
+
|
|
1046
|
+
var DEFAULT_LOGGING_URL = 'apps.rokt-api.com/v1/log';
|
|
1047
|
+
var DEFAULT_ERROR_URL = 'apps.rokt-api.com/v1/errors';
|
|
1048
|
+
var RATE_LIMIT_PER_SEVERITY = 10;
|
|
1049
|
+
|
|
1050
|
+
function RateLimiter() {
|
|
1051
|
+
this._logCount = {};
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
RateLimiter.prototype.incrementAndCheck = function (severity) {
|
|
1055
|
+
var count = this._logCount[severity] || 0;
|
|
1056
|
+
var newCount = count + 1;
|
|
1057
|
+
this._logCount[severity] = newCount;
|
|
1058
|
+
return newCount > RATE_LIMIT_PER_SEVERITY;
|
|
1059
|
+
};
|
|
1060
|
+
|
|
1061
|
+
// --- ReportingTransport: shared transport layer for reporting services ---
|
|
1062
|
+
|
|
1063
|
+
function ReportingTransport(
|
|
1064
|
+
config,
|
|
1065
|
+
integrationName,
|
|
1066
|
+
launcherInstanceGuid,
|
|
1067
|
+
accountId,
|
|
1068
|
+
rateLimiter
|
|
1069
|
+
) {
|
|
1070
|
+
var self = this;
|
|
1071
|
+
self._isLoggingEnabled = (config && config.isLoggingEnabled) || false;
|
|
1072
|
+
self._integrationName = integrationName || '';
|
|
1073
|
+
self._launcherInstanceGuid = launcherInstanceGuid;
|
|
1074
|
+
self._accountId = accountId || null;
|
|
1075
|
+
self._rateLimiter = rateLimiter || new RateLimiter();
|
|
1076
|
+
self._reporter = 'mp-wsdk';
|
|
1077
|
+
self._isEnabled = _isReportingEnabled(self);
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
ReportingTransport.prototype.send = function (
|
|
1081
|
+
url,
|
|
1082
|
+
severity,
|
|
1083
|
+
msg,
|
|
1084
|
+
code,
|
|
1085
|
+
stackTrace,
|
|
1086
|
+
onError
|
|
1087
|
+
) {
|
|
1088
|
+
if (!this._isEnabled || this._rateLimiter.incrementAndCheck(severity)) {
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
try {
|
|
1093
|
+
var logRequest = {
|
|
1094
|
+
additionalInformation: {
|
|
1095
|
+
message: msg,
|
|
1096
|
+
version: this._integrationName || '',
|
|
1097
|
+
},
|
|
1098
|
+
severity: severity,
|
|
1099
|
+
code: code || ErrorCodes.UNKNOWN_ERROR,
|
|
1100
|
+
url: _getUrl(),
|
|
1101
|
+
deviceInfo: _getUserAgent(),
|
|
1102
|
+
stackTrace: stackTrace,
|
|
1103
|
+
reporter: this._reporter,
|
|
1104
|
+
integration: this._integrationName || '',
|
|
1105
|
+
};
|
|
1106
|
+
var headers = {
|
|
1107
|
+
Accept: 'text/plain;charset=UTF-8',
|
|
1108
|
+
'Content-Type': 'application/json',
|
|
1109
|
+
'rokt-launcher-version': this._integrationName || '',
|
|
1110
|
+
'rokt-wsdk-version': 'joint',
|
|
1111
|
+
};
|
|
1112
|
+
if (this._launcherInstanceGuid) {
|
|
1113
|
+
headers['rokt-launcher-instance-guid'] = this._launcherInstanceGuid;
|
|
1114
|
+
}
|
|
1115
|
+
if (this._accountId) {
|
|
1116
|
+
headers['rokt-account-id'] = this._accountId;
|
|
1117
|
+
}
|
|
1118
|
+
var payload = {
|
|
1119
|
+
method: 'POST',
|
|
1120
|
+
headers: headers,
|
|
1121
|
+
body: JSON.stringify(logRequest),
|
|
1122
|
+
};
|
|
1123
|
+
fetch(url, payload).catch(function (error) {
|
|
1124
|
+
console.error('ReportingTransport: Failed to send log', error);
|
|
1125
|
+
if (onError) {
|
|
1126
|
+
onError(error);
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
} catch (error) {
|
|
1130
|
+
console.error('ReportingTransport: Failed to send log', error);
|
|
1131
|
+
if (onError) {
|
|
1132
|
+
onError(error);
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
};
|
|
1136
|
+
|
|
1137
|
+
function _isReportingEnabled(transport) {
|
|
1138
|
+
return (
|
|
1139
|
+
_isDebugModeEnabled() ||
|
|
1140
|
+
(_isRoktDomainPresent() && transport._isLoggingEnabled)
|
|
1141
|
+
);
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
function _isRoktDomainPresent() {
|
|
1145
|
+
return typeof window !== 'undefined' && Boolean(window['ROKT_DOMAIN']);
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
function _isDebugModeEnabled() {
|
|
1149
|
+
return (
|
|
1150
|
+
typeof window !== 'undefined' &&
|
|
1151
|
+
window.location &&
|
|
1152
|
+
window.location.search &&
|
|
1153
|
+
window.location.search
|
|
1154
|
+
.toLowerCase()
|
|
1155
|
+
.indexOf('mp_enable_logging=true') !== -1
|
|
1156
|
+
);
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
function _getUrl() {
|
|
1160
|
+
return typeof window !== 'undefined' && window.location
|
|
1161
|
+
? window.location.href
|
|
1162
|
+
: undefined;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
function _getUserAgent() {
|
|
1166
|
+
return typeof window !== 'undefined' && window.navigator
|
|
1167
|
+
? window.navigator.userAgent
|
|
1168
|
+
: undefined;
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
// --- ErrorReportingService: handles ERROR and WARNING severity ---
|
|
1172
|
+
|
|
1173
|
+
function ErrorReportingService(
|
|
1174
|
+
config,
|
|
1175
|
+
integrationName,
|
|
1176
|
+
launcherInstanceGuid,
|
|
1177
|
+
accountId,
|
|
1178
|
+
rateLimiter
|
|
1179
|
+
) {
|
|
1180
|
+
this._transport = new ReportingTransport(
|
|
1181
|
+
config,
|
|
1182
|
+
integrationName,
|
|
1183
|
+
launcherInstanceGuid,
|
|
1184
|
+
accountId,
|
|
1185
|
+
rateLimiter
|
|
1186
|
+
);
|
|
1187
|
+
this._errorUrl =
|
|
1188
|
+
'https://' + ((config && config.errorUrl) || DEFAULT_ERROR_URL);
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
ErrorReportingService.prototype.report = function (error) {
|
|
1192
|
+
if (!error) {
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
var severity = error.severity || WSDKErrorSeverity.ERROR;
|
|
1196
|
+
this._transport.send(
|
|
1197
|
+
this._errorUrl,
|
|
1198
|
+
severity,
|
|
1199
|
+
error.message,
|
|
1200
|
+
error.code,
|
|
1201
|
+
error.stackTrace
|
|
1202
|
+
);
|
|
1203
|
+
};
|
|
1204
|
+
|
|
1205
|
+
// --- LoggingService: handles INFO severity ---
|
|
1206
|
+
|
|
1207
|
+
function LoggingService(
|
|
1208
|
+
config,
|
|
1209
|
+
errorReportingService,
|
|
1210
|
+
integrationName,
|
|
1211
|
+
launcherInstanceGuid,
|
|
1212
|
+
accountId,
|
|
1213
|
+
rateLimiter
|
|
1214
|
+
) {
|
|
1215
|
+
this._transport = new ReportingTransport(
|
|
1216
|
+
config,
|
|
1217
|
+
integrationName,
|
|
1218
|
+
launcherInstanceGuid,
|
|
1219
|
+
accountId,
|
|
1220
|
+
rateLimiter
|
|
1221
|
+
);
|
|
1222
|
+
this._loggingUrl =
|
|
1223
|
+
'https://' + ((config && config.loggingUrl) || DEFAULT_LOGGING_URL);
|
|
1224
|
+
this._errorReportingService = errorReportingService;
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
LoggingService.prototype.log = function (entry) {
|
|
1228
|
+
if (!entry) {
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
var self = this;
|
|
1232
|
+
self._transport.send(
|
|
1233
|
+
self._loggingUrl,
|
|
1234
|
+
WSDKErrorSeverity.INFO,
|
|
1235
|
+
entry.message,
|
|
1236
|
+
entry.code,
|
|
1237
|
+
undefined,
|
|
1238
|
+
function (error) {
|
|
1239
|
+
if (self._errorReportingService) {
|
|
1240
|
+
self._errorReportingService.report({
|
|
1241
|
+
message:
|
|
1242
|
+
'LoggingService: Failed to send log: ' + error.message,
|
|
1243
|
+
code: ErrorCodes.UNKNOWN_ERROR,
|
|
1244
|
+
severity: WSDKErrorSeverity.ERROR,
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
);
|
|
1249
|
+
};
|
|
1250
|
+
|
|
989
1251
|
if (window && window.mParticle && window.mParticle.addForwarder) {
|
|
990
1252
|
window.mParticle.addForwarder({
|
|
991
1253
|
name: name,
|
|
@@ -996,9 +1258,27 @@ var RoktKit = (function (exports) {
|
|
|
996
1258
|
|
|
997
1259
|
var RoktKit = {
|
|
998
1260
|
register: register,
|
|
1261
|
+
ReportingTransport: ReportingTransport,
|
|
1262
|
+
ErrorReportingService: ErrorReportingService,
|
|
1263
|
+
LoggingService: LoggingService,
|
|
1264
|
+
RateLimiter: RateLimiter,
|
|
1265
|
+
ErrorCodes: ErrorCodes,
|
|
1266
|
+
WSDKErrorSeverity: WSDKErrorSeverity,
|
|
999
1267
|
};
|
|
1000
1268
|
var RoktKit_1 = RoktKit.register;
|
|
1001
|
-
|
|
1269
|
+
var RoktKit_2 = RoktKit.ReportingTransport;
|
|
1270
|
+
var RoktKit_3 = RoktKit.ErrorReportingService;
|
|
1271
|
+
var RoktKit_4 = RoktKit.LoggingService;
|
|
1272
|
+
var RoktKit_5 = RoktKit.RateLimiter;
|
|
1273
|
+
var RoktKit_6 = RoktKit.ErrorCodes;
|
|
1274
|
+
var RoktKit_7 = RoktKit.WSDKErrorSeverity;
|
|
1275
|
+
|
|
1276
|
+
exports.ErrorCodes = RoktKit_6;
|
|
1277
|
+
exports.ErrorReportingService = RoktKit_3;
|
|
1278
|
+
exports.LoggingService = RoktKit_4;
|
|
1279
|
+
exports.RateLimiter = RoktKit_5;
|
|
1280
|
+
exports.ReportingTransport = RoktKit_2;
|
|
1281
|
+
exports.WSDKErrorSeverity = RoktKit_7;
|
|
1002
1282
|
exports.default = RoktKit;
|
|
1003
1283
|
exports.register = RoktKit_1;
|
|
1004
1284
|
|