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

WIP/DNM: Add page requests metric 209 #389

Merged
merged 1 commit into from Mar 30, 2017

Conversation

groovecoder
Copy link
Member

No description provided.

@groovecoder groovecoder changed the title Add page requests metric 209 WIP/DNM: Add page requests metric 209 Mar 16, 2017
@@ -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?
Copy link
Member Author

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

@groovecoder
Copy link
Member Author

@bakulf or @jonathanKingston - can I get an r? on the JS code here?

@@ -19,8 +19,11 @@
"homepage_url": "https://testpilot.firefox.com/",

"permissions": [
"contextualIdentitities",
Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Member Author

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.

"cookies",
"tabs"
"tabs",
"webRequest",
Copy link
Contributor

Choose a reason for hiding this comment

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

Merge issues ahead... :feelsgood:

@@ -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 => {
Copy link
Contributor

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.

Copy link
Contributor

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(...)
    });
  }
}

Copy link
Member Author

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() { ... }
}

@groovecoder
Copy link
Member Author

Refactored a new tabPageCounter.

@groovecoder groovecoder force-pushed the add-page-requests-metric-209 branch 3 times, most recently from 0c0d760 to 1ab789e Compare March 30, 2017 18:44
const tabPageCounter = {
init() {
browser.tabs.onCreated.addListener(this.initTabCounter);
browser.tabs.onRemoved.addListener(this.sendTabCountAndDelete);
Copy link
Contributor

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?

Copy link
Member Author

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.

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"]});
Copy link
Contributor

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?

Copy link
Member Author

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?

@@ -1,3 +1,4 @@
const tabPageRequestCounter = {};
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved.

},

incrementTabCount(details) {
browser.tabs.get(details.tabId).then(tab => {
Copy link
Contributor

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 :(

Copy link
Member Author

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.

@groovecoder groovecoder merged commit 9e1da08 into master Mar 30, 2017
@groovecoder groovecoder deleted the add-page-requests-metric-209 branch March 30, 2017 20:52
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

2 participants