Skip to content

Commit b8adf60

Browse files
Move Unity into the common Getting Started (#3414)
* move Unity into the common Getting Started * move and rename images * Update src/platforms/unity/unity-lite.mdx Co-authored-by: Bruno Garcia <[email protected]> * modify config statement in common * Update src/platforms/unity/unity-lite.mdx Co-authored-by: Bruno Garcia <[email protected]> * Update src/platforms/unity/unity-lite.mdx Co-authored-by: Bruno Garcia <[email protected]> Co-authored-by: Bruno Garcia <[email protected]>
1 parent 9f77350 commit b8adf60

File tree

11 files changed

+101
-136
lines changed

11 files changed

+101
-136
lines changed
Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
You can attach Sentry to a Game Object and initialize it with the DSN programatically:
1+
Currently, you can only configure Sentry using the Unity tools window.
22

3-
```csharp
4-
var sentry = gameObject.AddComponent<SentrySdk>();
5-
sentry.Dsn = "___PUBLIC_DSN___";
6-
```
3+
Open `Tools` -> `Sentry`.
4+
5+
The first time you open the window, Unity Sentry SDK related files are created:
6+
7+
* `Assets/Resources/Sentry/SentryOptions.json` - Sentry settings
8+
* `Assets/Resources/Sentry/link.xml` - [a special file](https://docs.unity3d.com/Manual/ManagedCodeStripping.html) for [ILL2CPP](https://docs.unity3d.com/Manual/IL2CPP.html) builds
9+
10+
![Sentry tools](tools_sentry.png)
11+
12+
And the Sentry configuration window will open:
13+
14+
![Sentry window](sentry_window.png)
15+
16+
* Check `Enable` to enable Sentry event capturing
17+
* `DSN` displays the Sentry DSN value
18+
19+
After you close the window, all settings are saved into `Assets/Resources/Sentry/SentryOptions.json`.
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
Get the SDK via the [Unity Package Manager using a Git URL](https://docs.unity3d.com/Manual/upm-ui-giturl.html) to Sentry's SDK repository:
1+
Install the SDK from [`Unity UPM`](https://docs.unity3d.com/Manual/upm-ui.html) using a Git URL to Sentry's SDK repository:
22

33
```
4-
https://github.com/getsentry/sentry-unity-lite.git#1.0.3
4+
https://github.com/getsentry/unity.git#{{ packages.version('sentry.dotnet.unity', '0.0.5') }}
55
```
6+
<Note>
7+
8+
Confirm there's no empty space at the end of the line. The Unity Package Manager will fail to find the package if an empty space is appended to the end of the URL.
9+
10+
</Note>
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<Note>
22

3-
_Pure C# 6 SDK compiled with Unity and supported by all Unity platforms._
3+
This is preview SDK. Features available in a preview are still in progress and may have bugs. We recognize the irony, and we'd appreciate your feedback.
4+
5+
To use a stable version, please see our [Unity Lite content](/platforms/unity/unity-lite/).
46

57
</Note>
Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,53 @@
1-
Once the SDK is configured with the DSN, you can call from anywhere:
1+
Create `TestMonoBehaviour.cs` with contains `Debug.LogError` (but can be any exception like the C# expression `throw null`):
22

33
```csharp
4-
SentrySdk.CaptureMessage("Test event");
4+
using UnityEngine;
5+
6+
public class TestMonoBehaviour : MonoBehaviour
7+
{
8+
void Start()
9+
{
10+
Debug.Log("Log");
11+
Debug.LogWarning("Warning");
12+
Debug.LogError("Error");
13+
}
14+
}
15+
```
16+
17+
Assign it to any object you have in the scene and press play. Open up your Sentry project in the web UI and check the logs.
18+
19+
You should see a new issue:
20+
21+
![Sentry issue](sentry_issue.png)
22+
23+
Open it up and check breadcrumbs:
24+
25+
![Sentry breadcrumbs](sentry_breadcrumbs.png)
26+
27+
The list of captured events are displayed.
28+
29+
### Event debouncer
30+
31+
A debouncing mechanism is in place. This means that if you try to send a many requests in a quick succession (with the same log type), we will take the first one and ignore the others given the time slot. Current settings:
32+
33+
* `LogType.Error` (also exceptions) or `LogType.Exception` or `LogType.Assert` - one second
34+
* `LogType.Log` - one second
35+
* `LogType.Warning` - one second
36+
37+
Create another `DebouncerTestMonoBehaviour.cs`, then assign it to any object in the scene and run it.
38+
39+
```csharp
40+
using UnityEngine;
41+
42+
public class DebouncerTestMonoBehaviour : MonoBehaviour
43+
{
44+
void Start()
45+
{
46+
Debug.Log("Log"); // recorded
47+
Debug.Log("Log2"); // not recorded (1 second didn't expire from the previous call)
48+
Debug.LogWarning("Warning"); // recorded
49+
Debug.LogWarning("Warning2"); // not recorded
50+
Debug.LogError("Error"); // recorded
51+
}
52+
}
553
```

src/platforms/common/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ Sentry captures data by using an SDK within your application’s runtime.
2222

2323
## Configure
2424

25+
<PlatformSection notSupported={["unity"]}>
26+
2527
Configuration should happen as early as possible in your application's lifecycle.
2628

29+
</PlatformSection>
30+
2731
<PlatformContent includePath="getting-started-config" />
2832

2933
## Verify

src/platforms/unity/index.mdx

Lines changed: 0 additions & 120 deletions
This file was deleted.

src/platforms/unity/unity-lite.mdx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ description: "Unity Lite Sentry SDK."
44
sidebar_order: 5
55
---
66

7-
<PlatformContent includePath="getting-started-primer" />
7+
_Unity Lite is a pure C# 6 SDK compiled with Unity and supported by all Unity platforms._
88

99
On this page, we get you up and running with Sentry's SDK, so that it will automatically report errors and exceptions in your application.
1010

1111
<Note>
1212

13-
This is a stable but lightweight SDK which doesn't support all of Sentry's features. It's in the process of being replaced by [Unity SDK](/platforms/unity).
13+
This is a stable but lightweight SDK that doesn't support all of Sentry's features. It's in the process of being replaced by [Unity SDK](/platforms/unity).
1414

1515
</Note>
1616

@@ -20,23 +20,36 @@ This is a stable but lightweight SDK which doesn't support all of Sentry's featu
2020

2121
Sentry captures data by using an SDK within your application’s runtime.
2222

23-
<PlatformContent includePath="getting-started-install" />
23+
Get the SDK via the [Unity Package Manager](https://docs.unity3d.com/Manual/upm-ui-giturl.html) using a Git URL to Sentry's SDK repository:
24+
25+
```
26+
https://github.com/getsentry/sentry-unity-lite.git#1.0.3
27+
```
2428

2529
## Configure
2630

2731
Configuration should happen as early as possible in your application's lifecycle.
2832

29-
<PlatformContent includePath="getting-started-config" />
33+
You can attach Sentry to a Game Object and initialize it with the DSN programatically:
34+
35+
```csharp
36+
var sentry = gameObject.AddComponent<SentrySdk>();
37+
sentry.Dsn = "___PUBLIC_DSN___";
38+
```
3039

3140
## Verify
3241

3342
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up:
3443

35-
<PlatformContent includePath="getting-started-verify" />
44+
Once the SDK is configured with the DSN, you can call from anywhere:
45+
46+
```csharp
47+
SentrySdk.CaptureMessage("Test event");
48+
```
3649

3750
<Note>
3851

39-
Learn more about manually capturing an error or message, in our <PlatformLink to="/enriching-events/breadcrumbs/">Usage documentation</PlatformLink>.
52+
Learn more about manually capturing an error or message, in our <PlatformLink to="/usage/">Usage documentation</PlatformLink>.
4053

4154
</Note>
4255

0 commit comments

Comments
 (0)