ChildMindInstitute / mindlogger-app

MindLogger (React Native) data collection app
Other
15 stars 6 forks source link

App crashes/dashboard is refreshed after tapping the notification #2836

Closed natalia-muzyka closed 1 year ago

natalia-muzyka commented 1 year ago

Preconditions The user is logged on admin panel There is the applet with activity flow The mobile app is installed and launched

Steps to reproduce

  1. Set up the schedule for the activity and activity flow with the notification
  2. Refresh the app home screen or log out/log in
  3. Wait for notification time
  4. Tap the flow notification
  5. Observe the result

Actual result App crashes on iOS/dashboard is refreshed on Android after tapping the Flow notification

Expected result The first activity screen is opened after tapping the Flow notification if the flow was not started yet. The pop-up with Resume and Restart buttons is shown up after tapping the Flow notification if the flow was already started.

Video (Android): https://www.screencast.com/t/x7glcb5HCFK8 Video (iOS): https://www.screencast.com/t/MZbRLeVuNL

Environment: https://admin.mindlogger.org/ Win 10 / Chrome 103 ML v0.21.48 staging, prod iPhone 7 // iOS 13.1.1 Samsung Galaxy Tab S6 SM-T865 // Android 9.0 Apple iPad 9th gen (2021) / iOS 15.5 test-user1@com.us / qwerty Schedule flow https://admin-staging.mindlogger.org/ user-stg@ml.com / 123456 Config reports v13 Applet password: Qwe123!!!

natalia-muzyka commented 1 year ago

Crash is reproducible on iOS after tapping the push notification of any scheduled activity. Video: https://www.screencast.com/t/o7oQmZe5CM

cc: @WorldImpex

Environment: https://admin.mindlogger.org/ Win 10 / Chrome 103 ML v0.21.48 staging, prod Samsung Galaxy Tab S6 SM-T865 // Android 9.0 Apple iPad 9th gen (2021) / iOS 15.5 test-user1@com.us / qwerty Schedule https://admin-staging.mindlogger.org/ user-stg@ml.com Test applet Applet password: Qwe123!!!

anq83 commented 1 year ago

re.crash - versioning firebase for react native issue

https://github.com/invertase/react-native-firebase/issues/4610

should to figure out how to resolve.

anq83 commented 1 year ago

About crash - it has been resolved (but has not deployed for test yet)

About resume of activity flow. There're several reasons:

  1. We do not receive necessary data in the body of push notification (assigned to Tom):
image
  1. 2 endpoints: a. for getting all applets (when refresh the app or login) and b. get a single applet (about this one not sure 100%, need to check)
    • do not contain the schedule events related to activity flow. They only have the ones related to activities (single) user/applet/${appletId} /user/applets?${queryParams}

use my creds to reproduce (nalivaiko@scnsoft.com / a8R3arar), the applet: applet_2822

ask me for more details if you need

image

(Tom is also aware)

  1. Open mobile app -> add a schedule event in Admin website (for a single activity for now) and notification -> switch to mobile app again, do not refresh!, wait for the notification -> the notification comes with the eventId which is not in the mobile app state, that's why it will not open or resume the activiity. But if to refresh before getting notiication - then it will work.

Idea how to fix - use getTargetApplet method which already exists in the notification handler.

DeepDeveloper1996 commented 1 year ago

I found out when frontend sets events using this endpoint http://localhost/api/v1/applet/632ab2b3dd21057d7593fb61/setSchedule, it is not sending activity_flow_id for flow event, as it is missing, on getting events validation is removing this event

