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

Bug 1706102 - Collect Qt platform information #288

Merged
merged 5 commits into from May 7, 2021

Conversation

Dexterp37
Copy link
Contributor

@Dexterp37 Dexterp37 commented May 6, 2021

This uses the global Qt object to get the OS name and the locale. Unfortunately, os version and architecture are not available.

I manually tested that this works using the Glean.js Qt sample app. I get the following output:

D:\Mozilla\glean.js\samples\qt-qml-app>python main.py
qml: Initialized Glean succesfully.
qml: Adding to the `button_clicked` metric.
qml: Attempted to delete an entry from an invalid index. Ignoring.
qml: {
  "metrics": {
    "datetime": {
      "sample.app_started": "2021-05-06T16:17:26.529+02:00"
    },
    "counter": {
      "sample.button_clicked": 1
    }
  },
  "ping_info": {
    "seq": 0,
    "start_time": "2021-05-06T16:17+02:00",
    "end_time": "2021-05-06T16:17+02:00"
  },
  "client_info": {
    "telemetry_sdk_build": "0.11.0",
    "client_id": "06cbc5b3-2c1b-4cc5-bdaf-85ba62a4afca",
    "first_run_date": "2021-05-06+02:00",
    "os": "Windows",
    "os_version": "Unknown",
    "architecture": "Unknown",
    "locale": "it_IT",
    "app_build": "Unknown",
    "app_display_version": "Unknown"
  }
}
qml: Ping e23108de-1a60-4091-9b7f-b70215d3115d succesfully sent 200.

This uses the global `Qt` object to get the OS name
and the locale. Unfortunately, os version and architecture
are not available.
This is required in order to satisfy the TS compiler. Without
this file, we would be forced to pollute the code with various
eslint rules suppression.
@Dexterp37 Dexterp37 self-assigned this May 6, 2021
Comment on lines +39 to +47
async osVersion(): Promise<string> {
// This data point is not available in Qt QML.
return Promise.resolve("Unknown");
},

async arch(): Promise<string> {
// This data point is not available in Qt QML.
return Promise.resolve("Unknown");
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bakulf do you know any way to get this in Qt-QML?

Copy link

@bakulf bakulf left a comment

Choose a reason for hiding this comment

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

My main concern is related to the use of Qt.locale(). The rest of the code looks good!

},

async locale(): Promise<string> {
const locale = Qt.locale();
Copy link

Choose a reason for hiding this comment

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

Reading this: https://doc.qt.io/qt-5/qml-qtqml-qt.html#locale-method it seems that if name is not valid, QT uses the 'C' locale. Have you tested if this works with non-'C' locales?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, this seems to behave as expected, thanks!

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand the docs, so for understanding: this will give us the dash-separated locale like es-ES or en-US?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I understand the docs, so for understanding: this will give us the dash-separated locale like es-ES or en-US?

Good thing you mentioned this, I double checked and I missed that we were sending es_ES and not es-ES. I twaked the code to fix this :)

This was mistakenly using the QT path, but it was
working because the QT platform was using the "test
platform".
@Dexterp37 Dexterp37 requested a review from badboy May 6, 2021 14:19
Copy link
Member

@badboy badboy left a comment

Choose a reason for hiding this comment

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

Seems simple enough for what's there. Just the one question about the locale.
If Qt has functionality to get os_version and arch, then yeah, we should include that, but it's fine to report unknown for now too

},

async locale(): Promise<string> {
const locale = Qt.locale();
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand the docs, so for understanding: this will give us the dash-separated locale like es-ES or en-US?

This means reporting "it-IT" instead of "it_IT".
@Dexterp37 Dexterp37 merged commit 7900eb5 into mozilla:main May 7, 2021
@Dexterp37 Dexterp37 deleted the qt_platform branch May 7, 2021 08:28
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.

None yet

3 participants