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

Firebase Analytics + Sentry error logging #54

Merged
merged 16 commits into from
May 11, 2020
Merged

Conversation

wangannie
Copy link
Member

@wangannie wangannie commented Apr 25, 2020

What's new in this PR

  • Integrated Firebase Analytics (new compatibility with Expo SDK 37 from v1.1.1 Release + misc fixes  #52 ) as a free alternative to FullStory. Getting a clear view of how clerks navigate the app can hopefully assist with remote user testing and expose bugs or points of confusion in the UX.
  • Added Analytics logging for the following events:
    • ClerkLogOut
    • GoBackApplyRewards
    • ConfirmTransaction
    • ClerkLogin
    • CustomerFound
    • SelectTrainingMode
    • ConfirmQuantity
    • OpenQuantityModal
    • OpenRewardsModal
    • ConfirmApplyRewards
  • Added Sentry error logging in all try/catch blocks

Relevant Links

Online sources

Firebase setup
Expo Firebase Analytics

Related PRs

Analogous to calblueprint/dccentralkitchen#88

How to review

  • In App.js set Analytics.setAnalyticsCollectionEnabled(false) to true.
  • Log into the Firebase console (shared with [email protected] , credentials pinned in Slack)
  • In the console, go to StreamView under Analytics in the menu on the left
  • Click around the app -- complete test transactions, clerk login, clerk training mode etc and see if the events are properly logged. You may need to refresh the Firebase console a few times for events to start showing up.
  • Look through the Events and various parameters and make sure everything is accurate. Look out for anything that's marked undefined.
  • Make sure the event names and parameters all make sense

Next steps

  • Possibly clean up the event logging into functions in logUtils like Sentry. This might be difficult to standardize since the parameters attached to each event vary so much, but
  • More extensive event logging--look into tracking each transaction process as a session instead of individual events

Tests Performed, Edge Cases

  • Tested several transactions/combinations etc.

Screenshots

  • Successful event logging in the Firebase Console
    analytics events

CC: @anniero98

@wangannie wangannie requested review from annieyro and tommypoa April 25, 2020 07:21
@annieyro
Copy link
Contributor

I keep getting

Possible Unhandled Promise Rejection (id 3): Error: The method or property expo-firebase-analytics.setAnalyticsEnabled is not available on ios, are you sure you've linked all the native dependencies properly?

(this is testing on iPad btw) nothing seems wrong, but I also installed packages yarn complained about just in case. Anyway unable to test it because of that 😅

@annieyro
Copy link
Contributor

annieyro commented May 5, 2020

I'm getting a new error logging into A&S with 1111 ):

Possible Unhandled Promise Rejection (id 0): Error: Invalid user-property value specified. Value should be a string of up to 36 characters long.

Copy link
Contributor

@tommypoa tommypoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks so clean and overall pretty good 😍Left a nit on naming, and some additional ones below:

  • Logging: All my actions are logging onto Firebase fine! I have one thing about logs that I couldn't quite figure out/wrap my head around – why are some of the events within screen_view while others are not? See pic below.
    image
  • Additional Events: Noticed that most of the events logged are successful ones – think there might be some value in capturing events that are failure cases? That's unless there are plans to log with Sentry. Left an example above, but others I can think of:
    • When customer is not found
    • Clerk fail to log in?
  • Redundant events: Unless there are specific functions for logging certain actions, thought that there are a lot of things being logged right now - maybe consider removing some that are less helpful? Mostly concerned that it might slow down the app.

screens/CheckoutScreen.js Show resolved Hide resolved
Analytics.logEvent('ConfirmQuantity', {
name: 'Apply product quantity',
function: 'handleUpdateCart',
screen: 'QuantityModal',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be confusing to have screen as an event property since screen_name is captured with the Analytics too. Perhaps component?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Thanks Tommy

Copy link
Contributor

@annieyro annieyro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I added Sentry logging to all the catch blocks we currently have since one already got added. Remember to add documentation for Firebase ! Because we have two projects and both have to be shared to the HC team if they aren't yet; wondering if we should share all the accounts to their team email or make one for them (since I have two sites deployed also under my accounts)

@@ -69,6 +70,11 @@ export default class StoreLookupScreen extends React.Component {
handleNavigate = async () => {
// Clerk training: set `trainingMode` to "true" in AsyncStorage
if (this.state.store.storeName === 'CLERK TRAINING') {
await Analytics.logEvent('SelectTrainingMode', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Analytics.logEvent returns a promise? Googled a bit and it doesn't seem like it. If it does, we'll have to add try/catch blocks because that means there are unhandled promise rejections. Otherwise, using await here is a bit misleading

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you're right. I removed the awaits

@@ -41,6 +42,13 @@ export default class CustomerLookupScreen extends React.Component {

_asyncCustomerFound = async (customerRecord) => {
await AsyncStorage.setItem('customerId', customerRecord.id);
await Analytics.logEvent('CustomerFound', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await used here

screens/CheckoutScreen.js Outdated Show resolved Hide resolved
component: 'ClerkLoginScreen',
clerk_id: clerkRecord.id,
clerk_name: clerkRecord.clerkName,
store_name: clerkRecord.storeName[0],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity why did this fix it? Do lookup type records always return arrays from Airtable :o I was not aware

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah apparently they do return arrays. Not sure if there's a better way to do this, since clerks should only ever be connected to a single store?

@wangannie wangannie changed the title Firebase Analytics Firebase Analytics + Sentry error logging May 11, 2020
@wangannie wangannie merged commit c0c9862 into master May 11, 2020
@wangannie wangannie deleted the AnnieW/firebase branch May 11, 2020 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants