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
WIP/DNM: Add page requests metric 209 #389
Conversation
@@ -49,7 +49,7 @@ whether they are actively interacting with it. | |||
* Average number of container tabs when new window was clicked | |||
* How many containers do users have hidden at the same time? (when should we measure this? each time a container is hidden?) | |||
* Do users pin container tabs? (do we have existing Telemetry for pinning?) | |||
* Do users change URLs in a container tab? (sounds like it could be a flood unless we only record the first URL change?) | |||
* Do users visit more pages in container tabs than non-container tabs? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To query for this, we will need to do something like:
SELECT AVG(pagerequestcount)
FROM containers_testpilottest
WHERE event = 'page-requests-completed-per-tab'
AND totalcontainerscount = 0
GROUP BY uuid
compared to
SELECT AVG(pagerequestcount)
FROM containers_testpilottest
WHERE event = 'page-requests-completed-per-tab'
AND totalcontainerscount > 0
GROUP BY uuid
@bakulf or @jonathanKingston - can I get an r? on the JS code here? |
webextension/manifest.json
Outdated
@@ -19,8 +19,11 @@ | |||
"homepage_url": "https://testpilot.firefox.com/", | |||
|
|||
"permissions": [ | |||
"contextualIdentitities", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this even required? This is only available in 53 which is an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how I get to tab.cookieStoreId
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure enough, didn't need this. Just needed the cookies
permission.
webextension/manifest.json
Outdated
"cookies", | ||
"tabs" | ||
"tabs", | ||
"webRequest", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge issues ahead...
webextension/background.js
Outdated
@@ -72,3 +73,28 @@ function disableAddon(tabId) { | |||
browser.browserAction.disable(tabId); | |||
browser.browserAction.setTitle({ tabId, title: "Containers disabled in Private Browsing Mode" }); | |||
} | |||
|
|||
browser.tabs.onCreated.addListener(tab => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth having these methods self contained. I did the same for the assign code as it ended up getting mental. Seems like this is all related to tracking tabPageCounters etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either that or for efficiency maybe we have an that does all the browser.apiName obj call methods to other objects for both the assignment and counting... however I dunno if we have a perf issue.
Like:
const apiObj = {
init() {
browser.webRequest.onCompleted.addListener((details) => {
tabPageCounters.request.onComplete(....)
assignManager.calculateContextMenu(...)
});
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes more sense to contain browser.*
API calls when they may share some code and/or scope. Like the themeManager
. So something more like ...
const TabPageCountManager = {
init() {
this.counter = {};
browser.tabs.onCreated.addListener(this.initTabPageloadCounter);
browser.tabs.onRemoved.addListener(this.sendTabPageloadCountAndDelete);
browser.webRequest.onCompleted.addListener(this.incrementTabPageloadCount, {urls: ["<all_urls>"], types: ["main_frame"]});
},
initTabPageloadCounter() { ... },
sendTabPageloadCountAndDelete() { ... },
incrementTabPageloadCount() { ... }
}
6c13b93
to
53dfbf9
Compare
Refactored a new |
0c0d760
to
1ab789e
Compare
webextension/background.js
Outdated
const tabPageCounter = { | ||
init() { | ||
browser.tabs.onCreated.addListener(this.initTabCounter); | ||
browser.tabs.onRemoved.addListener(this.sendTabCountAndDelete); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this capture window closures?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checked in about:telemetry and yes - it does.
webextension/background.js
Outdated
init() { | ||
browser.tabs.onCreated.addListener(this.initTabCounter); | ||
browser.tabs.onRemoved.addListener(this.sendTabCountAndDelete); | ||
browser.webRequest.onCompleted.addListener(this.incrementTabCount, {urls: ["<all_urls>"], types: ["main_frame"]}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you care about tab.tabId might be -1 for non rendered tabs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's an example of a non-rendered tab I can spot-check?
webextension/background.js
Outdated
@@ -1,3 +1,4 @@ | |||
const tabPageRequestCounter = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may as well be internal to tabPageCounter no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved.
webextension/background.js
Outdated
}, | ||
|
||
incrementTabCount(details) { | ||
browser.tabs.get(details.tabId).then(tab => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we (singleArg) => {} or singleArg => {}. One of us will have to change. Seems we are inconsistent in existing code anyway :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mildly prefer NOT to have the extra (
and )
characters in the code just to reduce character noise. But I don't care too much.
1ab789e
to
5e94941
Compare
No description provided.