From cfafd1044280ca6fb11204794dfb07e0c627b897 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Sun, 24 Mar 2024 12:45:15 +0100 Subject: [PATCH 1/4] feat: PowerShell (frontend) --- README.md | 1 + fixtures/integration-docs/_platforms.json | 12 + fixtures/integration-docs/powershell.json | 6 + .../frame/usePrismTokensSourceContext.tsx | 1 + static/app/data/platformCategories.tsx | 1 + static/app/data/platformPickerCategories.tsx | 1 + static/app/data/platforms.tsx | 7 + .../powershell/powershell.spec.tsx | 35 +++ .../powershell/powershell.tsx | 207 ++++++++++++++++++ static/app/types/project.tsx | 1 + static/app/utils/docs.tsx | 2 + static/app/utils/fileExtension.tsx | 1 + 12 files changed, 275 insertions(+) create mode 100644 fixtures/integration-docs/powershell.json create mode 100644 static/app/gettingStartedDocs/powershell/powershell.spec.tsx create mode 100644 static/app/gettingStartedDocs/powershell/powershell.tsx diff --git a/README.md b/README.md index 227cf5f58bc00a..73aa954472a28d 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Sentry is a developer-first error tracking and performance monitoring platform t - [Elixir](https://github.com/getsentry/sentry-elixir) - [Unity](https://github.com/getsentry/sentry-unity) - [Unreal Engine](https://github.com/getsentry/sentry-unreal) +- [PowerShell](https://github.com/getsentry/sentry-powershell) # Resources diff --git a/fixtures/integration-docs/_platforms.json b/fixtures/integration-docs/_platforms.json index d92d47cb5bcb0a..902ae3e0e07f71 100644 --- a/fixtures/integration-docs/_platforms.json +++ b/fixtures/integration-docs/_platforms.json @@ -425,6 +425,18 @@ ], "id": "mock", "name": "Mock" + }, + { + "integrations": [ + { + "link": "https://docs.getsentry.com/platforms/powershell/", + "type": "language", + "id": "powershell", + "name": "PowerShell" + } + ], + "id": "powershell", + "name": "PowerShell" } ] } diff --git a/fixtures/integration-docs/powershell.json b/fixtures/integration-docs/powershell.json new file mode 100644 index 00000000000000..e8c62b64fbc92e --- /dev/null +++ b/fixtures/integration-docs/powershell.json @@ -0,0 +1,6 @@ +{ + "html": "
\n

Installation

\n

A PowerShell module is available for Sentry.

\n
\n", + "link": "https://docs.getsentry.com/platforms/powrshell/", + "id": "powershell", + "name": "PowerShell" +} diff --git a/static/app/components/events/interfaces/frame/usePrismTokensSourceContext.tsx b/static/app/components/events/interfaces/frame/usePrismTokensSourceContext.tsx index ebabdd45329cc7..7fc3e56077d458 100644 --- a/static/app/components/events/interfaces/frame/usePrismTokensSourceContext.tsx +++ b/static/app/components/events/interfaces/frame/usePrismTokensSourceContext.tsx @@ -39,6 +39,7 @@ const BLOCK_COMMENT_SYNTAX_BY_LANGUAGE: Record = { julia: [{start: '#=', end: '=#'}], lua: [{start: '--[[', end: ']]'}], perl: [{start: {example: '=comment', search: /^\s*?=\S+/m}, end: '=cut'}], + powershell: [{start: '<#', end: '#>'}], python: [ {start: '"""', end: '"""'}, {start: "'''", end: "'''"}, diff --git a/static/app/data/platformCategories.tsx b/static/app/data/platformCategories.tsx index 33b517fc1b890f..1a76cce6b71574 100644 --- a/static/app/data/platformCategories.tsx +++ b/static/app/data/platformCategories.tsx @@ -87,6 +87,7 @@ export const backend: PlatformKey[] = [ 'php-laravel', 'php-monolog', 'php-symfony', + 'powershell', 'python', 'python-aiohttp', 'python-asgi', diff --git a/static/app/data/platformPickerCategories.tsx b/static/app/data/platformPickerCategories.tsx index da0d246bcbc635..43a37da6569d85 100644 --- a/static/app/data/platformPickerCategories.tsx +++ b/static/app/data/platformPickerCategories.tsx @@ -73,6 +73,7 @@ const server: Set = new Set([ 'php', 'php-laravel', 'php-symfony', + 'powershell', 'python', 'python-aiohttp', 'python-asgi', diff --git a/static/app/data/platforms.tsx b/static/app/data/platforms.tsx index 10b16cea1d23b8..8f50a758638386 100644 --- a/static/app/data/platforms.tsx +++ b/static/app/data/platforms.tsx @@ -431,6 +431,13 @@ export const platforms: PlatformIntegration[] = [ language: 'php', link: 'https://docs.sentry.io/platforms/php/guides/symfony/', }, + { + id: 'powershell', + name: 'PowerShell', + type: 'language', + language: 'powershell', + link: 'https://docs.sentry.io/platforms/powershell/', + }, { id: 'python', name: 'Python', diff --git a/static/app/gettingStartedDocs/powershell/powershell.spec.tsx b/static/app/gettingStartedDocs/powershell/powershell.spec.tsx new file mode 100644 index 00000000000000..5f22ffd964d488 --- /dev/null +++ b/static/app/gettingStartedDocs/powershell/powershell.spec.tsx @@ -0,0 +1,35 @@ +import {renderWithOnboardingLayout} from 'sentry-test/onboarding/renderWithOnboardingLayout'; +import {screen} from 'sentry-test/reactTestingLibrary'; +import {textWithMarkupMatcher} from 'sentry-test/utils'; + +import docs from './powershell'; + +describe('powershell onboarding docs', function () { + it('renders docs correctly', async function () { + renderWithOnboardingLayout(docs, { + releaseRegistry: { + 'sentry.powershell': { + version: '1.99.9', + }, + }, + }); + + // Renders main headings + expect(screen.getByRole('heading', {name: 'Install'})).toBeInTheDocument(); + expect(screen.getByRole('heading', {name: 'Configure SDK'})).toBeInTheDocument(); + expect(screen.getByRole('heading', {name: 'Verify'})).toBeInTheDocument(); + expect( + screen.getByRole('heading', {name: 'Performance Monitoring'}) + ).toBeInTheDocument(); + expect(screen.getByRole('heading', {name: 'Samples'})).toBeInTheDocument(); + + // Renders SDK version from registry + expect( + await screen.findByText( + textWithMarkupMatcher( + /Install-Module -Name Sentry -Repository PSGallery -RequiredVersion 1\.99\.9/ + ) + ) + ).toBeInTheDocument(); + }); +}); diff --git a/static/app/gettingStartedDocs/powershell/powershell.tsx b/static/app/gettingStartedDocs/powershell/powershell.tsx new file mode 100644 index 00000000000000..7bddcdba809212 --- /dev/null +++ b/static/app/gettingStartedDocs/powershell/powershell.tsx @@ -0,0 +1,207 @@ +import ExternalLink from 'sentry/components/links/externalLink'; +import List from 'sentry/components/list'; +import ListItem from 'sentry/components/list/listItem'; +import altCrashReportCallout from 'sentry/components/onboarding/gettingStartedDoc/feedback/altCrashReportCallout'; +import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step'; +import type { + Docs, + DocsParams, + OnboardingConfig, +} from 'sentry/components/onboarding/gettingStartedDoc/types'; +import { + getCrashReportApiIntroduction, + getCrashReportInstallDescription, +} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding'; +import {t, tct} from 'sentry/locale'; +import {getPackageVersion} from 'sentry/utils/gettingStartedDocs/getPackageVersion'; + +type Params = DocsParams; + +const getConfigureSnippet = (params: Params) => ` +# You need to import the module once in a script. +Import-Module Sentry + +# Start the Sentry SDK with the default options. +# It may be helpful when investigating issues with your setup to pass \`-Debug\` to \`Start-Sentry\`. +# This enables debug logging (\`Write-Debug\`) for the Sentry client. +# We enable it here for demonstration purposes when first trying Sentry. +# You shouldn't do this in your applications unless you're troubleshooting issues with Sentry. +Start-Sentry -Debug { + # A Sentry Data Source Name (DSN) is required. + # See https://docs.sentry.io/product/sentry-basics/dsn-explainer/ + # You can set it in the SENTRY_DSN environment variable, or you can set it in code here. + $_.Dsn = '${params.dsn}' + + # This option will enable Sentry's tracing features. You still need to start transactions and spans. + # For example, setting the rate to 0.1 would capture 10% of transactions. + $_.TracesSampleRate = 1.0 +} + +# Later on in your production script, you should omit the \`-Debug\` flag.: +Start-Sentry { + $_.Dsn = '${params.dsn}' + $_.TracesSampleRate = 0.1 +}`; + +const getPerformanceMonitoringSnippet = () => ` +# Transaction can be started by providing, at minimum, the name and the operation +$transaction = Start-SentryTransaction 'test-transaction-name' 'test-transaction-operation' + +# Transactions can have child spans (and those spans can have child spans as well) +$span = $transaction.StartChild("test-child-operation") +# ... +# (Perform the operation represented by the span/transaction) +# ... +$span.Finish() # Mark the span as finished + +$span = $transaction.StartChild("another-span") +# ... +$span.Finish() + +$transaction.Finish() # Mark the transaction as finished and send it to Sentry`; + +const onboarding: OnboardingConfig = { + introduction: () => + tct( + 'Sentry for PowerShell module supports PowerShell 7.2+ on Windows, macOS, and Linux as well as Windows PowerShell 5.1+.', + { + strong: , + link: , + } + ), + install: params => [ + { + type: StepType.INSTALL, + description: tct('Install the module:', { + strong: , + }), + configurations: [ + { + partialLoading: params.sourcePackageRegistries.isLoading, + code: [ + { + language: 'powershell', + label: 'Install Module', + value: 'powershellget', + code: `Install-Module -Name Sentry -Repository PSGallery -RequiredVersion ${getPackageVersion(params, 'sentry.powershell', '1.0.0')} -Force`, + }, + ], + }, + ], + }, + ], + configure: params => [ + { + type: StepType.CONFIGURE, + description: tct('Initialize the SDK as early as possible.', { + sentrySdkCode: , + programCode: , + }), + configurations: [ + { + language: 'powershell', + code: getConfigureSnippet(params), + }, + ], + }, + ], + verify: () => [ + { + type: StepType.VERIFY, + description: t('Verify Sentry is correctly configured by sending a message:'), + configurations: [ + { + language: 'powershell', + code: '"Something went wrong" | Out-Sentry', + }, + ], + }, + { + title: t('Performance Monitoring'), + description: t( + 'You can measure the performance of your code by capturing transactions and spans.' + ), + configurations: [ + { + language: 'powershell', + code: getPerformanceMonitoringSnippet(), + }, + ], + additionalInfo: tct( + 'Check out [link:the documentation] to learn more about the API and instrumentations.', + { + link: ( + + ), + } + ), + }, + { + title: t('Samples'), + description: t('You can find sample usage of the SDK:'), + configurations: [ + { + description: ( + + + {tct('[link:Samples in the [code:powershell] SDK repository]', { + link: ( + + ), + code: , + strong: , + })} + + + {tct( + '[link:Many more samples in the [code:dotnet] SDK repository] [strong:(C#)]', + { + link: ( + + ), + code: , + strong: , + } + )} + + + ), + }, + ], + }, + ], +}; + +export const powershellFeedbackOnboarding: OnboardingConfig = { + introduction: () => getCrashReportApiIntroduction(), + install: () => [ + { + type: StepType.INSTALL, + description: getCrashReportInstallDescription(), + configurations: [ + { + code: [ + { + label: 'PowerShell', + value: 'powershell', + language: 'powershell', + code: `$eventId = "An event that will receive user feedback." | Out-Sentry +[Sentry.SentrySdk]::CaptureUserFeedback($eventId, "user@example.com", "It broke.", "The User")`, + }, + ], + }, + ], + additionalInfo: altCrashReportCallout(), + }, + ], + configure: () => [], + verify: () => [], + nextSteps: () => [], +}; + +const docs: Docs = { + onboarding, + feedbackOnboardingCrashApi: powershellFeedbackOnboarding, +}; + +export default docs; diff --git a/static/app/types/project.tsx b/static/app/types/project.tsx index 9af37f377177fd..32a1d0ca4eb3cd 100644 --- a/static/app/types/project.tsx +++ b/static/app/types/project.tsx @@ -230,6 +230,7 @@ export type PlatformKey = | 'php-monolog' | 'php-symfony' | 'php-symfony2' + | 'powershell' | 'python' | 'python-aiohttp' | 'python-asgi' diff --git a/static/app/utils/docs.tsx b/static/app/utils/docs.tsx index 2e7a0fc70c0adc..2e44bb5ebf8975 100644 --- a/static/app/utils/docs.tsx +++ b/static/app/utils/docs.tsx @@ -14,6 +14,7 @@ const platforms = [ 'node', 'perl', 'php', + 'powershell', 'python', 'react-native', 'ruby', @@ -32,6 +33,7 @@ const performancePlatforms: DocPlatform[] = [ 'javascript', 'node', 'php', + 'powershell', 'python', 'react-native', 'ruby', diff --git a/static/app/utils/fileExtension.tsx b/static/app/utils/fileExtension.tsx index d5e98d9589518a..f019791a397047 100644 --- a/static/app/utils/fileExtension.tsx +++ b/static/app/utils/fileExtension.tsx @@ -22,6 +22,7 @@ const FILE_EXTENSION_TO_PLATFORM = { fs: 'fsharp', vb: 'visualbasic', ps1: 'powershell', + psd1: 'powershell', psm1: 'powershell', kt: 'kotlin', dart: 'dart', From 5798caf92f297774b53948952980593445f6d82e Mon Sep 17 00:00:00 2001 From: Ivan Dlugos <6349682+vaind@users.noreply.github.com> Date: Sun, 7 Apr 2024 20:45:37 +0200 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: ArthurKnaus --- .../powershell/powershell.tsx | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/static/app/gettingStartedDocs/powershell/powershell.tsx b/static/app/gettingStartedDocs/powershell/powershell.tsx index 7bddcdba809212..3894c8f147cb83 100644 --- a/static/app/gettingStartedDocs/powershell/powershell.tsx +++ b/static/app/gettingStartedDocs/powershell/powershell.tsx @@ -62,19 +62,13 @@ $transaction.Finish() # Mark the transaction as finished and send it to Sentry`; const onboarding: OnboardingConfig = { introduction: () => - tct( - 'Sentry for PowerShell module supports PowerShell 7.2+ on Windows, macOS, and Linux as well as Windows PowerShell 5.1+.', - { - strong: , - link: , - } + t( + 'Sentry for PowerShell module supports PowerShell 7.2+ on Windows, macOS, and Linux as well as Windows PowerShell 5.1+.' ), install: params => [ { type: StepType.INSTALL, - description: tct('Install the module:', { - strong: , - }), + description: t('Install the module:'), configurations: [ { partialLoading: params.sourcePackageRegistries.isLoading, @@ -93,10 +87,7 @@ const onboarding: OnboardingConfig = { configure: params => [ { type: StepType.CONFIGURE, - description: tct('Initialize the SDK as early as possible.', { - sentrySdkCode: , - programCode: , - }), + description: tct('Initialize the SDK as early as possible.'), configurations: [ { language: 'powershell', @@ -149,7 +140,6 @@ const onboarding: OnboardingConfig = { ), code: , - strong: , })} From 11b20609a3a7d5813457778efea864f90280308a Mon Sep 17 00:00:00 2001 From: Ivan Dlugos <6349682+vaind@users.noreply.github.com> Date: Thu, 11 Apr 2024 11:45:20 +0200 Subject: [PATCH 3/4] Update static/app/gettingStartedDocs/powershell/powershell.tsx Co-authored-by: ArthurKnaus --- static/app/gettingStartedDocs/powershell/powershell.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/app/gettingStartedDocs/powershell/powershell.tsx b/static/app/gettingStartedDocs/powershell/powershell.tsx index 3894c8f147cb83..c2cc1e26427d8c 100644 --- a/static/app/gettingStartedDocs/powershell/powershell.tsx +++ b/static/app/gettingStartedDocs/powershell/powershell.tsx @@ -87,7 +87,7 @@ const onboarding: OnboardingConfig = { configure: params => [ { type: StepType.CONFIGURE, - description: tct('Initialize the SDK as early as possible.'), + description: t('Initialize the SDK as early as possible.'), configurations: [ { language: 'powershell', From fec2cff46f278fd3fa9e57b886ab183caef3c244 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos <6349682+vaind@users.noreply.github.com> Date: Thu, 2 May 2024 13:06:59 +0200 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Bruno Garcia --- static/app/gettingStartedDocs/powershell/powershell.spec.tsx | 2 +- static/app/gettingStartedDocs/powershell/powershell.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/static/app/gettingStartedDocs/powershell/powershell.spec.tsx b/static/app/gettingStartedDocs/powershell/powershell.spec.tsx index 5f22ffd964d488..f7c6b908a4fadd 100644 --- a/static/app/gettingStartedDocs/powershell/powershell.spec.tsx +++ b/static/app/gettingStartedDocs/powershell/powershell.spec.tsx @@ -8,7 +8,7 @@ describe('powershell onboarding docs', function () { it('renders docs correctly', async function () { renderWithOnboardingLayout(docs, { releaseRegistry: { - 'sentry.powershell': { + 'sentry.dotnet.powershell': { version: '1.99.9', }, }, diff --git a/static/app/gettingStartedDocs/powershell/powershell.tsx b/static/app/gettingStartedDocs/powershell/powershell.tsx index c2cc1e26427d8c..eee09153dded87 100644 --- a/static/app/gettingStartedDocs/powershell/powershell.tsx +++ b/static/app/gettingStartedDocs/powershell/powershell.tsx @@ -77,7 +77,7 @@ const onboarding: OnboardingConfig = { language: 'powershell', label: 'Install Module', value: 'powershellget', - code: `Install-Module -Name Sentry -Repository PSGallery -RequiredVersion ${getPackageVersion(params, 'sentry.powershell', '1.0.0')} -Force`, + code: `Install-Module -Name Sentry -Repository PSGallery -RequiredVersion ${getPackageVersion(params, 'sentry.dotnet.powershell', '0.0.2')} -Force`, }, ], },