mirror of
https://github.com/meditohq/medito-app.git
synced 2024-09-11 12:15:46 +03:00
Update event params
This commit is contained in:
parent
07083c19e8
commit
1959eefb73
@ -16,7 +16,7 @@ class HTTPConstants {
|
||||
static const String TRACKS = 'tracks';
|
||||
static const String BACKGROUND_SOUNDS = 'backgroundSounds';
|
||||
static const String HOME = 'home';
|
||||
static const String LATEST_ANNOUNCEMENT = 'announcements/latest';
|
||||
static const String LATEST_ANNOUNCEMENT = 'announcements?latest=true';
|
||||
static const String HEADER = 'main/header';
|
||||
static const String QUOTE = 'main/quote';
|
||||
static const String SHORTCUTS = 'main/shortcuts';
|
||||
|
@ -7,6 +7,9 @@ class TypeConstants {
|
||||
static const String flow = 'flow';
|
||||
static const String fileIdKey = 'fileId';
|
||||
static const String trackIdKey = 'trackId';
|
||||
static const String timestampIdKey = 'timestamp';
|
||||
static const String guideIdKey = 'guide';
|
||||
static const String durationIdKey = 'duration';
|
||||
static const String donationAskCard = 'donationAskCard';
|
||||
static const String feedbackCard = 'feedbackCard';
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ abstract class AudioStartedModel with _$AudioStartedModel {
|
||||
required String fileId,
|
||||
required String fileGuide,
|
||||
required int fileDuration,
|
||||
required int timestamp,
|
||||
}) = _AudioStartedModel;
|
||||
|
||||
factory AudioStartedModel.fromJson(Map<String, Object?> json) =>
|
||||
|
@ -49,6 +49,7 @@ class PlayerProvider extends StateNotifier<TrackModel?> {
|
||||
ref,
|
||||
track,
|
||||
file,
|
||||
track.audio.first.guideName ?? '',
|
||||
);
|
||||
|
||||
state = track;
|
||||
@ -58,10 +59,14 @@ class PlayerProvider extends StateNotifier<TrackModel?> {
|
||||
Ref ref,
|
||||
TrackModel track,
|
||||
TrackFilesModel file,
|
||||
String guideName,
|
||||
) async {
|
||||
await _startBackgroundThreadForAudioCompleteEvent(
|
||||
track.id,
|
||||
file.duration,
|
||||
file.id,
|
||||
DateTime.now().millisecondsSinceEpoch,
|
||||
guideName,
|
||||
);
|
||||
|
||||
var downloadPath = await ref.read(audioDownloaderProvider).getTrackPath(
|
||||
@ -84,6 +89,9 @@ class PlayerProvider extends StateNotifier<TrackModel?> {
|
||||
Future<void> _startBackgroundThreadForAudioCompleteEvent(
|
||||
String trackId,
|
||||
int duration,
|
||||
String fileID,
|
||||
int timestamp,
|
||||
String fileGuide,
|
||||
) async {
|
||||
await Workmanager().initialize(
|
||||
callbackDispatcher,
|
||||
@ -94,7 +102,8 @@ class PlayerProvider extends StateNotifier<TrackModel?> {
|
||||
audioCompletedTaskKey,
|
||||
audioCompletedTaskKey,
|
||||
backoffPolicy: BackoffPolicy.linear,
|
||||
initialDelay: Duration(milliseconds: duration * audioPercentageListened as int),
|
||||
initialDelay:
|
||||
Duration(milliseconds: duration * audioPercentageListened as int),
|
||||
constraints: Constraints(
|
||||
networkType: NetworkType.connected,
|
||||
requiresBatteryNotLow: false,
|
||||
@ -104,6 +113,10 @@ class PlayerProvider extends StateNotifier<TrackModel?> {
|
||||
),
|
||||
inputData: {
|
||||
TypeConstants.trackIdKey: trackId,
|
||||
TypeConstants.durationIdKey: duration,
|
||||
TypeConstants.fileIdKey: fileID,
|
||||
TypeConstants.guideIdKey: fileGuide,
|
||||
TypeConstants.timestampIdKey: timestamp,
|
||||
WorkManagerConstants.userTokenKey: getUserToken(),
|
||||
},
|
||||
);
|
||||
@ -139,8 +152,10 @@ class PlayerProvider extends StateNotifier<TrackModel?> {
|
||||
fileId: audioFileId,
|
||||
fileDuration: duration,
|
||||
fileGuide: guide,
|
||||
timestamp: DateTime.now().millisecondsSinceEpoch,
|
||||
);
|
||||
ref.read(audioStartedEventProvider(event: audio.toJson(), trackId: trackId));
|
||||
ref.read(
|
||||
audioStartedEventProvider(event: audio.toJson(), trackId: trackId));
|
||||
}
|
||||
|
||||
Future<void> seekToPosition(int position) async {
|
||||
@ -174,4 +189,4 @@ class PlayerProvider extends StateNotifier<TrackModel?> {
|
||||
}
|
||||
}
|
||||
|
||||
const audioPercentageListened = 0.7;
|
||||
const audioPercentageListened = 0.7;
|
||||
|
@ -9,7 +9,8 @@ abstract class EventsRepository {
|
||||
|
||||
Future<void> saveFirebaseToken(Map<String, dynamic> event);
|
||||
|
||||
Future<void> trackAudioStartedEvent(Map<String, dynamic> event, String trackId);
|
||||
Future<void> trackAudioStartedEvent(
|
||||
Map<String, dynamic> event, String trackId);
|
||||
|
||||
Future<void> trackAnnouncementDismissEvent(String id);
|
||||
|
||||
@ -17,7 +18,14 @@ abstract class EventsRepository {
|
||||
|
||||
Future<void> markTrackAsNotListenedEvent(String id);
|
||||
|
||||
Future<void> markAudioAsListenedEvent(String id);
|
||||
Future<void> markAudioAsListenedEvent(
|
||||
String trackId,
|
||||
int? timestamp,
|
||||
int? fileId,
|
||||
int? fileDuration,
|
||||
String? fileGuide, {
|
||||
String? userToken,
|
||||
});
|
||||
|
||||
Future<void> deleteEvent(Map<String, dynamic> event);
|
||||
}
|
||||
@ -40,7 +48,8 @@ class EventsRepositoryImpl extends EventsRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> trackAudioStartedEvent(Map<String, dynamic> event, String trackId) async {
|
||||
Future<void> trackAudioStartedEvent(
|
||||
Map<String, dynamic> event, String trackId) async {
|
||||
await client.postRequest(
|
||||
HTTPConstants.AUDIO + '/' + trackId + HTTPConstants.AUDIO_START_EVENT,
|
||||
data: event,
|
||||
@ -50,7 +59,10 @@ class EventsRepositoryImpl extends EventsRepository {
|
||||
@override
|
||||
Future<void> trackAnnouncementDismissEvent(String id) async {
|
||||
await client.postRequest(
|
||||
HTTPConstants.ANNOUNCEMENT_EVENT + '/' + id + HTTPConstants.ANNOUNCEMENT_DISMISS_EVENT,
|
||||
HTTPConstants.ANNOUNCEMENT_EVENT +
|
||||
'/' +
|
||||
id +
|
||||
HTTPConstants.ANNOUNCEMENT_DISMISS_EVENT,
|
||||
);
|
||||
}
|
||||
|
||||
@ -63,10 +75,23 @@ class EventsRepositoryImpl extends EventsRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> markAudioAsListenedEvent(String id, {String? userToken}) async {
|
||||
Future<void> markAudioAsListenedEvent(
|
||||
String trackId,
|
||||
int? timestamp,
|
||||
int? fileId,
|
||||
int? fileDuration,
|
||||
String? fileGuide, {
|
||||
String? userToken,
|
||||
}) async {
|
||||
await client.postRequest(
|
||||
'${HTTPConstants.AUDIO}/$id${HTTPConstants.COMPLETE_EVENT}',
|
||||
'${HTTPConstants.AUDIO}/$trackId${HTTPConstants.COMPLETE_EVENT}',
|
||||
userToken: userToken,
|
||||
data: {
|
||||
'timestamp': timestamp,
|
||||
'fileId': fileId,
|
||||
'fileDuration': fileDuration,
|
||||
'fileGuide': fileGuide,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,10 @@ void callbackDispatcher() {
|
||||
if (inputData != null) {
|
||||
await eventsRpo.markAudioAsListenedEvent(
|
||||
inputData[TypeConstants.trackIdKey],
|
||||
inputData[TypeConstants.timestampIdKey],
|
||||
inputData[TypeConstants.durationIdKey],
|
||||
inputData[TypeConstants.fileIdKey],
|
||||
inputData[TypeConstants.guideIdKey],
|
||||
userToken: inputData[WorkManagerConstants.userTokenKey],
|
||||
);
|
||||
}
|
||||
@ -47,4 +51,4 @@ void callbackDispatcher() {
|
||||
|
||||
return Future.value(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,6 @@ class _HomeViewState extends ConsumerState<HomeView>
|
||||
|
||||
final stats = ref.watch(fetchStatsProvider);
|
||||
|
||||
var topPadding = MediaQuery.of(context).padding.top.toDouble();
|
||||
|
||||
return home.when(
|
||||
loading: () => HomeShimmerWidget(),
|
||||
error: (err, stack) => MeditoErrorWidget(
|
||||
|
58
pubspec.lock
58
pubspec.lock
@ -301,10 +301,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: coverage
|
||||
sha256: "595a29b55ce82d53398e1bcc2cba525d7bd7c59faeb2d2540e9d42c390cfeeeb"
|
||||
sha256: "8acabb8306b57a409bf4c83522065672ee13179297a6bb0cb9ead73948df7c76"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.6.4"
|
||||
version: "1.7.2"
|
||||
cross_file:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -744,6 +744,30 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.7.1"
|
||||
leak_tracker:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker
|
||||
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "10.0.0"
|
||||
leak_tracker_flutter_testing:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker_flutter_testing
|
||||
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
leak_tracker_testing:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker_testing
|
||||
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
list_counter:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -780,26 +804,26 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
|
||||
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.12.16"
|
||||
version: "0.12.16+1"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
|
||||
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.0"
|
||||
version: "0.8.0"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
|
||||
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.10.0"
|
||||
version: "1.11.0"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -860,10 +884,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
|
||||
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.8.3"
|
||||
version: "1.9.0"
|
||||
path_drawing:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1505,10 +1529,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vm_service
|
||||
sha256: c538be99af830f478718b51630ec1b6bee5e74e52c8a802d328d9e71d35d2583
|
||||
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "11.10.0"
|
||||
version: "13.0.0"
|
||||
watcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1517,14 +1541,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web
|
||||
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.0"
|
||||
web_socket_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1590,5 +1606,5 @@ packages:
|
||||
source: hosted
|
||||
version: "3.1.2"
|
||||
sdks:
|
||||
dart: ">=3.2.0-194.0.dev <3.7.0-13.0"
|
||||
dart: ">=3.2.0-0 <3.7.0-13.0"
|
||||
flutter: ">=3.16.0"
|
||||
|
Loading…
Reference in New Issue
Block a user