Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

✨ Ask for a G2 review after a host's second finalized poll (#3449)

Luke Vella8618b0f40513
diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.json
index 1355e0231..fe837d7ab 100644
--- a/apps/web/public/locales/en/app.json
+++ b/apps/web/public/locales/en/app.json
@@ -391,8 +391,6 @@
"finalizePoll": "Finalize poll",
"finalizePollDescription": "Pick the date that works best.",
"finalizePollError": "Failed to finalize poll",
- "finalizeSuccessDate": "Your event is booked for <date></date>.",
- "finalizeSuccessNotified": "{count, plural, =0 {No participants were notified.} one {# participant will be notified.} other {# participants will be notified.}}",
"finalizeSuccessTitle": "Date scheduled",
"finalizeSummaryDescription": "Check the details before you finalize.",
"finalizeSummaryTitle": "Summary",
@@ -893,6 +891,10 @@
"responseOptions": "Response options",
"responses": "Responses",
"resumePlan": "Resume plan",
+ "reviewRequestClose": "Dismiss",
+ "reviewRequestCta": "Write a review",
+ "reviewRequestFounderRole": "Founder of Rallly",
+ "reviewRequestMessage": "If Rallly saved you some back-and-forth, would you leave a quick review on G2? It helps others find us.",
"revoke": "Revoke",
"revokeConfirmation": "Are you sure you want to revoke {name}? This will immediately disable the key.",
"revoked": "Revoked",
diff --git a/apps/web/public/static/luke.webp b/apps/web/public/static/luke.webp
new file mode 100644
index 000000000..e8d617b9a
Binary files /dev/null and b/apps/web/public/static/luke.webp differ
diff --git a/apps/web/src/features/poll/components/finalize-poll-dialog.tsx b/apps/web/src/features/poll/components/finalize-poll-dialog.tsx
index 5ac44dbe8..5b8b15906 100644
--- a/apps/web/src/features/poll/components/finalize-poll-dialog.tsx
+++ b/apps/web/src/features/poll/components/finalize-poll-dialog.tsx
@@ -40,6 +40,7 @@ import { VOTE_TYPES } from "@/features/poll/constants";
import type { PollParticipant } from "@/features/poll/types";
import type { OptionVotes } from "@/features/poll/utils";
import { rankOptionsByPopularity } from "@/features/poll/utils";
+import { ReviewRequestCard } from "@/features/review-request/components/review-request-card";
import {
EventDate,
EventTimeRange,
@@ -574,9 +575,11 @@ function FinalizeWizard({ onClose }: { onClose: () => void }) {
() => new Set(participants.filter((p) => p.email).map((p) => p.id)),
);
const option = options.find((o) => o.id === optionId);
+ const [askForReview, setAskForReview] = React.useState(false);
const finalize = trpc.polls.book.useMutation({
- onSuccess: () => {
+ onSuccess: (data) => {
+ setAskForReview(data?.askForReview ?? false);
setStep("done");
// The page behind the dialog picks up the scheduled status.
router.refresh();
@@ -633,19 +636,11 @@ function FinalizeWizard({ onClose }: { onClose: () => void }) {
<Trans i18nKey="finalizeSuccessTitle" defaults="Date scheduled" />
</DialogTitle>
<DialogDescription>
- <Trans
- i18nKey="finalizeSuccessDate"
- defaults="Your event is booked for <date></date>."
- components={{ date: <PickedDateText option={option} /> }}
- />{" "}
- <Trans
- i18nKey="finalizeSuccessNotified"
- defaults="{count, plural, =0 {No participants were notified.} one {# participant will be notified.} other {# participants will be notified.}}"
- values={{ count: notifyIds.size }}
- />
+ <PickedDateText option={option} />
</DialogDescription>
</DialogHeader>
</div>
+ {askForReview ? <ReviewRequestCard /> : null}
<Button className="w-full" onClick={onClose}>
<Trans i18nKey="backToPoll" defaults="Back to poll" />
</Button>
diff --git a/apps/web/src/features/review-request/components/review-request-card.tsx b/apps/web/src/features/review-request/components/review-request-card.tsx
new file mode 100644
index 000000000..ef0cad6d6
--- /dev/null
+++ b/apps/web/src/features/review-request/components/review-request-card.tsx
@@ -0,0 +1,88 @@
+"use client";
+
+import { posthog } from "@rallly/posthog/client";
+import { Button } from "@rallly/ui/button";
+import { XIcon } from "lucide-react";
+import Image from "next/image";
+import React from "react";
+import { Trans, useTranslation } from "@/i18n/client";
+import { reviewRequestUrl } from "../constants";
+
+/**
+ * Asks the user for a G2 review as a short note signed by the founder. The
+ * server decides eligibility and records the ask, so this renders only when
+ * it should and only once per user.
+ */
+export function ReviewRequestCard() {
+ const { t } = useTranslation();
+ const [dismissed, setDismissed] = React.useState(false);
+
+ if (dismissed) {
+ return null;
+ }
+
+ return (
+ <div className="relative flex flex-col gap-4 rounded-lg border bg-gray-50 p-5 text-left text-sm dark:bg-gray-700/50">
+ <Button
+ size="icon-sm"
+ variant="ghost"
+ className="absolute top-2 right-2"
+ aria-label={t("reviewRequestClose", { defaultValue: "Dismiss" })}
+ onClick={() => {
+ posthog?.capture("review_request:dismiss_click", {
+ channel: "in_app",
+ destination: "g2",
+ });
+ setDismissed(true);
+ }}
+ >
+ <XIcon />
+ </Button>
+ <p className="text-pretty pr-6">
+ <Trans
+ i18nKey="reviewRequestMessage"
+ defaults="If Rallly saved you some back-and-forth, would you leave a quick review on G2? It helps others find us."
+ />
+ </p>
+ <Button
+ className="w-full"
+ variant="primary"
+ nativeButton={false}
+ render={
+ <a
+ href={reviewRequestUrl}
+ target="_blank"
+ rel="noopener noreferrer"
+ />
+ }
+ onClick={() => {
+ posthog?.capture("review_request:cta_click", {
+ channel: "in_app",
+ destination: "g2",
+ });
+ setDismissed(true);
+ }}
+ >
+ <Trans i18nKey="reviewRequestCta" defaults="Write a review" />
+ </Button>
+ <div className="flex items-center gap-3">
+ <Image
+ src="/static/luke.webp"
+ alt="Luke Vella"
+ width={40}
+ height={40}
+ className="size-10 rounded-full object-cover"
+ />
+ <div className="flex flex-col">
+ <span className="font-medium">Luke Vella</span>
+ <span className="text-muted-foreground text-xs">
+ <Trans
+ i18nKey="reviewRequestFounderRole"
+ defaults="Founder of Rallly"
+ />
+ </span>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/review-request/constants.ts b/apps/web/src/features/review-request/constants.ts
new file mode 100644
index 000000000..67a79c4a6
--- /dev/null
+++ b/apps/web/src/features/review-request/constants.ts
@@ -0,0 +1,10 @@
+import { isSelfHosted } from "@/lib/constants";
+
+// Review sites list the Rallly cloud product; self-hosted users are asked
+// through the README and the license email instead
+export const isReviewRequestEnabled = !isSelfHosted;
+
+// G2 first: splitting a few reviews a week across sites leaves both too thin
+// for G2's badges. Add Capterra once G2 has enough reviews.
+export const reviewRequestUrl =
+ "https://www.g2.com/products/rallly/review_modalities/new?utm_source=rallly&utm_medium=in-app&utm_campaign=review-request";
diff --git a/apps/web/src/features/review-request/data.ts b/apps/web/src/features/review-request/data.ts
new file mode 100644
index 000000000..27721da7d
--- /dev/null
+++ b/apps/web/src/features/review-request/data.ts
@@ -0,0 +1,13 @@
+import "server-only";
+
+import { prisma } from "@rallly/database";
+
+/**
+ * Polls whose current scheduled event this user finalized. A poll that was
+ * reopened has no scheduled event, so it no longer counts.
+ */
+export async function countFinalizedPolls(userId: string) {
+ return prisma.poll.count({
+ where: { scheduledEvent: { userId } },
+ });
+}
diff --git a/apps/web/src/features/review-request/mutations.ts b/apps/web/src/features/review-request/mutations.ts
new file mode 100644
index 000000000..1bef3607e
--- /dev/null
+++ b/apps/web/src/features/review-request/mutations.ts
@@ -0,0 +1,72 @@
+import "server-only";
+
+import { prisma } from "@rallly/database";
+import { createLogger } from "@rallly/logger";
+import { isFeatureEnabled } from "@/lib/feature-flags/server";
+import { track } from "@/lib/posthog";
+import { countFinalizedPolls } from "./data";
+import { isEligibleForReviewRequest } from "./utils";
+
+const logger = createLogger("review-request");
+
+/**
+ * Decides whether to ask the user for a review right after they finalize a
+ * poll, and records the ask so it is shown once per user. Returns true when
+ * the caller should show the ask. Never throws: it runs after the poll is
+ * already finalized, so a failure here must not fail the finalize request.
+ */
+export async function claimReviewRequest(params: {
+ userId: string;
+ participantCount: number;
+}) {
+ try {
+ return await claimReviewRequestOrThrow(params);
+ } catch (error) {
+ logger.error({ error, userId: params.userId }, "Review request failed");
+ return false;
+ }
+}
+
+async function claimReviewRequestOrThrow({
+ userId,
+ participantCount,
+}: {
+ userId: string;
+ participantCount: number;
+}) {
+ if (!isFeatureEnabled("reviewRequests")) {
+ return false;
+ }
+
+ const finalizedPollCount = await countFinalizedPolls(userId);
+
+ if (!isEligibleForReviewRequest({ finalizedPollCount, participantCount })) {
+ return false;
+ }
+
+ // Conditional on the column being unset, so two finalizations racing each
+ // other still ask only once.
+ const { count } = await prisma.user.updateMany({
+ where: { id: userId, reviewRequestedAt: null },
+ data: { reviewRequestedAt: new Date() },
+ });
+
+ if (count === 0) {
+ return false;
+ }
+
+ track(
+ { id: userId, isGuest: false },
+ {
+ event: "review_request:prompt_view",
+ properties: {
+ channel: "in_app",
+ destination: "g2",
+ finalized_poll_count: finalizedPollCount,
+ participant_count: participantCount,
+ },
+ },
+ );
+
+ return true;
+}
diff --git a/apps/web/src/features/review-request/utils.test.ts b/apps/web/src/features/review-request/utils.test.ts
new file mode 100644
index 000000000..1bd7b4866
--- /dev/null
+++ b/apps/web/src/features/review-request/utils.test.ts
@@ -0,0 +1,31 @@
+import { describe, expect, it } from "vitest";
+import { isEligibleForReviewRequest } from "./utils";
+
+describe("isEligibleForReviewRequest", () => {
+ it("asks on the second finalized poll with three participants", () => {
+ expect(
+ isEligibleForReviewRequest({
+ finalizedPollCount: 2,
+ participantCount: 3,
+ }),
+ ).toBe(true);
+ });
+
+ it("does not ask on the first finalized poll", () => {
+ expect(
+ isEligibleForReviewRequest({
+ finalizedPollCount: 1,
+ participantCount: 10,
+ }),
+ ).toBe(false);
+ });
+
+ it("does not ask when fewer than three people responded", () => {
+ expect(
+ isEligibleForReviewRequest({
+ finalizedPollCount: 5,
+ participantCount: 2,
+ }),
+ ).toBe(false);
+ });
+});
diff --git a/apps/web/src/features/review-request/utils.ts b/apps/web/src/features/review-request/utils.ts
new file mode 100644
index 000000000..d97aaafe7
--- /dev/null
+++ b/apps/web/src/features/review-request/utils.ts
@@ -0,0 +1,17 @@
+// One finalized poll can be a fluke; a second one means Rallly worked for them
+const minFinalizedPolls = 2;
+// Filters out solo tests: the poll worked for a group
+const minParticipants = 3;
+
+export function isEligibleForReviewRequest({
+ finalizedPollCount,
+ participantCount,
+}: {
+ finalizedPollCount: number;
+ participantCount: number;
+}) {
+ return (
+ finalizedPollCount >= minFinalizedPolls &&
+ participantCount >= minParticipants
+ );
+}
diff --git a/apps/web/src/lib/feature-flags/config.ts b/apps/web/src/lib/feature-flags/config.ts
index 05de63d8b..6326c6466 100644
--- a/apps/web/src/lib/feature-flags/config.ts
+++ b/apps/web/src/lib/feature-flags/config.ts
@@ -6,6 +6,7 @@ import { isConferencingEnabled } from "@/features/conferencing/constants";
import { isEventTypesEnabled } from "@/features/event-types/constants";
import { isFeedbackEnabled } from "@/features/feedback/constants";
import { isQuickCreateEnabled } from "@/features/quick-create/constants";
+import { isReviewRequestEnabled } from "@/features/review-request/constants";
import { isSelfHosted } from "@/lib/constants";
import type { FeatureFlagConfig } from "@/lib/feature-flags/types";
import { isStorageEnabled } from "@/lib/storage";
@@ -46,4 +47,6 @@ export const featureFlagConfig: FeatureFlagConfig = {
// Cloud deploys continuously and is never behind a release; the check
// exists for operators who pull images.
updateCheck: isSelfHosted,
+ // Review sites list the cloud product; nobody to review it for self-hosted.
+ reviewRequests: isReviewRequestEnabled,
};
diff --git a/apps/web/src/lib/feature-flags/types.ts b/apps/web/src/lib/feature-flags/types.ts
index 361955f86..c00037153 100644
--- a/apps/web/src/lib/feature-flags/types.ts
+++ b/apps/web/src/lib/feature-flags/types.ts
@@ -14,6 +14,7 @@ export interface FeatureFlagConfig {
api: boolean;
webhooks: boolean;
updateCheck: boolean;
+ reviewRequests: boolean;
}
export type Feature = keyof FeatureFlagConfig;
diff --git a/apps/web/src/trpc/routers/polls.ts b/apps/web/src/trpc/routers/polls.ts
index d9ce2db49..2cf9f7b99 100644
--- a/apps/web/src/trpc/routers/polls.ts
+++ b/apps/web/src/trpc/routers/polls.ts
@@ -40,6 +40,7 @@ import {
getFinalizePlanGate,
summarizeNotifySelection,
} from "@/features/poll/utils";
+import { claimReviewRequest } from "@/features/review-request/mutations";
import { formatEventDateTime } from "@/features/scheduled-event/utils";
import { getActiveSpaceForUser } from "@/features/space/data";
import type { SpaceTier } from "@/features/space/schema";
@@ -1472,6 +1473,13 @@ export const polls = router({
poll: poll.id,
},
});
+
+ const askForReview = await claimReviewRequest({
+ userId: ctx.user.id,
+ participantCount: poll.participants.length,
+ });
+
+ return { askForReview };
}
}),
reopen: privateProcedure
diff --git a/apps/web/tests/invite-emails.spec.ts b/apps/web/tests/invite-emails.spec.ts
index 80da4bfc0..c721f78df 100644
--- a/apps/web/tests/invite-emails.spec.ts
+++ b/apps/web/tests/invite-emails.spec.ts
@@ -371,9 +371,7 @@ test.describe("Booking a poll", () => {
await dialog
.getByRole("button", { name: "Finalize and notify 1 participant" })
.click();
- await expect(
- dialog.getByText("1 participant will be notified."),
- ).toBeVisible();
+ await expect(dialog.getByText("Date scheduled")).toBeVisible();
// No cron run: the booking's own after() sends the first batch.
const { email } = await captureOne(ALICE);
diff --git a/packages/database/prisma/migrations/20261005120000_add_user_review_requested_at/migration.sql b/packages/database/prisma/migrations/20261005120000_add_user_review_requested_at/migration.sql
new file mode 100644
index 000000000..2217e46d5
--- /dev/null
+++ b/packages/database/prisma/migrations/20261005120000_add_user_review_requested_at/migration.sql
@@ -0,0 +1,2 @@
+-- AlterTable
+ALTER TABLE "users" ADD COLUMN "review_requested_at" TIMESTAMP(3);
diff --git a/packages/database/prisma/models/user.prisma b/packages/database/prisma/models/user.prisma
index 5b12e5602..1135ed933 100644
--- a/packages/database/prisma/models/user.prisma
+++ b/packages/database/prisma/models/user.prisma
@@ -37,31 +37,34 @@ enum UserRole {
}
model User {
- id String @id @default(cuid())
- name String
- email String @unique @db.Citext
- emailVerified Boolean? @map("email_verified")
- image String?
- timeZone String? @map("time_zone")
- weekStart Int? @map("week_start")
- timeFormat TimeFormat? @map("time_format")
- locale String?
- createdAt DateTime @default(now()) @map("created_at")
- updatedAt DateTime? @updatedAt @map("updated_at")
- customerId String? @map("customer_id")
- banned Boolean @default(false)
- bannedAt DateTime? @map("banned_at")
- banReason String? @map("ban_reason")
- banExpires DateTime? @map("ban_expires")
- role UserRole @default(user)
- lastLoginMethod String? @map("last_login_method")
- isAnonymous Boolean @default(false) @map("anonymous")
- lastSeenAt DateTime @default(now()) @map("last_seen_at")
- deletedAt DateTime? @map("deleted_at")
+ id String @id @default(cuid())
+ name String
+ email String @unique @db.Citext
+ emailVerified Boolean? @map("email_verified")
+ image String?
+ timeZone String? @map("time_zone")
+ weekStart Int? @map("week_start")
+ timeFormat TimeFormat? @map("time_format")
+ locale String?
+ createdAt DateTime @default(now()) @map("created_at")
+ updatedAt DateTime? @updatedAt @map("updated_at")
+ customerId String? @map("customer_id")
+ banned Boolean @default(false)
+ bannedAt DateTime? @map("banned_at")
+ banReason String? @map("ban_reason")
+ banExpires DateTime? @map("ban_expires")
+ role UserRole @default(user)
+ lastLoginMethod String? @map("last_login_method")
+ isAnonymous Boolean @default(false) @map("anonymous")
+ lastSeenAt DateTime @default(now()) @map("last_seen_at")
+ deletedAt DateTime? @map("deleted_at")
// Self-declared role, optional. Free-form string rather than an enum so
// the taxonomy can change without a migration; validation lives in
// features/user/schema.ts.
- jobTitle String? @map("job_title")
+ jobTitle String? @map("job_title")
+ // When the user was asked in-app for a review on a third-party site. The
+ // ask shows once per user, so a set value means never ask again.
+ reviewRequestedAt DateTime? @map("review_requested_at")
comments Comment[]
polls Poll[]