initialize static method

Future<void> initialize({
  1. String channel = 'production',
  2. String branch = 'main',
  3. String? deviceId,
  4. String? runtimeFingerprint,
  5. BloomUpdateClientAdapter? adapter,
  6. WatchdogStorage? watchdogStorage,
  7. String? currentPatchId,
  8. bool autoHookErrorHandlers = true,
})

Initializes the BloomUpdates runtime engine.

Implementation

static Future<void> initialize({

  String channel = 'production',
  String branch = 'main',
  String? deviceId,
  String? runtimeFingerprint,
  BloomUpdateClientAdapter? adapter,
  WatchdogStorage? watchdogStorage,
  String? currentPatchId,
  bool autoHookErrorHandlers = true,
}) async {
  _activeChannel = channel;
  _activeBranch = branch;
  _deviceId = deviceId ?? _deviceId;

  // Automatically derive runtime fingerprint from environment if not explicitly provided
  _localRuntimeFingerprint = runtimeFingerprint ??
      BloomRuntimeFingerprint.current().computeHash();

  if (adapter != null) _adapter = adapter;

  _watchdog = StartupCrashWatchdog(
    storage: watchdogStorage,
    onRollbackTriggered: (faultyId, reason) {
      rollback(reason: reason);
    },
  );

  _watchdog.recordAppLaunch(currentPatchId);

  // Auto-hook startup error handlers for crash detection
  if (autoHookErrorHandlers) {
    _hookStartupErrorHandlers();
  }

  logger.info('BloomUpdates: Initialized (Channel: "$_activeChannel", Fingerprint: "${_localRuntimeFingerprint.length >= 8 ? _localRuntimeFingerprint.substring(0, 8) : _localRuntimeFingerprint}...")');
}