@robotical/webapp-types 3.25.25 → 3.26.1

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.25.25",
3
+ "version": "3.26.1",
4
4
  "private": true,
5
5
  "engines": {
6
6
  "node": ">=20"
@@ -1,7 +1,9 @@
1
1
  import { FeedbackRating } from "../../../utils/feedback/submitFeedback";
2
+ import type { FeedbackReason } from "../../../utils/feedback/feedbackReasons";
2
3
  type Props = {
3
4
  otherInfoObject?: Record<string, unknown>;
4
5
  rating?: FeedbackRating;
6
+ reason?: FeedbackReason;
5
7
  };
6
- export default function DetailedFeedbackModal({ otherInfoObject, rating, }: Props): import("react/jsx-runtime").JSX.Element;
8
+ export default function DetailedFeedbackModal({ otherInfoObject, rating, reason, }: Props): import("react/jsx-runtime").JSX.Element;
7
9
  export {};
@@ -56,7 +56,7 @@ import styles from "./styles.module.css";
56
56
  import SimpleButton from "../../disposables/buttons/SimpleButton";
57
57
  export default function DetailedFeedbackModal(_a) {
58
58
  var _this = this;
59
- var otherInfoObject = _a.otherInfoObject, rating = _a.rating;
59
+ var otherInfoObject = _a.otherInfoObject, rating = _a.rating, reason = _a.reason;
60
60
  var t = useTranslation().t;
61
61
  var _b = useState(""), report = _b[0], setReport = _b[1];
62
62
  var _c = useState(""), email = _c[0], setEmail = _c[1];
@@ -75,11 +75,7 @@ export default function DetailedFeedbackModal(_a) {
75
75
  _c.label = 1;
76
76
  case 1:
77
77
  _c.trys.push([1, 3, , 4]);
78
- return [4 /*yield*/, submitFeedback({
79
- rating: rating,
80
- context: otherInfoObject,
81
- source: "emoji-modal",
82
- })];
78
+ return [4 /*yield*/, submitFeedback(__assign(__assign({ rating: rating }, (reason ? { reason: reason } : {})), { context: otherInfoObject, source: "emoji-modal" }))];
83
79
  case 2:
84
80
  _c.sent();
85
81
  page = getFeedbackPromptPageFromContext(otherInfoObject);
@@ -140,13 +136,7 @@ export default function DetailedFeedbackModal(_a) {
140
136
  _c.label = 1;
141
137
  case 1:
142
138
  _c.trys.push([1, 3, 4, 5]);
143
- return [4 /*yield*/, submitFeedback({
144
- rating: rating,
145
- message: report,
146
- email: email,
147
- context: otherInfoObject,
148
- source: "detailed-feedback",
149
- })];
139
+ return [4 /*yield*/, submitFeedback(__assign(__assign({ rating: rating }, (reason ? { reason: reason } : {})), { message: report, email: email, context: otherInfoObject, source: "detailed-feedback" }))];
150
140
  case 2:
151
141
  _c.sent();
152
142
  page = getFeedbackPromptPageFromContext(otherInfoObject);
@@ -0,0 +1,21 @@
1
+ export declare const FEEDBACK_REASONS: readonly [{
2
+ readonly value: "connection";
3
+ readonly label: "Connection";
4
+ }, {
5
+ readonly value: "loading";
6
+ readonly label: "Loading";
7
+ }, {
8
+ readonly value: "controls";
9
+ readonly label: "Controls";
10
+ }, {
11
+ readonly value: "difficulty";
12
+ readonly label: "Difficulty";
13
+ }, {
14
+ readonly value: "bug";
15
+ readonly label: "Bug";
16
+ }, {
17
+ readonly value: "other";
18
+ readonly label: "Other";
19
+ }];
20
+ export type FeedbackReason = typeof FEEDBACK_REASONS[number]["value"];
21
+ export declare function normalizeFeedbackReason(rating: number | null | undefined, reason: unknown): FeedbackReason | null;
@@ -0,0 +1,15 @@
1
+ export var FEEDBACK_REASONS = [
2
+ { value: "connection", label: "Connection" },
3
+ { value: "loading", label: "Loading" },
4
+ { value: "controls", label: "Controls" },
5
+ { value: "difficulty", label: "Difficulty" },
6
+ { value: "bug", label: "Bug" },
7
+ { value: "other", label: "Other" },
8
+ ];
9
+ export function normalizeFeedbackReason(rating, reason) {
10
+ var _a, _b;
11
+ if (rating !== 1 && rating !== 2) {
12
+ return null;
13
+ }
14
+ return (_b = (_a = FEEDBACK_REASONS.find(function (option) { return option.value === reason; })) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : null;
15
+ }
@@ -1,4 +1,5 @@
1
1
  import type { UserDeviceInfo } from "../../types/userDeviceInfo";
2
+ import { type FeedbackReason } from "./feedbackReasons";
2
3
  export type FeedbackRating = 1 | 2 | 3 | 4 | 5;
3
4
  export type FeedbackSource = "emoji-modal" | "detailed-feedback" | "help-bug-report";
4
5
  export type FeedbackAppRuntime = "phone-app" | "web-app";
@@ -27,6 +28,7 @@ export type FeedbackEnvironment = {
27
28
  };
28
29
  export type SubmitFeedbackInput = {
29
30
  rating?: FeedbackRating;
31
+ reason?: FeedbackReason;
30
32
  message?: string;
31
33
  email?: string;
32
34
  context?: Record<string, unknown> | null;
@@ -36,6 +38,7 @@ export type SubmitFeedbackInput = {
36
38
  };
37
39
  export type FeedbackRecord = {
38
40
  rating: FeedbackRating | null;
41
+ reason: FeedbackReason | null;
39
42
  message: string | null;
40
43
  email: string | null;
41
44
  source: FeedbackSource;
@@ -49,6 +49,7 @@ import Logger from "../../services/logger/Logger";
49
49
  import { FEEDBACK_REQUIRES_ROBOT_CONNECTION_MESSAGE, getActiveFeedbackRobotConnection, isRobotConnectionRequiredForFeedbackSource, } from "./feedbackConnectionEligibility";
50
50
  import randomHashGenerator from "../helpers/randomHashGenerator";
51
51
  import isPhoneApp from "../phone-app-communication/is-phone-app";
52
+ import { FEEDBACK_REASONS, normalizeFeedbackReason, } from "./feedbackReasons";
52
53
  var SHOW_LOGS = true;
53
54
  var TAG = "submitFeedback";
54
55
  var WEB_APP_FEEDBACK_DB_URL = "https://web-app-bug-reports-default-rtdb.europe-west1.firebasedatabase.app/";
@@ -167,6 +168,7 @@ function getEnvironmentTextLines(environment) {
167
168
  return lines.concat(deviceLines);
168
169
  }
169
170
  export function buildFeedbackText(record) {
171
+ var _a;
170
172
  var lines = ["Source: ".concat(record.source)];
171
173
  lines.push.apply(lines, getEnvironmentTextLines(record.environment));
172
174
  var page = record.context && typeof record.context.page === "string"
@@ -202,6 +204,13 @@ export function buildFeedbackText(record) {
202
204
  if (record.rating) {
203
205
  lines.push("Rating: ".concat(record.rating, "/5"));
204
206
  }
207
+ if (record.reason) {
208
+ var label = (_a = FEEDBACK_REASONS.find(function (_a) {
209
+ var value = _a.value;
210
+ return value === record.reason;
211
+ })) === null || _a === void 0 ? void 0 : _a.label;
212
+ lines.push("Reason: ".concat(label));
213
+ }
205
214
  if (record.screenshots.length > 0) {
206
215
  lines.push("Screenshots: ".concat(record.screenshots.length, " (view in Marty Web App Insights)"));
207
216
  }
@@ -219,6 +228,7 @@ export function createFeedbackRecord(input) {
219
228
  var environment = (_a = input.environment) !== null && _a !== void 0 ? _a : collectFeedbackEnvironment();
220
229
  var record = {
221
230
  rating: (_b = input.rating) !== null && _b !== void 0 ? _b : null,
231
+ reason: normalizeFeedbackReason(input.rating, input.reason),
222
232
  message: normalizedMessage,
223
233
  email: normalizedEmail,
224
234
  source: input.source,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robotical/webapp-types",
3
- "version": "3.25.25",
3
+ "version": "3.26.1",
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",