ispectify_riverpod 7.0.0-dev2 copy "ispectify_riverpod: ^7.0.0-dev2" to clipboard
ispectify_riverpod: ^7.0.0-dev2 copied to clipboard

Riverpod ProviderObserver for ISpect with add, update, dispose, fail, and redacted metadata logging.

ispectify_riverpod plugs the riverpod and flutter_riverpod ecosystem into the ISpect toolkit. One ProviderObserver forwards every provider add, update, dispose, and failure through the log pipeline, so the whole provider lifecycle shows up in the log viewer.

  • Adds, updates, disposes, and failures with coarse structural summaries by default.
  • Per-provider filtering. Mute noisy providers without touching their code.
  • Zero configuration. Hand the observer to ProviderScope (or ProviderContainer) and you are done.

Install #

dependencies:
  flutter_riverpod: ^2.5.0
  ispectify: ^7.0.0-dev2
  ispectify_riverpod: ^7.0.0-dev2

Quick start #

import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:ispect/ispect.dart';
import 'package:ispectify_riverpod/ispectify_riverpod.dart';

ISpect.run(
  () => runApp(
    ProviderScope(
      observers: [ISpectRiverpodObserver(logger: ISpect.logger)],
      child: const MyApp(),
    ),
  ),
);

The observer emits logs under the riverpod-add, riverpod-update, riverpod-dispose, and riverpod-fail log-type keys, each with a dedicated icon, palette entry, and localized description in the log viewer. Filter them in the debug panel or through ISpectSettingsState.disabledLogTypes.

Settings #

ISpectRiverpodSettings controls which lifecycle events are captured and whether provider values are written to trace meta. printValues defaults to false, so values and family arguments use coarse structural labels such as String, int, List, or Map; other caller-owned objects use Object. Unnamed providers use the family label Provider. These summaries do not call application runtimeType or toString() methods.

const settings = ISpectRiverpodSettings(
  printAdds: true,
  printUpdates: true,
  printDisposes: true,
  printFails: true,
  printValues: false,       // coarse structural summaries — default
  enableRedaction: true,    // route values through RedactionService when set
);

Presets #

// Logs disabled entirely.
ISpectRiverpodObserver(settings: ISpectRiverpodSettings.silent);

// Lifecycle creation, disposal, and failures — updates are muted.
ISpectRiverpodObserver(settings: ISpectRiverpodSettings.minimal);

// Reduces values to coarse structural labels. Use when provider state may
// carry PII and you still want lifecycle visibility.
ISpectRiverpodObserver(settings: ISpectRiverpodSettings.compact);

// Explicit local-development value capture; redaction remains enabled.
ISpectRiverpodObserver(settings: ISpectRiverpodSettings.development);

Filtering noisy providers #

ISpectRiverpodObserver(
  // Drop everything for providers whose name matches one of these patterns.
  filters: [RegExp(r'cache'), 'metrics'],
  settings: ISpectRiverpodSettings(
    // Or skip individual updates by inspecting the values.
    updateFilter: (provider, previous, next) =>
        previous != next,
  ),
);

Data redaction #

Sensitive data is masked before it reaches logs or observers. Redaction is on by default. The built-in rules cover auth headers, tokens, passwords, API keys, cookies, common PII (SSN, passport, driver's license), financial data (credit cards, IBAN), and phone numbers.

The default policy is a single source of truth. Configure it once and core logs, traces, persistence, network and database adapters, BLoC and Riverpod observers, supported exports, clipboard helpers, and cURL generation resolve it when each diagnostic operation runs.

Redaction works best paired with focused capture. Keep body and header logging off unless you actually need the payload, and register project-specific keys for the business identifiers only your application understands.

Global configuration #

import 'package:ispectify/ispectify.dart';

ISpectRedaction.configure(
  service: RedactionService(
    additionalSensitiveKeys: {
      'x-custom-secret',
      'internal_token',
    },
    additionalSensitiveKeyPatterns: [
      RegExp(r'my_app_secret_\w+', caseSensitive: false),
    ],
    fullyMaskedKeys: {'filename'},
    placeholder: '***',
    visibleEdgeLength: 3,
  ),
);

additionalSensitiveKeys and additionalSensitiveKeyPatterns extend the built-in policy. Use sensitiveKeys or sensitiveKeyPatterns only when you intentionally want to replace the corresponding defaults:

final replacementPolicy = RedactionService(
  sensitiveKeys: {
    'x-custom-secret',
    'internal_token',
  },
  sensitiveKeyPatterns: [
    RegExp(r'my_app_secret_\w+', caseSensitive: false),
  ],
);

Flutter apps can pass the same policy as ISpect.run(redactionService: ...); ISpect.dispose() restores the policy that was active before that run. An explicit RedactionService supplied to one integration stays local and takes precedence over the global policy. Existing integrations without an explicit service pick up later global reconfiguration. The policy is scoped to the current Dart isolate.

Local exceptions #

final redactor = RedactionService(
  ignoredKeys: {'mobile', 'platform_token'},
  ignoredValues: {'<test-token>', 'public-api-key'},
);

Disabling #

ISpectRedaction.configure(enabled: false) is the global content-masking opt-out. Each interceptor also accepts enableRedaction: false on its settings object for a local opt-out. Size limits, non-executing snapshots, private-storage checks, and the compile-time ISPECT_ENABLED gate remain enforced.

Only disable redaction in isolated local or deterministic test environments. Exported sessions and observer events should be handled according to the data they contain.

Supply a custom RedactionService to mask sensitive provider state:

ISpectRiverpodObserver(
  logger: ISpect.logger,
  settings: ISpectRiverpodSettings(
    redactor: RedactionService(
      additionalSensitiveKeys: {'access-token'},
    ),
  ),
);

The ISpect toolkit #

ISpect is a modular monorepo. Pick the packages your project needs. Each one works on its own.

Package What it does
ispect Flutter UI: debug panel, log viewer, navigation observer, inspector integration.
ispect_layout Visual layout inspector with sizes, constraints, decorations, compare mode, and a color picker.
ispectify Pure-Dart logging core: typed log entries, filtering, tracing, observers.
ispectify_dio Dio HTTP interceptor with automatic redaction.
ispectify_http http package interceptor with automatic redaction.
ispectify_ws Provider-agnostic WebSocket capture (any client) with automatic redaction.
ispectify_db Database operation tracing for SQL, ORMs, and KV stores.
ispectify_bloc BLoC event, state, transition, and error observer.
ispectify_riverpod Riverpod provider add, update, dispose, and failure observer.

Contributing #

Contributions are welcome. See CONTRIBUTING.md for guidelines, and open issues or pull requests at the ISpect repository.

License #

MIT. See LICENSE.


2
likes
0
points
1.22k
downloads

Publisher

unverified uploader

Weekly Downloads

Riverpod ProviderObserver for ISpect with add, update, dispose, fail, and redacted metadata logging.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

ispectify, meta, riverpod

More

Packages that depend on ispectify_riverpod