75 lines
2.1 KiB
Dart
75 lines
2.1 KiB
Dart
import 'package:guru_analytics_flutter/events_constants.dart';
|
|
import 'package:json_annotation/json_annotation.dart';
|
|
import 'package:guru_utils/converts/converts.dart';
|
|
|
|
/// Created by Haoyi on 2023/2/9
|
|
///
|
|
part 'analytics_model.g.dart';
|
|
|
|
@JsonSerializable()
|
|
class AnalyticsConfig {
|
|
@JsonKey(name: "cap", defaultValue: ["firebase", "facebook", "guru"])
|
|
@joinedStringConvert
|
|
final List<String> capabilities;
|
|
|
|
@JsonKey(name: "init_delay_s", defaultValue: 10)
|
|
final int delayedInSeconds;
|
|
|
|
@JsonKey(name: "expired_d", defaultValue: 7)
|
|
final int expiredInDays;
|
|
|
|
@JsonKey(name: "strategy", defaultValue: '')
|
|
final String strategy;
|
|
|
|
@JsonKey(name: "enabled_strategy", defaultValue: false)
|
|
final bool enabledStrategy;
|
|
|
|
AppEventCapabilities toAppEventCapabilities() {
|
|
int capValue = 0;
|
|
if (capabilities.contains("firebase")) {
|
|
capValue |= AppEventCapabilities.firebase;
|
|
}
|
|
if (capabilities.contains("facebook")) {
|
|
capValue |= AppEventCapabilities.facebook;
|
|
}
|
|
if (capabilities.contains("guru")) {
|
|
capValue |= AppEventCapabilities.guru;
|
|
}
|
|
return AppEventCapabilities(capValue);
|
|
}
|
|
|
|
AnalyticsConfig(this.capabilities, this.delayedInSeconds, this.expiredInDays, this.strategy,
|
|
this.enabledStrategy);
|
|
|
|
factory AnalyticsConfig.fromJson(Map<String, dynamic> json) => _$AnalyticsConfigFromJson(json);
|
|
|
|
Map<String, dynamic> toJson() => _$AnalyticsConfigToJson(this);
|
|
}
|
|
|
|
@JsonSerializable()
|
|
class UserIdentification {
|
|
@JsonKey(name: 'firebaseAppInstanceId', defaultValue: "")
|
|
final String firebaseAppInstanceId;
|
|
|
|
@JsonKey(name: 'idfa')
|
|
final String? idfa;
|
|
|
|
@JsonKey(name: "adid")
|
|
final String? adId;
|
|
|
|
@JsonKey(name: "gpsAdid")
|
|
final String? gpsAdId;
|
|
|
|
UserIdentification({this.firebaseAppInstanceId = '', this.idfa, this.adId, this.gpsAdId});
|
|
|
|
factory UserIdentification.fromJson(Map<String, dynamic> json) =>
|
|
_$UserIdentificationFromJson(json);
|
|
|
|
Map<String, dynamic> toJson() => _$UserIdentificationToJson(this);
|
|
|
|
@override
|
|
String toString() {
|
|
return 'UserIdentification{firebaseAppInstanceId: $firebaseAppInstanceId, idfa: $idfa, adId: $adId, gpsAdId: $gpsAdId}';
|
|
}
|
|
}
|