AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Merge branch 'master' into dev
Krzysztof Czerwinski134ef84812c3
diff --cc autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/SubscriptionStep/useSubscriptionStep.tsindex 9afb472366,90f5759355..71482726d0--- a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/SubscriptionStep/useSubscriptionStep.ts+++ b/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/SubscriptionStep/useSubscriptionStep.ts@@@ -133,10 -116,9 +133,10 @@@ export function useSubscriptionStep()// A Checkout URL is the only proof that Stripe Checkout actually// starts — reporting earlier would count the in-place and failed// paths as conversions.- trackAdsConversion("begin_checkout", {+ await trackAdsConversionBeforeNavigation("begin_checkout", {value: getSubscriptionValue(planKey, cycle),});+ markPaywallCheckoutStarted();// Navigating away — don't refetch (would set state on an// unmounting component while Stripe Checkout takes over).window.location.href = url;diff --cc autogpt_platform/frontend/src/app/(platform)/PaywallGate/usePaywallModal.tsindex a1e65a8d04,39c8aaef80..e3a1d3b91f--- a/autogpt_platform/frontend/src/app/(platform)/PaywallGate/usePaywallModal.ts+++ b/autogpt_platform/frontend/src/app/(platform)/PaywallGate/usePaywallModal.ts@@@ -22,14 -22,8 +22,14 @@@ import { getEligibleTrialOffer } from "import { useTrialCard } from "@/components/organisms/TrialCard/useTrialCard";import {getSubscriptionValue,- trackAdsConversion,+ trackAdsConversionBeforeNavigation,} from "@/services/analytics/google-ads";+import {+ trackCheckoutAbandoned,+ trackPaywallViewed,+ trackPlanSelected,+} from "@/services/analytics/monetization-analytics";+import { buildPaywallCancelUrl, consumePaywallCheckoutCancel } from "./helpers";interface CheckoutResponse {url?: string;@@@ -174,12 -165,7 +179,12 @@@ export function usePaywallModal()}async function handleSelectPlan(tier: string) {- if (isPending) return;+ if (isCheckingOut) return;+ trackPlanSelected({+ subscription_tier: tier,+ billing_cycle: selectedCycle,+ surface: "paywall_gate",+ });// Team (BUSINESS) is contact-sales, not a self-serve Stripe Checkout —// divert to the intake form like onboarding + Settings billing do.// Without this, the POST hits the backend with tier=BUSINESS which 422sdiff --cc autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/YourPlanCard/useYourPlanCard.tsindex 2d1812acde,181403cb3a..1ac0ed7274--- a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/YourPlanCard/useYourPlanCard.ts+++ b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/YourPlanCard/useYourPlanCard.ts@@@ -16,13 -16,8 +16,13 @@@ import { toast } from "@/components/molimport {centsToUSD,getSubscriptionValue,- trackAdsConversion,+ trackAdsConversionBeforeNavigation,} from "@/services/analytics/google-ads";+import {+ trackBillingPortalOpened,+ trackPaywallViewed,+ trackPlanSelected,+} from "@/services/analytics/monetization-analytics";import { formatCents, formatShortDate } from "../../../helpers";diff --cc autogpt_platform/frontend/src/components/molecules/ExpertAvatarPicker/ExpertAvatarPicker.test.tsxindex e72a4a0b74,e72a4a0b74..a1bc689afd--- a/autogpt_platform/frontend/src/components/molecules/ExpertAvatarPicker/ExpertAvatarPicker.test.tsx+++ b/autogpt_platform/frontend/src/components/molecules/ExpertAvatarPicker/ExpertAvatarPicker.test.tsx@@@ -1,5 -1,5 +1,6 @@@import { server } from "@/mocks/mock-server";import { render, screen, waitFor } from "@/tests/integrations/test-utils";++import { SUBMISSION_MEDIA_MAX_SIZE_MB } from "@/lib/direct-upload";import userEvent from "@testing-library/user-event";import { http, HttpResponse } from "msw";import { expect, test, vi } from "vitest";@@@ -174,7 -174,7 +175,7 @@@ test("uploads remain previews until choexpect(onPick).toHaveBeenCalledWith("https://cdn.test/upload.png");});--test("rejects oversized uploads before making a request", async () => {++test("rejects uploads above the private media limit before making a request", async () => {const upload = vi.fn();server.use(http.post("*/api/store/submissions/media", () => {@@@ -186,12 -186,12 +187,38 @@@<ExpertAvatarPicker name="Nova" category="content" onPick={vi.fn()} />,);const file = new File(["png"], "avatar.png", { type: "image/png" });-- Object.defineProperty(file, "size", { value: 6 * 1024 * 1024 });++ Object.defineProperty(file, "size", {++ value: SUBMISSION_MEDIA_MAX_SIZE_MB * 1024 * 1024 + 1,++ });await userEvent.upload(screen.getByLabelText("Upload avatar"), file);-- expect((await screen.findByRole("alert")).textContent).toContain("under 5MB");++ expect((await screen.findByRole("alert")).textContent).toContain(++ `Maximum size is ${SUBMISSION_MEDIA_MAX_SIZE_MB}MB`,++ );expect(upload).not.toHaveBeenCalled();});++test("accepts uploads at the private media limit", async () => {++ const upload = vi.fn();++ server.use(++ http.post("*/api/store/submissions/media", () => {++ upload();++ return HttpResponse.json("https://cdn.test/upload.png");++ }),++ );++ render(++ <ExpertAvatarPicker name="Nova" category="content" onPick={vi.fn()} />,++ );++ const file = new File(["png"], "avatar.png", { type: "image/png" });++ Object.defineProperty(file, "size", {++ value: SUBMISSION_MEDIA_MAX_SIZE_MB * 1024 * 1024,++ });++++ await userEvent.upload(screen.getByLabelText("Upload avatar"), file);++++ await waitFor(() => expect(upload).toHaveBeenCalledOnce());++ expect(screen.queryByRole("alert")).toBeNull();++});++test("a pending generation allows uploads and confirmation", async () => {server.use(http.post("*/api/experts/avatars/generations", () =>diff --cc autogpt_platform/frontend/src/components/molecules/ExpertAvatarPicker/helpers.tsindex 56795784f8,56795784f8..b53d27058c--- a/autogpt_platform/frontend/src/components/molecules/ExpertAvatarPicker/helpers.ts+++ b/autogpt_platform/frontend/src/components/molecules/ExpertAvatarPicker/helpers.ts@@@ -11,7 -11,7 +11,6 @@@ import} from "../ExpertAvatar/helpers";export const ACCEPTED_AVATAR_TYPES = "image/png,image/jpeg,image/webp";--export const MAX_AVATAR_BYTES = 5 * 1024 * 1024;export function defaultAvatarUrl(category: ExpertAvatarRequestCategory,diff --cc autogpt_platform/frontend/src/components/molecules/ExpertAvatarPicker/useExpertAvatarPicker.tsindex 749107ca65,749107ca65..24d7c1b7da--- a/autogpt_platform/frontend/src/components/molecules/ExpertAvatarPicker/useExpertAvatarPicker.ts+++ b/autogpt_platform/frontend/src/components/molecules/ExpertAvatarPicker/useExpertAvatarPicker.ts@@@ -1,11 -1,11 +1,14 @@@import type { ExpertAvatarRequestCategory } from "@/app/api/__generated__/models/expertAvatarRequestCategory";--import { uploadSubmissionMediaDirect } from "@/lib/direct-upload";++import {++ getFileSizeError,++ SUBMISSION_MEDIA_MAX_SIZE_MB,++ uploadSubmissionMediaDirect,++} from "@/lib/direct-upload";import { useMutation } from "@tanstack/react-query";import { useRef, useState } from "react";import { resolveExpertAvatarUrl } from "../ExpertAvatar/helpers";import {ACCEPTED_AVATAR_TYPES,-- MAX_AVATAR_BYTES,defaultAvatarUrl,randomAvatarRequest,} from "./helpers";@@@ -50,11 -50,11 +53,9 @@@ export function useExpertAvatarPicker(async function uploadFile(file: File | undefined) {if (!file) return;-- if (-- !ACCEPTED_AVATAR_TYPES.split(",").includes(file.type) ||-- file.size > MAX_AVATAR_BYTES-- ) {-- setUploadError("Choose a PNG, JPEG, or WEBP under 5MB.");++ const sizeError = getFileSizeError(file, SUBMISSION_MEDIA_MAX_SIZE_MB);++ if (!ACCEPTED_AVATAR_TYPES.split(",").includes(file.type) || sizeError) {++ setUploadError(sizeError ?? "Choose a PNG, JPEG, or WEBP.");return;}setUploadError(null);diff --cc autogpt_platform/frontend/src/components/organisms/TrialCard/useTrialCard.tsindex 5b8bba5c4e,dd0bf24be7..58f074b1a8--- a/autogpt_platform/frontend/src/components/organisms/TrialCard/useTrialCard.ts+++ b/autogpt_platform/frontend/src/components/organisms/TrialCard/useTrialCard.ts@@@ -3,7 -3,7 +3,8 @@@ importusePostTrialsStartTrialCheckout,} from "@/app/api/__generated__/endpoints/trials/trials";import { useAuthStore } from "@/lib/auth/hooks/useAuthStore";+ import { trackAdsConversionBeforeNavigation } from "@/services/analytics/google-ads";+import { markTrialCheckoutStarted } from "@/services/analytics/monetization-analytics";import { TrialEvent } from "@/services/analytics/posthog-events";import { useTrialStatus } from "@/services/trials/useTrialStatus";import { updateTrialStatusCache } from "@/services/trials/updateTrialStatusCache";@@@ -50,7 -56,14 +57,11 @@@ export function useTrialCard(returnTo:if (useAuthStore.getState().user?.id !== userID) return;if (response.status !== 200)throw new Error("Unable to start trial checkout.");- posthog?.capture(TrialEvent.SUBSCRIPTION_TRIAL_CHECKOUT_STARTED, {- trial_offer_version: offer.version,- surface: returnTo,- });+ markTrialCheckoutStarted(returnTo);+ await trackAdsConversionBeforeNavigation("begin_checkout", {+ value: getTrialChargeAmount(offer),+ currency: offer.currency.toUpperCase(),+ });window.location.assign(response.data.url);} catch (error) {setFailure({