OnBoarding: Send analytics on each button press

This commit is contained in:
Vishesh Handa
2019-01-18 12:28:32 +01:00
parent a88a6d0701
commit d6d68a5a0f
2 changed files with 22 additions and 24 deletions

View File

@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:journal/analytics.dart';
class OnBoardingGitUrl extends StatefulWidget {
final Function doneFunction;
@ -110,7 +112,7 @@ class OnBoardingButton extends StatelessWidget {
style: Theme.of(context).textTheme.button,
),
color: Theme.of(context).primaryColor,
onPressed: onPressed,
onPressed: this._onPressedWithAnalytics,
),
);
} else {
@ -124,9 +126,21 @@ class OnBoardingButton extends StatelessWidget {
),
icon: Image.asset(iconUrl, width: 32, height: 32),
color: Theme.of(context).primaryColor,
onPressed: onPressed,
onPressed: this._onPressedWithAnalytics,
),
);
}
}
void _onPressedWithAnalytics() {
print("onboarding_button_click " + text);
getAnalytics().logEvent(
name: "onboarding_button_click",
parameters: <String, dynamic>{
'text': text,
'icon_url': iconUrl == null ? "" : iconUrl,
},
);
onPressed();
}
}

View File

@ -353,30 +353,14 @@ class OnBoardingInitialChoice extends StatelessWidget {
style: Theme.of(context).textTheme.headline,
),
SizedBox(height: 8.0),
SizedBox(
width: double.infinity,
child: RaisedButton(
child: Text(
"Create a New Repo",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.button,
),
color: Theme.of(context).primaryColor,
onPressed: onCreateNewRepo,
),
OnBoardingButton(
text: "Create a New Repo",
onPressed: onCreateNewRepo,
),
SizedBox(height: 8.0),
SizedBox(
width: double.infinity,
child: RaisedButton(
child: Text(
"I already have one",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.button,
),
color: Theme.of(context).primaryColor,
onPressed: onExistingRepo,
),
OnBoardingButton(
text: "I already have one",
onPressed: onExistingRepo,
),
],
mainAxisAlignment: MainAxisAlignment.center,