5

Enhance user experience using SAP BTP Mobile Services Part 5

 1 year ago
source link: https://blogs.sap.com/2022/11/10/enhance-user-experience-using-sap-btp-mobile-services-part-5/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
November 10, 2022 3 minute read

Enhance user experience using SAP BTP Mobile Services Part 5

My name is Nhat Doan. I am currently in SAP Student Training and Rotation (STAR) Program. In my first rotation, I have a chance to join CoE Mobile & UX team. I have learned a lot of things especially about current developments in mobile technology. Today, smartphones become essential for daily life. Businesses are using mobile applications to serve their clients and they will see many benefits such as brand building, customer connection, and profit boosts. I would like to share some topics concerning mobile development.

How to reads log, traces issue, and measures performance for MDK application

For this blog, I would like to share how I use Android Studio to read logs, traces issue, and measure the performance for MDK application.

Read log

Set up to run the application on virtual device.  Open Android Studio, select Logcat tab at the bottom of the application. Select the package (AppId) that we want to see the log.

pic_5_1.png

Figure 1: Use Logcat to see the log of MDK application

Trace issue

Here is an example of updating a record unsuccessful. The application shows the error.

pic_5_2.png

Figure 2: The application show error when updating a record

Go to Logcat and check the log. We can see the error log in the Logcat.

pic_5_3.png

Figure 3: The error log in Logcat

Based on the log error, the issue is we update the record using PATH method (The UpdateValue in action file is Merge). However, the oData service does not support PATCH. We need to change the UpdateMode value  from Merge to Replace.

pic_5_4.png

Figure 4: Change UpdateMode to Replace

Now the application can update the records successfully.

pic_5_5.png

Figure 5: The application run normally after fixing the bug

Performance measure

This example shows how to measure the time the application performs an action to update a record and the actual time of oData service takes to update the record. It will be very useful for analyzing performance issue of MDK application.

We can use the rule file to log the time of an action. The code below is the content of ExecuteUpdateCartItem.js

export default async function ExecuteUpdateCartItem(context) {
    try {
        console.log('ExecuteUpdateCartItem start')
        console.time('ExecuteUpdateCartItem')
        return await context.executeAction({
            'Name': '/ProductCatalog2/Actions/Cart/UpdateCartItem.action'
        })
    } catch (e) {
        console.error(e);
    } finally {
        console.timeEnd('ExecuteUpdateCartItem')
        console.log('ExecuteUpdateCartItem end')
    }
}

This rule file will be called when we update a record instead of using UpdateCartItem.action directly.

pic_5_6.png

Figure 6: Use rule file to have the log

Run the application and check the log. Now we have the time for performing UpdateCartItem.action in the log.

pic_5_7.png

Figure 7: The time of executing UpdateCartItem.action

We can use App Inspection in Android Studio to measure the time of calling oData service to update a record. Click on App Inspection at the bottom of Android Studio. Select the package that we want to inspect (AppId). And select Network Inspector tab. Select the timeline that we want to inspect.

pic_5_8.png

Figure 8: The time of sending and receiving data

We can use the time from the log file and from App Inspection for analyzing the performance of MDK application.

Conclusion

We have just finished reading logs, analyzing issues, and tracing performance for MDK application. It will be useful in the future for fixing bug, or analyzing the performance issue.

Please let me know your feedback, questions in the comments. I would be happy to get back to you.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK