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

[DO NOT MERGE] Bug 1727776, #1599 - Attempt at fixing Glean.js + iOS issues #1854

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Setup Glean Dependency
shell: bash
run: |
pip3 install "glean_parser==3.5"
pip3 install "glean_parser==4.0"
pip3 install pyyaml

- name: Compilation
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
shell: bash
run: |
sudo apt-get install golang debhelper -y
pip3 install "glean_parser==3.5"
pip3 install "glean_parser==4.0"
pip3 install pyyaml

- name: Build source bundle
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/macos-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Generating glean samples
shell: bash
run: |
pip3 install "glean_parser==3.5"
pip3 install "glean_parser==4.0"
pip3 install pyyaml
python3 scripts/generate_glean.py

Expand Down Expand Up @@ -193,7 +193,7 @@ jobs:
- name: Generating glean samples
shell: bash
run: |
pip3 install "glean_parser==3.5"
pip3 install "glean_parser==4.0"
pip3 install pyyaml
python3 scripts/generate_glean.py

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wasm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Install glean depedencies
shell: bash
run: |
pip3 install "glean_parser==3.5"
pip3 install "glean_parser==4.0"
pip3 install pyyaml

- name: Setup emsdk
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Install glean depedencies
shell: bash
run: |
pip3 install "glean_parser==3.5"
pip3 install "glean_parser==4.0"
pip3 install pyyaml

- name: Adding msbuild to PATH
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ following dependencies:

Python3 (pip) depedencies:

- glean_parser==3.5
- glean_parser==4.0
- pyyaml