{
   "around":1661972400000,
   "events":[
      {
         "data":{
            "URI":"632ab2b3dd21057d7593fb54",
            "activity_id":"632ab2b3dd21057d7593fb54",
            "availability":false,
            "busy":true,
            "calendar":"",
            "color":"#F44336",
            "completion":false,
            "description":"",
            "eventType":"",
            "extendedTime":{
               "allow":false,
               "minute":1
            },
            "forecolor":"#ffffff",
            "icon":"",
            "idleTime":{
               "allow":false,
               "minute":1
            },
            "isActivityFlow":false,
            "location":"",
            "notifications":[
               {
                  "end":"None",
                  "random":false,
                  "start":"None"
               }
            ],
            "onlyScheduledDay":false,
            "reminder":{
               "days":0,
               "time":"",
               "valid":false
            },
            "timedActivity":{
               "allow":false,
               "hour":0,
               "minute":59,
               "second":59
            },
            "timeout":{
               "access":false,
               "allow":false,
               "day":0,
               "hour":23,
               "minute":59
            },
            "title":"Activity 1",
            "useNotifications":true,
            "users":[
               "632ab2b6dd21057d7593fb6a"
            ]
         },
         "id":"63315a78dd21052ea429565c",
         "schedule":{
            "dayOfMonth":[
               26
            ],
            "month":[
               8
            ],
            "year":[
               2022
            ]
         }
      },
      {
         "data":{
            "URI":"632ab485dd21057d7593fb75",
            "activity_id":"632ab485dd21057d7593fb75",
            "availability":false,
            "busy":true,
            "calendar":"",
            "color":"#E91E63",
            "completion":false,
            "description":"",
            "eventType":"",
            "extendedTime":{
               "allow":false,
               "minute":1
            },
            "forecolor":"#ffffff",
            "icon":"",
            "idleTime":{
               "allow":false,
               "minute":1
            },
            "isActivityFlow":false,
            "location":"",
            "onlyScheduledDay":false,
            "reminder":{
               "days":0,
               "time":"",
               "valid":false
            },
            "timedActivity":{
               "allow":false,
               "hour":0,
               "minute":59,
               "second":59
            },
            "timeout":{
               "access":false,
               "allow":false,
               "day":0,
               "hour":23,
               "minute":59
            },
            "title":"Activity2",
            "users":[
               "632ab2b6dd21057d7593fb6a"
            ]
         },
         "id":"63315a78dd21052ea429565e",
         "schedule":{
            "dayOfMonth":[
               26
            ],
            "month":[
               8
            ],
            "year":[
               2022
            ]
         }
      },
      {
         "data":{
            "URI":"63315a36dd21052ea4295654",
            "availability":false,
            "busy":true,
            "calendar":"",
            "color":"#9C27B0",
            "completion":false,
            "description":"",
            "eventType":"",
            "extendedTime":{
               "allow":false,
               "minute":1
            },
            "forecolor":"#ffffff",
            "icon":"",
            "idleTime":{
               "allow":false,
               "minute":1
            },
            "isActivityFlow":true,
            "location":"",
            "onlyScheduledDay":false,
            "reminder":{
               "days":0,
               "time":"",
               "valid":false
            },
            "timedActivity":{
               "allow":false,
               "hour":0,
               "minute":59,
               "second":59
            },
            "timeout":{
               "access":false,
               "allow":false,
               "day":0,
               "hour":23,
               "minute":59
            },
            "title":"Flow1",
            "users":[
               "632ab2b6dd21057d7593fb6a"
            ]
         },
         "id":"63315f28dd21052ea4295661",
         "schedule":{
            "dayOfMonth":[
               26
            ],
            "month":[
               8
            ],
            "year":[
               2022
            ]
         }
      }
   ],
   "eventsOutside":true,
   "fill":true,
   "listTimes":false,
   "minimumSize":0,
   "repeatCovers":true,
   "size":1,
   "type":2,
   "updateColumns":false,
   "updateRows":true
}
DeepDeveloper1996 commented 1 year ago

Request body is written

anq83 commented 1 year ago

@Tom1204

  1. Re. endpoint get single applet: e.g. https://api.mindlogger.org/api/v1/user/applet/631f0dd1b7ee970ffa900df3?retrieveSchedule=true&role=user&getAllApplets=true&nextActivity=

We can see that beside the "events" property there is no property "data" Whereas for the get multiple applets - it exists. So you need

  1. ensure that property "events" contain the events that related to activity flow
  2. ensure that property "data" exist, it will contain the information about schedule and events also

This is response for single applet:

image

This is response for multiple applets:

image
iradchenk0 commented 1 year ago

Fixed setSchedule request payload, added activity_flow_id field. Branch with fix in PR

