Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .ai/pr-descriptions/OSS-381.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!--
Compact PR template (pilot: flutter-template)
1. Pick your risk size first (section 1). It decides how much evidence you provide.
2. Replace every TODO. Not applicable? Write "n/a" with a short reason.
3. Do not remove these comment blocks; they are invisible in the rendered PR.
-->

## 1. Risk: M

<!--
L: at least one of
- auth, sessions, secure storage or tokens
- payments or personal data
- database schema or migration (lib/database)
- navigation, routes or deeplinks (lib/navigator)
- new dependency in pubspec, or new permission (Info.plist, AndroidManifest)
- shared core: lib/styles, lib/widget, lib/di, lib/webservice
- flavors, signing or fastlane
M: new behaviour or a new flow inside one feature, or platform-specific behaviour
S: copy, styling, internal refactor with existing tests, small bugfix with a regression test
The reviewer may raise the size, never lower it.
-->

**Why this size?**

The Sentry filter is wired into all four flavor entrypoints (`main`, `main_alpha`, `main_beta`, `main_prod`) The `SentryEventFilter` is registered in `lib/di`, and it decides which events reach Sentry in production.

Therefore specific filter events are created. So we can determine if a background or foreground event is triggered. If an event matches one of the rules we can drop it. So it doesn't reach Sentry.

<!-- hint: the real change is the per-flavor wiring in lib/main*.dart (minimum level: dev debug, alpha and beta warning, prod error). The drop rule list is still the example that never matches, so no event is dropped yet. -->
<!-- hint: this branch also contains unrelated changes: the pr-template, pre-push hook and pr-description skill, regenerated *.mocks.dart in 8 test files, a reordered main_navigator.navigator.dart, and an end-of-file change in .gitignore. -->

**Where should the reviewer look, and what am I unsure about?**

Most important files are in the `lib/utilsentry/`-folder.
This was tested in Blue-bike and was shown succesfull.

## 2. What changed and why

**Jira:** OSS-381: https://github.com/icapps/flutter-template/issues/381

Sentry is cluttered with a lot of events that we do not need. Therefore we created a filter.

## 3. Evidence: Flow / Proof of Delivery

<!--
One row per acceptance criterion from the ticket. "Evidence" is a link or a test name, not a claim.
Minimum evidence per size:
S: a test or screenshot per criterion
M: S + a screen recording or Maestro flow of the main flow + the key edge cases
L: M + tested on both iOS and Android (device/emulator + OS version)
-->

| Acceptance criterion | Evidence (test / screenshot / recording / Maestro) | Covered? |
|---|---|---|
<!-- hint: no acceptance criteria were available. Paste them from the ticket, one row each. Tests that already exist and could serve as evidence:
test/util/sentry/sentry_event_filter_test.dart (rule matching, minimum level)
test/util/sentry/background_sentry_event_filter_test.dart (rules only apply in the background)
test/util/sentry/combined_sentry_event_filter_test.dart (background + general filter combined)
test/util/sentry/general_sentry_event_filter_test.dart, sentry_drop_rule_test.dart, observability_error_filter_test.dart
test/util/lifecycle/lifecycle_util_test.dart (background detection)
No test covers the wiring in lib/main*.dart (beforeSend and the per-flavor minimum level). -->
See test scenarios

**Edge cases tested (M and L):**

No edge cases

**Tested on (M and L):** Simulator and temporariy crash.

**Does anything deviate from the ticket?** No

<!-- Ready for review when every field is filled in. The pre-push hook and the pipeline check this. -->
54 changes: 54 additions & 0 deletions .bitbucket/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!--
Compact PR template (pilot: flutter-template)
1. Pick your risk size first (section 1). It decides how much evidence you provide.
2. Replace every TODO. Not applicable? Write "n/a" with a short reason.
3. Do not remove these comment blocks; they are invisible in the rendered PR.
-->

## 1. Risk: TODO (S / M / L)

<!--
L: at least one of
- auth, sessions, secure storage or tokens
- payments or personal data
- database schema or migration (lib/database)
- navigation, routes or deeplinks (lib/navigator)
- new dependency in pubspec, or new permission (Info.plist, AndroidManifest)
- shared core: lib/styles, lib/widget, lib/di, lib/webservice
- flavors, signing or fastlane
M: new behaviour or a new flow inside one feature, or platform-specific behaviour
S: copy, styling, internal refactor with existing tests, small bugfix with a regression test
The reviewer may raise the size, never lower it.
-->

**Why this size?** TODO (1 sentence, name the criterion)

**Where should the reviewer look, and what am I unsure about?** TODO

## 2. What changed and why

**Jira:** TODO (link)

