Initial commit: 91dj android client dev_1.0.0
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/// 内部桥接层:解除 widget 对 AnalyticsSdk 的直接依赖。
|
||||
///
|
||||
/// AnalyticsSdk.init() 调用 [register] 注册实现;
|
||||
/// widget 层通过此类的静态方法访问 SDK 能力,
|
||||
/// 无需 import analytics_sdk.dart,避免上行依赖。
|
||||
class WidgetBridge {
|
||||
static void Function(dynamic event)? _track;
|
||||
static String Function()? _getUserType;
|
||||
static bool _enableDebugBanner = false;
|
||||
static List<Map<String, String>> Function()? _getDebugSteps;
|
||||
|
||||
/// 由 AnalyticsSdk.init() 调用,注册 SDK 实现
|
||||
static void register({
|
||||
required void Function(dynamic event) track,
|
||||
required String Function() getUserType,
|
||||
required bool enableDebugBanner,
|
||||
required List<Map<String, String>> Function() getDebugSteps,
|
||||
}) {
|
||||
_track = track;
|
||||
_getUserType = getUserType;
|
||||
_enableDebugBanner = enableDebugBanner;
|
||||
_getDebugSteps = getDebugSteps;
|
||||
}
|
||||
|
||||
static void track(dynamic event) => _track?.call(event);
|
||||
|
||||
/// 获取当前用户类型,SDK 未初始化时返回 'normal'。
|
||||
static String getUserType() => _getUserType?.call() ?? 'normal';
|
||||
|
||||
static bool get enableDebugBanner => _enableDebugBanner;
|
||||
|
||||
static List<Map<String, String>> getDebugSteps() =>
|
||||
_getDebugSteps?.call() ?? [];
|
||||
}
|
||||
Reference in New Issue
Block a user