DeepDeveloper1996 commented 1 year ago

@anq83 Added accepting query parameter numberOfDays, so when you get detail of single applet send numberOfDays=7 in order to get data parameter in schedule, here is pull request https://github.com/ChildMindInstitute/mindlogger-backend/pull/1312, once @karser confirm and push to staging environment, you can check it

natalia-muzyka commented 1 year ago

waiting on a new mobile app build

anq83 commented 1 year ago

Build has deployed on TestFlight versionCode 606 versionName "0.21.53"

anq83 commented 1 year ago

The schedules for activity flows that already exist - should be re-created for getting this working. Every edit of a schedule means a new entity of schedule, that means a new event id on mobile app as well. In-progress state relies on event id + activity id. That means if you edit a schedule and get noltification - you'll not see the dialog Resume or Restart. The activity or flow will just start.

natalia-muzyka commented 1 year ago

The app is not crashing anymore, but there are a few related issues appeared:

1 - If the flow was interrupted not on the first activity, then the new notification is not received (this issue is not reproduced on prod). Video (staging): https://www.screencast.com/t/PMGza43K8X2 Video (prod): https://www.screencast.com/t/VlbPNHD06

2 - The restart/resume pop-up is not always shown after tapping the notification even if the app was refreshed and activity flow started/interrupted after the refreshing. It was retested with a new flow every time. Reproducibility: 4/5 It is not reproduced on a single activity. Video: https://www.screencast.com/t/oJQNt4LuOJV7

3 - Activity flow's names are disappeared from the event cards for some flows (could this be related to 1803 PR?) (not reproduced on prod) Video: https://www.screencast.com/t/Ej8aPbSywyC

4 - After tapping a notification there is a delay 3-7 seconds and the dashboard is refreshing before opening the activity. Is this a part of the fix, and is it possible to make it faster? Video: https://www.screencast.com/t/SRpp0dao1

Environment: ML v0.21.53 iPhone 7 // iOS 13.1.1 iPhone 13 // iOS 15.6 Samsung Galaxy S7 // Android 8 Google Pixel 5a // Android 11 staging: user-stg@ml.com / 123456 applet: new schedule retest Applet password: Qwe123!!! prod: test-user1@com.us / qwerty schedule flow retest 2 Applet password: Qwe123!!!

anq83 commented 1 year ago

@natalia-muzyka re. 4, as I mentioned this is not a bug, because the applet re-loaded from server (for getting actual schedule events and-or added activities). But, I suppose we also should add the preloader on activity list page. If agree, then add a ticket please.

natalia-muzyka commented 1 year ago

As a crashing issue is fixed, the current ticket can be closed. Activity flow scheduling (as well as notifications) are in a lower priority now. Related issues are moved to JIRA: https://mindlogger.atlassian.net/browse/MIN-12

natalia-muzyka commented 1 year ago

After the latest changes, the application dashboard refreshes after tapping the notification. If notification is tapped in offline (without an internet connection) then activity won't be opened, because dashboard can't be refreshed. The infinity preloader is on the board, but the application is not blocked (user can take assessments, etc).

@binarybottle @WorldImpex is this issue a blocker for release?

@anq83 is it possible to make a different behavior only for offline, or the fix should be changed overall then?

As this ticket includes all the relevant changes and all the participants, I'm leaving a comment here, and depending on a solution we'll create a new ticket in JIRA or will continue work with the current.

cc: @eleonova-scn @yzenchanka

natalia-muzyka commented 1 year ago

image.png

cc: @eleonova-scn @anq83 @yzenchanka @Tom1204

anq83 commented 1 year ago

Please check fix: 0.21.54 (607) @natalia-muzyka

natalia-muzyka commented 1 year ago

The notification received offline for single is opened now. Fixed on Android and iOS. The flow notification is not opening. Created a new ticket in JIRA (as an activity flow scheduling has a lower priority): https://mindlogger.atlassian.net/browse/MIN-18

Environment: ML v0.21.54 staging iPhone 13 // iOS 15.6 Google Pixel 5a // Android 11 iPhone 7+ DM / iOS 14.4.1 Samsung Galaxy S20 FE SM-G780G / Android 12