TODO (2 to 4 sentences, in your own words. What changes for the user, what changes in the code, and why this way?)

## 3. Evidence: Flow / Proof of Delivery

<!--
One row per acceptance criterion from the ticket. "Evidence" is a link or a test name, not a claim.
Minimum evidence per size:
S: a test or screenshot per criterion
M: S + a screen recording or Maestro flow of the main flow + the key edge cases
L: M + tested on both iOS and Android (device/emulator + OS version)
-->

| Acceptance criterion | Evidence (test / screenshot / recording / Maestro) | Covered? |
|---|---|---|
| TODO | TODO | Yes / No / Partial |

**Edge cases tested (M and L):** TODO (e.g. no network, empty state, error message, long text, rotation)

**Tested on (M and L):** TODO (device/emulator + OS version)

**Does anything deviate from the ticket?** TODO (if not: "No")

<!-- Ready for review when every field is filled in. The pre-push hook and the pipeline check this. -->
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ Gemfile.lock

# Fvm
.fvm/
/test/coverage_helper_test.dart
/test/coverage_helper_test.dart
65 changes: 65 additions & 0 deletions .opencode/skills/pr-description/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
name: pr-description
description: "PR description preparation: builds `.ai/pr-descriptions/<TICKET>.md` from the branch, the Jira ticket and the diff, using `.bitbucket/pull_request_template.md`, and reports gaps for the author. Use when a branch is ready for a pull request, or when the PR description must be refreshed after more commits."
metadata:
domain: "delivery"
version: "0.2"
---

# PR description

Prepare the pull request description so the reviewer can spend time on what matters. The skill fills what the repository can prove and leaves what only the author knows as `TODO`. It never presents a guess as evidence.

`.bitbucket/pull_request_template.md` is the single source of the structure: a risk size (S, M, L), "What changed and why", and an evidence table. Read it every run; never copy its sections into this skill or into a generated file from memory. The `tool/hooks/pre-push` hook and the pipeline check the finished file.

## 1. Resolve the ticket and the output path

1. Read the branch with `git branch --show-current`.
2. Take the first match of `[A-Z][A-Z0-9]+-[0-9]+` (uppercase only, so `fix/dark-mode-2` is not a ticket).
3. The output path is `.ai/pr-descriptions/<TICKET>.md`.

No match, or a detached HEAD: stop and ask the author for the ticket key and to rename the branch. Do not invent one.

Done when the ticket key and the output path are known.

## 2. Gather evidence

- **Diff**: base is `git merge-base HEAD origin/<default-branch>`; read the commit list and `git diff --stat` for the range.
- **Ticket**: the description and acceptance criteria from Jira through the `tracker` skill when it is configured. Otherwise ask the author to paste the acceptance criteria. Do not reconstruct criteria from the diff.
- **Tests**: the test files the diff adds or changes, with the test names (`test(`, `testWidgets(`, `group(`).

Done when each of the three is read, or marked unavailable with the reason.

## 3. Propose the risk size

Apply the criteria in the template's risk comment to the diff. State the size and the criterion that decided it. One **L** criterion makes it L, whatever the line count. The author may raise the size, never lower it below what a criterion demands.

## 4. Fill the template

Fill only what the evidence supports. Everything else keeps its `TODO`.

| Field | Rule |
|---|---|
| Risk and "Why this size?" | The proposal from step 3, naming the criterion. |
| "Where should the reviewer look, and what am I unsure about?" | Keep `TODO`. You may add one `<!-- hint: ... -->` comment naming the largest or most unusual change. |
| Jira | The ticket link. |
| What changed and why | Keep `TODO`. It must be the author's own words. |
| Acceptance criteria rows | Copy each criterion verbatim. Fill "Evidence" with a test file and test name only when a test in the diff covers it, and mark "Covered?" **Yes** only then. Otherwise keep `TODO`. |
| Edge cases, "Tested on", recordings, Maestro | Keep `TODO`. Only the author ran them. |

For size S, the evidence minimum is a test or screenshot per criterion; for M and L the template asks for more. Do not weaken the template's minimum.

If the output file already exists, keep every line the author changed and update only the lines derived from evidence. Show the author what changed.

Done when the file exists at the output path and every remaining `TODO` is a field only the author can answer.

## 5. Report the gaps

End with a short list in the chat, not only in the file:

- acceptance criteria no test in the diff covers
- remaining `TODO` fields, grouped by section
- evidence the chosen size still requires (recording, Maestro flow, second platform)
- a diff that is unusually large or mixes unrelated changes; suggest splitting it

