530
Views
3
Comments
[Common Plugin] Error cordova is not defined gets logged
Question
common-plugin
Mobile icon
Forge asset by OutSystems

Invoking GetPlatform on a browser logs an error "cordova is not defined" unnecessarily, and then returns an empty value. This might pollute error logs if your developers use a browser to test the app, or if you're distributing using PWA.


To fix, simply include an IF checking if IsCordovaDefined:


I would also remove the error handlers in this module, which follow the Error Hiding anti-pattern, and could be hiding other issues, although I haven't detected anything else so far.

I'm attaching the module with my suggested changes.

CommonPlugin.oml
UserImage.jpg
Paul Davies

Leonardo,

This is super helpful having the same-ish issues with a PWA.

2021-02-17 18-31-05
Alexandre Jacinto
Staff

Hi @Leonardo Fernandes.

First of all, thank you for your interest in our supported Common Plugin.

We are going to have a closer look into this, and we'll get back to you once we have news to share.

Best regards,
Alexandre Jacinto

2024-04-04 20-38-07
Dallas James

Hello @Leonardo Fernandes

I just wanted to share a quick follow up that the team has taken a look at this suggestion and has implemented some changes to the common plugin. These changes will be made available in the next release of the common plugin.

Thanks!

Dallas James

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.