|
| 1 | +import {ExternalLink} from '@sentry/scraps/link'; |
| 2 | + |
| 3 | +import type { |
| 4 | + ContentBlock, |
| 5 | + DocsParams, |
| 6 | + OnboardingConfig, |
| 7 | +} from 'sentry/components/onboarding/gettingStartedDoc/types'; |
| 8 | +import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/types'; |
| 9 | +import {t, tct} from 'sentry/locale'; |
| 10 | + |
| 11 | +export const metricsVerify = (params: DocsParams): ContentBlock => ({ |
| 12 | + type: 'conditional', |
| 13 | + condition: params.isMetricsSelected, |
| 14 | + content: [ |
| 15 | + { |
| 16 | + type: 'text', |
| 17 | + text: t( |
| 18 | + 'Send test metrics from your app to verify metrics are arriving in Sentry.' |
| 19 | + ), |
| 20 | + }, |
| 21 | + { |
| 22 | + type: 'code', |
| 23 | + language: 'csharp', |
| 24 | + code: `using Sentry; |
| 25 | +
|
| 26 | +SentrySdk.Metrics.Increment("player_interaction", |
| 27 | + tags: new Dictionary<string, string> {{"action", "jump"}, {"scene", "main_menu"}}); |
| 28 | +SentrySdk.Metrics.Distribution("scene_load", 230, |
| 29 | + unit: MeasurementUnit.Duration.Millisecond, |
| 30 | + tags: new Dictionary<string, string> {{"scene", "world_1"}}); |
| 31 | +SentrySdk.Metrics.Gauge("active_players", 42, |
| 32 | + tags: new Dictionary<string, string> {{"server", "us-east-1"}});`, |
| 33 | + }, |
| 34 | + { |
| 35 | + type: 'text', |
| 36 | + text: tct('For more detailed information, see the [link:metrics documentation].', { |
| 37 | + link: <ExternalLink href="https://docs.sentry.io/platforms/unity/metrics/" />, |
| 38 | + }), |
| 39 | + }, |
| 40 | + ], |
| 41 | +}); |
| 42 | + |
| 43 | +export const metrics: OnboardingConfig = { |
| 44 | + install: () => [ |
| 45 | + { |
| 46 | + type: StepType.INSTALL, |
| 47 | + content: [ |
| 48 | + { |
| 49 | + type: 'text', |
| 50 | + text: tct( |
| 51 | + 'Metrics for Unity are supported in Sentry SDK version [code:4.1.0] and above.', |
| 52 | + { |
| 53 | + code: <code />, |
| 54 | + } |
| 55 | + ), |
| 56 | + }, |
| 57 | + ], |
| 58 | + }, |
| 59 | + ], |
| 60 | + configure: (params: DocsParams) => [ |
| 61 | + { |
| 62 | + type: StepType.CONFIGURE, |
| 63 | + content: [ |
| 64 | + { |
| 65 | + type: 'text', |
| 66 | + text: t( |
| 67 | + 'To enable metrics in your Unity game, you need to configure the Sentry SDK with metrics enabled.' |
| 68 | + ), |
| 69 | + }, |
| 70 | + { |
| 71 | + type: 'text', |
| 72 | + text: tct( |
| 73 | + 'Open your project settings: [strong:Tools > Sentry > Advanced > Metrics] and check the [strong:Enable Metrics] option.', |
| 74 | + { |
| 75 | + strong: <strong />, |
| 76 | + } |
| 77 | + ), |
| 78 | + }, |
| 79 | + { |
| 80 | + type: 'text', |
| 81 | + text: t('Alternatively, you can enable metrics programmatically:'), |
| 82 | + }, |
| 83 | + { |
| 84 | + type: 'code', |
| 85 | + language: 'csharp', |
| 86 | + code: `SentrySdk.Init(options => |
| 87 | +{ |
| 88 | + options.Dsn = "${params.dsn.public}"; |
| 89 | +
|
| 90 | + // Enable metrics to be sent to Sentry |
| 91 | + options.ExperimentalMetrics = new ExperimentalMetricsOptions |
| 92 | + { |
| 93 | + EnableCodeLocations = true |
| 94 | + }; |
| 95 | +});`, |
| 96 | + }, |
| 97 | + ], |
| 98 | + }, |
| 99 | + ], |
| 100 | + verify: (params: DocsParams) => [ |
| 101 | + { |
| 102 | + type: StepType.VERIFY, |
| 103 | + content: [metricsVerify(params)], |
| 104 | + }, |
| 105 | + ], |
| 106 | +}; |
0 commit comments