Skip to content

Commit f6298be

Browse files
committed
Add issue release id and release label fields
1 parent 3ad12e4 commit f6298be

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

Runtime/Scripts/BugReportUI.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ public class BugReportUI : MonoBehaviour
9292
[FormerlySerializedAs("includeVideo")]
9393
public bool IncludeVideo = true;
9494

95+
[Tooltip("The release ID to associate the bug report with. If not set (0), the bug report will be " +
96+
"associated with the latest release. Requires the AuthToken to have a permission of creating new releases.")]
97+
public int ReleaseId = 0;
98+
99+
[Tooltip("The release label to associate the bug report with. If not created yet on the backend, " +
100+
"a new release will be created with this label. Requires the AuthToken to have a permission of creating new releases. " +
101+
"If not set (null), the bug report will be associated with the latest release.")]
102+
public string ReleaseLabel = "";
103+
95104
public UnityEvent OnBugReportWindowShown;
96105
public UnityEvent OnBugReportWindowHidden;
97106

@@ -396,7 +405,7 @@ void SubmitBugReport()
396405

397406

398407
CoroutineUtils.StartThrowingCoroutine(this,
399-
issue.PostIssue(description, steps, screenshots, logFiles, false,
408+
issue.PostIssue(description, steps, screenshots, logFiles, ReleaseId, ReleaseLabel, false,
400409
(issueId) => // successful post
401410
{
402411
SubmitButton.interactable = true;

Runtime/Scripts/Issue.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ public struct ScreenshotFileReference
5454
public bool removeAfterUpload;
5555
}
5656

57-
public Issue(string betahubEndpoint, string projectId, string authToken,
58-
MessagePanelUI messagePanelUI, ReportSubmittedUI reportSubmittedUI, GameRecorder gameRecorder)
57+
public Issue(string betahubEndpoint, string projectId,
58+
string authToken,
59+
MessagePanelUI messagePanelUI, ReportSubmittedUI reportSubmittedUI, GameRecorder gameRecorder)
5960
{
6061
_betahubEndpoint = betahubEndpoint;
6162
if (!betahubEndpoint.EndsWith("/"))
@@ -108,6 +109,7 @@ public Issue(string betahubEndpoint, string projectId, string authToken,
108109
// - autoPublish: (optional) if true, the issue will be requested to be published automatically after media upload.
109110
public IEnumerator PostIssue(string description, string steps = null,
110111
List<ScreenshotFileReference> screenshots = null, List<LogFileReference> logFiles = null,
112+
int releaseId = 0, string releaseLabel = "",
111113
bool autoPublish = false,
112114
Action<string> onAllMediaUploaded = null, MediaUploadType mediaUploadType = MediaUploadType.UploadInBackground, Action<string> onError = null)
113115
{
@@ -116,6 +118,11 @@ public IEnumerator PostIssue(string description, string steps = null,
116118
throw new Exception("Issue instance cannot be reused for posting.");
117119
}
118120

121+
if (releaseId > 0 && !string.IsNullOrEmpty(releaseLabel))
122+
{
123+
throw new Exception("Cannot set both release ID and release label");
124+
}
125+
119126
// Initialize state for this posting attempt
120127
_publishRequested = autoPublish;
121128
_mediaUploadComplete = false;
@@ -126,7 +133,7 @@ public IEnumerator PostIssue(string description, string steps = null,
126133
string updateIssueAuthTokenLocal = null;
127134
string error = null;
128135

129-
yield return PostIssueDraft(description, steps, (draftResult) =>
136+
yield return PostIssueDraft(description, steps, releaseId, releaseLabel, (draftResult) =>
130137
{
131138
issueIdLocal = draftResult.IssueId;
132139
updateIssueAuthTokenLocal = draftResult.UpdateIssueAuthToken;
@@ -246,13 +253,22 @@ private IEnumerator CheckAndPublishIfReady()
246253

247254
// posts a draft issue to BetaHub.
248255
// returns the issue id and the update issue auth token via callback
249-
private IEnumerator PostIssueDraft(string description, string steps, Action<DraftResult> onResult)
256+
private IEnumerator PostIssueDraft(string description, string steps, int releaseId, string releaseLabel, Action<DraftResult> onResult)
250257
{
251258
WWWForm form = new WWWForm();
252259
form.AddField("issue[description]", description);
253260
form.AddField("issue[unformatted_steps_to_reproduce]", steps);
254261
form.AddField("draft", "true"); // this enables the draft flow
255262

263+
if (releaseId > 0)
264+
{
265+
form.AddField("issue[release_id]", releaseId);
266+
}
267+
else if (!string.IsNullOrEmpty(releaseLabel))
268+
{
269+
form.AddField("issue[release_label]", releaseLabel);
270+
}
271+
256272
string url = GetPostIssueUrl();
257273

258274
using (UnityWebRequest www = UnityWebRequest.Post(url, form))

0 commit comments

Comments
 (0)