From e40a83068b731130787fe357f59fecd77f991e6c Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Wed, 18 Dec 2024 12:26:13 +0100 Subject: [PATCH 1/4] feat(python): Add Typer integration docs --- docs/platforms/python/integrations/index.mdx | 3 +- .../python/integrations/typer/index.mdx | 53 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 docs/platforms/python/integrations/typer/index.mdx diff --git a/docs/platforms/python/integrations/index.mdx b/docs/platforms/python/integrations/index.mdx index b306e5dcc0164..177163d2a0922 100644 --- a/docs/platforms/python/integrations/index.mdx +++ b/docs/platforms/python/integrations/index.mdx @@ -116,10 +116,11 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra | | | | | | | | | -| | | +| | | | | | | | | | | | +| | | | | | ### Default Integrations diff --git a/docs/platforms/python/integrations/typer/index.mdx b/docs/platforms/python/integrations/typer/index.mdx new file mode 100644 index 0000000000000..c9490466452f2 --- /dev/null +++ b/docs/platforms/python/integrations/typer/index.mdx @@ -0,0 +1,53 @@ +--- +title: Typer +description: Learn how to use Sentry to capture Typer exceptions. +--- + +The `TyperIntegration` captures exceptions raised when using Typer CLI applications. + +## Install + +```bash +pip install --upgrade "sentry-sdk" +``` + +## Configure + +To enable the `TyperIntegration`, add it to the `integrations` list of your `sentry_sdk.init`. + + + +```python +import sentry_sdk +from sentry_sdk.integrations.typer import TyperIntegration + +sentry_sdk.init( + dsn="___PUBLIC_DSN___", + integrations=[TyperIntegration()], +) +``` + + +## Verify + +Create a small CLI application: + +```python +import typer +import sentry_sdk +from sentry_sdk.integrations.typer import TyperIntegration + +sentry_sdk.init( + dsn="___PUBLIC_DSN___", + integrations=[TyperIntegration()], +) + +def main(): + 1 / 0 + +if __name__ == "__main__": + typer.run(main) +``` + +When you run this, Sentry will capture the `ZeroDivisionError` from the `main()` +function and you will be able to see it on [sentry.io](https://sentry.io). From 3cb7d380c0cb442621643cb42400357adb22adb4 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Wed, 18 Dec 2024 12:27:10 +0100 Subject: [PATCH 2/4] wording --- docs/platforms/python/integrations/typer/index.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/platforms/python/integrations/typer/index.mdx b/docs/platforms/python/integrations/typer/index.mdx index c9490466452f2..6bca0e9f2e41a 100644 --- a/docs/platforms/python/integrations/typer/index.mdx +++ b/docs/platforms/python/integrations/typer/index.mdx @@ -7,8 +7,10 @@ The `TyperIntegration` captures exceptions raised when using Typer CLI applicati ## Install +Install Typer and the Sentry SDK. + ```bash -pip install --upgrade "sentry-sdk" +pip install --upgrade "sentry-sdk" typer ``` ## Configure From f242b53172bfed8a3c63ceb627218edfa506c1e2 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Wed, 18 Dec 2024 12:44:54 +0100 Subject: [PATCH 3/4] fixes --- docs/platforms/python/integrations/typer/index.mdx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/platforms/python/integrations/typer/index.mdx b/docs/platforms/python/integrations/typer/index.mdx index 6bca0e9f2e41a..9f7b40865ba7a 100644 --- a/docs/platforms/python/integrations/typer/index.mdx +++ b/docs/platforms/python/integrations/typer/index.mdx @@ -7,7 +7,7 @@ The `TyperIntegration` captures exceptions raised when using Typer CLI applicati ## Install -Install Typer and the Sentry SDK. +Install Typer and the Sentry Python SDK. ```bash pip install --upgrade "sentry-sdk" typer @@ -17,8 +17,6 @@ pip install --upgrade "sentry-sdk" typer To enable the `TyperIntegration`, add it to the `integrations` list of your `sentry_sdk.init`. - - ```python import sentry_sdk from sentry_sdk.integrations.typer import TyperIntegration @@ -29,7 +27,6 @@ sentry_sdk.init( ) ``` - ## Verify Create a small CLI application: From f599208fd44215b3b7a62b71fc76db4a50138661 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Thu, 19 Dec 2024 12:12:28 +0100 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Alex Krawiec --- docs/platforms/python/integrations/typer/index.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/platforms/python/integrations/typer/index.mdx b/docs/platforms/python/integrations/typer/index.mdx index 9f7b40865ba7a..4498490d6f3f0 100644 --- a/docs/platforms/python/integrations/typer/index.mdx +++ b/docs/platforms/python/integrations/typer/index.mdx @@ -3,7 +3,7 @@ title: Typer description: Learn how to use Sentry to capture Typer exceptions. --- -The `TyperIntegration` captures exceptions raised when using Typer CLI applications. +The `TyperIntegration` captures exceptions raised when using [Typer CLI](https://typer.tiangolo.com/) applications. ## Install @@ -49,4 +49,4 @@ if __name__ == "__main__": ``` When you run this, Sentry will capture the `ZeroDivisionError` from the `main()` -function and you will be able to see it on [sentry.io](https://sentry.io). +function and you'll be able to see it on [sentry.io](https://sentry.io).