magic-sentry
Skill3 starsChanged 17 days agoMITView on GitHub
Boot Sentry before Magic.init, report HTTP failures, track the user and mask URL tokens with magic_sentry.
- Reads credentials
1 other project uses a version of this.
Adopted by
Most recently taken up by
- anilcancakir/aiword for word, first seen Nov 16, 2026
Other versions1 project uses a version of this.
Word for word · 1
- anilcancakir/ai★ 3100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository19 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- crumbsSkill
- dowelSkill
- flutter-reviewSkill
- magic-analyticsSkill
- magic-deeplinkSkill
- magic-deviceSkill
- magic-devtoolsSkill
- magic-encryptionSkill
- magic-frameworkSkill
- magic-local-storageSkill
- magic-notificationsSkill
- magic-paymentsSkill
- magic-pickerSkill
- magic-social-authSkill
- magic-socketSkill
- magic-starterSkill
- tapirSkill
- wind-uiSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
Never call WidgetsFlutterBinding.ensureInitialized() before run.
- Very specific: line 28
Import configureSentry from the app's own config/sentry.dart.
- Very specific: line 31
Call MagicSentry.installErrorWidgetBreadcrumb() once, early in appRunner.
- Very specific: line 38
Leave captureFailedRequests off on sentry_dio's addSentry().
- Very specific: line 50
Keep secrets out of breadcrumbData and transaction extra.
- Distinctive: line 123
No mocking library is needed, and without a DSN nothing needs setting up.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
magic_sentry
Sentry for a Magic app. MagicSentry.run starts the SDK before Magic.init in one web-safe zone; SentryServiceProvider then wires an HTTP failure interceptor, the scope user, event breadcrumbs and the navigator observer; SentryTokenScrubber masks URL-borne tokens before anything is sent. Every part is inert without a DSN. The package is generic on purpose: it has no user model, team or tag, and app data reaches it through callbacks.
This skill covers magic_sentry only. The Magic framework itself (container, facades, routing, Auth) is the magic-framework skill, and Sentry's own SDK is Sentry's documentation.
Install
flutter pub add magic_sentry
dart run magic:dowel plugin:install magic_sentryRequires Dart >=3.13, Flutter >=3.47 and magic ^1.0.0, with sentry_flutter and sentry_dio ^10.4.0 pulled in (Android minSdk 24, iOS 15, macOS 12). The installer publishes lib/config/sentry.dart and registers the provider in lib/config/app.dart; it cannot rewrite main(). Import only the barrel: package:magic_sentry/magic_sentry.dart. package:magic_sentry/cli.dart (MagicSentryDowelProvider, no commands) is for dowel's plugin:install, never for app code.
Boot rules
MagicSentry.run(configure: configureSentry, appRunner: _boot)is the entire body ofmain(), andMagic.initplusrunAppgo insideappRunner. Sentry starts first so a boot failure is reported, and one zone keeps Flutter web from raising a "Zone mismatch".- Never call
WidgetsFlutterBinding.ensureInitialized()beforerun. It createsSentryWidgetsFlutterBinding, and an existing plain binding is kept, which switches frame tracking off. configureruns beforeConfigexists, so read.envthroughEnv, neverConfig.get. The publishedlib/config/sentry.dartalready does, andinstall.yamlhas nomagic.config_factorykey for that reason.- Import
configureSentryfrom the app's ownconfig/sentry.dart. The barrel exports no config names, and a package copy would make the documentedmain()an ambiguous import. - An empty
SENTRY_DSNis valid and means off:Sentry.isEnabledis false,boot()returns early,appRunnerstill runs.sentryDsnis aString, never null, becauseSentry.initthrows on a null DSN. sendDefaultPiiand session replay stay off inconfigureSentry. An app that wants either sets it in its ownconfigure, never from.env.SENTRY_RELEASEis read from the bundled.env, not from--dart-define.- Call
MagicSentry.installErrorWidgetBreadcrumb()once, early inappRunner; it tags a build error that replaced the interface.
Provider rules
- Register
SentryServiceProvider<T>in theproviderslist oflib/config/app.dart.boot()addsSentryNavigatorObservertoMagicRouter, which refuses one after it has built itsrouterConfig, so wiring it later fails. userIdturns user reporting on;userEmailanduserExtrasare optional.Tis the app's ownAuthenticatablemodel. Read straight off the model: the callbacks run on every auth change, so no network call. Return aStringfromuserId:Model.idisdynamicand often anint, which throws when the context installs, so writeuser.id?.toString() ?? ''.Auth.stateNotifierdrives the user, so sign-out sets it to null.userExtraskeys replace the previous call's, so a team switch leaks no old tag.- Leave
captureFailedRequestsoff onsentry_dio'saddSentry().SentryNetworkInterceptoris the one layer that reports HTTP failures, and its events carry a stack trace at your call site and an endpoint fingerprint.
HTTP rules
Magic's Http never throws, so a failure is a MagicResponse value and only the interceptor reports it. Status 0 (no response) and >= 500 become an event, fingerprinted ['http', method, endpoint, status]; anything else is a warning breadcrumb, because a 4xx is usually the product working. The endpoint has its query dropped and numeric or UUID segments collapsed to {id} so one endpoint is one issue. One event per distinct METHOD endpoint status per session, then (repeat) breadcrumbs. Do not use normalizeEndpoint to make a URL safe to send: it collapses ids only, and SentryTokenScrubber.scrubApiUrl masks what is left.
Scrubbing rules
run installs SentryTokenScrubber after configure, so it runs first in beforeSend, beforeSendTransaction, beforeSendSpan, beforeBreadcrumb and beforeSendLog and hands the masked value to the app's hook. It masks query values whose key contains token, password, secret, signature, credential or api_key; path segments bound to a route param whose name contains token (from MagicRouter.instance.allRoutes, groups included); and on an http breadcrumb or span URL any 32+ character opaque segment, a UUID excepted. It only masks, fails closed to [Filtered], and covers streamed spans because sentry_flutter 10 streams by default and never builds a transaction.
- Set app hooks inside
configure. A hook assigned afterSentryFlutter.initreplaces the scrubber. - Name a credential route param with
tokenin it (:resetToken), or the route rule does not see it. - Keep secrets out of
breadcrumbDataand transactionextra; the first is sent as written apart from masking, the second is not scrubbed.
Recipes
Wire the app:
import 'package:magic/magic.dart';
import 'package:magic_sentry/magic_sentry.dart';
import 'package:material_ui/material_ui.dart';
import 'config/app.dart';
import 'config/sentry.dart'; // published by plugin:install
void main() {
MagicSentry.run(configure: configureSentry, appRunner: _boot);
}
Future<void> _boot() async {
MagicSentry.installErrorWidgetBreadcrumb();
await Magic.init(
configFactories: [
() => appConfig,
// Keep every other config factory your main() already passes.
],
);
runApp(MagicApplication(title: 'My App'));
}Report the user and tag a team (User and its plan are the app's own):
import 'package:magic_sentry/magic_sentry.dart';
import '../app/models/user.dart';
// The entry in the providers list of lib/config/app.dart.
final List<Object> providers = [
(app) => SentryServiceProvider<User>(
app,
userId: (user) => user.id?.toString() ?? '',
userEmail: (user) => user.email,
userExtras: (user) => {'plan': user.plan},
),
];Make an event leave a breadcrumb:
import 'package:magic/magic.dart';
class InvoicePaid extends MagicEvent implements ReportsBreadcrumb {
InvoicePaid(this.invoiceId);
final String invoiceId;
@override
String get breadcrumbCategory => 'billing';
@override
String get breadcrumbMessage => 'Invoice paid';
@override
Map<String, Object?> get breadcrumbData => {'invoice_id': invoiceId};
}Testing
No mocking library is needed, and without a DSN nothing needs setting up. To read the scope user, bind a hub with a placeholder DSN and undo it afterwards:
import 'package:flutter_test/flutter_test.dart';
import 'package:magic/magic.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
void main() {
setUp(() async {
MagicApp.reset();
Magic.flush();
await Sentry.init(
(options) => options.dsn = 'https://public@o0.ingest.sentry.io/0',
);
});
tearDown(() async {
Auth.unfake();
await Sentry.close();
});
test('the scope starts with no user', () async {
SentryUser? user;
await Sentry.configureScope((scope) => user = scope.user);
expect(user, isNull);
});
}SentryNetworkInterceptor.dispositionFor, normalizeEndpoint, SentryUserContext.userFor and EventBreadcrumbs.breadcrumbFor are plain functions. The scrubber's route rule reads MagicRouter.instance.allRoutes, so register routes with MagicRoute.page first and call MagicRouter.reset() in tearDown. SentryNetworkInterceptor.reportedFailures is a static set that survives between tests: clear it in setUp.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

