-
- {isOAuthEnabled && (
- <>
-
-
-
-
-
- >
- )}
-
-
+
+
+
+
+
Zalvena
+
+
+
+
+
+
Sign up for an account
+
+
+
+
+
-
-
-
- );
+
+ )
}
diff --git a/src/webapp/features/auth/auth.ts b/src/webapp/features/auth/auth.ts
index 15247b7..dc4de6b 100755
--- a/src/webapp/features/auth/auth.ts
+++ b/src/webapp/features/auth/auth.ts
@@ -1,5 +1,4 @@
import { api } from "@fns/api";
-import { trackEvent } from "@aptabase/web";
export type UserAccount = {
id: string;
@@ -22,7 +21,6 @@ export async function requestSignInLink(email: string): Promise
{
export async function requestRegisterLink(name: string, email: string): Promise {
await api.post("/_auth/register", { name, email });
- trackEvent("register");
}
export async function me(): Promise {
diff --git a/src/webapp/features/billing/BillingPage.tsx b/src/webapp/features/billing/BillingPage.tsx
deleted file mode 100755
index 39a65be..0000000
--- a/src/webapp/features/billing/BillingPage.tsx
+++ /dev/null
@@ -1,123 +0,0 @@
-import { Button } from "@components/Button";
-import { ErrorState } from "@components/ErrorState";
-import { LoadingState } from "@components/LoadingState";
-import { Page, PageHeading } from "@components/Page";
-import { formatPeriod } from "@fns/format-date";
-import { useState } from "react";
-import { CurrentPlan } from "./CurrentPlan";
-import { CurrentUsage } from "./CurrentUsage";
-import { DeleteAccountModal } from "./DeleteAccountModal";
-import { MonthlyUsageChart } from "./MonthlyUsageChart";
-import { BillingHistoricalUsage, BillingInfo, useBilling, useHistoricalData } from "./useBilling";
-
-Component.displayName = "BillingPage";
-export function Component() {
- const { isLoading: isLoadingBilling, isError: isErrorBilling, data: billing } = useBilling();
- const { isLoading: isLoadingHistorical, isError: isErrorHistorical, data: historical } = useHistoricalData();
-
- const isLoading = isLoadingBilling || isLoadingHistorical;
- const isError = isErrorBilling || isErrorHistorical;
-
- return (
-
-
-
-
- {isLoading && }
- {isError && }
- {billing && historical &&
}
-
-
- );
-}
-
-function Body(props: { billing: BillingInfo; historical: BillingHistoricalUsage[] }) {
- const [showDeleteModal, setShowDeleteModal] = useState(false);
- const openDeleteModal = () => setShowDeleteModal(true);
- const closeDeleteModal = () => setShowDeleteModal(false);
-
- return (
- <>
-
-
-
Monthly Usage
-
-
- formatPeriod("month", x.date))}
- events={props.historical.map((x) => x.events)}
- state={props.billing.state}
- quota={props.billing.plan.monthlyEvents}
- />
-
-
-
-
-
-
-
-
- >
- );
-}
-
-function DangerZoneItem({
- title,
- description,
- subDescription,
- actionText,
- onClick,
-}: {
- title: string;
- description: string;
- subDescription: string;
- actionText: string;
- onClick: () => void;
-}) {
- return (
-
-
-
{title}
-
{description}
-
{subDescription}
-
-
- {actionText}
-
-
- );
-}
diff --git a/src/webapp/features/billing/CurrentPlan.tsx b/src/webapp/features/billing/CurrentPlan.tsx
deleted file mode 100755
index 96fdea4..0000000
--- a/src/webapp/features/billing/CurrentPlan.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { api } from "@fns/api";
-import { useState } from "react";
-import { SubscriptionStatusBadge } from "./SubscriptionStatusBadge";
-import { BillingInfo } from "./useBilling";
-import { Button } from "@components/Button";
-import { formatDate } from "@fns/format-date";
-
-type Props = {
- billing: BillingInfo;
-};
-
-export function CurrentPlan(props: Props) {
- const [loading, setLoading] = useState(false);
-
- const status = props.billing.subscription?.status;
- const expiresOn = status === "cancelled" ? props.billing.subscription?.endsAt : undefined;
- const isExpired = status === "expired";
- const hasSubscription = !!props.billing.subscription;
-
- const action = async () => {
- setLoading(true);
-
- const path = hasSubscription ? `/_billing/portal` : `/_billing/checkout`;
- const response = await api.post<{ url: string }>(path);
- location.href = response.url;
- };
-
- return (
-
-
- {props.billing.plan.name}
- {props.billing.plan.monthlyPrice > 0 && (
-
- ${props.billing.plan.monthlyPrice} /mo + Tax
-
- )}
-
-
- {props.billing.plan.freeTrialEndsAt ? (
-
- Free access until
- {new Date(props.billing.plan.freeTrialEndsAt).toLocaleDateString()}
-
- ) : (
-
- {props.billing.plan.monthlyEvents.toLocaleString()}{" "}
- events / mo
-
- )}
-
- {hasSubscription ? "Manage Subscription" : "Upgrade"}
-
-
- {status && !isExpired && (
-
-
- {expiresOn && Expires on {formatDate(expiresOn)} }
-
- )}
-
- );
-}
diff --git a/src/webapp/features/billing/CurrentUsage.tsx b/src/webapp/features/billing/CurrentUsage.tsx
deleted file mode 100755
index 4ae3b94..0000000
--- a/src/webapp/features/billing/CurrentUsage.tsx
+++ /dev/null
@@ -1,58 +0,0 @@
-import { PingSignal } from "@components/PingSignal";
-import { twMerge } from "tailwind-merge";
-
-const months = [
- "January",
- "February",
- "March",
- "April",
- "May",
- "June",
- "July",
- "August",
- "September",
- "October",
- "November",
- "December",
-];
-
-type Props = {
- month: number;
- year: number;
- usage: number;
- quota: number;
- state: "OK" | "OVERUSE";
-};
-
-const colors = {
- OK: "bg-primary",
- OVERUSE: "bg-destructive",
-};
-
-export function CurrentUsage(props: Props) {
- const percentage = (props.usage / props.quota) * 100;
-
- return (
-
-
- Usage
-
- {months[props.month - 1]} / {props.year}
-
-
-
-
-
{props.usage.toLocaleString()}
-
- / {props.quota.toLocaleString()} events ({percentage.toFixed(2)}
- %)
-
- {props.state === "OVERUSE" &&
}
-
-
-
-
- );
-}
diff --git a/src/webapp/features/billing/MonthlyUsageChart.tsx b/src/webapp/features/billing/MonthlyUsageChart.tsx
deleted file mode 100755
index e68e823..0000000
--- a/src/webapp/features/billing/MonthlyUsageChart.tsx
+++ /dev/null
@@ -1,78 +0,0 @@
-import { Chart } from "@components/Chart";
-import { useChartColors } from "@features/theme";
-import { ChartConfigurationCustomTypesPerDataset } from "chart.js";
-
-type Props = {
- dates: string[];
- events: number[];
- quota: number;
- state: "OK" | "OVERUSE";
-};
-
-export function MonthlyUsageChart(props: Props) {
- const colors = useChartColors();
-
- const config: ChartConfigurationCustomTypesPerDataset = {
- data: {
- labels: props.dates,
- datasets: [
- {
- type: "bar",
- label: "Daily Users",
- data: props.events,
- backgroundColor: colors.primary,
- hoverBackgroundColor: colors.primary,
- },
- {
- type: "line",
- data: props.events.map(() => props.quota),
- borderColor: props.state === "OK" ? colors.success : colors.destructive,
- borderWidth: 2,
- pointRadius: 0,
- pointHoverRadius: 0,
- },
- ],
- },
- options: {
- plugins: {
- tooltip: {
- enabled: false,
- },
- },
- animation: false,
- interaction: {
- mode: "index",
- intersect: false,
- },
- maintainAspectRatio: false,
- layout: {
- padding: 0,
- },
- scales: {
- x: {
- grid: {
- display: false,
- },
- border: {
- display: false,
- },
- },
- y: {
- grid: {
- color: colors.highlight,
- tickWidth: 0,
- },
- beginAtZero: true,
- ticks: {
- maxTicksLimit: 8,
- },
- border: {
- display: false,
- },
- },
- },
- },
- };
-
- return
;
-}
diff --git a/src/webapp/features/billing/SubscriptionStatusBadge.tsx b/src/webapp/features/billing/SubscriptionStatusBadge.tsx
deleted file mode 100755
index de657d4..0000000
--- a/src/webapp/features/billing/SubscriptionStatusBadge.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-Possible statuses:
-- active
-- cancelled
-- expired
-- paused
-- past_due
-- unpaid
-*/
-
-const statuses: Record
= {
- active: ["Active", "text-success"],
- cancelled: ["Cancelled", "text-destructive"],
- expired: ["Expired", "text-destructive"],
- paused: ["Paused", "text-primary"],
- past_due: ["Past Due", "text-destructive"],
- unpaid: ["Unpaid", "text-destructive"],
-};
-
-export function SubscriptionStatusBadge(props: { status: string }) {
- const [statusFormatted, color] = statuses[props.status] ?? [props.status, ""];
- return {statusFormatted} ;
-}
diff --git a/src/webapp/features/billing/TrialReminder.tsx b/src/webapp/features/billing/TrialReminder.tsx
deleted file mode 100755
index 1689d12..0000000
--- a/src/webapp/features/billing/TrialReminder.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { Link } from "react-router-dom";
-import { useBilling } from "./useBilling";
-import { Alert, AlertDescription } from "@components/Alert";
-import { isBillingEnabled } from "@features/env";
-
-export function TrialReminder() {
- const { data: billing } = useBilling();
-
- if (!isBillingEnabled || !billing || !billing.plan.freeTrialEndsAt) return null;
-
- const endsAt = new Date(billing.plan.freeTrialEndsAt);
- const differenceInMs = new Date(endsAt).getTime() - new Date().getTime();
- const days = Math.floor(differenceInMs / (1000 * 60 * 60 * 24));
-
- if (days <= -1) return null;
-
- return (
-
-
-
- Trial{" "}
- {days === 1 ? `ends tomorrow` : days > 0 ? `ends in ${days} days` : days === 0 ? "ends today" : "expired"}
-
-
-
- );
-}
diff --git a/src/webapp/features/billing/index.tsx b/src/webapp/features/billing/index.tsx
deleted file mode 100755
index 33c9112..0000000
--- a/src/webapp/features/billing/index.tsx
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./useBilling";
-export * from "./TrialReminder";
diff --git a/src/webapp/features/billing/useBilling.tsx b/src/webapp/features/billing/useBilling.tsx
deleted file mode 100755
index 878461b..0000000
--- a/src/webapp/features/billing/useBilling.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import { UseQueryResult, useQuery } from "@tanstack/react-query";
-import { api } from "@fns/api";
-import { isBillingEnabled } from "@features/env";
-
-export type BillingInfo = {
- usage: number;
- month: number;
- year: number;
- state: "OK" | "OVERUSE";
- subscription?: {
- status: string;
- endsAt: string;
- };
- plan: {
- name: string;
- monthlyPrice: number;
- monthlyEvents: number;
- freeTrialEndsAt?: string;
- };
-};
-
-export type BillingHistoricalUsage = {
- date: string;
- events: number;
-};
-
-export function useBilling(): UseQueryResult {
- return useQuery({ queryKey: ["billing"], queryFn: () => api.get(`/_billing`), refetchOnMount: true });
-}
-
-export function useHistoricalData(): UseQueryResult {
- return useQuery({
- queryKey: ["billing-historical"],
- queryFn: () => api.get(`/_billing/historical`),
- });
-}
-
-export function useBillingState(): "OK" | "OVERUSE" {
- if (!isBillingEnabled) return "OK";
-
- const { data } = useBilling();
- return data?.state ?? "OK";
-}
diff --git a/src/webapp/features/env/env.ts b/src/webapp/features/env/env.ts
index 61f24ff..2ade437 100755
--- a/src/webapp/features/env/env.ts
+++ b/src/webapp/features/env/env.ts
@@ -1,6 +1,5 @@
-const regions: { [host: string]: "eu" | "us" } = {
- "us.aptabase.com": "us",
- "eu.aptabase.com": "eu",
+const regions: { [host: string]: "Mars" } = {
+ "beta.events.sudovanilla.org": "Mars"
};
function getUserHourCycle(): "h12" | "h24" {
diff --git a/src/webapp/features/export/YearlyGrid.tsx b/src/webapp/features/export/YearlyGrid.tsx
index 0077158..67c3378 100755
--- a/src/webapp/features/export/YearlyGrid.tsx
+++ b/src/webapp/features/export/YearlyGrid.tsx
@@ -1,4 +1,3 @@
-import { trackEvent } from "@aptabase/web";
import { Button } from "@components/Button";
import { Popover, PopoverContent, PopoverTrigger } from "@components/Popover";
import { Application, BuildMode } from "@features/apps";
@@ -36,9 +35,7 @@ export function YearlyGrid(props: Props) {
const endDateUTC = new Date(endDate!.getTime() - endDate!.getTimezoneOffset() * 60000);
params.set("startDate", startDateUTC.toISOString());
params.set("endDate", endDateUTC.toISOString());
-
- trackEvent("export", { name: props.app.name });
-
+
location.href = `/api/_export/download?${params.toString()}`;
};
diff --git a/src/webapp/features/navigation/NavMenu.tsx b/src/webapp/features/navigation/NavMenu.tsx
index 56c85fd..99bf4dc 100755
--- a/src/webapp/features/navigation/NavMenu.tsx
+++ b/src/webapp/features/navigation/NavMenu.tsx
@@ -9,6 +9,7 @@ import {
} from "@tabler/icons-react";
import { NavCategory } from "./NavCategory";
import { NavItem } from "./NavItem";
+import React from "react";
export function NavMenu(props: { onNavigation?: VoidFunction }) {
const currentApp = useCurrentApp();
@@ -19,6 +20,9 @@ export function NavMenu(props: { onNavigation?: VoidFunction }) {
+
+ {!currentApp ? 'Select an app' : currentApp.appKey}
+
);
-}
+}
\ No newline at end of file
diff --git a/src/webapp/features/navigation/UserMenu.tsx b/src/webapp/features/navigation/UserMenu.tsx
index 0dd6abb..6d88ae5 100755
--- a/src/webapp/features/navigation/UserMenu.tsx
+++ b/src/webapp/features/navigation/UserMenu.tsx
@@ -1,6 +1,4 @@
import { PingSignal } from "@components/PingSignal";
-import { useBillingState } from "@features/billing";
-import { isBillingEnabled } from "@features/env";
import { ThemeToggle } from "@features/theme";
import { Menu, Transition } from "@headlessui/react";
import { IconCreditCard, IconDoorExit } from "@tabler/icons-react";
@@ -39,7 +37,6 @@ const MenuItem = (props: {
);
export function UserMenu(props: Props) {
- const billing = useBillingState();
return (