Created
August 18, 2023 17:26
-
-
Save AyushBherwani1998/c0ff5a2ef6e97452ca63f87efa5606b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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