-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(onboarding): Added Metrics to Unity #108118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
23bab8e
Added Metrics to Unity
bitsandfoxes 986241b
:hammer_and_wrench: apply pre-commit fixes
getsantry[bot] 8316bcc
Merge branch 'master' into feat/unity-metrics
bitsandfoxes 521191c
mock
bitsandfoxes d9934e2
Merge branch 'feat/unity-metrics' of https://github.com/getsentry/sen…
bitsandfoxes 1c761a8
Merge remote-tracking branch 'origin/master' into feat/unity-metrics
bitsandfoxes bc2df9f
fixed import
bitsandfoxes 641521d
Merge branch 'master' into feat/unity-metrics
bitsandfoxes 4d565dd
Merge branch 'master' into feat/unity-metrics
bitsandfoxes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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', () => { | ||
| 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(); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)], | ||
| }, | ||
| ], | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.