shared_prefs_telemetry 0.1.1 copy "shared_prefs_telemetry: ^0.1.1" to clipboard
shared_prefs_telemetry: ^0.1.1 copied to clipboard

A Flutter package that automatically reads SharedPreferences data and sends it to a telemetry server at app launch.

SharedPrefs Telemetry #

A Flutter package that automatically reads SharedPreferences data and sends it to a telemetry server at app launch.

Features #

  • Automatic Initialization: Automatically triggers at app launch
  • Privacy Controls: Exclude sensitive keys from telemetry
  • Configurable: Customizable server URL, API key, timeout, and logging
  • Error Handling: Graceful error handling with optional logging
  • Cross-Platform: Works on iOS, Android, and other Flutter platforms

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  shared_prefs_telemetry: ^0.1.0

Usage #

Basic Setup #

Initialize the telemetry package in your main() function:

import 'package:flutter/material.dart';
import 'package:shared_prefs_telemetry/shared_prefs_telemetry.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  // Initialize telemetry
  await SharedPrefsTelemetry.initialize(
    TelemetryConfig(
      serverUrl: 'https://your-telemetry-server.com/api/collect',
      apiKey: 'your-api-key-here', // Optional
      enableLogging: true, // Optional, default: false
      excludeKeys: ['password', 'token'], // Optional, default: []
      timeout: const Duration(seconds: 15), // Optional, default: 10s
    ),
  );
  
  runApp(MyApp());
}

Configuration Options #

  • serverUrl (required): The URL of your telemetry server
  • apiKey (optional): API key for authentication
  • enableLogging (optional): Enable debug logging (default: false)
  • excludeKeys (optional): List of SharedPreferences keys to exclude from telemetry
  • timeout (optional): HTTP request timeout (default: 10 seconds)

Data Format #

The package sends data in the following JSON format:

{
  "timestamp": "2023-12-01T10:30:00.000Z",
  "platform": "android",
  "sharedPreferences": {
    "user_name": "john_doe",
    "theme_mode": "dark",
    "notification_enabled": true,
    "last_login": "2023-11-30T15:20:00.000Z"
  }
}

Privacy Considerations #

⚠️ Important: This package reads ALL SharedPreferences data by default. Make sure to:

  1. Use the excludeKeys parameter to exclude sensitive data
  2. Comply with your app's privacy policy and applicable laws (GDPR, CCPA, etc.)
  3. Inform users about data collection in your privacy policy
  4. Consider implementing user consent mechanisms

Example #

See the example/ directory for a complete working example.

License #

This project is licensed under the MIT License.

0
likes
125
points
50
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package that automatically reads SharedPreferences data and sends it to a telemetry server at app launch.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

firebase_core, firebase_remote_config, flutter, http, shared_preferences

More

Packages that depend on shared_prefs_telemetry