fix: countly double init due to rebuild app

This commit is contained in:
lollipopkit
2023-03-21 15:02:43 +08:00
parent 4cc72328a7
commit f1ae924724
5 changed files with 31 additions and 29 deletions

View File

@@ -359,7 +359,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 239; CURRENT_PROJECT_VERSION = 241;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
@@ -367,7 +367,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.239; MARKETING_VERSION = 1.0.241;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -490,7 +490,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 239; CURRENT_PROJECT_VERSION = 241;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
@@ -498,7 +498,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.239; MARKETING_VERSION = 1.0.241;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -515,7 +515,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 239; CURRENT_PROJECT_VERSION = 241;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
@@ -523,7 +523,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.239; MARKETING_VERSION = 1.0.241;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";

View File

@@ -12,14 +12,14 @@ class Analysis {
static const _url = 'https://countly.xuty.cc'; static const _url = 'https://countly.xuty.cc';
static const _key = '80372a2a66424b32d0ac8991bfa1ef058bd36b1f'; static const _key = '80372a2a66424b32d0ac8991bfa1ef058bd36b1f';
static bool _enabled = false; static bool enabled = false;
static Future<void> init() async { static Future<void> init() async {
if (!BuildMode.isRelease) { if (!BuildMode.isRelease) {
return; return;
} }
if (isAndroid || isIOS) { if (isAndroid || isIOS) {
_enabled = true; enabled = true;
final config = CountlyConfig(_url, _key) final config = CountlyConfig(_url, _key)
.setLoggingEnabled(false) .setLoggingEnabled(false)
.enableCrashReporting(); .enableCrashReporting();
@@ -33,13 +33,13 @@ class Analysis {
} }
static void recordView(String view) { static void recordView(String view) {
if (_enabled) { if (enabled) {
Countly.recordView(view); Countly.recordView(view);
} }
} }
static void recordException(Object exception, [bool fatal = false]) { static void recordException(Object exception, [bool fatal = false]) {
if (_enabled) { if (enabled) {
Countly.logException(exception.toString(), !fatal, null); Countly.logException(exception.toString(), !fatal, null);
} }
} }

View File

@@ -2,9 +2,8 @@
class BuildData { class BuildData {
static const String name = "ServerBox"; static const String name = "ServerBox";
static const int build = 239; static const int build = 241;
static const String engine = static const String engine = "Flutter 3.7.7 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 2ad6cd72c0 (13 days ago) • 2023-03-08 09:41:59 -0800\nEngine • revision 1837b5be5f\nTools • Dart 2.19.4 • DevTools 2.20.1\n";
"Flutter 3.7.7 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 2ad6cd72c0 (13 days ago) • 2023-03-08 09:41:59 -0800\nEngine • revision 1837b5be5f\nTools • Dart 2.19.4 • DevTools 2.20.1\n"; static const String buildAt = "2023-03-21 15:00:34.919375";
static const String buildAt = "2023-03-21 14:03:13.656226"; static const int modifications = 6;
static const int modifications = 17;
} }

View File

@@ -82,7 +82,8 @@ Future<void> main() async {
runInZone(() async { runInZone(() async {
await initApp(); await initApp();
runApp( runApp(
MultiProvider( RebuildWidget(
child: MultiProvider(
providers: [ providers: [
ChangeNotifierProvider(create: (_) => locator<AppProvider>()), ChangeNotifierProvider(create: (_) => locator<AppProvider>()),
ChangeNotifierProvider(create: (_) => locator<PkgProvider>()), ChangeNotifierProvider(create: (_) => locator<PkgProvider>()),
@@ -91,10 +92,10 @@ Future<void> main() async {
ChangeNotifierProvider(create: (_) => locator<ServerProvider>()), ChangeNotifierProvider(create: (_) => locator<ServerProvider>()),
ChangeNotifierProvider(create: (_) => locator<SnippetProvider>()), ChangeNotifierProvider(create: (_) => locator<SnippetProvider>()),
ChangeNotifierProvider(create: (_) => locator<VirtualKeyboard>()), ChangeNotifierProvider(create: (_) => locator<VirtualKeyboard>()),
ChangeNotifierProvider(create: (_) => locator<PrivateKeyProvider>()), ChangeNotifierProvider(
create: (_) => locator<PrivateKeyProvider>()),
ChangeNotifierProvider(create: (_) => locator<SftpProvider>()), ChangeNotifierProvider(create: (_) => locator<SftpProvider>()),
], ],
child: RebuildWidget(
child: MyApp(), child: MyApp(),
), ),
), ),

View File

@@ -308,6 +308,8 @@ class _MyHomePageState extends State<MyHomePage>
await GetIt.I.allReady(); await GetIt.I.allReady();
await locator<ServerProvider>().loadLocalData(); await locator<ServerProvider>().loadLocalData();
await doUpdate(context); await doUpdate(context);
if (!Analysis.enabled) {
await Analysis.init(); await Analysis.init();
} }
}
} }