Bug 1958135 - Update OPEN_NEW_WINDOW event to fire Glean telemetry event r=home-newtab-reviewers,nbarrett
Differential Revision: https://phabricator.services.mozilla.com/D244676
This commit is contained in:
@@ -721,7 +721,7 @@ newtab:
|
||||
description: >
|
||||
position of section on newtab
|
||||
type: string
|
||||
event_source:
|
||||
event_source: &event_source
|
||||
description: >
|
||||
Where the source of the event originated ("button", "context menu", etc.)
|
||||
type: string
|
||||
@@ -751,10 +751,7 @@ newtab:
|
||||
description: >
|
||||
position of section on newtab
|
||||
type: string
|
||||
event_source:
|
||||
description: >
|
||||
Where the source of the event originated ("button", "context menu", etc.)
|
||||
type: string
|
||||
event_source: *event_source
|
||||
send_in_pings:
|
||||
- newtab
|
||||
|
||||
@@ -781,10 +778,7 @@ newtab:
|
||||
description: >
|
||||
position of section on newtab
|
||||
type: string
|
||||
event_source:
|
||||
description: >
|
||||
Where the source of the event originated ("button", "context menu", etc.)
|
||||
type: string
|
||||
event_source: *event_source
|
||||
send_in_pings:
|
||||
- newtab
|
||||
|
||||
@@ -811,10 +805,7 @@ newtab:
|
||||
description: >
|
||||
position of section on newtab
|
||||
type: string
|
||||
event_source:
|
||||
description: >
|
||||
Where the source of the event originated ("button", "context menu", etc.)
|
||||
type: string
|
||||
event_source: *event_source
|
||||
send_in_pings:
|
||||
- newtab
|
||||
|
||||
@@ -1602,6 +1593,7 @@ pocket:
|
||||
If click belongs in a section, the numeric position of the section
|
||||
type: string
|
||||
is_section_followed: *is_section_followed
|
||||
event_source: *event_source
|
||||
send_in_pings:
|
||||
- newtab
|
||||
|
||||
@@ -2287,10 +2279,7 @@ newtab_content:
|
||||
description: >
|
||||
position of section on newtab
|
||||
type: string
|
||||
event_source:
|
||||
description: >
|
||||
Where the source of the event originated ("button", "context menu", etc.)
|
||||
type: string
|
||||
event_source: *event_source
|
||||
send_in_pings:
|
||||
- newtab-content
|
||||
|
||||
@@ -2317,10 +2306,7 @@ newtab_content:
|
||||
description: >
|
||||
position of section on newtab
|
||||
type: string
|
||||
event_source:
|
||||
description: >
|
||||
Where the source of the event originated ("button", "context menu", etc.)
|
||||
type: string
|
||||
event_source: *event_source
|
||||
send_in_pings:
|
||||
- newtab-content
|
||||
|
||||
@@ -2347,10 +2333,7 @@ newtab_content:
|
||||
description: >
|
||||
position of section on newtab
|
||||
type: string
|
||||
event_source:
|
||||
description: >
|
||||
Where the source of the event originated ("button", "context menu", etc.)
|
||||
type: string
|
||||
event_source: *event_source
|
||||
send_in_pings:
|
||||
- newtab-content
|
||||
|
||||
@@ -2377,10 +2360,7 @@ newtab_content:
|
||||
description: >
|
||||
position of section on newtab
|
||||
type: string
|
||||
event_source:
|
||||
description: >
|
||||
Where the source of the event originated ("button", "context menu", etc.)
|
||||
type: string
|
||||
event_source: *event_source
|
||||
send_in_pings:
|
||||
- newtab-content
|
||||
|
||||
|
||||
@@ -350,6 +350,7 @@ export class _DSCard extends React.PureComponent {
|
||||
source: this.props.type.toUpperCase(),
|
||||
action_position: this.props.pos,
|
||||
value: {
|
||||
event_source: "card",
|
||||
card_type: this.props.flightId ? "spoc" : "organic",
|
||||
recommendation_id: this.props.recommendation_id,
|
||||
tile_id: this.props.id,
|
||||
@@ -921,7 +922,18 @@ export class _DSCard extends React.PureComponent {
|
||||
section={this.props.section}
|
||||
section_position={this.props.sectionPosition}
|
||||
is_section_followed={this.props.sectionFollowed}
|
||||
format={format}
|
||||
fetchTimestamp={this.props.fetchTimestamp}
|
||||
firstVisibleTimestamp={this.props.firstVisibleTimestamp}
|
||||
format={
|
||||
format
|
||||
? format
|
||||
: getActiveCardSize(
|
||||
window.innerWidth,
|
||||
this.props.sectionsClassNames,
|
||||
this.props.section,
|
||||
this.props.flightId
|
||||
)
|
||||
}
|
||||
isSectionsCard={this.props.mayHaveSectionsCards}
|
||||
topic={this.props.topic}
|
||||
selected_topics={this.props.selected_topics}
|
||||
|
||||
@@ -74,6 +74,7 @@ export class _DSLinkMenu extends React.PureComponent {
|
||||
recommendation_id: this.props.recommendation_id,
|
||||
corpus_item_id: this.props.corpus_item_id,
|
||||
scheduled_corpus_item_id: this.props.scheduled_corpus_item_id,
|
||||
firstVisibleTimestamp: this.props.firstVisibleTimestamp,
|
||||
recommended_at: this.props.recommended_at,
|
||||
received_rank: this.props.received_rank,
|
||||
topic: this.props.topic,
|
||||
|
||||
@@ -67,19 +67,64 @@ export class _LinkMenu extends React.PureComponent {
|
||||
}
|
||||
dispatch(action);
|
||||
if (eventName) {
|
||||
let value;
|
||||
// Bug 1958135: Pass additional info to ac.OPEN_NEW_WINDOW event
|
||||
if (action.type === "OPEN_NEW_WINDOW") {
|
||||
const {
|
||||
card_type,
|
||||
corpus_item_id,
|
||||
event_source,
|
||||
fetchTimestamp,
|
||||
firstVisibleTimestamp,
|
||||
format,
|
||||
is_list_card,
|
||||
is_section_followed,
|
||||
received_rank,
|
||||
recommendation_id,
|
||||
recommended_at,
|
||||
scheduled_corpus_item_id,
|
||||
section_position,
|
||||
section,
|
||||
selected_topics,
|
||||
tile_id,
|
||||
topic,
|
||||
} = action.data;
|
||||
|
||||
value = {
|
||||
card_type,
|
||||
corpus_item_id,
|
||||
event_source,
|
||||
fetchTimestamp,
|
||||
firstVisibleTimestamp,
|
||||
format,
|
||||
is_list_card,
|
||||
received_rank,
|
||||
recommendation_id,
|
||||
recommended_at,
|
||||
scheduled_corpus_item_id,
|
||||
...(section
|
||||
? { is_section_followed, section_position, section }
|
||||
: {}),
|
||||
selected_topics: selected_topics ? selected_topics : "",
|
||||
tile_id,
|
||||
topic,
|
||||
};
|
||||
} else {
|
||||
value = { card_type: site.flight_id ? "spoc" : "organic" };
|
||||
}
|
||||
const userEventData = Object.assign(
|
||||
{
|
||||
event: eventName,
|
||||
source,
|
||||
action_position: index,
|
||||
value: { card_type: site.flight_id ? "spoc" : "organic" },
|
||||
value,
|
||||
},
|
||||
siteInfo
|
||||
);
|
||||
dispatch(userEvent(userEventData));
|
||||
}
|
||||
if (impression && shouldSendImpressionStats) {
|
||||
dispatch(impression);
|
||||
if (impression && shouldSendImpressionStats) {
|
||||
dispatch(impression);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,7 +12,11 @@ const _OpenInPrivateWindow = site => ({
|
||||
icon: "new-window-private",
|
||||
action: ac.OnlyToMain({
|
||||
type: at.OPEN_PRIVATE_WINDOW,
|
||||
data: { url: site.url, referrer: site.referrer },
|
||||
data: {
|
||||
url: site.url,
|
||||
referrer: site.referrer,
|
||||
event_source: "CONTEXT_MENU",
|
||||
},
|
||||
}),
|
||||
userEvent: "OPEN_PRIVATE_WINDOW",
|
||||
});
|
||||
@@ -71,10 +75,24 @@ export const LinkMenuOptions = {
|
||||
action: ac.AlsoToMain({
|
||||
type: at.OPEN_NEW_WINDOW,
|
||||
data: {
|
||||
card_type: site.card_type,
|
||||
referrer: site.referrer,
|
||||
typedBonus: site.typedBonus,
|
||||
url: site.url,
|
||||
sponsored_tile_id: site.sponsored_tile_id,
|
||||
event_source: "CONTEXT_MENU",
|
||||
topic: site.topic,
|
||||
firstVisibleTimestamp: site.firstVisibleTimestamp,
|
||||
tile_id: site.tile_id,
|
||||
recommendation_id: site.recommendation_id,
|
||||
scheduled_corpus_item_id: site.scheduled_corpus_item_id,
|
||||
corpus_item_id: site.corpus_item_id,
|
||||
received_rank: site.received_rank,
|
||||
recommended_at: site.recommended_at,
|
||||
format: site.format,
|
||||
...(site.flight_id ? { flight_id: site.flight_id } : {}),
|
||||
is_pocket_card: site.type === "CardGrid",
|
||||
is_list_card: site.is_list_card,
|
||||
...(site.section
|
||||
? {
|
||||
section: site.section,
|
||||
@@ -86,6 +104,7 @@ export const LinkMenuOptions = {
|
||||
}),
|
||||
userEvent: "OPEN_NEW_WINDOW",
|
||||
}),
|
||||
|
||||
// This blocks the url for regular stories,
|
||||
// but also sends a message to DiscoveryStream with flight_id.
|
||||
// If DiscoveryStream sees this message for a flight_id
|
||||
|
||||
@@ -1701,7 +1701,11 @@ const _OpenInPrivateWindow = site => ({
|
||||
icon: "new-window-private",
|
||||
action: actionCreators.OnlyToMain({
|
||||
type: actionTypes.OPEN_PRIVATE_WINDOW,
|
||||
data: { url: site.url, referrer: site.referrer },
|
||||
data: {
|
||||
url: site.url,
|
||||
referrer: site.referrer,
|
||||
event_source: "CONTEXT_MENU",
|
||||
},
|
||||
}),
|
||||
userEvent: "OPEN_PRIVATE_WINDOW",
|
||||
});
|
||||
@@ -1760,10 +1764,24 @@ const LinkMenuOptions = {
|
||||
action: actionCreators.AlsoToMain({
|
||||
type: actionTypes.OPEN_NEW_WINDOW,
|
||||
data: {
|
||||
card_type: site.card_type,
|
||||
referrer: site.referrer,
|
||||
typedBonus: site.typedBonus,
|
||||
url: site.url,
|
||||
sponsored_tile_id: site.sponsored_tile_id,
|
||||
event_source: "CONTEXT_MENU",
|
||||
topic: site.topic,
|
||||
firstVisibleTimestamp: site.firstVisibleTimestamp,
|
||||
tile_id: site.tile_id,
|
||||
recommendation_id: site.recommendation_id,
|
||||
scheduled_corpus_item_id: site.scheduled_corpus_item_id,
|
||||
corpus_item_id: site.corpus_item_id,
|
||||
received_rank: site.received_rank,
|
||||
recommended_at: site.recommended_at,
|
||||
format: site.format,
|
||||
...(site.flight_id ? { flight_id: site.flight_id } : {}),
|
||||
is_pocket_card: site.type === "CardGrid",
|
||||
is_list_card: site.is_list_card,
|
||||
...(site.section
|
||||
? {
|
||||
section: site.section,
|
||||
@@ -1775,6 +1793,7 @@ const LinkMenuOptions = {
|
||||
}),
|
||||
userEvent: "OPEN_NEW_WINDOW",
|
||||
}),
|
||||
|
||||
// This blocks the url for regular stories,
|
||||
// but also sends a message to DiscoveryStream with flight_id.
|
||||
// If DiscoveryStream sees this message for a flight_id
|
||||
@@ -2323,18 +2342,64 @@ class _LinkMenu extends (external_React_default()).PureComponent {
|
||||
}
|
||||
dispatch(action);
|
||||
if (eventName) {
|
||||
let value;
|
||||
// Bug 1958135: Pass additional info to ac.OPEN_NEW_WINDOW event
|
||||
if (action.type === "OPEN_NEW_WINDOW") {
|
||||
const {
|
||||
card_type,
|
||||
corpus_item_id,
|
||||
event_source,
|
||||
fetchTimestamp,
|
||||
firstVisibleTimestamp,
|
||||
format,
|
||||
is_list_card,
|
||||
is_section_followed,
|
||||
received_rank,
|
||||
recommendation_id,
|
||||
recommended_at,
|
||||
scheduled_corpus_item_id,
|
||||
section_position,
|
||||
section,
|
||||
selected_topics,
|
||||
tile_id,
|
||||
topic
|
||||
} = action.data;
|
||||
value = {
|
||||
card_type,
|
||||
corpus_item_id,
|
||||
event_source,
|
||||
fetchTimestamp,
|
||||
firstVisibleTimestamp,
|
||||
format,
|
||||
is_list_card,
|
||||
received_rank,
|
||||
recommendation_id,
|
||||
recommended_at,
|
||||
scheduled_corpus_item_id,
|
||||
...(section ? {
|
||||
is_section_followed,
|
||||
section_position,
|
||||
section
|
||||
} : {}),
|
||||
selected_topics: selected_topics ? selected_topics : "",
|
||||
tile_id,
|
||||
topic
|
||||
};
|
||||
} else {
|
||||
value = {
|
||||
card_type: site.flight_id ? "spoc" : "organic"
|
||||
};
|
||||
}
|
||||
const userEventData = Object.assign({
|
||||
event: eventName,
|
||||
source,
|
||||
action_position: index,
|
||||
value: {
|
||||
card_type: site.flight_id ? "spoc" : "organic"
|
||||
}
|
||||
value
|
||||
}, siteInfo);
|
||||
dispatch(userEvent(userEventData));
|
||||
}
|
||||
if (impression && shouldSendImpressionStats) {
|
||||
dispatch(impression);
|
||||
if (impression && shouldSendImpressionStats) {
|
||||
dispatch(impression);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -2493,6 +2558,7 @@ class _DSLinkMenu extends (external_React_default()).PureComponent {
|
||||
recommendation_id: this.props.recommendation_id,
|
||||
corpus_item_id: this.props.corpus_item_id,
|
||||
scheduled_corpus_item_id: this.props.scheduled_corpus_item_id,
|
||||
firstVisibleTimestamp: this.props.firstVisibleTimestamp,
|
||||
recommended_at: this.props.recommended_at,
|
||||
received_rank: this.props.received_rank,
|
||||
topic: this.props.topic,
|
||||
@@ -3639,6 +3705,7 @@ class _DSCard extends (external_React_default()).PureComponent {
|
||||
source: this.props.type.toUpperCase(),
|
||||
action_position: this.props.pos,
|
||||
value: {
|
||||
event_source: "card",
|
||||
card_type: this.props.flightId ? "spoc" : "organic",
|
||||
recommendation_id: this.props.recommendation_id,
|
||||
tile_id: this.props.id,
|
||||
@@ -4099,7 +4166,9 @@ class _DSCard extends (external_React_default()).PureComponent {
|
||||
section: this.props.section,
|
||||
section_position: this.props.sectionPosition,
|
||||
is_section_followed: this.props.sectionFollowed,
|
||||
format: format,
|
||||
fetchTimestamp: this.props.fetchTimestamp,
|
||||
firstVisibleTimestamp: this.props.firstVisibleTimestamp,
|
||||
format: format ? format : getActiveCardSize(window.innerWidth, this.props.sectionsClassNames, this.props.section, this.props.flightId),
|
||||
isSectionsCard: this.props.mayHaveSectionsCards,
|
||||
topic: this.props.topic,
|
||||
selected_topics: this.props.selected_topics
|
||||
|
||||
@@ -595,11 +595,16 @@ export class TelemetryFeed {
|
||||
},
|
||||
});
|
||||
const session = this.sessions.get(au.getPortIdOfSender(action));
|
||||
|
||||
switch (action.data?.event) {
|
||||
// TODO: Determine if private window should be tracked?
|
||||
// case "OPEN_PRIVATE_WINDOW":
|
||||
case "OPEN_NEW_WINDOW":
|
||||
case "CLICK": {
|
||||
const {
|
||||
card_type,
|
||||
corpus_item_id,
|
||||
event_source,
|
||||
feature,
|
||||
fetchTimestamp,
|
||||
firstVisibleTimestamp,
|
||||
@@ -618,6 +623,7 @@ export class TelemetryFeed {
|
||||
tile_id,
|
||||
topic,
|
||||
} = action.data.value ?? {};
|
||||
|
||||
if (
|
||||
action.data.source === "POPULAR_TOPICS" ||
|
||||
card_type === "topics_widget"
|
||||
@@ -649,6 +655,7 @@ export class TelemetryFeed {
|
||||
is_list_card,
|
||||
position: action.data.action_position,
|
||||
tile_id,
|
||||
event_source,
|
||||
// We conditionally add in a few props.
|
||||
...(corpus_item_id ? { corpus_item_id } : {}),
|
||||
...(scheduled_corpus_item_id ? { scheduled_corpus_item_id } : {}),
|
||||
@@ -686,6 +693,7 @@ export class TelemetryFeed {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case "POCKET_THUMBS_DOWN":
|
||||
|
||||
@@ -304,6 +304,7 @@ describe("<DSCard>", () => {
|
||||
source: "FOO",
|
||||
action_position: 1,
|
||||
value: {
|
||||
event_source: "card",
|
||||
card_type: "organic",
|
||||
recommendation_id: undefined,
|
||||
tile_id: "fooidx",
|
||||
@@ -365,6 +366,7 @@ describe("<DSCard>", () => {
|
||||
source: "FOO",
|
||||
action_position: 1,
|
||||
value: {
|
||||
event_source: "card",
|
||||
card_type: "spoc",
|
||||
recommendation_id: undefined,
|
||||
tile_id: "fooidx",
|
||||
@@ -428,6 +430,7 @@ describe("<DSCard>", () => {
|
||||
source: "FOO",
|
||||
action_position: 1,
|
||||
value: {
|
||||
event_source: "card",
|
||||
card_type: "organic",
|
||||
recommendation_id: undefined,
|
||||
tile_id: "fooidx",
|
||||
|
||||
@@ -373,6 +373,7 @@ describe("<LinkMenu>", () => {
|
||||
typedBonus: true,
|
||||
url: "https://foo.com",
|
||||
sponsored_tile_id: 12345,
|
||||
card_type: "organic",
|
||||
};
|
||||
const dispatch = sinon.stub();
|
||||
const propOptions = [
|
||||
@@ -403,14 +404,28 @@ describe("<LinkMenu>", () => {
|
||||
type: FAKE_SITE.type,
|
||||
},
|
||||
"newtab-menu-open-new-window": {
|
||||
url: FAKE_SITE.url,
|
||||
card_type: FAKE_SITE.card_type,
|
||||
referrer: FAKE_SITE.referrer,
|
||||
typedBonus: FAKE_SITE.typedBonus,
|
||||
url: FAKE_SITE.url,
|
||||
sponsored_tile_id: FAKE_SITE.sponsored_tile_id,
|
||||
event_source: "CONTEXT_MENU",
|
||||
topic: undefined,
|
||||
firstVisibleTimestamp: undefined,
|
||||
tile_id: undefined,
|
||||
recommendation_id: undefined,
|
||||
scheduled_corpus_item_id: undefined,
|
||||
corpus_item_id: undefined,
|
||||
received_rank: undefined,
|
||||
recommended_at: undefined,
|
||||
format: undefined,
|
||||
is_pocket_card: false,
|
||||
is_list_card: undefined,
|
||||
},
|
||||
"newtab-menu-open-new-private-window": {
|
||||
url: FAKE_SITE.url,
|
||||
referrer: FAKE_SITE.referrer,
|
||||
event_source: "CONTEXT_MENU",
|
||||
},
|
||||
"newtab-menu-dismiss": [
|
||||
{
|
||||
@@ -424,7 +439,7 @@ describe("<LinkMenu>", () => {
|
||||
received_rank: undefined,
|
||||
isSponsoredTopSite: undefined,
|
||||
type: "bookmark",
|
||||
card_type: undefined,
|
||||
card_type: FAKE_SITE.card_type,
|
||||
position: 3,
|
||||
is_pocket_card: false,
|
||||
is_list_card: undefined,
|
||||
|
||||
Reference in New Issue
Block a user