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,46 @@
|
||||
import 'package:analytics_sdk/const/event_type.dart';
|
||||
import 'package:analytics_sdk/manager/sdk_context.dart';
|
||||
|
||||
/// App 安装事件(客户端)
|
||||
class AppInstallEvent {
|
||||
/// 事件类型(固定)
|
||||
final String event = EventType.appInstall.event;
|
||||
|
||||
/// 去重 ID(动态计算)
|
||||
late final String eventId;
|
||||
|
||||
/// 落地页点击生成唯一ID, 复制到剪切板, 打开APP后读取剪切板
|
||||
final String traceId;
|
||||
|
||||
/// 原生包是否开启归因:1 开启,0 关闭(默认)
|
||||
final int attributionFlag;
|
||||
|
||||
late final Map<String, dynamic> _commonFields;
|
||||
|
||||
AppInstallEvent({
|
||||
required this.traceId,
|
||||
this.attributionFlag = 0,
|
||||
}) {
|
||||
_commonFields = SdkContext.generateCommonFields(event);
|
||||
|
||||
eventId = SdkContext.generateEventIdFromCommonFields(_commonFields, [
|
||||
traceId,
|
||||
attributionFlag.toString(),
|
||||
]);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final payload = <String, dynamic>{
|
||||
'trace_id': traceId,
|
||||
'attribution_flag': attributionFlag,
|
||||
};
|
||||
return {..._commonFields, 'event_id': eventId, 'payload': payload};
|
||||
}
|
||||
|
||||
factory AppInstallEvent.fromJson(Map<String, dynamic> json) {
|
||||
return AppInstallEvent(
|
||||
traceId: json['trace_id'] as String,
|
||||
attributionFlag: (json['attribution_flag'] as int?) ?? 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user