registerIntelliToggleProvider function

Future<void> registerIntelliToggleProvider(
  1. Map<String, dynamic> config
)

Registers the IntelliToggle provider with DartStream's feature flag manager.

Example usage:

registerIntelliToggleProvider({
  'clientId': Platform.environment['INTELLITOGGLE_CLIENT_ID']!,
  'clientSecret': Platform.environment['INTELLITOGGLE_CLIENT_SECRET']!,
  'tenantId': Platform.environment['INTELLITOGGLE_TENANT_ID']!,
  'environment': 'production', // optional
});

Implementation

Future<void> registerIntelliToggleProvider(
    Map<String, dynamic> config) async {
  final clientId = _requireString(config, 'clientId');
  final clientSecret = _requireString(config, 'clientSecret');
  final tenantId = _requireString(config, 'tenantId');
  final environment = _optionalString(config, 'environment',
      fallback: 'production');

  // Select config preset based on environment
  final DSIntelliToggleConfig providerConfig;
  if (environment == 'development') {
    providerConfig = DSIntelliToggleConfig.development();
  } else {
    providerConfig = DSIntelliToggleConfig.production();
  }

  final provider = DSIntelliToggleProvider(
    clientId: clientId,
    clientSecret: clientSecret,
    tenantId: tenantId,
    config: providerConfig,
  );

  await provider.initialize();

  // Register provider without metadata (not supported in feature flags yet)
  DSFeatureFlagManager.registerProvider('intellitoggle', provider);
}