Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: break analytics dependency on ramp_partner #1668

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import 'package:decimal/decimal.dart';
import 'package:injectable/injectable.dart';
import 'package:mixpanel_flutter/mixpanel_flutter.dart';

import '../ramp_partner/models/ramp_partner.dart';

@lazySingleton
class AnalyticsManager {
const AnalyticsManager(this._analytics);
Expand Down Expand Up @@ -98,19 +96,19 @@ class AnalyticsManager {
);

void rampOpened({
required RampPartner partner,
required String partnerName,
required String rampType,
}) =>
_analytics.track(
'rampOpened',
properties: {
'partner': partner.name,
'partner': partnerName,
'type': rampType,
},
);

void rampInitiated({
required RampPartner partner,
required String partnerName,
required String rampType,
required String? amount,
required String countryCode,
Expand All @@ -119,7 +117,7 @@ class AnalyticsManager {
_analytics.track(
'rampStarted',
properties: {
'partner': partner.name,
'partner': partnerName,
'type': rampType,
'amount': amount,
'countryCode': countryCode,
Expand All @@ -128,14 +126,14 @@ class AnalyticsManager {
);

void rampCompleted({
required RampPartner partner,
required String partnerName,
required String rampType,
required String id,
}) =>
_analytics.track(
'rampCompleted',
properties: {
'partner': partner.name,
'partner': partnerName,
'type': rampType,
'id': id,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class BrijOffRampOrderService implements Disposable {
);

_analytics.rampInitiated(
partner: RampPartner.brij,
partnerName: RampPartner.brij.name,
rampType: RampType.offRamp.name,
amount: submittedAmount.value.toString(),
countryCode: countryCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class BrijOnRampOrderService implements Disposable {
final countryCode = _kycSharingService.value?.countryCode;

_analytics.rampInitiated(
partner: RampPartner.brij,
partnerName: RampPartner.brij.name,
rampType: RampType.onRamp.name,
amount: submittedAmount.value.toString(),
countryCode: countryCode ?? '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class CoinflowOffRampOrderWatcher implements RampWatcher {
await _subscription?.cancel();

_analytics.rampCompleted(
partner: RampPartner.coinflow,
partnerName: RampPartner.coinflow.name,
rampType: RampType.offRamp.name,
id: orderId,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class KadoOffRampOrderWatcher implements RampWatcher {
await _subscription?.cancel();

_analytics.rampCompleted(
partner: RampPartner.kado,
partnerName: RampPartner.kado.name,
rampType: RampType.offRamp.name,
id: orderId,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class KadoOnRampOrderWatcher implements RampWatcher {
status = OnRampOrderStatus.completed;

_analytics.rampCompleted(
partner: RampPartner.kado,
partnerName: RampPartner.kado.name,
rampType: RampType.onRamp.name,
id: orderId,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class MoneygramOffRampOrderService implements Disposable {
_subscribe(order.id);

_analytics.rampInitiated(
partner: RampPartner.moneygram,
partnerName: RampPartner.moneygram.name,
rampType: RampType.offRamp.name,
amount: submittedAmount.value.toString(),
countryCode: countryCode,
Expand Down Expand Up @@ -648,7 +648,7 @@ class MoneygramOffRampOrderService implements Disposable {
);

_analytics.rampCompleted(
partner: RampPartner.moneygram,
partnerName: RampPartner.moneygram.name,
rampType: RampType.offRamp.name,
id: id,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class MoneygramOnRampOrderService implements Disposable {
await _db.into(_db.onRampOrderRows).insert(order);

_analytics.rampInitiated(
partner: RampPartner.moneygram,
partnerName: RampPartner.moneygram.name,
rampType: RampType.onRamp.name,
amount: submittedAmount.value.toString(),
countryCode: countryCode,
Expand Down Expand Up @@ -386,7 +386,7 @@ class MoneygramOnRampOrderService implements Disposable {
);

_analytics.rampCompleted(
partner: RampPartner.moneygram,
partnerName: RampPartner.moneygram.name,
rampType: RampType.onRamp.name,
id: id,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ScalexOffRampOrderWatcher implements RampWatcher {
await _subscription?.cancel();

_analytics.rampCompleted(
partner: RampPartner.scalex,
partnerName: RampPartner.scalex.name,
rampType: RampType.offRamp.name,
id: orderId,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ScalexOnRampOrderWatcher implements RampWatcher {

if (isCompleted) {
_analytics.rampCompleted(
partner: RampPartner.scalex,
partnerName: RampPartner.scalex.name,
rampType: RampType.onRamp.name,
id: orderId,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class OffRampOrderService implements Disposable {
await _watch(order.id);

_analytics.rampInitiated(
partner: partner,
partnerName: partner.name,
rampType: RampType.offRamp.name,
amount: amount.value.toString(),
countryCode: countryCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class OnRampOrderService implements Disposable {
_subscribe(order.id);

_analytics.rampInitiated(
partner: partner,
partnerName: partner.name,
rampType: RampType.onRamp.name,
amount: submittedAmount.value.toString(),
countryCode: countryCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,10 @@ extension RampBuildContextExt on BuildContext {
throw UnimplementedError('Not implemented for $partner');
}

sl<AnalyticsManager>()
.rampOpened(partner: partner, rampType: RampType.onRamp.name);
sl<AnalyticsManager>().rampOpened(
partnerName: partner.name,
rampType: RampType.onRamp.name,
);
}

void _launchOffRampPartner(
Expand All @@ -244,7 +246,9 @@ extension RampBuildContextExt on BuildContext {
throw UnimplementedError('Not implemented for $partner');
}

sl<AnalyticsManager>()
.rampOpened(partner: partner, rampType: RampType.offRamp.name);
sl<AnalyticsManager>().rampOpened(
partnerName: partner.name,
rampType: RampType.offRamp.name,
);
}
}
7 changes: 3 additions & 4 deletions packages/espressocash_app/test/stub_analytics_manager.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:decimal/decimal.dart';
import 'package:espressocash_app/features/analytics/analytics_manager.dart';
import 'package:espressocash_app/features/ramp_partner/models/ramp_partner.dart';

class StubAnalyticsManager implements AnalyticsManager {
const StubAnalyticsManager();
Expand Down Expand Up @@ -47,20 +46,20 @@ class StubAnalyticsManager implements AnalyticsManager {

@override
void rampCompleted({
required RampPartner partner,
required String partnerName,
required String rampType,
required String id,
}) {}

@override
void rampInitiated({
required RampPartner partner,
required String partnerName,
required String rampType,
required String? amount,
required String countryCode,
required String id,
}) {}

@override
void rampOpened({required RampPartner partner, required String rampType}) {}
void rampOpened({required String partnerName, required String rampType}) {}
}
Loading