Skip to content

Commit 9ca6142

Browse files
committed
Remove unused GA4SubscriptionEvents
This essentially reverts #5101 Except it was done manually to avoid conflicts, leaves the migration in place and adds a new one to drop that table.
1 parent 1672aba commit 9ca6142

File tree

11 files changed

+34
-363
lines changed

11 files changed

+34
-363
lines changed

.env

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,5 @@ SENTRY_AUTH_TOKEN=
169169
# Whether GA4 sends data or not. NOTE: must be set in build environment.
170170
NEXT_PUBLIC_GA4_DEBUG_MODE=true
171171

172-
GA4_API_SECRET=unsafe-default-secret-for-dev
173-
174172
# Data broker removal estimates data
175173
DATA_BROKER_REMOVAL_ESTIMATES_DATA=[]

functional-tests/tests/general.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { getBaseTestEnvUrl } from "../utils/environment";
1414
const isLocal = process.env.E2E_TEST_ENV === "local";
1515

1616
// extend enabled local feature flags for testing purposes
17-
const extraFeatureFlags: FeatureFlagName[] = ["GA4SubscriptionEvents"];
17+
const extraFeatureFlags: FeatureFlagName[] = [];
1818
test.use({ extraLocalForcedFeatureFlags: extraFeatureFlags });
1919

2020
// General tests to confirm the E2E test setup works as expected

functional-tests/tests/subscriptions.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { getBaseTestEnvUrl } from "../utils/environment";
77
import { FeatureFlagName } from "../../src/db/tables/featureFlags";
88

99
// extend enabled local feature flags for testing purposes
10-
const extraFeatureFlags: FeatureFlagName[] = ["GA4SubscriptionEvents"];
10+
const extraFeatureFlags: FeatureFlagName[] = [];
1111
test.use({ extraLocalForcedFeatureFlags: extraFeatureFlags });
1212

1313
const productPlans = ["Monitor Plus"];

src/app/(proper_react)/layout.tsx

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

55
import { ReactNode } from "react";
6-
import { headers, cookies } from "next/headers";
6+
import { headers } from "next/headers";
77
import { getServerSession } from "../functions/server/getServerSession";
88
import {
99
getAcceptLangHeaderInServerComponents,
@@ -16,8 +16,6 @@ import { CountryCodeProvider } from "../../contextProviders/country-code";
1616
import { getCountryCode } from "../functions/server/getCountryCode";
1717
import { PageLoadEvent } from "../components/client/PageLoadEvent";
1818
import { PromptNoneAuth } from "../components/client/PromptNoneAuth";
19-
import { addClientIdForSubscriber } from "../../db/tables/google_analytics_clients";
20-
import { logger } from "../functions/server/logging";
2119
import { CookiesProvider } from "../../contextProviders/cookies";
2220
import { SubscriptionBillingProvider } from "../../contextProviders/subscription-billing-context";
2321
import { getSubscriptionBillingAmount } from "../functions/server/getPremiumSubscriptionInfo";
@@ -31,33 +29,6 @@ export default async function Layout({ children }: { children: ReactNode }) {
3129
const session = await getServerSession();
3230
const billing = getSubscriptionBillingAmount();
3331

34-
const cookieStore = await cookies();
35-
// This expects the default Google Analytics cookie documented here: https://support.google.com/analytics/answer/11397207?hl=en
36-
const gaCookie = cookieStore.get("_ga");
37-
38-
if (gaCookie && gaCookie.value) {
39-
const [gaCookieVersion, gaCookiePath, gaCookieClientId, gaCookieTimestamp] =
40-
gaCookie.value.split(".");
41-
if (session?.user.subscriber?.id) {
42-
try {
43-
const parsedCookieTimestamp = new Date(
44-
parseInt(gaCookieTimestamp) * 1000,
45-
);
46-
await addClientIdForSubscriber(
47-
session?.user.subscriber?.id,
48-
gaCookieVersion,
49-
parseInt(gaCookiePath),
50-
gaCookieClientId,
51-
parsedCookieTimestamp,
52-
);
53-
} catch (e) {
54-
logger.error("could_not_parse_ga_cookie_from_header", {
55-
message: (e as Error).message,
56-
});
57-
}
58-
}
59-
}
60-
6132
return (
6233
<L10nProvider bundleSources={l10nBundles}>
6334
<ReactAriaI18nProvider locale={getLocale(l10nBundles)}>

src/app/api/v1/fxa-rp-events/route.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import { revokeOAuthTokens } from "../../../../utils/fxa";
2525
import { changeSubscription } from "../../../functions/server/changeSubscription";
2626
import { deleteAccount } from "../../../functions/server/deleteAccount";
2727
import { record } from "../../../functions/server/glean";
28-
import { sendPingToGA } from "../../../functions/server/googleAnalytics";
29-
import { getEnabledFeatureFlags } from "../../../../db/tables/featureFlags";
3028

3129
const FXA_PROFILE_CHANGE_EVENT =
3230
"https://schemas.accounts.firefox.com/event/profile-change";
@@ -278,10 +276,6 @@ export async function POST(request: NextRequest) {
278276
});
279277

280278
try {
281-
const enabledFeatureFlags = await getEnabledFeatureFlags({
282-
email: subscriber.primary_email,
283-
});
284-
285279
if (
286280
updatedSubscriptionFromEvent.isActive &&
287281
updatedSubscriptionFromEvent.capabilities.includes(
@@ -362,10 +356,6 @@ export async function POST(request: NextRequest) {
362356
monitorUserId: subscriber.id.toString(),
363357
},
364358
});
365-
366-
if (enabledFeatureFlags.includes("GA4SubscriptionEvents")) {
367-
await sendPingToGA(subscriber.id, "subscribe");
368-
}
369359
} else if (
370360
!updatedSubscriptionFromEvent.isActive &&
371361
updatedSubscriptionFromEvent.capabilities.includes(
@@ -423,10 +413,6 @@ export async function POST(request: NextRequest) {
423413
monitorUserId: subscriber.id.toString(),
424414
},
425415
});
426-
427-
if (enabledFeatureFlags.includes("GA4SubscriptionEvents")) {
428-
await sendPingToGA(subscriber.id, "unsubscribe");
429-
}
430416
}
431417
} catch (e) {
432418
captureMessage(

src/app/functions/server/googleAnalytics.test.ts

Lines changed: 0 additions & 182 deletions
This file was deleted.

src/app/functions/server/googleAnalytics.ts

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)