Skip to content

Commit

Permalink
Stop sending user_id on page.view events
Browse files Browse the repository at this point in the history
Co-authored-by: Robert Helmer <rhelmer@mozilla.com>
  • Loading branch information
Vinnl and rhelmer committed Apr 26, 2024
1 parent 101f7bc commit 2d60e66
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ export const View = (props: Props) => {
onSelectionChange={(selectedKey) => {
setSelectedTab(selectedKey as TabType);
recordTelemetry("dashboard", "view", {
user_id: props.telemetryId,
dashboard_tab: selectedKey as TabType,
legacy_user: !props.isNewUser,
breach_count: breachesDataArray.length,
Expand Down Expand Up @@ -453,7 +452,6 @@ export const View = (props: Props) => {
onShowFixed={() => {
setSelectedTab("fixed");
recordTelemetry("dashboard", "view", {
user_id: props.telemetryId,
dashboard_tab: "fixed",
legacy_user: !props.isNewUser,
breach_count: breachesDataArray.length,
Expand Down
25 changes: 5 additions & 20 deletions src/app/components/client/PageLoadEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

"use client";

import { useEffect, useMemo } from "react";
import { useEffect } from "react";
import { useCookies } from "react-cookie";
import { usePathname } from "next/navigation";
import { FeatureFlagName } from "../../../db/tables/featureFlags";
Expand All @@ -27,34 +27,19 @@ export const PageLoadEvent = (props: Props) => {

const recordTelemetry = useTelemetry(props.userId);

const userId: GleanMetricMap["page"]["view"]["user_id"] = useMemo(() => {
// If the user is not logged in, use randomly-generated user ID and store in cookie.
if (props.userId.startsWith("guest")) {
if (!cookies.experimentationId) {
setCookie("experimentationId", props.userId);
}
return props.userId;
}

if (props.enabledFlags.includes("FxaUidTelemetry")) {
return props.userId;
} else {
return undefined;
}
}, [cookies.experimentationId, setCookie, props.userId, props.enabledFlags]);
if (props.userId.startsWith("guest") && !cookies.experimentationId) {
setCookie("experimentationId", props.userId);
}

// On first load of the page, record a page view.
useEffect(() => {
const pageViewParams: GleanMetricMap["page"]["view"] = {
...getUtmParams(),
path: pathname,
};
if (typeof userId === "string") {
pageViewParams.user_id = userId;
}

recordTelemetry("page", "view", pageViewParams);
}, [recordTelemetry, pathname, userId]);
}, [recordTelemetry, pathname]);

useEffect(() => {
// record attributions on page load
Expand Down

0 comments on commit 2d60e66

Please sign in to comment.