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

enhance(telemetry): measure BCD table views, link clicks, cell expansions #12030

Merged
merged 33 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a06721c
enhance(telemetry): measure BCD table views + clicks
caugner Oct 24, 2024
057446e
refactor(bcd): extract getCurrentStatus()
caugner Oct 24, 2024
11ce0f6
refactor(bcd): extract getStatus()
caugner Oct 24, 2024
ddca183
refactor(bcd): extract getCurrentSupportType()
caugner Oct 24, 2024
8aca71d
refactor(bcd): extract SupportType
caugner Oct 24, 2024
f1b1653
refactor(bcd): extract getCurrentSupportAttributes()
caugner Oct 24, 2024
22f4131
fixup! refactor(bcd): extract getCurrentSupportType()
caugner Oct 24, 2024
b327895
enhance(telemetry): measure BCD support {type,attrs}
caugner Oct 24, 2024
8a60430
chore(telemetry): use "bcd:" for BCD table
caugner Oct 24, 2024
c7ff980
fixup! enhance(telemetry): measure BCD support {type,attrs}
caugner Oct 24, 2024
a4f419d
enhance(telemetry): measure links in BCD table
caugner Oct 24, 2024
473ff5d
chore(bcd): record query on view
caugner Oct 28, 2024
1d36f8d
fix(bcd): observe header, not full table
caugner Oct 28, 2024
16a1f26
Add intersectionObserverOptions for useViewed
fiji-flo Oct 29, 2024
4b87dad
Revert "fix(bcd): observe header, not full table"
caugner Oct 30, 2024
143719f
fix(bcd): measure any partial view
caugner Oct 30, 2024
2560d79
fix(hooks): disable IntersectionObserver on view
caugner Oct 30, 2024
d9df733
enhance(bcd): add "removed" support type
caugner Oct 30, 2024
3f22122
refactor(bcd): simplify getSupportType()
caugner Oct 30, 2024
ef0532d
Revert "refactor(bcd): simplify getSupportType()"
caugner Nov 4, 2024
85fa1a6
Revert "enhance(bcd): add "removed" support type"
caugner Nov 4, 2024
fe3c4ef
Revert "fixup! refactor(bcd): extract getCurrentSupportType()"
caugner Nov 4, 2024
6d983d1
Revert "refactor(bcd): extract getCurrentSupportAttributes()"
caugner Nov 4, 2024
e5d4c55
Revert "refactor(bcd): extract SupportType"
caugner Nov 4, 2024
49af2b4
Revert "refactor(bcd): extract getCurrentSupportType()"
caugner Nov 4, 2024
3c6d272
Revert "refactor(bcd): extract getStatus()"
caugner Nov 4, 2024
b38a264
Revert "refactor(bcd): extract getCurrentStatus()"
caugner Nov 4, 2024
2b9c595
chore(bcd): duplicate support {type,attrs} calculation inline
caugner Nov 4, 2024
1b8dad9
Merge branch 'main' into MP-1619-measure-bcd-table-usage
caugner Nov 4, 2024
a68d282
fixup! chore(bcd): duplicate support {type,attrs} calculation inline
caugner Nov 4, 2024
92ac2be
chore(bcd): move dispatchCellToggle() up to return early
caugner Nov 4, 2024
83cd317
Merge branch 'main' into MP-1619-measure-bcd-table-usage
caugner Nov 4, 2024
01d645c
fixup! chore(bcd): duplicate support {type,attrs} calculation inline
caugner Nov 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useReducer } from "react";
import React, { useReducer, useRef } from "react";
import { useLocation } from "react-router-dom";
import type BCD from "@mdn/browser-compat-data/types";
import { BrowserInfoContext } from "./browser-info";
Expand All @@ -7,6 +7,9 @@ import { FeatureRow } from "./feature-row";
import { Headers } from "./headers";
import { Legend } from "./legend";
import { listFeatures } from "./utils";
import { useViewed } from "../../../hooks";
import { BCD_TABLE } from "../../../telemetry/constants";
import { useGleanClick } from "../../../telemetry/glean-context";

// Note! Don't import any SCSS here inside *this* component.
// It's done in the component that lazy-loads this component.
Expand Down Expand Up @@ -85,10 +88,12 @@ function FeatureListAccordion({
features,
browsers,
locale,
query,
}: {
features: ReturnType<typeof listFeatures>;
browsers: BCD.BrowserName[];
locale: string;
query: string;
}) {
const [[activeRow, activeColumn], dispatchCellToggle] = useReducer<
React.Reducer<CellIndex | [null, null], CellIndex>
Expand All @@ -100,6 +105,9 @@ function FeatureListAccordion({
[null, null]
);

const gleanClick = useGleanClick();
const clickedCells = useRef(new Set<string>());

return (
<>
{features.map((feature, i) => (
Expand All @@ -109,6 +117,13 @@ function FeatureListAccordion({
index={i}
activeCell={activeRow === i ? activeColumn : null}
onToggleCell={([row, column]: [number, number]) => {
const cell = `${column}:${row}`;
if (!clickedCells.current.has(cell)) {
clickedCells.current.add(cell);
gleanClick(
`${BCD_TABLE}: click ${browsers[column]} ${query} -> ${features[row].name}`
caugner marked this conversation as resolved.
Show resolved Hide resolved
);
}
dispatchCellToggle([row, column]);
}}
locale={locale}
Expand All @@ -130,6 +145,11 @@ export default function BrowserCompatibilityTable({
locale: string;
}) {
const location = useLocation();
const gleanClick = useGleanClick();

const observedNode = useViewed(() => {
gleanClick(`${BCD_TABLE}: view`);
caugner marked this conversation as resolved.
Show resolved Hide resolved
});

if (!data || !Object.keys(data).length) {
throw new Error(
Expand Down Expand Up @@ -177,7 +197,11 @@ export default function BrowserCompatibilityTable({
</a>
<figure className="table-container">
<figure className="table-container-inner">
<table key="bc-table" className="bc-table bc-table-web">
<table
key="bc-table"
className="bc-table bc-table-web"
ref={observedNode}
>
<Headers
platforms={platforms}
browsers={browsers}
Expand All @@ -188,6 +212,7 @@ export default function BrowserCompatibilityTable({
browsers={browsers}
features={listFeatures(data, "", name)}
locale={locale}
query={query}
/>
</tbody>
</table>
Expand Down
1 change: 1 addition & 0 deletions client/src/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const AI_EXPLAIN = "ai_explain";
export const SETTINGS = "settings";
export const OBSERVATORY = "observatory";
export const CURRICULUM = "curriculum";
export const BCD_TABLE = "bcd_table";

export const A11Y_MENU = "a11y_menu";

Expand Down
Loading