fix #209: page-requests-completed-per-tab metric
This commit is contained in:
parent
52ceef8586
commit
5e94941377
3 changed files with 52 additions and 3 deletions
|
@ -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?
|
||||
|
||||
### Follow-up Questions
|
||||
|
||||
|
@ -178,6 +178,17 @@ of a `testpilottest` telemetry ping for each scenario.
|
|||
}
|
||||
```
|
||||
|
||||
* The user closes a tab
|
||||
|
||||
```js
|
||||
{
|
||||
"uuid": <uuid>,
|
||||
"userContextId": <userContextId>,
|
||||
"event": "page-requests-completed-per-tab",
|
||||
"pageRequestCount": <pageRequestCount>
|
||||
}
|
||||
```
|
||||
|
||||
### A Redshift schema for the payload:
|
||||
|
||||
```lua
|
||||
|
@ -188,6 +199,7 @@ local schema = {
|
|||
{"clickedContainerTabCount", "INTEGER", 255, nil, "Fields[payload.clickedContainerTabCount]"},
|
||||
{"eventSource", "VARCHAR", 255, nil, "Fields[payload.eventSource]"},
|
||||
{"event", "VARCHAR", 255, nil, "Fields[payload.event]"},
|
||||
{"pageRequestCount", "INTEGER", 255, nil, "Fields[payload.pageRequestCount]"}
|
||||
{"hiddenContainersCount", "INTEGER", 255, nil, "Fields[payload.hiddenContainersCount]"},
|
||||
{"shownContainersCount", "INTEGER", 255, nil, "Fields[payload.shownContainersCount]"},
|
||||
{"totalContainersCount", "INTEGER", 255, nil, "Fields[payload.totalContainersCount]"},
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
const themeManager = {
|
||||
existingTheme: null,
|
||||
init() {
|
||||
|
@ -43,7 +42,43 @@ const themeManager = {
|
|||
}
|
||||
};
|
||||
|
||||
const tabPageCounter = {
|
||||
counter: {},
|
||||
|
||||
init() {
|
||||
browser.tabs.onCreated.addListener(this.initTabCounter.bind(this));
|
||||
browser.tabs.onRemoved.addListener(this.sendTabCountAndDelete.bind(this));
|
||||
browser.webRequest.onCompleted.addListener(this.incrementTabCount.bind(this), {urls: ["<all_urls>"], types: ["main_frame"]});
|
||||
},
|
||||
|
||||
initTabCounter(tab) {
|
||||
this.counter[tab.id] = {
|
||||
"cookieStoreId": tab.cookieStoreId,
|
||||
"pageRequests": 0
|
||||
};
|
||||
},
|
||||
|
||||
sendTabCountAndDelete(tab) {
|
||||
browser.runtime.sendMessage({
|
||||
method: "sendTelemetryPayload",
|
||||
event: "page-requests-completed-per-tab",
|
||||
userContextId: this.counter[tab].cookieStoreId,
|
||||
pageRequestCount: this.counter[tab].pageRequests
|
||||
});
|
||||
delete this.counter[tab.id];
|
||||
},
|
||||
|
||||
incrementTabCount(details) {
|
||||
browser.tabs.get(details.tabId).then(tab => {
|
||||
this.counter[tab.id].pageRequests++;
|
||||
}).catch(e => {
|
||||
throw e;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
themeManager.init();
|
||||
tabPageCounter.init();
|
||||
|
||||
browser.runtime.sendMessage({
|
||||
method: "getPreference",
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
|
||||
"permissions": [
|
||||
"cookies",
|
||||
"tabs"
|
||||
"tabs",
|
||||
"webRequest",
|
||||
"<all_urls>"
|
||||
],
|
||||
|
||||
"browser_action": {
|
||||
|
|
Loading…
Add table
Reference in a new issue