Skip to content

Instantly share code, notes, and snippets.

@AyushBherwani1998
Created August 18, 2023 17:26
Show Gist options
  • Select an option

  • Save AyushBherwani1998/c0ff5a2ef6e97452ca63f87efa5606b9 to your computer and use it in GitHub Desktop.

Select an option

Save AyushBherwani1998/c0ff5a2ef6e97452ca63f87efa5606b9 to your computer and use it in GitHub Desktop.
import 'package:mixpanel_flutter/mixpanel_flutter.dart';
import 'package:unplash_sample/core/utils/target_platform_extended.dart';
import 'package:unplash_sample/dependency_injection.dart';
abstract class MixpanelConfig {
void trackImageDetaislsEvent(String photoId);
/// Helps us get the metrics of experimentation to analysis
/// the different position of the share image button.
void trackLikeEventForExperimentation({
required String variant,
required String photoId,
});
}
class MixpanelConfigImpl implements MixpanelConfig {
final TargetPlatformExtended targetPlatformExtended;
MixpanelConfigImpl(this.targetPlatformExtended);
Mixpanel get mixpanel {
return DependencyInjection.getIt<Mixpanel>();
}
@override
void trackImageDetaislsEvent(String photoId) {
if (targetPlatformExtended.isMobile) {
mixpanel.track(
"image-details",
properties: {"photoId": photoId},
);
}
}
@override
void trackLikeEventForExperimentation({
required String variant,
required String photoId,
}) {
if (targetPlatformExtended.isMobile) {
mixpanel.track('like-experimentation', properties: {
"variant": variant,
"photoId": photoId,
});
}
}
}
@override
void trackShareEventForExperimentation({
required String variant,
required String photoId,
}) {
if (targetPlatformExtended.isMobile) {
mixpanel.track('share-experimentation', properties: {
"variant": variant,
"photoId": photoId,
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment