initialize static method

Future<SmartGrowLogs> initialize({
  1. required String apiKey,
  2. required String baseUrl,
  3. bool debug = false,
})

Initialize the Smart Grow Logs SDK

Must be called before using any logging methods. Typically called once at app startup.

@param apiKey API Key for authentication (required) @param baseUrl Base URL of the Smart Grow Logs server (required) @param debug Enable debug logging (optional, default: false)

Implementation

static Future<SmartGrowLogs> initialize({
  required String apiKey,
  required String baseUrl,
  bool debug = false,
}) async {
  if (apiKey.isEmpty) {
    throw ArgumentError('API key is required');
  }
  if (baseUrl.isEmpty) {
    throw ArgumentError('Base URL is required');
  }

  try {
    await SmartGrowLogsAPI.initialize(
      apiKey: apiKey,
      baseUrl: baseUrl,
      debug: debug,
    );

    _instance = SmartGrowLogs._internal(
      apiKey: apiKey,
      baseUrl: baseUrl,
      debug: debug,
    );

    return _instance!;
  } on PlatformException catch (e) {
    throw Exception("Failed to initialize SmartGrowLogs: ${e.message}");
  }
}