Skip to content

Commit a06c558

Browse files
committed
Add auth manager docs
1 parent 178ba53 commit a06c558

File tree

2 files changed

+140
-0
lines changed

2 files changed

+140
-0
lines changed

Documentation.html

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ <h3>API Usage and Terms</h3>
7272

7373
<p>Welcome to the BetaHub Unity Plugin! This guide will help you integrate our bug reporting tool into your Unity project, streamlining the process of collecting and managing bug reports from your game testers and players.</p>
7474

75+
<h2>Features</h2>
76+
77+
<ul>
78+
<li><strong>In-game bug submission form:</strong> Streamlined form asking only for description and reproduction steps</li>
79+
<li><strong>Device authentication:</strong> Optional OAuth-like sign-in flow via web browser for seamless user experience</li>
80+
<li><strong>Video recording:</strong> Automatic capture of gameplay footage with bug reports</li>
81+
<li><strong>Log collection:</strong> Automatic Unity log capture with support for custom logs</li>
82+
<li><strong>Screenshot capture:</strong> Automatic screenshot attachment with bug submissions</li>
83+
<li><strong>Working examples:</strong> Complete demo scenes and integration examples</li>
84+
<li><strong>Highly customizable:</strong> Flexible configuration for different project needs</li>
85+
</ul>
86+
7587
<h2>Prerequisites</h2>
7688

7789
<p>Before you begin, please ensure you have:</p>
@@ -158,6 +170,99 @@ <h3>Quick Start</h3>
158170

159171
<p>You're all set! Run your game and press <code>F12</code> to open the bug report form.</p>
160172

173+
<h2>Device Authentication (Optional)</h2>
174+
175+
<div class="note">
176+
<strong>Enhanced User Experience:</strong> Device authentication provides a seamless sign-in flow that eliminates the need for users to enter email addresses when submitting bug reports. Users authenticate once via web browser and stay signed in across game sessions.
177+
</div>
178+
179+
<h3>How Device Authentication Works</h3>
180+
181+
<ol>
182+
<li><strong>User Initiates Sign-In:</strong> User clicks the "Sign In" button in your game</li>
183+
<li><strong>Browser Authentication:</strong> System opens the default web browser to BetaHub's secure authentication page</li>
184+
<li><strong>User Authenticates:</strong> User signs in with their BetaHub account credentials in the browser</li>
185+
<li><strong>Token Exchange:</strong> Plugin receives a secure JWT token and stores it locally</li>
186+
<li><strong>Seamless Bug Reports:</strong> Authenticated users can submit bug reports without entering email addresses</li>
187+
</ol>
188+
189+
<h3>Benefits</h3>
190+
191+
<ul>
192+
<li><strong>No Email Required:</strong> Authenticated users skip email entry during bug submission</li>
193+
<li><strong>Persistent Authentication:</strong> Users stay signed in across game sessions (24-hour token expiry)</li>
194+
<li><strong>Automatic User Association:</strong> Bug reports are automatically linked to user accounts</li>
195+
<li><strong>Better User Experience:</strong> Reduces friction in the bug reporting process</li>
196+
<li><strong>Optional Feature:</strong> Works alongside traditional anonymous reporting</li>
197+
</ul>
198+
199+
<h3>Setup Instructions</h3>
200+
201+
<ol>
202+
<li>Locate the <code>DeviceAuthCanvas</code> prefab in <strong>Packages/BetaHub Bug Reporter/Runtime/Prefabs/</strong></li>
203+
<li>Drag it into your scene alongside the existing <code>BugReportingFormCanvas</code></li>
204+
<li>Configure the <code>DeviceAuthManager</code> component:
205+
<ul>
206+
<li><strong>Project ID:</strong> Same as your BugReportingFormCanvas (found in BetaHub Project Settings)</li>
207+
<li><strong>Entity Kind:</strong> "game" (default) or customize as needed</li>
208+
<li><strong>Entity Name:</strong> Your game's name (displayed during authentication)</li>
209+
<li><strong>Poll Interval:</strong> How often to check for authentication completion (default: 3 seconds)</li>
210+
<li><strong>Auth Timeout:</strong> Maximum time to wait for authentication (default: 5 minutes)</li>
211+
</ul>
212+
</li>
213+
<li>Link the components together:
214+
<ul>
215+
<li>Set the <code>DeviceAuthManager</code> reference in your <code>BugReportUI</code> component</li>
216+
<li>Set the <code>MessagePanelUI</code> reference in your <code>DeviceAuthUI</code> component</li>
217+
</ul>
218+
</li>
219+
</ol>
220+
221+
<h3>Programmatic Integration</h3>
222+
223+
<p>You can integrate device authentication programmatically:</p>
224+
225+
<pre><code>// Get reference to the DeviceAuthManager
226+
DeviceAuthManager authManager = FindObjectOfType&lt;DeviceAuthManager&gt;();
227+
228+
// Start authentication flow
229+
authManager.StartDeviceAuth();
230+
231+
// Check authentication status
232+
if (authManager.IsAuthenticated())
233+
{
234+
Debug.Log($"User signed in as: {authManager.UserDisplayName}");
235+
string jwtToken = authManager.JwtToken;
236+
}
237+
238+
// Sign out user
239+
authManager.SignOut();
240+
241+
// Listen for authentication state changes
242+
authManager.OnAuthStateChanged += (DeviceAuthState newState) =&gt; {
243+
Debug.Log($"Auth state changed to: {newState}");
244+
};
245+
246+
// Handle authentication errors
247+
authManager.OnAuthError += (string error) =&gt; {
248+
Debug.LogError($"Authentication error: {error}");
249+
};</code></pre>
250+
251+
<h3>Integration with Bug Reports</h3>
252+
253+
<p>When device authentication is properly set up:</p>
254+
255+
<ul>
256+
<li>Authenticated users will see a "Thank you" message immediately after submitting bug reports</li>
257+
<li>Non-authenticated users will see the traditional email entry form</li>
258+
<li>Bug reports from authenticated users are automatically linked to their BetaHub accounts</li>
259+
<li>The system automatically handles the authentication token in API requests</li>
260+
</ul>
261+
262+
<div class="note">
263+
<strong>Example Scene:</strong> The plugin includes <code>DeviceAuthExample.cs</code> in the Samples folder, demonstrating complete integration between device authentication and bug reporting systems.
264+
</div>
265+
161266
<h3>Configuration</h3>
162267

