Skip to content

Commit

Permalink
Merge branch 'main' into MNTOR-3844
Browse files Browse the repository at this point in the history
  • Loading branch information
mansaj authored Feb 4, 2025
2 parents 7ad8962 + c3639cb commit bbdff8d
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 39 deletions.
4 changes: 2 additions & 2 deletions config/nimbus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ features:
}
- channel: staging
value: {
"enabled": true,
"variant": redesign,
"enabled": false,
"variant": default,
}
- channel: production
value: {
Expand Down
33 changes: 13 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,14 @@
"react-stately": "^3.35.0",
"react-toastify": "^11.0.2",
"server-only": "^0.0.1",
"sharp": "^0.33.5",
"uuid": "^11.0.5",
"winston": "^3.17.0"
},
"devDependencies": {
"@faker-js/faker": "^9.4.0",
"@google-cloud/bigquery": "^7.9.1",
"@playwright/test": "^1.50.0",
"@playwright/test": "^1.50.1",
"@storybook/addon-a11y": "^8.5.3",
"@storybook/addon-actions": "^8.5.3",
"@storybook/addon-essentials": "^8.5.3",
Expand Down
Binary file modified public/images/email/mozilla-logo-bw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { logger } from "../../../../../functions/server/logging";
import { checkChurnCouponCode } from "../../../../../functions/server/applyCoupon";
import { applyRenewalCoupon } from "./actions";
import { getEnabledFeatureFlags } from "../../../../../../db/tables/featureFlags";
import { getChurnsToEmail } from "../../../../../../db/tables/subscriber_churns";
import { getUpcomingChurns } from "../../../../../../db/tables/subscriber_churns";

export default async function PlusExpirationPage() {
const session = await getServerSession();
Expand Down Expand Up @@ -41,7 +41,7 @@ export default async function PlusExpirationPage() {
}

const couponCheckResult = await checkChurnCouponCode(subscriber);
const subscribersToEmail = await getChurnsToEmail();
const expiringSubscriptions = await getUpcomingChurns();

return (
<View
Expand All @@ -50,9 +50,9 @@ export default async function PlusExpirationPage() {
applyCouponAction={applyRenewalCoupon}
manageSubscriptionsUrl={process.env.FXA_SUBSCRIPTIONS_URL!}
isOnExpirationList={
typeof subscribersToEmail.find(
(subscriberToEmail) =>
subscriberToEmail.userid === subscriber.fxa_uid,
typeof expiringSubscriptions.find(
(expiringSubscription) =>
expiringSubscription.userid === subscriber.fxa_uid,
) !== "undefined"
}
/>
Expand Down
9 changes: 2 additions & 7 deletions src/app/(proper_react)/images/mozilla-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/app/components/client/csat_survey/CsatSurvey.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("CSAT survey banner: Automatic Removal", () => {
expect(answerButton).toBeInTheDocument();
});

it.each([90, 180, 351])(
it.each([90, 180, 351, 716])(
"displays the survey to users with automatic data removal enabled for at least n days",
(dayCount) => {
const ComposedCsatSurvey = composeStory(CsatSurveyAutomaticRemoval, Meta);
Expand Down Expand Up @@ -115,7 +115,7 @@ describe("CSAT survey banner: Automatic Removal", () => {
it("shows the correct follow-up feedback link for response “Satisfied”", async () => {
const user = userEvent.setup();
const ComposedCsatSurvey = composeStory(CsatSurveyAutomaticRemoval, Meta);
render(<ComposedCsatSurvey elapsedTimeInDaysSinceInitialScan={91} />);
render(<ComposedCsatSurvey elapsedTimeInDaysSinceInitialScan={716} />);

const answerButton = screen.getByRole("button", {
name: "Satisfied",
Expand All @@ -128,7 +128,7 @@ describe("CSAT survey banner: Automatic Removal", () => {
expect(feedbackLink).toBeInTheDocument();
expect(feedbackLink).toHaveAttribute(
"href",
"https://survey.alchemer.com/s3/7718223/fbbb597a762a",
"https://survey.alchemer.com/s3/8176616/091e554aa6ab",
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from "./csatSurvey";

export type AutomaticRemovalVariation = {
id: "initial" | "3-months" | "6-months" | "12-months";
id: "initial" | "3-months" | "6-months" | "12-months" | "24-months";
showForUser: UserType[];
showOnTab: TabType[];
daysThreshold: number;
Expand Down Expand Up @@ -87,6 +87,20 @@ const surveyData: SurveyData = {
"very-satisfied": "https://survey.alchemer.com/s3/7718562/002e20b6b82f",
},
},
{
id: "24-months",
showForUser: ["plus-user"],
showOnTab: ["fixed"],
daysThreshold: 716,
followUpSurveyOptions: {
"very-dissatisfied":
"https://survey.alchemer.com/s3/8176616/edb0c3f18778",
dissatisfied: "https://survey.alchemer.com/s3/8176616/9b6ca1d007a5",
neutral: "https://survey.alchemer.com/s3/8176616/37955cef0c5e",
satisfied: "https://survey.alchemer.com/s3/8176616/091e554aa6ab",
"very-satisfied": "https://survey.alchemer.com/s3/8176616/7ac85d1249cd",
},
},
],
};

Expand Down
24 changes: 24 additions & 0 deletions src/db/tables/subscriber_churns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,29 @@ async function getAllSubscriberChurns(): Promise<SubscriberChurnRow[]> {
}
}

async function getUpcomingChurns(): Promise<Array<SubscriberChurnRow>> {
try {
const res = await knex("subscriber_churns")
.select("*")
.where("intervl", "year")
.whereNotNull("current_period_end")
.where(knex.raw("current_period_end::timestamptz"), ">=", knex.fn.now())
.where(
knex.raw("current_period_end::timestamptz"),
"<=",
knex.raw("CURRENT_TIMESTAMP + interval '7 days'"),
);

logger.info("get_upcoming_churns_success", { count: res.length });
return res;
} catch (e) {
logger.error("get_upcoming_churns_error", {
error: JSON.stringify(e),
});
throw e;
}
}

async function getChurnsToEmail(): Promise<
Array<SubscriberChurnRow & SubscriberRow>
> {
Expand Down Expand Up @@ -92,5 +115,6 @@ export {
upsertSubscriberChurns,
getAllSubscriberChurns,
deleteSubscriberChurns,
getUpcomingChurns,
getChurnsToEmail,
};

0 comments on commit bbdff8d

Please sign in to comment.