@robotical/webapp-types 3.21.9 → 3.21.10

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marty-web-app",
3
- "version": "3.21.9",
3
+ "version": "3.21.10",
4
4
  "private": true,
5
5
  "dependencies": {
6
6
  "@radix-ui/react-dropdown-menu": "^2.1.2",
@@ -58,7 +58,6 @@ import { AppSentMessage } from "../../types/communication-between-apps/wrapper-c
58
58
  import VerificationModalPhoneApp from "../../components/modals/VerificationModalPhoneApp";
59
59
  import { RaftConnEvent, } from "@robdobsn/raftjs";
60
60
  import Logger from "../../services/logger/Logger";
61
- import { getSafeErrorMetadata } from "../../services/observability/sanitizeTelemetry";
62
61
  import isPhoneApp from "../../utils/phone-app-communication/is-phone-app";
63
62
  import DisconnectConfirmationModal from "../../components/modals/DisconnectConfirmation";
64
63
  import Toaster from "../../utils/Toaster";
@@ -83,7 +82,7 @@ var UNSUPPORTED_WEB_BLUETOOTH_BROWSER_MESSAGE = "This browser can't connect to M
83
82
  var publishMissedConnectionEvent = function (raftId) {
84
83
  window.wrapperCommunicator
85
84
  .sendMessageAndWait(AppSentMessage.GET_MISSED_CONN_EVENT, { raftId: raftId })
86
- .catch(function (error) { return Logger.warn(SHOW_LOGS, TAG, "Failed to get missed connection event", { raftId: raftId }, getSafeErrorMetadata(error)); });
85
+ .catch(function (error) { return Logger.warn(SHOW_LOGS, TAG, "Failed to get missed connection event", { raftId: raftId }, error); });
87
86
  };
88
87
  var canUseWebBluetooth = function () {
89
88
  var bluetooth = navigator.bluetooth;
@@ -211,7 +210,7 @@ var ApplicationManager = /** @class */ (function () {
211
210
  return [3 /*break*/, 4];
212
211
  case 3:
213
212
  error_1 = _e.sent();
214
- Logger.warn(SHOW_LOGS, TAG, "Failed to determine phone app version for Wi-Fi", getSafeErrorMetadata(error_1));
213
+ Logger.warn(SHOW_LOGS, TAG, "Failed to determine phone app version for Wi-Fi", error_1);
215
214
  return [3 /*break*/, 4];
216
215
  case 4:
217
216
  if (isPhoneWrapperWifiSupported((_a = this.deviceInfo) === null || _a === void 0 ? void 0 : _a.appVersion)) {
@@ -285,7 +284,7 @@ var ApplicationManager = /** @class */ (function () {
285
284
  case 2: return [2 /*return*/, (_a.sent()) || ""];
286
285
  case 3:
287
286
  error_2 = _a.sent();
288
- Logger.warn(SHOW_LOGS, TAG, "Failed to read the RAFT name", { raftId: raft.id }, getSafeErrorMetadata(error_2));
287
+ Logger.warn(SHOW_LOGS, TAG, "Failed to read the RAFT name", { raftId: raft.id }, error_2);
289
288
  return [2 /*return*/, ""];
290
289
  case 4: return [2 /*return*/];
291
290
  }
@@ -350,7 +349,7 @@ var ApplicationManager = /** @class */ (function () {
350
349
  return [3 /*break*/, 5];
351
350
  case 4:
352
351
  error_3 = _a.sent();
353
- Logger.warn(SHOW_LOGS, TAG, "Failed to publish the QR verified event", { raftId: raft.id }, getSafeErrorMetadata(error_3));
352
+ Logger.warn(SHOW_LOGS, TAG, "Failed to publish the QR verified event", { raftId: raft.id }, error_3);
354
353
  this.publishLocalVerifiedConnection(raft);
355
354
  return [3 /*break*/, 5];
356
355
  case 5: return [2 /*return*/];
@@ -879,7 +878,7 @@ var ApplicationManager = /** @class */ (function () {
879
878
  case 7: return [3 /*break*/, 9];
880
879
  case 8:
881
880
  e_1 = _a.sent();
882
- Logger.error(SHOW_LOGS, TAG, "Failed to start discovery", getSafeErrorMetadata(e_1));
881
+ Logger.error(SHOW_LOGS, TAG, "Failed to start discovery", e_1);
883
882
  return [3 /*break*/, 9];
884
883
  case 9: return [3 /*break*/, 18];
885
884
  case 10:
@@ -908,7 +907,7 @@ var ApplicationManager = /** @class */ (function () {
908
907
  case 15: return [3 /*break*/, 17];
909
908
  case 16:
910
909
  e_2 = _a.sent();
911
- Logger.error(SHOW_LOGS, TAG, "Failed to connect to new robot", getSafeErrorMetadata(e_2));
910
+ Logger.error(SHOW_LOGS, TAG, "Failed to connect to new robot", e_2);
912
911
  if (isWifiConnection) {
913
912
  this.toaster.error(i18n.t("connection.wifi_connect_failed", {
914
913
  defaultValue: "Couldn't connect over Wi-Fi. Check the address, local-network permission, and that the device is online.",
@@ -959,7 +958,7 @@ var ApplicationManager = /** @class */ (function () {
959
958
  return [3 /*break*/, 6];
960
959
  case 5:
961
960
  e_3 = _a.sent();
962
- Logger.error(SHOW_LOGS, TAG, "Failed to disconnect from robot", getSafeErrorMetadata(e_3));
961
+ Logger.error(SHOW_LOGS, TAG, "Failed to disconnect from robot", e_3);
963
962
  return [3 /*break*/, 6];
964
963
  case 6: return [2 /*return*/];
965
964
  }
@@ -36,7 +36,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  };
37
37
  import { RaftOKFail } from "@robdobsn/raftjs";
38
38
  import Logger from "../../../services/logger/Logger";
39
- import { getSafeErrorMetadata } from "../../../services/observability/sanitizeTelemetry";
40
39
  var SHOW_LOGS = true;
41
40
  var TAG = "CalibrationManager";
42
41
  var CalibrationManager = /** @class */ (function () {
@@ -110,7 +109,7 @@ var CalibrationManager = /** @class */ (function () {
110
109
  return [3 /*break*/, 8];
111
110
  case 7:
112
111
  error_1 = _e.sent();
113
- Logger.error(SHOW_LOGS, TAG, "Joint calibration failed", { joint: jnt }, error_1 instanceof Error ? error_1 : getSafeErrorMetadata(error_1));
112
+ Logger.error(SHOW_LOGS, TAG, "Joint calibration failed", { joint: jnt }, error_1);
114
113
  return [3 /*break*/, 8];
115
114
  case 8:
116
115
  _i++;
@@ -142,7 +141,7 @@ var CalibrationManager = /** @class */ (function () {
142
141
  return [3 /*break*/, 15];
143
142
  case 14:
144
143
  error_2 = _e.sent();
145
- Logger.error(SHOW_LOGS, TAG, "Failed to enable joint", { joint: jnt }, error_2 instanceof Error ? error_2 : getSafeErrorMetadata(error_2));
144
+ Logger.error(SHOW_LOGS, TAG, "Failed to enable joint", { joint: jnt }, error_2);
146
145
  return [3 /*break*/, 15];
147
146
  case 15:
148
147
  _d++;
@@ -57,7 +57,6 @@ import { MartyWifiManager } from "./MartyWifiManager";
57
57
  import MartyAddonsManager from "./MartyAddonsManager";
58
58
  import CalibrationManager from "./CalibrationManager";
59
59
  import Logger from "../../../services/logger/Logger";
60
- import { getSafeErrorMetadata } from "../../../services/observability/sanitizeTelemetry";
61
60
  import { AppSentMessage } from "../../../types/communication-between-apps/wrapper-communication";
62
61
  import { RICNotificationsManager } from "./notifications-manager/RICNotificationsManager";
63
62
  import PublishedDataAnalyser from "./PublishedDataAnalyser";
@@ -190,7 +189,7 @@ var Marty = /** @class */ (function (_super) {
190
189
  return [2 /*return*/, !!response];
191
190
  case 2:
192
191
  error_1 = _a.sent();
193
- Logger.error(SHOW_LOGS, TAG, "Atomic read operation failed", error_1 instanceof Error ? error_1 : getSafeErrorMetadata(error_1));
192
+ Logger.error(SHOW_LOGS, TAG, "Atomic read operation failed", error_1);
194
193
  return [2 /*return*/, false];
195
194
  case 3: return [2 /*return*/];
196
195
  }
@@ -305,7 +304,7 @@ var Marty = /** @class */ (function (_super) {
305
304
  return [3 /*break*/, 3];
306
305
  case 2:
307
306
  error_2 = _a.sent();
308
- Logger.error(SHOW_LOGS, TAG, "Failed to process Marty notification", error_2 instanceof Error ? error_2 : getSafeErrorMetadata(error_2));
307
+ Logger.error(SHOW_LOGS, TAG, "Failed to process Marty notification", error_2);
309
308
  return [3 /*break*/, 3];
310
309
  case 3: return [2 /*return*/];
311
310
  }
@@ -36,7 +36,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  };
37
37
  import { RICConfiguredAddOns, RICHWElemList_Str } from "@robotical/roboticaljs";
38
38
  import Logger from "../../../services/logger/Logger";
39
- import { getSafeErrorMetadata } from "../../../services/observability/sanitizeTelemetry";
40
39
  import { RIC_WHOAMI_TYPE_CODE_ADDON_COLOUR } from "@robotical/ricjs-robotical-addons/dist/RICRoboticalAddOns";
41
40
  var SHOW_LOGS = true;
42
41
  var TAG = "MartyAddonsManager";
@@ -138,7 +137,7 @@ var MartyAddonsManager = /** @class */ (function () {
138
137
  return [2 /*return*/, addOnList];
139
138
  case 2:
140
139
  error_2 = _a.sent();
141
- Logger.error(SHOW_LOGS, TAG, "Failed to get add-on configurations", error_2 instanceof Error ? error_2 : getSafeErrorMetadata(error_2));
140
+ Logger.error(SHOW_LOGS, TAG, "Failed to get add-on configurations", error_2);
142
141
  return [2 /*return*/, new RICConfiguredAddOns()];
143
142
  case 3: return [2 /*return*/];
144
143
  }
@@ -158,7 +157,7 @@ var MartyAddonsManager = /** @class */ (function () {
158
157
  return [2 /*return*/, true];
159
158
  case 2:
160
159
  error_3 = _a.sent();
161
- Logger.warn(SHOW_LOGS, TAG, "Failed to identify add-on", getSafeErrorMetadata(error_3));
160
+ Logger.warn(SHOW_LOGS, TAG, "Failed to identify add-on", error_3);
162
161
  return [3 /*break*/, 3];
163
162
  case 3: return [2 /*return*/, false];
164
163
  }
@@ -178,7 +177,7 @@ var MartyAddonsManager = /** @class */ (function () {
178
177
  return [2 /*return*/, true];
179
178
  case 2:
180
179
  error_4 = _a.sent();
181
- Logger.warn(SHOW_LOGS, TAG, "Failed to set add-on configuration", getSafeErrorMetadata(error_4));
180
+ Logger.warn(SHOW_LOGS, TAG, "Failed to set add-on configuration", error_4);
182
181
  return [3 /*break*/, 3];
183
182
  case 3: return [2 /*return*/, false];
184
183
  }
@@ -198,7 +197,7 @@ var MartyAddonsManager = /** @class */ (function () {
198
197
  return [2 /*return*/, true];
199
198
  case 2:
200
199
  error_5 = _a.sent();
201
- Logger.warn(SHOW_LOGS, TAG, "Failed to delete add-on", getSafeErrorMetadata(error_5));
200
+ Logger.warn(SHOW_LOGS, TAG, "Failed to delete add-on", error_5);
202
201
  return [3 /*break*/, 3];
203
202
  case 3: return [2 /*return*/, false];
204
203
  }
@@ -43,7 +43,6 @@ import { ReportedWarningsState } from "./ReportedWarningsState";
43
43
  import { createTicket, isSerialNumberRegistered } from "../../../../utils/warranty-service/warranty-service-utils";
44
44
  import { RICHWElemList_Str } from "@robotical/roboticaljs";
45
45
  import Logger from "../../../../services/logger/Logger";
46
- import { getSafeErrorMetadata } from "../../../../services/observability/sanitizeTelemetry";
47
46
  var SHOW_LOGS = true;
48
47
  var TAG = "RICNotificationsManager";
49
48
  var USER_WARNING_MESSAGE = {
@@ -232,7 +231,7 @@ var RICNotificationsManager = /** @class */ (function () {
232
231
  case 6: return [3 /*break*/, 10];
233
232
  case 7:
234
233
  err_1 = _a.sent();
235
- Logger.error(SHOW_LOGS, TAG, "Failed to get hardware status; retrying", err_1 instanceof Error ? err_1 : getSafeErrorMetadata(err_1));
234
+ Logger.error(SHOW_LOGS, TAG, "Failed to get hardware status; retrying", err_1);
236
235
  if (!(i < maxRetries - 1)) return [3 /*break*/, 9];
237
236
  return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, delayMs); })];
238
237
  case 8:
@@ -289,7 +288,7 @@ var RICNotificationsManager = /** @class */ (function () {
289
288
  return [3 /*break*/, 4];
290
289
  case 3:
291
290
  err_2 = _a.sent();
292
- Logger.error(SHOW_LOGS, TAG, "Failed to get hardware version status", err_2 instanceof Error ? err_2 : getSafeErrorMetadata(err_2));
291
+ Logger.error(SHOW_LOGS, TAG, "Failed to get hardware version status", err_2);
293
292
  return [2 /*return*/, "Couldn't get versions info"];
294
293
  case 4: return [2 /*return*/];
295
294
  }
@@ -393,7 +392,7 @@ var RICNotificationsManager = /** @class */ (function () {
393
392
  return [3 /*break*/, 8];
394
393
  case 7:
395
394
  err_3 = _d.sent();
396
- Logger.error(SHOW_LOGS, TAG, "Failed to process servo fault report", err_3 instanceof Error ? err_3 : getSafeErrorMetadata(err_3));
395
+ Logger.error(SHOW_LOGS, TAG, "Failed to process servo fault report", err_3);
397
396
  return [3 /*break*/, 8];
398
397
  case 8:
399
398
  _i++;
@@ -456,7 +455,7 @@ var RICNotificationsManager = /** @class */ (function () {
456
455
  return [2 /*return*/];
457
456
  }
458
457
  });
459
- }); }).catch(function (err) { return Logger.error(SHOW_LOGS, TAG, "Failed to process element communications report", err instanceof Error ? err : getSafeErrorMetadata(err)); });
458
+ }); }).catch(function (err) { return Logger.error(SHOW_LOGS, TAG, "Failed to process element communications report", err); });
460
459
  };
461
460
  RICNotificationsManager.prototype.handleBusFailDet = function (report) {
462
461
  var _this = this;
@@ -507,7 +506,7 @@ var RICNotificationsManager = /** @class */ (function () {
507
506
  return [2 /*return*/];
508
507
  }
509
508
  });
510
- }); }).catch(function (err) { return Logger.error(SHOW_LOGS, TAG, "Failed to process bus communications report", err instanceof Error ? err : getSafeErrorMetadata(err)); });
509
+ }); }).catch(function (err) { return Logger.error(SHOW_LOGS, TAG, "Failed to process bus communications report", err); });
511
510
  };
512
511
  return RICNotificationsManager;
513
512
  }());
@@ -36,7 +36,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  };
37
37
  import { RaftWifiConnState, RaftWifiConnStatus, } from "@robdobsn/raftjs";
38
38
  import Logger from "../../services/logger/Logger";
39
- import { getSafeErrorMetadata } from "../../services/observability/sanitizeTelemetry";
40
39
  var SHOW_LOGS = true;
41
40
  var TAG = "RaftWifiManager";
42
41
  var flagIsSet = function (value) {
@@ -99,7 +98,7 @@ var RaftWifiManager = /** @class */ (function () {
99
98
  return [3 /*break*/, 4];
100
99
  case 3:
101
100
  error_1 = _a.sent();
102
- Logger.warn(SHOW_LOGS, TAG, "Failed to send Wi-Fi credentials", getSafeErrorMetadata(error_1));
101
+ Logger.warn(SHOW_LOGS, TAG, "Failed to send Wi-Fi credentials", error_1);
103
102
  return [2 /*return*/, false];
104
103
  case 4:
105
104
  timeoutCount = 0;
@@ -151,7 +150,7 @@ var RaftWifiManager = /** @class */ (function () {
151
150
  return [2 /*return*/, true];
152
151
  case 5:
153
152
  error_2 = _a.sent();
154
- Logger.warn(SHOW_LOGS, TAG, "Failed to clear Wi-Fi credentials", getSafeErrorMetadata(error_2));
153
+ Logger.warn(SHOW_LOGS, TAG, "Failed to clear Wi-Fi credentials", error_2);
155
154
  return [2 /*return*/, false];
156
155
  case 6: return [2 /*return*/];
157
156
  }
@@ -222,7 +221,7 @@ var RaftWifiManager = /** @class */ (function () {
222
221
  this._wifiConnStatus.isPaused === pause];
223
222
  case 4:
224
223
  error_4 = _a.sent();
225
- Logger.warn(SHOW_LOGS, TAG, pause ? "Failed to pause Wi-Fi" : "Failed to resume Wi-Fi", getSafeErrorMetadata(error_4));
224
+ Logger.warn(SHOW_LOGS, TAG, pause ? "Failed to pause Wi-Fi" : "Failed to resume Wi-Fi", error_4);
226
225
  return [2 /*return*/, false];
227
226
  case 5: return [2 /*return*/];
228
227
  }
@@ -242,7 +241,7 @@ var RaftWifiManager = /** @class */ (function () {
242
241
  return [2 /*return*/, response];
243
242
  case 2:
244
243
  error_5 = _a.sent();
245
- Logger.warn(SHOW_LOGS, TAG, "Failed to get Wi-Fi scan results", getSafeErrorMetadata(error_5));
244
+ Logger.warn(SHOW_LOGS, TAG, "Failed to get Wi-Fi scan results", error_5);
246
245
  return [2 /*return*/, false];
247
246
  case 3: return [2 /*return*/];
248
247
  }
@@ -262,7 +261,7 @@ var RaftWifiManager = /** @class */ (function () {
262
261
  return [2 /*return*/, responseSucceeded(response)];
263
262
  case 2:
264
263
  error_6 = _a.sent();
265
- Logger.warn(SHOW_LOGS, TAG, "Failed to start Wi-Fi scan", getSafeErrorMetadata(error_6));
264
+ Logger.warn(SHOW_LOGS, TAG, "Failed to start Wi-Fi scan", error_6);
266
265
  return [2 /*return*/, false];
267
266
  case 3: return [2 /*return*/];
268
267
  }
@@ -12,7 +12,6 @@ var __assign = (this && this.__assign) || function () {
12
12
  import * as Sentry from "@sentry/react";
13
13
  import packageInfo from "../../../package.json";
14
14
  import isPhoneApp from "../../utils/phone-app-communication/is-phone-app";
15
- import { getSafeErrorType, redactTelemetryText, sanitizeTelemetryValue, } from "./sanitizeTelemetry";
16
15
  var appVersion = packageInfo.version;
17
16
  var getRuntime = function () {
18
17
  try {
@@ -32,7 +31,7 @@ var getSafeAppSnapshot = function () {
32
31
  .filter(function (type) { return type !== undefined; })
33
32
  .map(function (type) { return String(type); })));
34
33
  var deviceInfo = applicationManager === null || applicationManager === void 0 ? void 0 : applicationManager.deviceInfo;
35
- return sanitizeTelemetryValue({
34
+ return {
36
35
  appVersion: appVersion,
37
36
  runtime: getRuntime(),
38
37
  route: window.location.pathname,
@@ -53,22 +52,7 @@ var getSafeAppSnapshot = function () {
53
52
  systemVersion: deviceInfo.systemVersion,
54
53
  }
55
54
  : undefined,
56
- });
57
- };
58
- var sanitizeEvent = function (event) {
59
- var _a, _b;
60
- var eventWithPrivateData = event;
61
- delete eventWithPrivateData.user;
62
- delete eventWithPrivateData.request;
63
- (_b = (_a = eventWithPrivateData.exception) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b.forEach(function (exception) {
64
- if (exception.type) {
65
- exception.type = getSafeErrorType(exception.type);
66
- }
67
- if (exception.value) {
68
- exception.value = "[REDACTED]";
69
- }
70
- });
71
- return sanitizeTelemetryValue(eventWithPrivateData);
55
+ };
72
56
  };
73
57
  export function initializeObservability() {
74
58
  var _a;
@@ -93,13 +77,10 @@ export function initializeObservability() {
93
77
  xhr: false,
94
78
  }),
95
79
  ],
96
- beforeBreadcrumb: function (breadcrumb) {
97
- return sanitizeTelemetryValue(breadcrumb);
98
- },
99
80
  beforeSend: function (event) {
100
81
  event.tags = __assign(__assign({}, event.tags), { app_runtime: getRuntime(), app_version: appVersion });
101
82
  event.contexts = __assign(__assign({}, event.contexts), { app_snapshot: getSafeAppSnapshot() });
102
- return sanitizeEvent(event);
83
+ return event;
103
84
  },
104
85
  });
105
86
  Sentry.setTags({
@@ -120,47 +101,44 @@ export function isObservabilityTransportUrl(url) {
120
101
  return false;
121
102
  }
122
103
  }
123
- var serializeLogArguments = function (messages) {
124
- return messages.map(function (message) { return sanitizeTelemetryValue(message); });
125
- };
126
104
  var getLogMessage = function (messages) {
127
105
  var message = messages
128
106
  .map(function (item) {
107
+ var _a;
129
108
  if (item instanceof Error)
130
- return getSafeErrorType(item);
109
+ return "".concat(item.name, ": ").concat(item.message);
131
110
  if (typeof item === "string")
132
111
  return item;
133
112
  try {
134
- return JSON.stringify(sanitizeTelemetryValue(item));
113
+ return (_a = JSON.stringify(item)) !== null && _a !== void 0 ? _a : String(item);
135
114
  }
136
- catch (_a) {
115
+ catch (_b) {
137
116
  return String(item);
138
117
  }
139
118
  })
140
119
  .join(" ")
141
120
  .trim();
142
- return redactTelemetryText(message || "Unknown error");
121
+ return message || "Unknown error";
143
122
  };
144
123
  export function captureLoggerError(tag, messages) {
145
124
  if (!Sentry.isInitialized())
146
125
  return;
147
126
  try {
148
127
  var error_1 = messages.find(function (message) { return message instanceof Error; });
149
- var safeTag_1 = redactTelemetryText(tag).slice(0, 100);
150
- var safeMessage_1 = getLogMessage(messages);
128
+ var message_1 = getLogMessage(messages);
151
129
  Sentry.withScope(function (scope) {
152
130
  scope.setLevel("error");
153
- scope.setTag("logger_tag", safeTag_1);
131
+ scope.setTag("logger_tag", tag);
154
132
  scope.setContext("logger", {
155
- message: safeMessage_1,
156
- arguments: serializeLogArguments(messages),
133
+ message: message_1,
134
+ arguments: messages,
157
135
  });
158
136
  scope.setContext("app_snapshot", getSafeAppSnapshot());
159
137
  if (error_1) {
160
138
  Sentry.captureException(error_1);
161
139
  }
162
140
  else {
163
- Sentry.captureMessage("".concat(safeTag_1, ": ").concat(safeMessage_1), "error");
141
+ Sentry.captureMessage("".concat(tag, ": ").concat(message_1), "error");
164
142
  }
165
143
  });
166
144
  }
@@ -172,13 +150,12 @@ export function addLoggerWarningBreadcrumb(tag, messages) {
172
150
  if (!Sentry.isInitialized())
173
151
  return;
174
152
  try {
175
- var safeTag = redactTelemetryText(tag).slice(0, 100);
176
153
  Sentry.addBreadcrumb({
177
154
  category: "app.warning",
178
155
  level: "warning",
179
- message: "".concat(safeTag, ": ").concat(getLogMessage(messages)),
156
+ message: "".concat(tag, ": ").concat(getLogMessage(messages)),
180
157
  data: {
181
- loggerTag: safeTag,
158
+ loggerTag: tag,
182
159
  route: window.location.pathname,
183
160
  runtime: getRuntime(),
184
161
  },
@@ -46,7 +46,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
46
  }
47
47
  };
48
48
  import Logger from "../../services/logger/Logger";
49
- import { getSafeErrorMetadata } from "../../services/observability/sanitizeTelemetry";
50
49
  import { FEEDBACK_REQUIRES_ROBOT_CONNECTION_MESSAGE, getActiveFeedbackRobotConnection, isRobotConnectionRequiredForFeedbackSource, } from "./feedbackConnectionEligibility";
51
50
  import randomHashGenerator from "../helpers/randomHashGenerator";
52
51
  import isPhoneApp from "../phone-app-communication/is-phone-app";
@@ -298,7 +297,7 @@ export function submitFeedback(input) {
298
297
  case 4:
299
298
  error_1 = _e.sent();
300
299
  slackDelivered = false;
301
- Logger.error(SHOW_LOGS, TAG, "Failed to submit feedback to Slack", getSafeErrorMetadata(error_1));
300
+ Logger.error(SHOW_LOGS, TAG, "Failed to submit feedback to Slack", error_1);
302
301
  return [3 /*break*/, 5];
303
302
  case 5: return [2 /*return*/, {
304
303
  record: record,
@@ -35,7 +35,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  }
36
36
  };
37
37
  import Logger from "../../services/logger/Logger";
38
- import { getSafeErrorMetadata } from "../../services/observability/sanitizeTelemetry";
39
38
  import { getOnboardingCookie, isOnboardingCookieExpired } from "./cookies";
40
39
  import WarranyFacade from "@robotical/appv2-warranty-service-lib";
41
40
  var SHOW_LOGS = true;
@@ -63,7 +62,7 @@ export function shouldShowOnboardingModal(serialNo) {
63
62
  case 3: return [3 /*break*/, 5];
64
63
  case 4:
65
64
  error_1 = _a.sent();
66
- Logger.error(SHOW_LOGS, TAG, "Error checking if onboarding should be shown", getSafeErrorMetadata(error_1));
65
+ Logger.error(SHOW_LOGS, TAG, "Error checking if onboarding should be shown", error_1);
67
66
  // Don't show the modal if there was an error (probably no internet connection)
68
67
  return [2 /*return*/, false];
69
68
  case 5: return [2 /*return*/, shouldShowModal];
@@ -109,7 +108,7 @@ export function registerUser(email, establishment, serialNumbers) {
109
108
  return [2 /*return*/, WarranyFacade.registerUser(email, establishment, serialNumbers)];
110
109
  }
111
110
  catch (error) {
112
- Logger.error(SHOW_LOGS, TAG, "Error registering user", getSafeErrorMetadata(error));
111
+ Logger.error(SHOW_LOGS, TAG, "Error registering user", error);
113
112
  return [2 /*return*/, false];
114
113
  }
115
114
  return [2 /*return*/];
@@ -130,7 +129,7 @@ export function isUserRegistered(email) {
130
129
  case 2: return [2 /*return*/, !!(_a.sent())];
131
130
  case 3:
132
131
  error_2 = _a.sent();
133
- Logger.error(SHOW_LOGS, TAG, "Error checking if user is registered", getSafeErrorMetadata(error_2));
132
+ Logger.error(SHOW_LOGS, TAG, "Error checking if user is registered", error_2);
134
133
  return [2 /*return*/, false];
135
134
  case 4: return [2 /*return*/];
136
135
  }
@@ -153,7 +152,7 @@ export function getUserGivenEmail(email) {
153
152
  return [2 /*return*/, user];
154
153
  case 3:
155
154
  error_3 = _a.sent();
156
- Logger.error(SHOW_LOGS, TAG, "Error getting user", getSafeErrorMetadata(error_3));
155
+ Logger.error(SHOW_LOGS, TAG, "Error getting user", error_3);
157
156
  return [2 /*return*/, null];
158
157
  case 4: return [2 /*return*/];
159
158
  }
@@ -167,7 +166,7 @@ export var isSerialNumberRegistered = function (serialNo) { return __awaiter(voi
167
166
  return [2 /*return*/, WarranyFacade.isSerialNumberRegistered(serialNo)];
168
167
  }
169
168
  catch (error) {
170
- Logger.error(SHOW_LOGS, TAG, "Error checking if serial number is registered", getSafeErrorMetadata(error));
169
+ Logger.error(SHOW_LOGS, TAG, "Error checking if serial number is registered", error);
171
170
  return [2 /*return*/, false];
172
171
  }
173
172
  return [2 /*return*/];
@@ -191,7 +190,7 @@ export var createTicket = function (serialNo, title, description, robotName, rob
191
190
  case 4: return [2 /*return*/, false];
192
191
  case 5:
193
192
  error_4 = _a.sent();
194
- Logger.error(SHOW_LOGS, TAG, "Error creating ticket", getSafeErrorMetadata(error_4));
193
+ Logger.error(SHOW_LOGS, TAG, "Error creating ticket", error_4);
195
194
  return [2 /*return*/, false];
196
195
  case 6: return [2 /*return*/];
197
196
  }
@@ -212,7 +211,7 @@ export var getEmailGivenSerialNumber = function (serialNo) { return __awaiter(vo
212
211
  return [2 /*return*/, serialNumber === null || serialNumber === void 0 ? void 0 : serialNumber.email];
213
212
  case 3:
214
213
  error_5 = _a.sent();
215
- Logger.error(SHOW_LOGS, TAG, "Error getting email for serial number", getSafeErrorMetadata(error_5));
214
+ Logger.error(SHOW_LOGS, TAG, "Error getting email for serial number", error_5);
216
215
  return [2 /*return*/, undefined];
217
216
  case 4: return [2 /*return*/];
218
217
  }
@@ -225,7 +224,7 @@ export var addRobotNameToSerialNumber = function (serialNo, name) { return __awa
225
224
  return [2 /*return*/, WarranyFacade.addRobotNameToSerialNumber(serialNo, name)];
226
225
  }
227
226
  catch (error) {
228
- Logger.error(SHOW_LOGS, TAG, "Error adding robot name to serial number", getSafeErrorMetadata(error));
227
+ Logger.error(SHOW_LOGS, TAG, "Error adding robot name to serial number", error);
229
228
  return [2 /*return*/, false];
230
229
  }
231
230
  return [2 /*return*/];
@@ -46,7 +46,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
46
46
  import { WrapperSentMessage } from "../types/communication-between-apps/wrapper-communication";
47
47
  import { RaftConnectionMethod, } from "../types/raft";
48
48
  import Logger from "../services/logger/Logger";
49
- import { getSafeErrorMetadata } from "../services/observability/sanitizeTelemetry";
50
49
  import { RaftConnEvent } from "@robdobsn/raftjs";
51
50
  import { ConnManager } from "@robotical/roboticaljs";
52
51
  import ConnectorFactory from "./connectors/ConnectorFactory";
@@ -166,13 +165,13 @@ var WrapperAppManager = /** @class */ (function () {
166
165
  return [3 /*break*/, 4];
167
166
  case 3:
168
167
  error_2 = _a.sent();
169
- Logger.warn(SHOW_LOGS, TAG, "Failed late WebSocket cleanup", getSafeErrorMetadata(error_2));
168
+ Logger.warn(SHOW_LOGS, TAG, "Failed late WebSocket cleanup", error_2);
170
169
  return [3 /*break*/, 4];
171
170
  case 4: return [2 /*return*/];
172
171
  }
173
172
  });
174
173
  }); }).catch(function (error) {
175
- Logger.warn(SHOW_LOGS, TAG, "WebSocket connection settled after timeout", getSafeErrorMetadata(error));
174
+ Logger.warn(SHOW_LOGS, TAG, "WebSocket connection settled after timeout", error);
176
175
  });
177
176
  Logger.warn(SHOW_LOGS, TAG, "WebSocket connection timed out after ".concat(WEBSOCKET_CONNECT_TIMEOUT_MS, "ms"));
178
177
  return [2 /*return*/, { success: false, reason: "failed" }];
@@ -230,7 +229,7 @@ var WrapperAppManager = /** @class */ (function () {
230
229
  case 12:
231
230
  if (!setupResult) {
232
231
  void connectorConnectionPromise.catch(function (error) {
233
- Logger.warn(SHOW_LOGS, TAG, "WebSocket setup settled after timeout", getSafeErrorMetadata(error));
232
+ Logger.warn(SHOW_LOGS, TAG, "WebSocket setup settled after timeout", error);
234
233
  });
235
234
  Logger.warn(SHOW_LOGS, TAG, "WebSocket setup timed out after ".concat(WEBSOCKET_CONNECT_TIMEOUT_MS, "ms"));
236
235
  return [2 /*return*/, { success: false, reason: "failed" }];
@@ -537,7 +536,7 @@ var WrapperAppManager = /** @class */ (function () {
537
536
  connManager.getConnector().disconnectForPageUnload();
538
537
  }
539
538
  catch (error) {
540
- Logger.warn(SHOW_LOGS, TAG, "Failed pending page-unload cleanup", getSafeErrorMetadata(error));
539
+ Logger.warn(SHOW_LOGS, TAG, "Failed pending page-unload cleanup", error);
541
540
  }
542
541
  };
543
542
  WrapperAppManager.prototype.isConnected = function (raftId) {
@@ -649,7 +648,7 @@ var WrapperAppManager = /** @class */ (function () {
649
648
  case 6: return [3 /*break*/, 14];
650
649
  case 7:
651
650
  error_3 = _a.sent();
652
- Logger.error(SHOW_LOGS, TAG, "Failed to discover warranty device", getSafeErrorMetadata(error_3));
651
+ Logger.error(SHOW_LOGS, TAG, "Failed to discover warranty device", error_3);
653
652
  return [2 /*return*/, existingDevices];
654
653
  case 8:
655
654
  if (!ownsTemporaryConnection) return [3 /*break*/, 13];
@@ -662,7 +661,7 @@ var WrapperAppManager = /** @class */ (function () {
662
661
  return [3 /*break*/, 13];
663
662
  case 11:
664
663
  error_4 = _a.sent();
665
- Logger.warn(SHOW_LOGS, TAG, "Failed warranty connection cleanup", getSafeErrorMetadata(error_4));
664
+ Logger.warn(SHOW_LOGS, TAG, "Failed warranty connection cleanup", error_4);
666
665
  return [3 /*break*/, 13];
667
666
  case 12:
668
667
  this._pendingConnManagers.delete(warrantyConnManager);
@@ -695,7 +694,7 @@ var WrapperAppManager = /** @class */ (function () {
695
694
  return [2 /*return*/, true];
696
695
  case 3:
697
696
  error_5 = _a.sent();
698
- Logger.error(SHOW_LOGS, TAG, "Failed to send atomic read operation to Marty", getSafeErrorMetadata(error_5));
697
+ Logger.error(SHOW_LOGS, TAG, "Failed to send atomic read operation to Marty", error_5);
699
698
  return [3 /*break*/, 4];
700
699
  case 4: return [3 /*break*/, 6];
701
700
  case 5:
@@ -39,7 +39,6 @@ import randomHashGenerator from "../../utils/helpers/randomHashGenerator";
39
39
  import CogConnector from "./CogConnector/CogConnector";
40
40
  import MartyConnector from "./MartyConnector/MartyConnector";
41
41
  import Logger from "../../services/logger/Logger";
42
- import { getSafeErrorMetadata } from "../../services/observability/sanitizeTelemetry";
43
42
  var SHOW_LOGS = true;
44
43
  var TAG = "ConnectorFactory";
45
44
  var ConnectorFactory = /** @class */ (function () {
@@ -103,7 +102,7 @@ var ConnectorFactory = /** @class */ (function () {
103
102
  return [3 /*break*/, 7];
104
103
  case 6:
105
104
  error_1 = _a.sent();
106
- Logger.warn(SHOW_LOGS, TAG, "Failed to clean up uncommitted RAFT connection", getSafeErrorMetadata(error_1));
105
+ Logger.warn(SHOW_LOGS, TAG, "Failed to clean up uncommitted RAFT connection", error_1);
107
106
  return [3 /*break*/, 7];
108
107
  case 7: return [7 /*endfinally*/];
109
108
  case 8: return [2 /*return*/];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robotical/webapp-types",
3
- "version": "3.21.9",
3
+ "version": "3.21.10",
4
4
  "description": "Type definitions for the Application Manager",
5
5
  "main": "dist/application-manager.d.ts",
6
6
  "types": "dist/application-manager.d.ts",
@@ -1,7 +0,0 @@
1
- export declare const isSensitiveTelemetryKey: (key: string) => boolean;
2
- export declare const getSafeErrorType: (value: unknown) => string;
3
- export declare const getSafeErrorMetadata: (error: unknown) => {
4
- errorType: string;
5
- };
6
- export declare function redactTelemetryText(value: string): string;
7
- export declare function sanitizeTelemetryValue(value: unknown, depth?: number, seen?: WeakSet<object>): unknown;
@@ -1,136 +0,0 @@
1
- var REDACTED = "[REDACTED]";
2
- var MAX_DEPTH = 12;
3
- var MAX_ARRAY_ITEMS = 100;
4
- var MAX_OBJECT_KEYS = 100;
5
- var MAX_STRING_LENGTH = 4000;
6
- var SAFE_ERROR_TYPES = new Set([
7
- "AbortError",
8
- "AggregateError",
9
- "DOMException",
10
- "Error",
11
- "EvalError",
12
- "NetworkError",
13
- "NotAllowedError",
14
- "RangeError",
15
- "ReferenceError",
16
- "SecurityError",
17
- "SyntaxError",
18
- "TimeoutError",
19
- "TypeError",
20
- "URIError",
21
- ]);
22
- var SENSITIVE_KEYS = new Set([
23
- "authorization",
24
- "authtoken",
25
- "base64",
26
- "bleaddress",
27
- "bssid",
28
- "cookie",
29
- "cookies",
30
- "credential",
31
- "credentials",
32
- "connectionlocator",
33
- "dataurl",
34
- "deviceid",
35
- "devicename",
36
- "email",
37
- "filecontents",
38
- "friendlyname",
39
- "ipaddress",
40
- "locator",
41
- "macaddress",
42
- "password",
43
- "passphrase",
44
- "raftid",
45
- "robotid",
46
- "secret",
47
- "serial",
48
- "serialno",
49
- "serialnumber",
50
- "ssid",
51
- "streamcontents",
52
- "token",
53
- "username",
54
- "wifipassword",
55
- "wifimac",
56
- "wifiusername",
57
- ]);
58
- var normalizeKey = function (key) {
59
- return key.replace(/[^a-z0-9]/gi, "").toLowerCase();
60
- };
61
- export var isSensitiveTelemetryKey = function (key) {
62
- return SENSITIVE_KEYS.has(normalizeKey(key));
63
- };
64
- export var getSafeErrorType = function (value) {
65
- var errorType = value instanceof Error ? value.name : value;
66
- return typeof errorType === "string" && SAFE_ERROR_TYPES.has(errorType)
67
- ? errorType
68
- : "Error";
69
- };
70
- export var getSafeErrorMetadata = function (error) { return ({
71
- errorType: error instanceof Error ? getSafeErrorType(error) : typeof error,
72
- }); };
73
- export function redactTelemetryText(value) {
74
- var redacted = value
75
- .replace(/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi, REDACTED)
76
- .replace(/\b(password|passphrase|token|authorization|cookie|secret|ssid|serial(?:\s*(?:number|no))?|device\s*id|device\s*name|robot\s*id|robot\s*name|raft(?:\s+with)?\s*id|mac\s*address|ble\s*address)\s*(?::|=|\s)\s*[^\s,;]+/gi, function (_match, label) { return "".concat(label, ": ").concat(REDACTED); })
77
- .replace(/\bWi-?Fi\s+network\s+[^\s,;]+/gi, "Wi-Fi network ".concat(REDACTED))
78
- .replace(/https:\/\/hooks\.slack\.com\/services\/[^\s"']+/gi, REDACTED)
79
- .replace(/([?&][^=&#\s]+)=([^&#\s]*)/g, "$1=".concat(REDACTED))
80
- .replace(/\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/gi, REDACTED)
81
- .replace(/\b(?:[0-9a-f]{2}:){5}[0-9a-f]{2}\b/gi, REDACTED);
82
- return redacted.length > MAX_STRING_LENGTH
83
- ? "".concat(redacted.slice(0, MAX_STRING_LENGTH), "\u2026")
84
- : redacted;
85
- }
86
- export function sanitizeTelemetryValue(value, depth, seen) {
87
- if (depth === void 0) { depth = 0; }
88
- if (seen === void 0) { seen = new WeakSet(); }
89
- if (typeof value === "string") {
90
- return redactTelemetryText(value);
91
- }
92
- if (value === null ||
93
- value === undefined ||
94
- typeof value === "boolean" ||
95
- typeof value === "number") {
96
- return value;
97
- }
98
- if (typeof value === "bigint" || typeof value === "symbol") {
99
- return String(value);
100
- }
101
- if (typeof value === "function") {
102
- return "[Function]";
103
- }
104
- if (depth >= MAX_DEPTH) {
105
- return "[Truncated]";
106
- }
107
- if (value instanceof Error) {
108
- return {
109
- name: getSafeErrorType(value),
110
- message: REDACTED,
111
- };
112
- }
113
- if (value instanceof Date) {
114
- return value.toISOString();
115
- }
116
- if (typeof value !== "object") {
117
- return redactTelemetryText(String(value));
118
- }
119
- if (seen.has(value)) {
120
- return "[Circular]";
121
- }
122
- seen.add(value);
123
- if (Array.isArray(value)) {
124
- return value
125
- .slice(0, MAX_ARRAY_ITEMS)
126
- .map(function (item) { return sanitizeTelemetryValue(item, depth + 1, seen); });
127
- }
128
- var sanitized = {};
129
- for (var _i = 0, _a = Object.entries(value).slice(0, MAX_OBJECT_KEYS); _i < _a.length; _i++) {
130
- var _b = _a[_i], key = _b[0], item = _b[1];
131
- sanitized[key] = isSensitiveTelemetryKey(key)
132
- ? REDACTED
133
- : sanitizeTelemetryValue(item, depth + 1, seen);
134
- }
135
- return sanitized;
136
- }