Skip to content

Commit

Permalink
fix android compatibility + speedup barcode login + resusing tracking…
Browse files Browse the repository at this point in the history
…service
  • Loading branch information
mario meltzow committed Jan 1, 2025
1 parent 377ef5e commit 902bd35
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 13 deletions.
6 changes: 3 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ android {
// ndkVersion "26.1.10909125"

compileOptions {
sourceCompatibility JavaVersion.VERSION_15
targetCompatibility JavaVersion.VERSION_15
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
Expand All @@ -35,7 +35,7 @@ android {
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk 23
// targetSdk 34
targetSdk 35
versionCode 99
versionName '2.0.0'
}
Expand Down
4 changes: 3 additions & 1 deletion lib/board_details/kanban_board_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:appflowy_board/appflowy_board.dart';
import 'package:deck_ng/board_details/kanban_board_screen.dart';
import 'package:deck_ng/model/models.dart' as NC;
import 'package:deck_ng/service/services.dart';
import 'package:deck_ng/service/tracking_service.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:wiredash/wiredash.dart';
Expand All @@ -18,6 +19,7 @@ class KanbanBoardController extends GetxController {
final BoardService _boardService = Get.find<BoardService>();
final StackService _stackService = Get.find<StackService>();
final CardService _cardService = Get.find<CardService>();
final TrackingService trackingService = Get.find<TrackingService>();
final NotificationService _notificationService =
Get.find<NotificationService>();

Expand Down Expand Up @@ -101,7 +103,7 @@ class KanbanBoardController extends GetxController {
currentDraggedCard.stackId, currentDraggedCard.id!, currentDraggedCard);

cardSuccessMsg();
Wiredash.trackEvent("reorder card on kanban board", data: {
trackingService.trackEvent("reorder card on kanban board", properties: {
"selectedStackIndex": selectedStackIndex,
"oldIndex": oldIndex,
"newIndex": newIndex
Expand Down
13 changes: 7 additions & 6 deletions lib/login/login_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import 'dart:async';

import 'package:barcode_scan2/barcode_scan2.dart';
import 'package:deck_ng/service/services.dart';
import 'package:deck_ng/service/tracking_service.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:wiredash/wiredash.dart';

class BarcodeScanData {
late String url;
Expand All @@ -20,6 +20,7 @@ class LoginController extends GetxController {
var credService = Get.find<StorageService>();
var authService = Get.find<AuthService>();
var notificationService = Get.find<NotificationService>();
var trackingService = Get.find<TrackingService>();

final focusNode = FocusNode();
Timer? typingTimer;
Expand Down Expand Up @@ -131,14 +132,14 @@ class LoginController extends GetxController {
// "Login", "Login not Successful. ${e.message}");
}
if (successful) {
await Wiredash.trackEvent('successfully login', data: {
trackingService.trackEvent('successfully login', properties: {
'url': url.value,
'nextcloudVersion': nextcloudVersionString.value
});
Get.toNamed('/boards');
notificationService.successMsg("Login", "Login Successful");
} else {
await Wiredash.trackEvent('not successfully login', data: {
trackingService.trackEvent('not successfully login', properties: {
'url': url.value,
'nextcloudVersion': nextcloudVersionString.value
});
Expand Down Expand Up @@ -178,15 +179,15 @@ class LoginController extends GetxController {
urlController.text = data.url;
userNameController.text = data.username;
passwordController.text = data.password;
await Wiredash.trackEvent('wants to login with barcode');
trackingService.trackEvent('wants to login with barcode');
login();
} else {
notificationService.errorMsg("Login", "Invalid barcode format");
await Wiredash.trackEvent('unsuccessfully login with barcode');
trackingService.trackEvent('unsuccessfully login with barcode');
}
} catch (e) {
notificationService.errorMsg("Login", "Failed to scan barcode: $e");
await Wiredash.trackEvent('unsuccessfully login with barcode');
trackingService.trackEvent('unsuccessfully login with barcode');
}
}

Expand Down
36 changes: 34 additions & 2 deletions lib/service/impl/tracking_service_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ class TrackingServiceImpl extends GetxService implements TrackingService {
}

@override
void trackEvent(String eventName, {Map<String, dynamic>? properties}) {
if (isOptedOut()) return;
Future<void> trackEvent(String eventName,
{Map<String, dynamic>? properties}) {
if (isOptedOut()) return Future.value();

final distinctId = storageService.getSetting()?.distinctId ?? '';
Posthog().capture(
Expand All @@ -95,6 +96,7 @@ class TrackingServiceImpl extends GetxService implements TrackingService {
'distinct_id': distinctId,
},
);
return Wiredash.trackEvent(eventName, data: properties);
}

@override
Expand Down Expand Up @@ -153,4 +155,34 @@ class TrackingServiceImpl extends GetxService implements TrackingService {
return metaData;
});
}

// @override
// void checkForSurvey() async {
// var posthogService = Get.find<PosthogService>();
// final surveys = await posthogService.fetchSurveys();
// if (surveys.isNotEmpty) {
// final firstSurvey = surveys.first;
// // Beispiel: Zeige die Umfrage in einem Dialog oder Widget
// showDialog(
// context: Get.context!,
// builder: (context) => AlertDialog(
// title: Text(firstSurvey['question']),
// content: Column(
// children: (firstSurvey['answers'] as List<String>).map((answer) {
// return ElevatedButton(
// onPressed: () {
// Posthog().capture(
// eventName: 'Survey Answered',
// properties: {'answer': answer},
// );
// Navigator.pop(context);
// },
// child: Text(answer),
// );
// }).toList(),
// ),
// ),
// );
// }
// }
}
2 changes: 1 addition & 1 deletion lib/service/tracking_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ abstract class TrackingService {

void optIn();

void trackEvent(String eventName, {Map<String, dynamic>? properties});
Future<void> trackEvent(String eventName, {Map<String, dynamic>? properties});

void onScreenEvent(String screenName);

Expand Down

0 comments on commit 902bd35

Please sign in to comment.