#### QT5
Expand Down Expand Up @@ -152,7 +152,7 @@ This step needs to be updated each time XCode updates.
```
4. Install python3 dependencies:
```
$ pip3 install 'glean_parser==3.5'
$ pip3 install 'glean_parser==4.0'
$ pip3 install pyyaml
```
5. Copy `xcode.xconfig.template` to `xcode.xconfig`
Expand Down Expand Up @@ -212,7 +212,7 @@ Once Qt has been installed, the IOS procedure is similar to the macOS one:

3. Install python3 dependencies:
```
$ pip3 install 'glean_parser==3.5'
$ pip3 install 'glean_parser==4.0'
$ pip3 install pyyaml
```

Expand Down Expand Up @@ -259,7 +259,7 @@ Add the Adjust SDK token with `-a | --adjust <adjust_token>`

5. Install python3 dependencies:
```
$ pip3 install 'glean_parser==3.5'
$ pip3 install 'glean_parser==4.0'
$ pip3 install pyyaml
```

Expand All @@ -286,7 +286,7 @@ The dependencies are:
2. nasm: https://www.nasm.us/
3. python3: https://www.python.org/downloads/windows/
4. visual studio 2019: https://visualstudio.microsoft.com/vs/
5. Install python3 dependencies (pip install "glean_parser==3.5" pyyaml)
5. Install python3 dependencies (pip install "glean_parser==4.0" pyyaml)

Openssl can be obtained from here: https://www.openssl.org/source/
Qt5.15 can be obtained from: https://download.qt.io/archive/qt/5.15/5.15.1/single/qt-everywhere-src-5.15.1.tar.xz
Expand Down
14 changes: 13 additions & 1 deletion glean/org/mozilla/Glean/glean.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
// This file is the actual entry point file for Glean.js in QML, that users will interact with.
//
// I was not able to figure out a way to simply use the Webpack generated file to
// be the entry point in Qt, because of the unusual syntax allowed in Qt Javascript.
// be the entry point in Qt, because of the unusual syntax allowed in Qt JavaScript.
// Thus, we compile the Glean.js library normaly into the `glean.lib.js` file and then
// we have this file which interacts opaquely with the Webpack generated one.
//
// **All functions and variables defined here are public.**

.pragma library

.import QtQuick.LocalStorage 2.15 as LocalStorage
.import "glean.lib.js" as Glean

/**
Expand Down Expand Up @@ -90,4 +91,15 @@ function setSourceTags(value) {
Glean.Glean.default.setSourceTags(value);
}

/**
* Finishes executing any ongoing tasks and shuts down Glean.
*
* This will attempt to send pending pings before resolving.
*
* @returns A promise which resolves once shutdown is complete.
*/
function shutdown() {
return Glean.shutdown();
}

const _private = Glean.Glean.default._private;
6,493 changes: 6,492 additions & 1 deletion glean/org/mozilla/Glean/glean.lib.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion glean/org/mozilla/Glean/qmldir
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
module org.mozilla.Glean
Glean 0.15 glean.js
Glean 0.20 glean.js
2 changes: 1 addition & 1 deletion scripts/generate_glean.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def camelize(string):
try:
subprocess.call(["glean_parser", "translate", "glean/metrics.yaml", "glean/pings.yaml",
"-f", "javascript", "-o", "glean/telemetry", "--option", "platform=qt",
"--option", "version=0.15"])
"--option", "version=0.20"])
except:
print("glean_parser failed. Is it installed? Try with:\n\tpip3 install glean_parser");
exit(1)
Expand Down
2 changes: 1 addition & 1 deletion src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ CONSTEXPR(uint32_t, captivePortalRequestTimeoutMsec, 10000, 4000, 0)
CONSTEXPR(uint32_t, statusIconAnimationMsec, 200, 200, 0)

// How often glean pings are sent
CONSTEXPR(uint32_t, gleanTimeoutMsec, 1200000, 1000, 0)
CONSTEXPR(uint32_t, gleanTimeoutMsec, 10000, 1000, 0)

// How often we check the surveys to be executed (no network requests are done
// for this check)
Expand Down
2 changes: 0 additions & 2 deletions src/featurelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "features/featureappreview.h"
#include "features/featurecaptiveportal.h"
#include "features/featurecustomdns.h"
#include "features/featureglean.h"
#include "features/featureinappaccountcreate.h"
#include "features/featureinappauth.h"
#include "features/featureinapppurchase.h"
Expand Down Expand Up @@ -43,7 +42,6 @@ void FeatureList::initialize() {
new FeatureAppReview();
new FeatureCaptivePortal();
new FeatureCustomDNS();
new FeatureGlean();
new FeatureInAppAccountCreate();
new FeatureInAppAuth();
new FeatureInAppPurchase();
Expand Down
40 changes: 0 additions & 40 deletions src/features/featureglean.h

This file was deleted.

5 changes: 4 additions & 1 deletion src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ QT += widgets
QT += charts
QT+= websockets

# Necessary for the Glean.js storage to work
QT += sql
ios:QTPLUGIN += qsqlite

# for the inspector
QT+= testlib
QT.testlib.CONFIG -= console
Expand Down Expand Up @@ -202,7 +206,6 @@ HEADERS += \
features/featureappreview.h \
features/featurecaptiveportal.h \
features/featurecustomdns.h \
features/featureglean.h \
features/featureinappaccountCreate.h \
features/featureinappauth.h \
features/featureinapppurchase.h \
Expand Down
4 changes: 2 additions & 2 deletions src/ui/components/VPNConnectionStability.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import QtQuick.Layouts 1.14
import Mozilla.VPN 1.0
import "../themes/themes.js" as Theme

import org.mozilla.Glean 0.15
import telemetry 0.15
import org.mozilla.Glean 0.20
import telemetry 0.20

Item {
property var gridFlow: grid.flow
Expand Down
4 changes: 2 additions & 2 deletions src/ui/components/VPNControllerView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import Mozilla.VPN 1.0
import "../themes/themes.js" as Theme
import "../themes/colors.js" as Color

import org.mozilla.Glean 0.15
import telemetry 0.15
import org.mozilla.Glean 0.20
import telemetry 0.20

Item {
id: box
Expand Down
4 changes: 2 additions & 2 deletions src/ui/components/VPNToggleCard.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import Mozilla.VPN 1.0
import "../components"
import "../themes/themes.js" as Theme

import org.mozilla.Glean 0.15
import telemetry 0.15
import org.mozilla.Glean 0.20
import telemetry 0.20

Item {
property alias labelText: label.text
Expand Down
4 changes: 2 additions & 2 deletions src/ui/components/VPNViewDNSSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import "../components"
import "../components/forms"
import "../themes/themes.js" as Theme

import org.mozilla.Glean 0.15
import telemetry 0.15
import org.mozilla.Glean 0.20
import telemetry 0.20


VPNFlickable {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/developerMenu/ViewFeatureList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import Mozilla.VPN 1.0
import "../components"
import "../themes/themes.js" as Theme

import org.mozilla.Glean 0.15
import telemetry 0.15
import org.mozilla.Glean 0.20
import telemetry 0.20


Item {
Expand Down
46 changes: 10 additions & 36 deletions src/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import Mozilla.VPN 1.0
import "./components"
import "themes/themes.js" as Theme

import org.mozilla.Glean 0.15
import telemetry 0.15
import org.mozilla.Glean 0.20
import telemetry 0.20

Window {
id: window
Expand Down Expand Up @@ -63,33 +63,11 @@ Window {
minimumWidth = Theme.desktopAppWidth
}

Glean.initialize('MozillaVPN', VPNSettings.gleanEnabled && VPNFeatureList.get("glean").isSupported, {
Glean.setLogPings(true);
Glean.setDebugViewTag("vpn-testing");
Copy link
Contributor Author

@brizental brizental Sep 21, 2021

Choose a reason for hiding this comment

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

This tag is a debugging feature. Setting this means all pings will be tagged upon sending, in practice that means the pings are re-routed to Glean's debug ping viewer. You can see the ping I sent when testing this here: https://debug-ping-preview.firebaseapp.com/pings/vpn-testing, subsequent pings sent with this tag will also show up there.

Glean.initialize('MozillaVPN', VPNSettings.gleanEnabled, {
appBuild: `MozillaVPN/${VPN.versionString}`,
appDisplayVersion: VPN.versionString,
httpClient: {
post(url, body, headers) {
if (typeof(VPNGleanTest) !== "undefined") {
VPNGleanTest.requestDone(url, body);
}
if (VPN.stagingMode) {
return Promise.reject('Glean disabled in staging mode');
}

return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open("POST", url);

for (const header in headers) {
xhr.setRequestHeader(header, headers[header]);
}
xhr.onloadend = () => {
resolve({status: xhr.status, result: 2 /* UploadResultStatus.Success */ });
}
xhr.send(body);

});
}
}
appDisplayVersion: VPN.versionString
});
}

Expand Down Expand Up @@ -313,21 +291,17 @@ Window {
}

function onSendGleanPings() {
if (VPNSettings.gleanEnabled && VPNFeatureList.get("glean").isSupported) {
Pings.main.submit();
}
Pings.main.submit();
}

function onTriggerGleanSample(sample) {
Sample[sample].record();
}

function onAboutToQuit() {
// We are about to quit. Let's see if we are fast enough to send
// the last chunck of data to the glean servers.
if (VPNSettings.gleanEnabled && VPNFeatureList.get("glean").isSupported) {
Pings.main.submit();
}
Pings.main.submit();
// TODO: Actually await somehow on this Promise beforre quitting.
Glean.shutdown();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/ui/settings/ViewAdvancedDNSSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import "../components"
import "../components/forms"
import "../themes/themes.js" as Theme

import org.mozilla.Glean 0.15
import telemetry 0.15
import org.mozilla.Glean 0.20
import telemetry 0.20


Item {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/settings/ViewAppPermissions.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import Mozilla.VPN 1.0
import "../components"
import "../themes/themes.js" as Theme

import org.mozilla.Glean 0.15
import telemetry 0.15
import org.mozilla.Glean 0.20
import telemetry 0.20


Item {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/settings/ViewNetworkSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import Mozilla.VPN 1.0
import "../components"
import "../themes/themes.js" as Theme

import org.mozilla.Glean 0.15
import telemetry 0.15
import org.mozilla.Glean 0.20
import telemetry 0.20


Item {
Expand Down
Loading