TLA Line data Source code
1 : // Copyright (c) 2026 Flipdare Pty Ltd. All rights reserved.
2 : //
3 : // This file is part of Flipdare's proprietary software and contains
4 : // confidential and copyrighted material. Unauthorised copying,
5 : // modification, distribution, or use of this file is strictly
6 : // prohibited without prior written permission from Flipdare Pty Ltd.
7 : //
8 : // This software includes third-party components licensed under MIT,
9 : // BSD, and Apache 2.0 licences. See THIRD_PARTY_NOTICES for details.
10 : //
11 :
12 : import 'package:core/analytics/analytics_interaction_type.dart';
13 : import 'package:core/analytics/analytics_route_source.dart';
14 : import 'package:core/analytics/analytics_type.dart';
15 : import 'package:core/app_constants.dart';
16 : import 'package:core/http/base_url.dart';
17 : import 'package:meta/meta.dart';
18 :
19 :
20 : abstract class AnalyticsEvent {
21 : final AnalyticsType type;
22 : final String srcUser;
23 : final String? dstUser;
24 :
25 HIT 1 : const AnalyticsEvent(this.type, {required this.srcUser, this.dstUser});
26 :
27 3 : bool get shouldTrack => kAnalyticsSourcesToTrack.contains(type);
28 :
29 : @mustBeOverridden
30 : Map<String, String> get ingestible;
31 : }
32 :
33 : class UrlAnalyticsEvent extends AnalyticsEvent {
34 : final String url;
35 : final AnalyticsRouteSource routeSource;
36 :
37 1 : const UrlAnalyticsEvent(
38 : this.routeSource, {
39 : required super.srcUser,
40 : super.dstUser,
41 : required this.url,
42 1 : }) : super(AnalyticsType.link);
43 :
44 1 : @override
45 5 : Map<String, String> get ingestible => {routeSource.name: BaseUrl.parseIf(url)};
46 : }
47 :
48 : class RouteAnalyticsEvent extends AnalyticsEvent {
49 : final String extra;
50 : final AnalyticsRouteSource routeSource;
51 :
52 1 : const RouteAnalyticsEvent(
53 : this.routeSource, {
54 : required super.srcUser,
55 : super.dstUser,
56 : required this.extra,
57 1 : }) : super(AnalyticsType.route);
58 :
59 1 : @override
60 4 : Map<String, String> get ingestible => {routeSource.name: extra};
61 : }
62 :
63 : class InteractionAnalyticsEvent extends AnalyticsEvent {
64 : final AnalyticsInteractionType interactionType;
65 : final String _ingestible;
66 :
67 1 : const InteractionAnalyticsEvent(
68 : this.interactionType, {
69 : required super.srcUser,
70 : super.dstUser,
71 : required String ingestible,
72 : }) : _ingestible = ingestible,
73 1 : super(AnalyticsType.interaction);
74 :
75 1 : @override
76 4 : Map<String, String> get ingestible => {interactionType.name: _ingestible};
77 : }
|