Skip to content
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

docs(flutter): Use sentry flutter init in samples #11858

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

denrase
Copy link
Collaborator

@denrase denrase commented Nov 18, 2024

DESCRIBE YOUR PR

Tell us what you're changing and why. If your PR resolves an issue, please link it so it closes automatically.

Add samples that use SentryFlutter.init instead of Sentry.init.

Relates to getsentry/sentry-dart#2383

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.

  • Urgent deadline (GA date, etc.):
  • Other deadline:
  • None: Not urgent, can wait up to 1 week+

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it.
    Thanks in advance for your help!

PRE-MERGE CHECKLIST

Make sure you've checked the following before merging your changes:

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

EXTRA RESOURCES

Copy link

vercel bot commented Nov 18, 2024

@denrase is attempting to deploy a commit to the Sentry Team on Vercel.

A member of the Team first needs to authorize it.

@denrase denrase changed the title dos(flutter): Use sentry flutter init in samples docs(flutter): Use sentry flutter init in samples Nov 18, 2024
Copy link
Contributor

@buenaflor buenaflor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments, I think we can improve the code snippets in general to reduce the size of the snippets

platform-includes/configuration/allow-urls/flutter.mdx Outdated Show resolved Hide resolved
platform-includes/configuration/allow-urls/flutter.mdx Outdated Show resolved Hide resolved
platform-includes/configuration/allow-urls/flutter.mdx Outdated Show resolved Hide resolved
Copy link

vercel bot commented Nov 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 19, 2024 6:40pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
changelog ⬜️ Ignored (Inspect) Visit Preview Nov 19, 2024 6:40pm
develop-docs ⬜️ Ignored (Inspect) Visit Preview Nov 19, 2024 6:40pm

@denrase
Copy link
Collaborator Author

denrase commented Nov 19, 2024

@buenaflor I noticed some formatting issues and one codeblock is still using Sentry.init. Will udate and notify you.

Copy link
Contributor

@buenaflor buenaflor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't add comment everywhere but if possible inline the callbacks to make the code snippets a bit more digestible

Comment on lines +2 to +14
FutureOr<SentryEvent?> beforeSend(SentryEvent event, Hint hint) async {
if (event.throwable is DatabaseException) {
event = event.copyWith(fingerprint: ['database-connection-error']);
}
return event;
}

await Sentry.init(
(options) {
options.beforeSend = beforeSend;
},
);
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep it concise, don't create another function but do it inline e.g

options.beforeSend = (event, hint) {
	// etc..
	return event;
}

Comment on lines +2 to +10
FutureOr<SentryEvent?> beforeSend(SentryEvent event, Hint hint) async {
return hint is MyHint ? null : event;
}

await SentryFlutter.init(
(options) {
options.beforeSend = beforeSend;
},
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as the other about keeping concise

Comment on lines +2 to +13
FutureOr<SentryEvent?> beforeSend(SentryEvent event, Hint hint) async {
// Modify the event here:
event = event.copyWith(serverName: null); // Don't send server names.
return event;
}

await SentryFlutter.init(
(options) {
options.beforeSend = beforeSend;
},
);
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as the other about keeping concise

Comment on lines +2 to +9
import 'package:flutter/widgets.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

Future<void> main() async {
// Capture only 25% of events
await SentryFlutter.init((options) => options.sampleRate = 0.25);
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need the import and add void main? at this point the user should've gone through the intro anyway, imo I'd prefer this and highlight the sampleRate line

await SentryFlutter.init(
  (options) {
		// Capture only 25% of events
    options.sampleRate = 0.25;
  },
);

wdyt

(options) {
options.attachViewHierarchy = true;
},
appRunner: () => runApp(MyApp()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
appRunner: () => runApp(MyApp()),

don't think we need it necessarily

Comment on lines +1 to +26
```dart
// Option 1: Retrieving SentryId from beforeSend
SentryId sentryId = SentryId.empty();

await SentryFlutter.init((options) {
options.beforeSend = (event, hint) async {
sentryId = event.eventId;
return event;
};
});

// Option 2: Retrieving SentryId from the method capturing the event
SentryId sentryId = Sentry.captureMessage("My message");

// Option 3: Retrieving SentryId from the beforeSend callback
SentryId sentryId = Sentry.lastEventId;

final userFeedback = SentryUserFeedback(
eventId: sentryId,
comments: 'Hello World!',
email: '[email protected]',
name: 'John Doe',
);

Sentry.captureUserFeedback(userFeedback);
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will we need this? I think we are going to update the feedback docs anyway: #11756

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants