Skip to content
Merged
2 changes: 1 addition & 1 deletion static/app/components/onboarding/productSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ export const platformProductAvailability = {
ProductSolution.PROFILING,
ProductSolution.LOGS,
],
unity: [ProductSolution.LOGS],
unity: [ProductSolution.LOGS, ProductSolution.METRICS],
unreal: [ProductSolution.LOGS],
} as Record<PlatformKey, ProductSolution[]>;

Expand Down
1 change: 1 addition & 0 deletions static/app/data/platformCategories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ export const withMetricsOnboarding = new Set<PlatformKey>([
'ruby',
'ruby-rack',
'ruby-rails',
'unity',
]);

// List of platforms that do not have metrics support. We make use of this list in the product to not provide any Metrics
Expand Down
2 changes: 2 additions & 0 deletions static/app/gettingStartedDocs/unity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import type {Docs} from 'sentry/components/onboarding/gettingStartedDoc/types';

import {crashReport} from './crashReport';
import {logs} from './logs';
import {metrics} from './metrics';
import {onboarding} from './onboarding';

export const docs: Docs = {
onboarding,
feedbackOnboardingCrashApi: crashReport,
crashReportOnboarding: crashReport,
logsOnboarding: logs,
metricsOnboarding: metrics,
};
42 changes: 42 additions & 0 deletions static/app/gettingStartedDocs/unity/metrics.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {ProjectFixture} from 'sentry-fixture/project';

import {renderWithOnboardingLayout} from 'sentry-test/onboarding/renderWithOnboardingLayout';
import {screen} from 'sentry-test/reactTestingLibrary';
import {textWithMarkupMatcher} from 'sentry-test/utils';

import {ProductSolution} from 'sentry/components/onboarding/gettingStartedDoc/types';

import {docs} from '.';

function renderMockRequests() {
MockApiClient.addMockResponse({
url: '/projects/org-slug/project-slug/',
body: [ProjectFixture()],
});
}

describe('metrics', () => {
Comment thread
bitsandfoxes marked this conversation as resolved.
it('unity metrics onboarding docs', () => {
renderMockRequests();

renderWithOnboardingLayout(docs, {
selectedProducts: [ProductSolution.METRICS],
});

expect(
screen.getByText(textWithMarkupMatcher(/SentrySdk\.Metrics\.Increment/))
).toBeInTheDocument();
});

it('does not render metrics configuration when metrics is not enabled', () => {
renderMockRequests();

renderWithOnboardingLayout(docs, {
selectedProducts: [],
});

expect(
screen.queryByText(textWithMarkupMatcher(/SentrySdk\.Metrics\.Increment/))
).not.toBeInTheDocument();
});
});
106 changes: 106 additions & 0 deletions static/app/gettingStartedDocs/unity/metrics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import {ExternalLink} from '@sentry/scraps/link';

import type {
ContentBlock,
DocsParams,
OnboardingConfig,
} from 'sentry/components/onboarding/gettingStartedDoc/types';
import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/types';
import {t, tct} from 'sentry/locale';

export const metricsVerify = (params: DocsParams): ContentBlock => ({
type: 'conditional',
condition: params.isMetricsSelected,
content: [
{
type: 'text',
text: t(
'Send test metrics from your app to verify metrics are arriving in Sentry.'
),
},
{
type: 'code',
language: 'csharp',
code: `using Sentry;

SentrySdk.Metrics.Increment("player_interaction",
tags: new Dictionary<string, string> {{"action", "jump"}, {"scene", "main_menu"}});
SentrySdk.Metrics.Distribution("scene_load", 230,
unit: MeasurementUnit.Duration.Millisecond,
tags: new Dictionary<string, string> {{"scene", "world_1"}});
SentrySdk.Metrics.Gauge("active_players", 42,
tags: new Dictionary<string, string> {{"server", "us-east-1"}});`,
},
{
type: 'text',
text: tct('For more detailed information, see the [link:metrics documentation].', {
link: <ExternalLink href="https://docs.sentry.io/platforms/unity/metrics/" />,
}),
},
],
});

export const metrics: OnboardingConfig = {
install: () => [
{
type: StepType.INSTALL,
content: [
{
type: 'text',
text: tct(
'Metrics for Unity are supported in Sentry SDK version [code:4.1.0] and above.',
{
code: <code />,
}
),
},
],
},
],
configure: (params: DocsParams) => [
{
type: StepType.CONFIGURE,
content: [
{
type: 'text',
text: t(
'To enable metrics in your Unity game, you need to configure the Sentry SDK with metrics enabled.'
),
},
{
type: 'text',
text: tct(
'Open your project settings: [strong:Tools > Sentry > Advanced > Metrics] and check the [strong:Enable Metrics] option.',
{
strong: <strong />,
}
),
},
{
type: 'text',
text: t('Alternatively, you can enable metrics programmatically:'),
},
{
type: 'code',
language: 'csharp',
code: `SentrySdk.Init(options =>
{
options.Dsn = "${params.dsn.public}";

// Enable metrics to be sent to Sentry
options.ExperimentalMetrics = new ExperimentalMetricsOptions
{
EnableCodeLocations = true
};
});`,
},
],
},
],
verify: (params: DocsParams) => [
{
type: StepType.VERIFY,
content: [metricsVerify(params)],
},
],
};
14 changes: 14 additions & 0 deletions static/app/gettingStartedDocs/unity/onboarding.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {renderWithOnboardingLayout} from 'sentry-test/onboarding/renderWithOnboa
import {screen} from 'sentry-test/reactTestingLibrary';
import {textWithMarkupMatcher} from 'sentry-test/utils';

import {ProductSolution} from 'sentry/components/onboarding/gettingStartedDoc/types';

import {docs} from '.';

function renderMockRequests() {
Expand Down Expand Up @@ -32,4 +34,16 @@ describe('unity onboarding docs', () => {
)
).toBeInTheDocument();
});

it('renders metrics snippet when metrics product is selected', () => {
renderMockRequests();

renderWithOnboardingLayout(docs, {
selectedProducts: [ProductSolution.METRICS],
});

expect(
screen.getByText(textWithMarkupMatcher(/SentrySdk\.Metrics\.Increment/))
).toBeInTheDocument();
});
});
22 changes: 22 additions & 0 deletions static/app/gettingStartedDocs/unity/onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {getConsoleExtensions} from 'sentry/components/onboarding/gettingStartedD
import {t, tct} from 'sentry/locale';

import {logsVerify} from './logs';
import {metricsVerify} from './metrics';

const getVerifySnippet = () => `
using Sentry; // On the top of the script
Expand Down Expand Up @@ -74,6 +75,19 @@ export const onboarding: OnboardingConfig = {
},
],
},
{
type: 'conditional',
condition: params.isMetricsSelected,
content: [
{
type: 'text',
text: tct(
'To enable metrics, navigate to [strong:Tools > Sentry > Advanced > Metrics] and check the [strong:Enable Metrics] option.',
{strong: <strong />}
),
},
],
},
{
type: 'text',
text: tct(
Expand Down Expand Up @@ -113,6 +127,14 @@ export const onboarding: OnboardingConfig = {
},
] satisfies OnboardingStep[])
: []),
...(params.isMetricsSelected
? ([
{
title: t('Metrics'),
content: [metricsVerify(params)],
},
] satisfies OnboardingStep[])
: []),
Comment thread
bitsandfoxes marked this conversation as resolved.
{
title: t('Troubleshooting'),
content: [
Expand Down
Loading