From e433266664f23b28134fe82263cdb97dcc4775c2 Mon Sep 17 00:00:00 2001 From: Illya Tsai Date: Thu, 28 Mar 2024 14:42:51 +0300 Subject: [PATCH 1/7] add event tracking to sign up --- .../lib/deriv_rudderstack.dart | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/packages/deriv_rudderstack/lib/deriv_rudderstack.dart b/packages/deriv_rudderstack/lib/deriv_rudderstack.dart index 368fa701f..76a158dc8 100644 --- a/packages/deriv_rudderstack/lib/deriv_rudderstack.dart +++ b/packages/deriv_rudderstack/lib/deriv_rudderstack.dart @@ -165,4 +165,124 @@ class DerivRudderstack { return false; } + + /// Captures app_open event when the app is opened. + void logAppOpened() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'open', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Captures user tap on Log in button on sign up screen. + void logUserTappedLoginButton() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'go_to_login', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Captures user tap on Get free account button on sign up screen. + void logAppGetFreeAccount(String slideName) { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'get_free_account', + 'form_source': 'mobile_derivgo', + 'getstarted_slide_name': + '${slideName.substring(slideName.indexOf('.') + 1, slideName.length)}', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when user turns on or off Refferal toggle switcher. + void logReferralToggleSwitched() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'tab_referral_toggle', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when user gets Invalid referral code pop up with Try again button. + void logTryAgainReferralCode() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'try_again_referral_code', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when Email confirmation is sent to a user. + void logEmailConfirmationSent() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'email_confirmation_sent', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when user land on Successfull email verification screen. + void logEmailConfirmed() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'email_confirmed', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when user taps Continue button on Successfull email verification screen. + void logSignupContinued() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'signup_continued', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when user lands on Country selection screen. + void logCountrySelectionPageOpened() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'country_selection_screen_opened', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when user lands on Create password page while creating demo account. + void logSetPasswordPageOpened() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'password_screen_opened', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when user's sign up is finished. + void logSignUpDone(String signupProvider) { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'signup_done', + 'signup_provider': '$signupProvider', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when user taps 'Create free demo account' or social log in button. + void logSignUpPageAction(String signupProvider, + [bool? isToggleOn, String? referralCode]) { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'started', + 'signup_provider': '$signupProvider', + 'referral_toggle_mode': '${isToggleOn ?? false} ', + 'referral_code': '$referralCode', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } } From d813bd0c5e3dae00675c329f19a81255c41308d5 Mon Sep 17 00:00:00 2001 From: Illya Tsai Date: Tue, 2 Apr 2024 15:13:08 +0300 Subject: [PATCH 2/7] add rudderstack events --- .../events/rudderstack_events.dart | 135 ++++++++++++++++++ .../sdk/deriv_rudderstack_sdk.dart | 7 +- 2 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 packages/analytics/lib/sdk/rudderstack/events/rudderstack_events.dart diff --git a/packages/analytics/lib/sdk/rudderstack/events/rudderstack_events.dart b/packages/analytics/lib/sdk/rudderstack/events/rudderstack_events.dart new file mode 100644 index 000000000..01d132418 --- /dev/null +++ b/packages/analytics/lib/sdk/rudderstack/events/rudderstack_events.dart @@ -0,0 +1,135 @@ +import 'package:analytics/sdk/rudderstack/core/rudderstack_configuration.dart'; +import 'package:analytics/sdk/rudderstack/sdk/deriv_rudderstack_sdk.dart'; + +/// Class which hold events which should be monitored. +class DerivRudderstackEvents { + /// Constructor for [DerivRudderstackEvents]. + const DerivRudderstackEvents(); + + ///Set ups Rudderstack connection. + void setup({required String dataPlaneUrl, required String writeKey}) { + DerivRudderstack().setup( + RudderstackConfiguration(dataPlaneUrl: dataPlaneUrl, writeKey: writeKey), + ); + } + + /// Captures app_open event when the app is opened. + void logAppOpened() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'open', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Captures user tap on Log in button on sign up screen. + void logUserTappedLoginButton() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'go_to_login', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Captures user tap on Get free account button on sign up screen. + void logAppGetFreeAccount(String slideName) { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'get_free_account', + 'form_source': 'mobile_derivgo', + 'getstarted_slide_name': + '${slideName.substring(slideName.indexOf('.') + 1, slideName.length)}', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when user turns on or off Refferal toggle switcher. + void logReferralToggleSwitched() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'tab_referral_toggle', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when user gets Invalid referral code pop up with Try again button. + void logTryAgainReferralCode() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'try_again_referral_code', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when Email confirmation is sent to a user. + void logEmailConfirmationSent() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'email_confirmation_sent', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when user land on Successfull email verification screen. + void logEmailConfirmed() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'email_confirmed', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when user taps Continue button on Successfull email verification screen. + void logSignupContinued() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'signup_continued', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when user lands on Country selection screen. + void logCountrySelectionPageOpened() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'country_selection_screen_opened', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when user lands on Create password page while creating demo account. + void logSetPasswordPageOpened() { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'password_screen_opened', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when user's sign up is finished. + void logSignUpDone(String signupProvider) { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'signup_done', + 'signup_provider': '$signupProvider', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } + + /// Tracks when user taps 'Create free demo account' or social log in button. + void logSignUpPageAction(String signupProvider, + [bool? isToggleOn, String? referralCode]) { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'started', + 'signup_provider': '$signupProvider', + 'referral_toggle_mode': '${isToggleOn ?? false} ', + 'referral_code': '$referralCode', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } +} diff --git a/packages/analytics/lib/sdk/rudderstack/sdk/deriv_rudderstack_sdk.dart b/packages/analytics/lib/sdk/rudderstack/sdk/deriv_rudderstack_sdk.dart index 06f366130..d46a5e711 100644 --- a/packages/analytics/lib/sdk/rudderstack/sdk/deriv_rudderstack_sdk.dart +++ b/packages/analytics/lib/sdk/rudderstack/sdk/deriv_rudderstack_sdk.dart @@ -53,8 +53,11 @@ class DerivRudderstack implements BaseAnalytics { _execute(() => rudderClient.identify(userId)); /// Tracks an event with the given [eventName]. - Future track({required String eventName}) async => - _execute(() => rudderClient.track(eventName)); + Future track( + {required String eventName, + Map? properties}) async => + _execute(() => rudderClient.track(eventName, + properties: RudderProperty.fromMap(properties!))); /// Logs a screen view with the given [screenName]. Future screen({required String screenName}) async => From 485428fb85098e25e69bc6e0ea59958e457e663a Mon Sep 17 00:00:00 2001 From: Illya Tsai Date: Tue, 2 Apr 2024 15:39:42 +0300 Subject: [PATCH 3/7] refactor --- .../lib/deriv_rudderstack.dart | 120 ------------------ 1 file changed, 120 deletions(-) diff --git a/packages/deriv_rudderstack/lib/deriv_rudderstack.dart b/packages/deriv_rudderstack/lib/deriv_rudderstack.dart index 76a158dc8..368fa701f 100644 --- a/packages/deriv_rudderstack/lib/deriv_rudderstack.dart +++ b/packages/deriv_rudderstack/lib/deriv_rudderstack.dart @@ -165,124 +165,4 @@ class DerivRudderstack { return false; } - - /// Captures app_open event when the app is opened. - void logAppOpened() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'open', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); - } - - /// Captures user tap on Log in button on sign up screen. - void logUserTappedLoginButton() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'go_to_login', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); - } - - /// Captures user tap on Get free account button on sign up screen. - void logAppGetFreeAccount(String slideName) { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'get_free_account', - 'form_source': 'mobile_derivgo', - 'getstarted_slide_name': - '${slideName.substring(slideName.indexOf('.') + 1, slideName.length)}', - 'form_name': 'virtual_signup_derivgo' - }); - } - - /// Tracks when user turns on or off Refferal toggle switcher. - void logReferralToggleSwitched() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'tab_referral_toggle', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); - } - - /// Tracks when user gets Invalid referral code pop up with Try again button. - void logTryAgainReferralCode() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'try_again_referral_code', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); - } - - /// Tracks when Email confirmation is sent to a user. - void logEmailConfirmationSent() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'email_confirmation_sent', - 'signup_provider': 'email', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); - } - - /// Tracks when user land on Successfull email verification screen. - void logEmailConfirmed() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'email_confirmed', - 'signup_provider': 'email', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); - } - - /// Tracks when user taps Continue button on Successfull email verification screen. - void logSignupContinued() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'signup_continued', - 'signup_provider': 'email', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); - } - - /// Tracks when user lands on Country selection screen. - void logCountrySelectionPageOpened() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'country_selection_screen_opened', - 'signup_provider': 'email', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); - } - - /// Tracks when user lands on Create password page while creating demo account. - void logSetPasswordPageOpened() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'password_screen_opened', - 'signup_provider': 'email', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); - } - - /// Tracks when user's sign up is finished. - void logSignUpDone(String signupProvider) { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'signup_done', - 'signup_provider': '$signupProvider', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); - } - - /// Tracks when user taps 'Create free demo account' or social log in button. - void logSignUpPageAction(String signupProvider, - [bool? isToggleOn, String? referralCode]) { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'started', - 'signup_provider': '$signupProvider', - 'referral_toggle_mode': '${isToggleOn ?? false} ', - 'referral_code': '$referralCode', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); - } } From 5900d6a4dcb215cae628a8ddf3dd5afc71687cc0 Mon Sep 17 00:00:00 2001 From: Illya Tsai Date: Tue, 9 Apr 2024 14:09:06 +0300 Subject: [PATCH 4/7] add error flow event --- .../sdk/rudderstack/events/rudderstack_events.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/analytics/lib/sdk/rudderstack/events/rudderstack_events.dart b/packages/analytics/lib/sdk/rudderstack/events/rudderstack_events.dart index 01d132418..0b084d0d8 100644 --- a/packages/analytics/lib/sdk/rudderstack/events/rudderstack_events.dart +++ b/packages/analytics/lib/sdk/rudderstack/events/rudderstack_events.dart @@ -132,4 +132,15 @@ class DerivRudderstackEvents { 'form_name': 'virtual_signup_derivgo' }); } + + /// Tracks any error is happening and shown to the user (validation, API communication, social providers errors). + void logSignUpFlowError(String? errorText, [String? signupProvider]) { + DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { + 'action': 'signup_flow_error', + 'signup_provider': '$signupProvider', + 'error_message': '$errorText', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }); + } } From ca7d8ee3556c44ee819dab41dd2605cdbf024743 Mon Sep 17 00:00:00 2001 From: Illya Tsai Date: Tue, 7 May 2024 10:02:41 +0300 Subject: [PATCH 5/7] test --- .../sdk/deriv_rudderstack_sdk.dart | 12 +++++----- .../sdk/deriv_rudderstack_sdk_test.dart | 24 +++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/packages/analytics/lib/sdk/rudderstack/sdk/deriv_rudderstack_sdk.dart b/packages/analytics/lib/sdk/rudderstack/sdk/deriv_rudderstack_sdk.dart index d46a5e711..70d38834c 100644 --- a/packages/analytics/lib/sdk/rudderstack/sdk/deriv_rudderstack_sdk.dart +++ b/packages/analytics/lib/sdk/rudderstack/sdk/deriv_rudderstack_sdk.dart @@ -52,12 +52,12 @@ class DerivRudderstack implements BaseAnalytics { Future identify({required String userId}) async => _execute(() => rudderClient.identify(userId)); - /// Tracks an event with the given [eventName]. - Future track( - {required String eventName, - Map? properties}) async => - _execute(() => rudderClient.track(eventName, - properties: RudderProperty.fromMap(properties!))); + /// Tracks an event with the given [eventName] and [properties]. + Future track({ + required String eventName, + RudderProperty? properties, // Change the parameter type to RudderProperty + }) async => + _execute(() => rudderClient.track(eventName, properties: properties)); /// Logs a screen view with the given [screenName]. Future screen({required String screenName}) async => diff --git a/packages/analytics/test/rudderstack/sdk/deriv_rudderstack_sdk_test.dart b/packages/analytics/test/rudderstack/sdk/deriv_rudderstack_sdk_test.dart index 09804da8c..df856b864 100644 --- a/packages/analytics/test/rudderstack/sdk/deriv_rudderstack_sdk_test.dart +++ b/packages/analytics/test/rudderstack/sdk/deriv_rudderstack_sdk_test.dart @@ -4,6 +4,7 @@ import 'package:analytics/sdk/rudderstack/sdk/deriv_rudderstack_sdk.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; import 'package:rudder_sdk_flutter/RudderController.dart'; +import 'package:rudder_sdk_flutter_platform_interface/platform.dart'; class MockRudderController extends Mock implements RudderController {} @@ -34,20 +35,23 @@ void main() { test('track calls rudderClient.track', () async { const String eventName = 'test_event_name'; + const Map properties = {'action': 'open'}; - final bool result = await derivRudderstack.track(eventName: eventName); + // Convert properties to RudderProperty + final rudderProperties = RudderProperty.fromMap(properties); - expect(result, isTrue); - verify(() => mockRudderController.track(eventName)).called(1); - }); - - test('track calls rudderClient.track', () async { - const String eventName = 'test_event_name'; - - final bool result = await derivRudderstack.track(eventName: eventName); + final bool result = await derivRudderstack.track( + eventName: eventName, + properties: rudderProperties, // Pass RudderProperty directly + ); expect(result, isTrue); - verify(() => mockRudderController.track(eventName)).called(1); + // Verify that the track method is called with the correct parameters + verify(() => mockRudderController.track( + eventName, + properties: rudderProperties, // Pass RudderProperty directly + options: null // Assuming options is not used in this case + )).called(1); }); test('screen calls rudderClient.screen', () async { From 4fa276718bd6e742437654ca12f649e7dabd26b5 Mon Sep 17 00:00:00 2001 From: Illya Tsai Date: Tue, 7 May 2024 10:18:27 +0300 Subject: [PATCH 6/7] refactor events --- .../events/rudderstack_events.dart | 183 ++++++++++-------- 1 file changed, 105 insertions(+), 78 deletions(-) diff --git a/packages/analytics/lib/sdk/rudderstack/events/rudderstack_events.dart b/packages/analytics/lib/sdk/rudderstack/events/rudderstack_events.dart index 0b084d0d8..2470b8758 100644 --- a/packages/analytics/lib/sdk/rudderstack/events/rudderstack_events.dart +++ b/packages/analytics/lib/sdk/rudderstack/events/rudderstack_events.dart @@ -1,5 +1,6 @@ import 'package:analytics/sdk/rudderstack/core/rudderstack_configuration.dart'; import 'package:analytics/sdk/rudderstack/sdk/deriv_rudderstack_sdk.dart'; +import 'package:rudder_sdk_flutter_platform_interface/platform.dart'; /// Class which hold events which should be monitored. class DerivRudderstackEvents { @@ -15,132 +16,158 @@ class DerivRudderstackEvents { /// Captures app_open event when the app is opened. void logAppOpened() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'open', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); + DerivRudderstack().track( + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'open', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + })); } /// Captures user tap on Log in button on sign up screen. void logUserTappedLoginButton() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'go_to_login', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); + DerivRudderstack().track( + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'go_to_login', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + })); } /// Captures user tap on Get free account button on sign up screen. void logAppGetFreeAccount(String slideName) { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'get_free_account', - 'form_source': 'mobile_derivgo', - 'getstarted_slide_name': - '${slideName.substring(slideName.indexOf('.') + 1, slideName.length)}', - 'form_name': 'virtual_signup_derivgo' - }); + DerivRudderstack().track( + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'get_free_account', + 'form_source': 'mobile_derivgo', + 'getstarted_slide_name': + '${slideName.substring(slideName.indexOf('.') + 1, slideName.length)}', + 'form_name': 'virtual_signup_derivgo' + })); } /// Tracks when user turns on or off Refferal toggle switcher. void logReferralToggleSwitched() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'tab_referral_toggle', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); + DerivRudderstack().track( + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'tab_referral_toggle', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + })); } /// Tracks when user gets Invalid referral code pop up with Try again button. void logTryAgainReferralCode() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'try_again_referral_code', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); + DerivRudderstack().track( + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'try_again_referral_code', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + })); } /// Tracks when Email confirmation is sent to a user. void logEmailConfirmationSent() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'email_confirmation_sent', - 'signup_provider': 'email', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); + DerivRudderstack().track( + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'email_confirmation_sent', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + })); } /// Tracks when user land on Successfull email verification screen. void logEmailConfirmed() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'email_confirmed', - 'signup_provider': 'email', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); + DerivRudderstack().track( + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'email_confirmed', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + })); } /// Tracks when user taps Continue button on Successfull email verification screen. void logSignupContinued() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'signup_continued', - 'signup_provider': 'email', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); + DerivRudderstack().track( + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'signup_continued', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + })); } /// Tracks when user lands on Country selection screen. void logCountrySelectionPageOpened() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'country_selection_screen_opened', - 'signup_provider': 'email', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); + DerivRudderstack().track( + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'country_selection_screen_opened', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + })); } /// Tracks when user lands on Create password page while creating demo account. void logSetPasswordPageOpened() { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'password_screen_opened', - 'signup_provider': 'email', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); + DerivRudderstack().track( + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'password_screen_opened', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + })); } /// Tracks when user's sign up is finished. void logSignUpDone(String signupProvider) { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'signup_done', - 'signup_provider': '$signupProvider', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); + DerivRudderstack().track( + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'signup_done', + 'signup_provider': '$signupProvider', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + })); } /// Tracks when user taps 'Create free demo account' or social log in button. void logSignUpPageAction(String signupProvider, [bool? isToggleOn, String? referralCode]) { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'started', - 'signup_provider': '$signupProvider', - 'referral_toggle_mode': '${isToggleOn ?? false} ', - 'referral_code': '$referralCode', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); + DerivRudderstack().track( + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'started', + 'signup_provider': '$signupProvider', + 'referral_toggle_mode': '${isToggleOn ?? false} ', + 'referral_code': '$referralCode', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + })); } /// Tracks any error is happening and shown to the user (validation, API communication, social providers errors). void logSignUpFlowError(String? errorText, [String? signupProvider]) { - DerivRudderstack().track(eventName: 'ce_virtual_signup_form', properties: { - 'action': 'signup_flow_error', - 'signup_provider': '$signupProvider', - 'error_message': '$errorText', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - }); + DerivRudderstack().track( + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'signup_flow_error', + 'signup_provider': '$signupProvider', + 'error_message': '$errorText', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + })); } } From 2a32fcbb770d96df74ad8299bd0f9013c17386c8 Mon Sep 17 00:00:00 2001 From: Illya Tsai Date: Tue, 7 May 2024 12:15:43 +0300 Subject: [PATCH 7/7] fix comment --- .../events/rudderstack_events.dart | 195 ++++++++++-------- 1 file changed, 104 insertions(+), 91 deletions(-) diff --git a/packages/analytics/lib/sdk/rudderstack/events/rudderstack_events.dart b/packages/analytics/lib/sdk/rudderstack/events/rudderstack_events.dart index 2470b8758..4840b0e90 100644 --- a/packages/analytics/lib/sdk/rudderstack/events/rudderstack_events.dart +++ b/packages/analytics/lib/sdk/rudderstack/events/rudderstack_events.dart @@ -17,157 +17,170 @@ class DerivRudderstackEvents { /// Captures app_open event when the app is opened. void logAppOpened() { DerivRudderstack().track( - eventName: 'ce_virtual_signup_form', - properties: RudderProperty.fromMap({ - 'action': 'open', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - })); + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'open', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }), + ); } /// Captures user tap on Log in button on sign up screen. void logUserTappedLoginButton() { DerivRudderstack().track( - eventName: 'ce_virtual_signup_form', - properties: RudderProperty.fromMap({ - 'action': 'go_to_login', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - })); + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'go_to_login', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }), + ); } /// Captures user tap on Get free account button on sign up screen. void logAppGetFreeAccount(String slideName) { DerivRudderstack().track( - eventName: 'ce_virtual_signup_form', - properties: RudderProperty.fromMap({ - 'action': 'get_free_account', - 'form_source': 'mobile_derivgo', - 'getstarted_slide_name': - '${slideName.substring(slideName.indexOf('.') + 1, slideName.length)}', - 'form_name': 'virtual_signup_derivgo' - })); + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'get_free_account', + 'form_source': 'mobile_derivgo', + 'getstarted_slide_name': + '${slideName.substring(slideName.indexOf('.') + 1, slideName.length)}', + 'form_name': 'virtual_signup_derivgo' + }), + ); } /// Tracks when user turns on or off Refferal toggle switcher. void logReferralToggleSwitched() { DerivRudderstack().track( - eventName: 'ce_virtual_signup_form', - properties: RudderProperty.fromMap({ - 'action': 'tab_referral_toggle', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - })); + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'tab_referral_toggle', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }), + ); } /// Tracks when user gets Invalid referral code pop up with Try again button. void logTryAgainReferralCode() { DerivRudderstack().track( - eventName: 'ce_virtual_signup_form', - properties: RudderProperty.fromMap({ - 'action': 'try_again_referral_code', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - })); + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'try_again_referral_code', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }), + ); } /// Tracks when Email confirmation is sent to a user. void logEmailConfirmationSent() { DerivRudderstack().track( - eventName: 'ce_virtual_signup_form', - properties: RudderProperty.fromMap({ - 'action': 'email_confirmation_sent', - 'signup_provider': 'email', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - })); + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'email_confirmation_sent', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }), + ); } /// Tracks when user land on Successfull email verification screen. void logEmailConfirmed() { DerivRudderstack().track( - eventName: 'ce_virtual_signup_form', - properties: RudderProperty.fromMap({ - 'action': 'email_confirmed', - 'signup_provider': 'email', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - })); + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'email_confirmed', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }), + ); } /// Tracks when user taps Continue button on Successfull email verification screen. void logSignupContinued() { DerivRudderstack().track( - eventName: 'ce_virtual_signup_form', - properties: RudderProperty.fromMap({ - 'action': 'signup_continued', - 'signup_provider': 'email', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - })); + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'signup_continued', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }), + ); } /// Tracks when user lands on Country selection screen. void logCountrySelectionPageOpened() { DerivRudderstack().track( - eventName: 'ce_virtual_signup_form', - properties: RudderProperty.fromMap({ - 'action': 'country_selection_screen_opened', - 'signup_provider': 'email', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - })); + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'country_selection_screen_opened', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }), + ); } /// Tracks when user lands on Create password page while creating demo account. void logSetPasswordPageOpened() { DerivRudderstack().track( - eventName: 'ce_virtual_signup_form', - properties: RudderProperty.fromMap({ - 'action': 'password_screen_opened', - 'signup_provider': 'email', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - })); + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'password_screen_opened', + 'signup_provider': 'email', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }), + ); } /// Tracks when user's sign up is finished. void logSignUpDone(String signupProvider) { DerivRudderstack().track( - eventName: 'ce_virtual_signup_form', - properties: RudderProperty.fromMap({ - 'action': 'signup_done', - 'signup_provider': '$signupProvider', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - })); + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'signup_done', + 'signup_provider': '$signupProvider', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }), + ); } /// Tracks when user taps 'Create free demo account' or social log in button. void logSignUpPageAction(String signupProvider, [bool? isToggleOn, String? referralCode]) { DerivRudderstack().track( - eventName: 'ce_virtual_signup_form', - properties: RudderProperty.fromMap({ - 'action': 'started', - 'signup_provider': '$signupProvider', - 'referral_toggle_mode': '${isToggleOn ?? false} ', - 'referral_code': '$referralCode', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - })); + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'started', + 'signup_provider': '$signupProvider', + 'referral_toggle_mode': '${isToggleOn ?? false} ', + 'referral_code': '$referralCode', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }), + ); } /// Tracks any error is happening and shown to the user (validation, API communication, social providers errors). void logSignUpFlowError(String? errorText, [String? signupProvider]) { DerivRudderstack().track( - eventName: 'ce_virtual_signup_form', - properties: RudderProperty.fromMap({ - 'action': 'signup_flow_error', - 'signup_provider': '$signupProvider', - 'error_message': '$errorText', - 'form_source': 'mobile_derivgo', - 'form_name': 'virtual_signup_derivgo' - })); + eventName: 'ce_virtual_signup_form', + properties: RudderProperty.fromMap({ + 'action': 'signup_flow_error', + 'signup_provider': '$signupProvider', + 'error_message': '$errorText', + 'form_source': 'mobile_derivgo', + 'form_name': 'virtual_signup_derivgo' + }), + ); } }