Do not push, open the pull request, or edit the ticket.
2 changes: 2 additions & 0 deletions lib/di/injectable.config.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:flutter_template/util/inspector/database_inspector.dart';
import 'package:flutter_template/util/inspector/local_storage_inspector.dart';
import 'package:flutter_template/util/inspector/niddler.dart';
import 'package:flutter_template/util/logging/sentry_performance_logger.dart';
import 'package:flutter_template/util/sentry/sentry_event_filter.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

Future<void> main() async {
Expand All @@ -31,9 +32,11 @@ Future<void> main() async {
await di.configureDependencies(Environments.dev);
await addDatabaseInspector();
await initAllStorageInspectors();

final sentryEventFilter = di.getIt<SentryEventFilter>()..init(minimumLevelToKeep: SentryLevel.debug);
await SentryFlutter.init(
(options) => SentryConfig.development(options),
(options) => SentryConfig.development(
options..beforeSend = sentryEventFilter.beforeSend,
),
appRunner: () {
di.getIt<SentryPerformanceLogger>().startAppLoadTransaction();
runApp(const MyApp());
Expand Down
6 changes: 5 additions & 1 deletion lib/main_alpha.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flutter_template/main_common.dart';
import 'package:flutter_template/util/env/sentry_config.dart';
import 'package:flutter_template/util/env/flavor_config.dart';
import 'package:flutter_template/util/logging/sentry_performance_logger.dart';
import 'package:flutter_template/util/sentry/sentry_event_filter.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

Future<void> main() async {
Expand All @@ -24,8 +25,11 @@ Future<void> main() async {
values: values,
);
await configureDependencies(Environments.prod);
final sentryEventFilter = di.getIt<SentryEventFilter>()..init(minimumLevelToKeep: SentryLevel.warning);
await SentryFlutter.init(
(options) => SentryConfig.alpha(options),
(options) => SentryConfig.alpha(
options..beforeSend = sentryEventFilter.beforeSend,
),
appRunner: () {
di.getIt<SentryPerformanceLogger>().startAppLoadTransaction();
runApp(const MyApp());
Expand Down
8 changes: 6 additions & 2 deletions lib/main_beta.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import 'package:flutter_template/main_common.dart';
import 'package:flutter_template/util/env/sentry_config.dart';
import 'package:flutter_template/util/env/flavor_config.dart';
import 'package:flutter_template/util/logging/sentry_performance_logger.dart';
import 'package:flutter_template/util/sentry/sentry_event_filter.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

Future<void> main() async {
await wrapMain(() async {
const values = FlavorValues(
baseUrl: 'https://jsonplaceholder.typicode.com/',
logNetworkInfo: false,
showFullErrorMessages: true,
showFullErrorMessages: true,
dsn: '',
);
FlavorConfig(
Expand All @@ -24,8 +25,11 @@ Future<void> main() async {
values: values,
);
await configureDependencies(Environments.prod);
final sentryEventFilter = di.getIt<SentryEventFilter>()..init(minimumLevelToKeep: SentryLevel.warning);
await SentryFlutter.init(
(options) => SentryConfig.beta(options),
(options) => SentryConfig.beta(
options..beforeSend = sentryEventFilter.beforeSend,
),
appRunner: () {
di.getIt<SentryPerformanceLogger>().startAppLoadTransaction();
runApp(const MyApp());
Expand Down
6 changes: 5 additions & 1 deletion lib/main_prod.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter_template/main_common.dart';
import 'package:flutter_template/util/env/sentry_config.dart';
import 'package:flutter_template/util/env/flavor_config.dart';
import 'package:flutter_template/util/logging/sentry_performance_logger.dart';
import 'package:flutter_template/util/sentry/sentry_event_filter.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

Future<void> main() async {
Expand All @@ -26,8 +27,11 @@ Future<void> main() async {
values: values,
);
await configureDependencies(Environments.prod);
final sentryEventFilter = di.getIt<SentryEventFilter>()..init(minimumLevelToKeep: SentryLevel.error);
await SentryFlutter.init(
(options) => SentryConfig.prod(options),
(options) => SentryConfig.prod(
options..beforeSend = sentryEventFilter.beforeSend,
),
appRunner: () {
di.getIt<SentryPerformanceLogger>().startAppLoadTransaction();
runApp(const MyApp());
Expand Down
22 changes: 11 additions & 11 deletions lib/navigator/main_navigator.navigator.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions lib/util/lifecycle/lifecycle_util.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:flutter/widgets.dart';

class LifecycleUtil {
static bool get appIsInBackground {
final state = WidgetsBinding.instance.lifecycleState;

return state == AppLifecycleState.paused || state == AppLifecycleState.hidden;
}
}
Loading
Loading