mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-26 16:46:51 +08:00
Analytics: Port to null safety
This commit is contained in:
@ -1,8 +1,5 @@
|
||||
// @dart=2.9
|
||||
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:device_info/device_info.dart';
|
||||
@ -138,8 +135,6 @@ String _eventToString(Event e) {
|
||||
case Event.AppUpdate:
|
||||
return "gj_app_update";
|
||||
}
|
||||
|
||||
return "unknown_event";
|
||||
}
|
||||
|
||||
class Analytics {
|
||||
@ -147,7 +142,7 @@ class Analytics {
|
||||
bool enabled = false;
|
||||
|
||||
Future<void> log({
|
||||
@required Event e,
|
||||
required Event e,
|
||||
Map<String, String> parameters = const {},
|
||||
}) async {
|
||||
String name = _eventToString(e);
|
||||
@ -164,14 +159,14 @@ class Analytics {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setCurrentScreen({@required String screenName}) async {
|
||||
Future<void> setCurrentScreen({required String screenName}) async {
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
await firebase.setCurrentScreen(screenName: screenName);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setUserProperty(
|
||||
{@required String name, @required String value}) async {
|
||||
{required String name, required String value}) async {
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
await firebase.setUserProperty(name: name, value: value);
|
||||
}
|
||||
@ -203,7 +198,7 @@ class AnalyticsRouteObserver extends RouteObserver<PageRoute<dynamic>> {
|
||||
}
|
||||
|
||||
@override
|
||||
void didPush(Route<dynamic> route, Route<dynamic> previousRoute) {
|
||||
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
|
||||
super.didPush(route, previousRoute);
|
||||
if (route is PageRoute) {
|
||||
_sendScreenView(route);
|
||||
@ -213,7 +208,7 @@ class AnalyticsRouteObserver extends RouteObserver<PageRoute<dynamic>> {
|
||||
}
|
||||
|
||||
@override
|
||||
void didReplace({Route<dynamic> newRoute, Route<dynamic> oldRoute}) {
|
||||
void didReplace({Route<dynamic>? newRoute, Route<dynamic>? oldRoute}) {
|
||||
super.didReplace(newRoute: newRoute, oldRoute: oldRoute);
|
||||
if (newRoute is PageRoute) {
|
||||
_sendScreenView(newRoute);
|
||||
@ -223,7 +218,7 @@ class AnalyticsRouteObserver extends RouteObserver<PageRoute<dynamic>> {
|
||||
}
|
||||
|
||||
@override
|
||||
void didPop(Route<dynamic> route, Route<dynamic> previousRoute) {
|
||||
void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
|
||||
super.didPop(route, previousRoute);
|
||||
if (previousRoute is PageRoute && route is PageRoute) {
|
||||
_sendScreenView(previousRoute);
|
||||
|
@ -1,4 +1,4 @@
|
||||
// @dart=2.9
|
||||
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
@ -8,33 +8,33 @@ import 'package:device_info/device_info.dart';
|
||||
// - https://support.google.com/firebase/answer/6317485?hl=en
|
||||
|
||||
class Event {
|
||||
DateTime date;
|
||||
String name;
|
||||
Map<String, dynamic> params;
|
||||
DateTime? date;
|
||||
String? name;
|
||||
Map<String, dynamic>? params;
|
||||
|
||||
String userId;
|
||||
String psuedoId;
|
||||
Map<String, dynamic> userProperties;
|
||||
String? userId;
|
||||
String? psuedoId;
|
||||
Map<String, dynamic>? userProperties;
|
||||
|
||||
// Unique session identifier (based on the timestamp of the session_start
|
||||
// event) associated with each event that occurs within a session
|
||||
String sessionID;
|
||||
String? sessionID;
|
||||
|
||||
String platform;
|
||||
DateTime userFirstTouchTimestamp;
|
||||
String? platform;
|
||||
DateTime? userFirstTouchTimestamp;
|
||||
}
|
||||
|
||||
class Device {
|
||||
String category; // mobile
|
||||
String mobileBrandName;
|
||||
String mobileModelName;
|
||||
String mobileOsHardwareModel;
|
||||
String operatingSystem;
|
||||
String operatingSystemVersion;
|
||||
String vendorId;
|
||||
String language;
|
||||
bool isLimitedAdTracking;
|
||||
int timeZoneOffsetSeconds;
|
||||
String? category; // mobile
|
||||
String? mobileBrandName;
|
||||
String? mobileModelName;
|
||||
String? mobileOsHardwareModel;
|
||||
String? operatingSystem;
|
||||
String? operatingSystemVersion;
|
||||
String? vendorId;
|
||||
String? language;
|
||||
bool? isLimitedAdTracking;
|
||||
int? timeZoneOffsetSeconds;
|
||||
|
||||
static Future<Device> build() async {
|
||||
var device = Device();
|
||||
@ -69,10 +69,10 @@ class Device {
|
||||
}
|
||||
|
||||
class AppInfo {
|
||||
String id;
|
||||
String version;
|
||||
String firebaseAppId;
|
||||
String installSource;
|
||||
String? id;
|
||||
String? version;
|
||||
String? firebaseAppId;
|
||||
String? installSource;
|
||||
}
|
||||
|
||||
//
|
||||
|
Reference in New Issue
Block a user