|
| 1 | +function [b, feedbackID, apiResponse, apiURL] = submitFeedback(app, category, description, options) |
| 2 | +%SUBMITFEEDBACK User-facing wrapper to submit an in-app problem report to NDI Cloud. |
| 3 | +% |
| 4 | +% [B, FEEDBACKID, APIRESPONSE, APIURL] = ndi.cloud.api.feedback.submitFeedback(APP, CATEGORY, DESCRIPTION, ...) |
| 5 | +% |
| 6 | +% Sends a problem report to POST /feedback. The reporter is the |
| 7 | +% logged-in user. The server redacts anything that looks like a bearer |
| 8 | +% token or a signed S3 URL credential before storing the report, but |
| 9 | +% callers should still scrub logs before sending. |
| 10 | +% |
| 11 | +% Inputs: |
| 12 | +% app - Name of the client sending the report (e.g., "lightsheetZarr-viewer"). |
| 13 | +% category - One of "bug", "performance" or "other". |
| 14 | +% description - The user's free-text description of the problem. |
| 15 | +% |
| 16 | +% Optional name-value inputs: |
| 17 | +% appVersion - Version of the client (e.g., "NDI-matlab 2.0"). |
| 18 | +% datasetId - Cloud dataset id the report concerns. |
| 19 | +% documentId - Document id the report concerns. |
| 20 | +% environment - Struct describing the client environment (os, versions, ...). |
| 21 | +% state - Struct with client state useful for diagnosis. |
| 22 | +% log - Recent log lines. |
| 23 | +% traceback - Error stack, if any. |
| 24 | +% |
| 25 | +% Server limits: 1 MB per request; description 20,000 characters, log |
| 26 | +% 500,000, traceback 50,000; environment 20 kB and state 200 kB as JSON; |
| 27 | +% 10 reports per user per hour. |
| 28 | +% |
| 29 | +% Outputs: |
| 30 | +% b - True if the call succeeded, false otherwise. |
| 31 | +% feedbackID - The id of the stored report (use it with deleteFeedback). |
| 32 | +% apiResponse - The full matlab.net.http.ResponseMessage object. |
| 33 | +% apiURL - The URL that was called. |
| 34 | +% |
| 35 | +% See also: ndi.cloud.api.feedback.deleteFeedback, |
| 36 | +% ndi.cloud.api.implementation.feedback.SubmitFeedback |
| 37 | + |
| 38 | + arguments |
| 39 | + app (1,1) string {mustBeNonzeroLengthText} |
| 40 | + category (1,1) string {mustBeMember(category, ["bug", "performance", "other"])} |
| 41 | + description (1,1) string {mustBeNonzeroLengthText} |
| 42 | + options.appVersion (1,1) string = missing |
| 43 | + options.datasetId (1,1) string = missing |
| 44 | + options.documentId (1,1) string = missing |
| 45 | + options.environment struct {mustBeScalarOrEmpty} = struct.empty |
| 46 | + options.state struct {mustBeScalarOrEmpty} = struct.empty |
| 47 | + options.log (1,1) string = missing |
| 48 | + options.traceback (1,1) string = missing |
| 49 | + end |
| 50 | + |
| 51 | + feedbackStruct = struct( ... |
| 52 | + 'schemaVersion', 1, ... |
| 53 | + 'app', app, ... |
| 54 | + 'category', category, ... |
| 55 | + 'description', description); |
| 56 | + |
| 57 | + stringFields = ["appVersion", "datasetId", "documentId", "log", "traceback"]; |
| 58 | + for fieldName = stringFields |
| 59 | + if ~ismissing(options.(fieldName)) |
| 60 | + feedbackStruct.(fieldName) = options.(fieldName); |
| 61 | + end |
| 62 | + end |
| 63 | + for fieldName = ["environment", "state"] |
| 64 | + if ~isempty(options.(fieldName)) |
| 65 | + feedbackStruct.(fieldName) = options.(fieldName); |
| 66 | + end |
| 67 | + end |
| 68 | + |
| 69 | + % 1. Create an instance of the implementation class. |
| 70 | + api_call = ndi.cloud.api.implementation.feedback.SubmitFeedback('feedbackStruct', feedbackStruct); |
| 71 | + |
| 72 | + % 2. Call the execute method and return its outputs directly. |
| 73 | + [b, feedbackID, apiResponse, apiURL] = api_call.execute(); |
| 74 | + |
| 75 | +end |
0 commit comments