Browse Source

chore: Added Unity Metrics onboarding (#67064)

Added onboarding for the frontend platform `Unity`.
Stefan Jandl 11 months ago
parent
commit
296e2ec282

+ 8 - 8
static/app/components/onboarding/gettingStartedDoc/utils/metricsOnboarding.tsx

@@ -580,13 +580,13 @@ export const getPythonMetricsOnboarding = ({
 
 const getDotnetConfigureSnippet = (params: DocsParams) => `
 SentrySdk.Init(options =>
+{
+  options.Dsn = "${params.dsn}";
+  options.ExperimentalMetrics = new ExperimentalMetricsOptions
   {
-    options.Dsn = "${params.dsn}";
-    options.ExperimentalMetrics = new ExperimentalMetricsOptions
-    {
-      EnableCodeLocations = true
-    };
-  });`;
+    EnableCodeLocations = true
+  };
+});`;
 
 const getDotnetVerifySnippet = () => `
 SentrySdk.Metrics.Increment(
@@ -603,7 +603,7 @@ export const getDotnetMetricsOnboarding = ({
     {
       type: StepType.INSTALL,
       description: tct(
-        'You need a minimum version [codeVersion:4.0.0] of the .NET SDK installed',
+        'You need a minimum version [codeVersion:4.0.0] of the .NET SDK installed.',
         {
           codeVersion: <code />,
         }
@@ -611,7 +611,7 @@ export const getDotnetMetricsOnboarding = ({
       configurations: [
         {
           language: 'powershell',
-          code: `dotnet add package ${packageName} -v 4.1.2`,
+          code: `dotnet add package ${packageName}`,
         },
       ],
     },

+ 1 - 0
static/app/data/platformCategories.tsx

@@ -528,6 +528,7 @@ const customMetricFrontendPlatforms: readonly PlatformKey[] = [
   'javascript-vue',
   'javascript',
   'react-native',
+  'unity',
 ];
 
 // These are all the platforms that can set up custom metrics.

+ 80 - 0
static/app/gettingStartedDocs/unity/unity.tsx

@@ -20,6 +20,21 @@ using Sentry; // On the top of the script
 
 SentrySdk.CaptureMessage("Test event");`;
 
+const getMetricsConfigureSnippet = () => `
+public override void Configure(SentryUnityOptions options)
+{
+    options.ExperimentalMetrics = new ExperimentalMetricsOptions
+    {
+      EnableCodeLocations = true
+    };
+}`;
+
+const getMetricsVerifySnippet = () => `
+SentrySdk.Metrics.Increment(
+  "drank-drinks",
+  tags:new Dictionary<string, string> {{"kind", "coffee"}}
+);`;
+
 const onboarding: OnboardingConfig = {
   install: params => [
     {
@@ -157,10 +172,75 @@ SentrySdk.CaptureUserFeedback(eventId, "user@example.com", "It broke.", "The Use
   nextSteps: () => [],
 };
 
+const metricsOnboarding: OnboardingConfig = {
+  install: () => [
+    {
+      type: StepType.INSTALL,
+      description: tct(
+        'You need a minimum version [codeVersion:2.0.0] of the Unity SDK installed.',
+        {
+          codeVersion: <code />,
+        }
+      ),
+    },
+  ],
+  configure: () => [
+    {
+      type: StepType.CONFIGURE,
+      description: t(
+        'Once the SDK is installed or updated, you can enable the experimental metrics feature and code locations being emitted in your RuntimeConfiguration.'
+      ),
+      configurations: [
+        {
+          language: 'csharp',
+          code: getMetricsConfigureSnippet(),
+        },
+      ],
+    },
+  ],
+  verify: () => [
+    {
+      type: StepType.VERIFY,
+      description: tct(
+        "Then you'll be able to add metrics as [codeCounters:counters], [codeSets:sets], [codeDistribution:distributions], [codeGauge:gauges], and [codeTimings:timings]. Try out this example:",
+        {
+          codeCounters: <code />,
+          codeSets: <code />,
+          codeDistribution: <code />,
+          codeGauge: <code />,
+          codeTimings: <code />,
+        }
+      ),
+      configurations: [
+        {
+          language: 'csharp',
+          code: getMetricsVerifySnippet(),
+        },
+        {
+          description: t(
+            'With a bit of delay you can see the data appear in the Sentry UI.'
+          ),
+        },
+        {
+          description: tct(
+            'Learn more about metrics and how to configure them, by reading the [docsLink:docs].',
+            {
+              docsLink: (
+                <ExternalLink href="https://docs.sentry.io/platforms/unity/metrics/" />
+              ),
+            }
+          ),
+        },
+      ],
+    },
+  ],
+};
+
 const docs: Docs = {
   onboarding,
   feedbackOnboardingCrashApi: feedbackOnboarding,
   crashReportOnboarding: feedbackOnboarding,
+  customMetricsOnboarding: metricsOnboarding,
 };
 
 export default docs;