Fix Bug 1459318 - Enable telemetry for AS Router
This commit is contained in:
Родитель
20df47894f
Коммит
d1f54414fd
|
@ -140,6 +140,21 @@ Schema definitions/validations that can be used for tests can be found in `syste
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Example Activity Stream `Router` Pings
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
"client_id": "n/a",
|
||||||
|
"action": ["snippets_user_event" | "onboarding_user_event"],
|
||||||
|
"impression_id": "{005deed0-e3e4-4c02-a041-17405fd703f6}",
|
||||||
|
"source": "pocket",
|
||||||
|
"addon_version": "1.0.12",
|
||||||
|
"locale": "en-US",
|
||||||
|
"source": "NEWTAB_FOOTER_BAR",
|
||||||
|
"message_id": "some_snippet_id",
|
||||||
|
"event": "IMPRESSION"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
| KEY | DESCRIPTION | |
|
| KEY | DESCRIPTION | |
|
||||||
|-----|-------------|:-----:|
|
|-----|-------------|:-----:|
|
||||||
|
@ -195,8 +210,9 @@ and losing focus. | :one:
|
||||||
| `is_prerendered` | [Required] A boolean to signify whether the page is prerendered or not | :one:
|
| `is_prerendered` | [Required] A boolean to signify whether the page is prerendered or not | :one:
|
||||||
| `is_preloaded` | [Required] A boolean to signify whether the page is preloaded or not | :one:
|
| `is_preloaded` | [Required] A boolean to signify whether the page is preloaded or not | :one:
|
||||||
| `icon_type` | [Optional] ("tippytop", "rich_icon", "screenshot_with_icon", "screenshot", "no_image") | :one:
|
| `icon_type` | [Optional] ("tippytop", "rich_icon", "screenshot_with_icon", "screenshot", "no_image") | :one:
|
||||||
| `region` | [Optional] An string maps to pref "browser.search.region", which is essentially the two letter ISO 3166-1 country code populated by the Firefox search service. Note that: 1). it reports "OTHER" for those regions with smaller Firefox user base (less than 10000) so that users cannot be uniquely identified; 2). it reports "UNSET" if this pref is missing; 3). it reports "EMPTY" if the value of this pref is an empty string. | :one:
|
| `region` | [Optional] A string maps to pref "browser.search.region", which is essentially the two letter ISO 3166-1 country code populated by the Firefox search service. Note that: 1). it reports "OTHER" for those regions with smaller Firefox user base (less than 10000) so that users cannot be uniquely identified; 2). it reports "UNSET" if this pref is missing; 3). it reports "EMPTY" if the value of this pref is an empty string. | :one:
|
||||||
| `profile_creation_date` | [Optional] An integer to record the age of the Firefox profile as the total number of days since the UNIX epoch. | :one:
|
| `profile_creation_date` | [Optional] An integer to record the age of the Firefox profile as the total number of days since the UNIX epoch. | :one:
|
||||||
|
|`message_id` | [required] A string identifier of the message in Activity Stream Router. | :one:
|
||||||
|
|
||||||
**Where:**
|
**Where:**
|
||||||
|
|
||||||
|
|
|
@ -462,7 +462,7 @@ This reports the duration of the domain affinity calculation in milliseconds.
|
||||||
|
|
||||||
## Undesired event pings
|
## Undesired event pings
|
||||||
|
|
||||||
There pings record the undesired events happen in the addon for further investigation.
|
These pings record the undesired events happen in the addon for further investigation.
|
||||||
|
|
||||||
### Addon initialization failure
|
### Addon initialization failure
|
||||||
|
|
||||||
|
@ -479,3 +479,42 @@ This reports when the addon fails to initialize
|
||||||
"value": -1
|
"value": -1
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Activity Stream Router pings
|
||||||
|
|
||||||
|
These pings record the impression and user interactions within Activity Stream Router.
|
||||||
|
|
||||||
|
### Impression ping
|
||||||
|
|
||||||
|
This reports the impression of Activity Stream Router.
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
"client_id": "n/a",
|
||||||
|
"action": ["snippets_user_event" | "onboarding_user_event"],
|
||||||
|
"impression_id": "{005deed0-e3e4-4c02-a041-17405fd703f6}",
|
||||||
|
"source": "pocket",
|
||||||
|
"addon_version": "1.0.12",
|
||||||
|
"locale": "en-US",
|
||||||
|
"source": "NEWTAB_FOOTER_BAR",
|
||||||
|
"message_id": "some_snippet_id",
|
||||||
|
"event": "IMPRESSION"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### User interaction pings
|
||||||
|
|
||||||
|
This reports the user's interaction with Activity Stream Router.
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
"client_id": "n/a",
|
||||||
|
"action": ["snippets_user_event" | "onboarding_user_event"],
|
||||||
|
"addon_version": "1.0.12",
|
||||||
|
"impression_id": "{005deed0-e3e4-4c02-a041-17405fd703f6}",
|
||||||
|
"locale": "en-US",
|
||||||
|
"source": "NEWTAB_FOOTER_BAR",
|
||||||
|
"message_id": "some_snippet_id",
|
||||||
|
"event": ["CLICK_BUTTION" | "BLOCK"]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
|
@ -368,8 +368,10 @@ this.TelemetryFeed = class TelemetryFeed {
|
||||||
createASRouterEvent(action) {
|
createASRouterEvent(action) {
|
||||||
const appInfo = this.store.getState().App;
|
const appInfo = this.store.getState().App;
|
||||||
const ping = {
|
const ping = {
|
||||||
|
client_id: "n/a",
|
||||||
addon_version: appInfo.version,
|
addon_version: appInfo.version,
|
||||||
locale: Services.locale.getAppLocaleAsLangTag()
|
locale: Services.locale.getAppLocaleAsLangTag(),
|
||||||
|
impression_id: this._impressionId
|
||||||
};
|
};
|
||||||
return Object.assign(ping, action.data);
|
return Object.assign(ping, action.data);
|
||||||
}
|
}
|
||||||
|
@ -406,9 +408,7 @@ this.TelemetryFeed = class TelemetryFeed {
|
||||||
|
|
||||||
handleASRouterUserEvent(action) {
|
handleASRouterUserEvent(action) {
|
||||||
let event = this.createASRouterEvent(action);
|
let event = this.createASRouterEvent(action);
|
||||||
// TODO call this.sendASRouterEvent(event) once the ping gets finalized
|
this.sendASRouterEvent(event);
|
||||||
// and data reviewed
|
|
||||||
console.log(event); // eslint-disable-line
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleUndesiredEvent(action) {
|
handleUndesiredEvent(action) {
|
||||||
|
|
|
@ -202,6 +202,17 @@ export const SessionPing = Joi.object().keys(Object.assign({}, baseKeys, {
|
||||||
}).required()
|
}).required()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
export const ASRouterEventPing = Joi.object().keys({
|
||||||
|
client_id: Joi.string().required(),
|
||||||
|
action: Joi.string().required(),
|
||||||
|
impression_id: Joi.string().required(),
|
||||||
|
source: Joi.string().required(),
|
||||||
|
addon_version: Joi.string().required(),
|
||||||
|
locale: Joi.string().required(),
|
||||||
|
message_id: Joi.string().required(),
|
||||||
|
event: Joi.string().required()
|
||||||
|
});
|
||||||
|
|
||||||
export const UTSessionPing = Joi.array().items(
|
export const UTSessionPing = Joi.array().items(
|
||||||
Joi.string().required().valid("activity_stream"),
|
Joi.string().required().valid("activity_stream"),
|
||||||
Joi.string().required().valid("end"),
|
Joi.string().required().valid("end"),
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* global Services */
|
/* global Services */
|
||||||
import {actionCreators as ac, actionTypes as at} from "common/Actions.jsm";
|
import {actionCreators as ac, actionTypes as at} from "common/Actions.jsm";
|
||||||
import {
|
import {
|
||||||
|
ASRouterEventPing,
|
||||||
BasePing,
|
BasePing,
|
||||||
ImpressionStatsPing,
|
ImpressionStatsPing,
|
||||||
PerfPing,
|
PerfPing,
|
||||||
|
@ -474,12 +475,17 @@ describe("TelemetryFeed", () => {
|
||||||
});
|
});
|
||||||
describe("#createASRouterEvent", () => {
|
describe("#createASRouterEvent", () => {
|
||||||
it("should create a valid AS Router event", async () => {
|
it("should create a valid AS Router event", async () => {
|
||||||
const data = {source: "SNIPPETS", event: "CLICK"};
|
const data = {
|
||||||
|
action: "snippet_user_event",
|
||||||
|
source: "SNIPPETS",
|
||||||
|
event: "CLICK",
|
||||||
|
message_id: "snippets_message_01"
|
||||||
|
};
|
||||||
const action = ac.ASRouterUserEvent(data);
|
const action = ac.ASRouterUserEvent(data);
|
||||||
const ping = await instance.createASRouterEvent(action);
|
const ping = await instance.createASRouterEvent(action);
|
||||||
|
|
||||||
// TODO check the payload with the Joi schema
|
assert.validate(ping, ASRouterEventPing);
|
||||||
|
assert.propertyVal(ping, "client_id", "n/a");
|
||||||
assert.propertyVal(ping, "source", "SNIPPETS");
|
assert.propertyVal(ping, "source", "SNIPPETS");
|
||||||
assert.propertyVal(ping, "event", "CLICK");
|
assert.propertyVal(ping, "event", "CLICK");
|
||||||
});
|
});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче