import 'dart:io';

import 'package:atmob_channel_reader/atmob_channel_reader.dart';
import 'package:umeng_common_sdk/umeng_common_sdk.dart';

import '../../data/consts/build_config.dart';
import '../../data/consts/constants.dart';
import '../../utils/mmkv_util.dart';

class UmengHelper {
  UmengHelper._();

  static Future<void> initCommon() async {
    // if (BuildConfig.isDebug) {
    //   return;
    // }

    if (Platform.isIOS) {
      UmengCommonSdk.initCommon(UmengConfig.umengAndroidAppKey,
          UmengConfig.umengIosAppKey, "AppStore");
    } else {
      String? channel = KVUtil.getString(
          Constants.appChanelName, await AtmobChannelReader.getChannel());
      UmengCommonSdk.initCommon(UmengConfig.umengAndroidAppKey,
          UmengConfig.umengIosAppKey, channel ?? "android");
    }
  }

  static void onEvent(String event, Map<String, dynamic> properties) {
    UmengCommonSdk.onEvent(event, properties);
  }
}