163268
<p>Adjust these settings in the BugReportingFormCanvas inspector:</p>

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ For continued use and more extensive testing, we strongly recommend creating you
2525
## Features
2626

2727
- **In-game bug submission form**: Easily submit bugs with a form that only asks for a description and steps to reproduce. Titles, priority, and tags are handled by BetaHub's AI algorithms.
28+
- **Device authentication**: Optional OAuth-like authentication flow that allows users to sign in via web browser. Authenticated users can submit bug reports without providing email addresses.
2829
- **Video recording**: Record a video of the bug happening in-game. The video is automatically recorded and attached to the bug report.
2930
- **Log collection**: Collect logs from the game and attach them to the bug report. By default, Unity logs are collected, but you can also add custom logs.
3031
- **Screenshot of the game**: A screenshot of the game is automatically attached to the bug report when the user submits a bug.
@@ -45,6 +46,40 @@ For continued use and more extensive testing, we strongly recommend creating you
4546

4647
The installation and setup documentation is available [here](https://www.betahub.io/docs/integration-guides/).
4748

49+
## Device Authentication (Optional)
50+
51+
The plugin supports an optional device authentication flow that provides a seamless user experience for bug reporting.
52+
53+
### How It Works
54+
55+
1. **User Authentication**: Users click "Sign In" which opens a browser window for BetaHub authentication
56+
2. **Secure Token Storage**: JWT authentication tokens are securely stored locally and persist across game sessions (24-hour expiry)
57+
3. **Streamlined Bug Reports**: Authenticated users can submit bug reports without entering email addresses
58+
4. **Automatic User Association**: Bug reports are automatically linked to the authenticated user's BetaHub account
59+
60+
### Setup
61+
62+
1. Add the `DeviceAuthCanvas` prefab to your scene alongside the existing `BugReportingFormCanvas`
63+
2. Configure both prefabs with the same Project ID
64+
3. Link the `DeviceAuthManager` component to your `BugReportUI` component
65+
4. Optionally customize entity information (game name, type) in the `DeviceAuthManager`
66+
67+
### Integration Example
68+
69+
```csharp
70+
// Example: Programmatically trigger authentication
71+
DeviceAuthManager authManager = FindObjectOfType<DeviceAuthManager>();
72+
authManager.StartDeviceAuth(); // Opens browser for user authentication
73+
74+
// Check authentication status
75+
if (authManager.IsAuthenticated())
76+
{
77+
Debug.Log($"Signed in as: {authManager.UserDisplayName}");
78+
}
79+
```
80+
81+
The plugin includes a complete example scene (`DeviceAuthExample.cs`) demonstrating the integration between device authentication and bug reporting.
82+
4883
## Support
4984

5085
Join our [Discord server](https://discord.gg/g2wpRtG) for support, feedback, and feature requests.

0 commit comments

Comments
 (0)