diff --git a/apps/resources/app/resources/Resources/ResourcesTable/ResourcesList/DownloadButton/DownloadButtonClient.tsx b/apps/resources/app/resources/Resources/ResourcesTable/ResourcesList/DownloadButton/DownloadButtonClient.tsx
index 552d4618..36bfd7c5 100644
--- a/apps/resources/app/resources/Resources/ResourcesTable/ResourcesList/DownloadButton/DownloadButtonClient.tsx
+++ b/apps/resources/app/resources/Resources/ResourcesTable/ResourcesList/DownloadButton/DownloadButtonClient.tsx
@@ -15,7 +15,7 @@ export const DownloadButtonClient = ({ csv }: Props) => {
size="large"
onClick={() => {
downloadCsv(csv, 'lifecentereddesign-net-resources.csv');
- track('Download Resources', {});
+ track('Download Resources');
}}
>
diff --git a/apps/resources/app/resources/Suggestion/SuggestionForm.tsx b/apps/resources/app/resources/Suggestion/SuggestionForm.tsx
index 6985999a..2e6ed299 100644
--- a/apps/resources/app/resources/Suggestion/SuggestionForm.tsx
+++ b/apps/resources/app/resources/Suggestion/SuggestionForm.tsx
@@ -21,7 +21,7 @@ export const SuggestionForm = () => {
if (document.activeElement instanceof HTMLElement) {
document.activeElement.blur();
}
- track('Resource Suggestion', {});
+ track('Resource Suggestion');
},
onError: () => {
if (!linkInputRef.current) return;
diff --git a/apps/resources/components/Header/CO2Badge/CO2Badge.tsx b/apps/resources/components/Header/CO2Badge/CO2Badge.tsx
index b8b14d52..5e71d23a 100644
--- a/apps/resources/components/Header/CO2Badge/CO2Badge.tsx
+++ b/apps/resources/components/Header/CO2Badge/CO2Badge.tsx
@@ -17,7 +17,7 @@ export const CO2Badge = ({ co2, cleanerThan }: Props) => {
const onOpenChange = (open: boolean) => {
if (open) {
- track('Open CO2 Badge', {});
+ track('Open CO2 Badge');
}
setOpen(open);
};
diff --git a/apps/resources/components/Newsletter/NewsletterForm.tsx b/apps/resources/components/Newsletter/NewsletterForm.tsx
index 69497778..82261d20 100644
--- a/apps/resources/components/Newsletter/NewsletterForm.tsx
+++ b/apps/resources/components/Newsletter/NewsletterForm.tsx
@@ -29,7 +29,7 @@ export const NewsletterForm = () => {
if (document.activeElement instanceof HTMLElement) {
document.activeElement.blur();
}
- track('Newsletter Signup', {});
+ track('Newsletter Signup');
},
onError: () => {
if (!emailInputRef.current) return;
diff --git a/apps/resources/hooks/useFilter.tsx b/apps/resources/hooks/useFilter.tsx
index 08c4afca..f4a04b0f 100644
--- a/apps/resources/hooks/useFilter.tsx
+++ b/apps/resources/hooks/useFilter.tsx
@@ -81,11 +81,11 @@ export const useFilter = () => {
}
if (param === 'likes') {
- track('Toggle filter resources by likes', {});
+ track('Toggle filter resources by likes');
}
if (param === 'comments') {
- track('Toggle filter resources by comments', {});
+ track('Toggle filter resources by comments');
}
if (param === 'limit') {
diff --git a/apps/resources/lib/serverActions/client.ts b/apps/resources/lib/serverActions/client.ts
index b0bb5a5b..0f0afd90 100644
--- a/apps/resources/lib/serverActions/client.ts
+++ b/apps/resources/lib/serverActions/client.ts
@@ -71,12 +71,11 @@ const createReducer =
export const useAction = <
TInputSchema extends z.ZodTypeAny,
- TInput extends TInputSchema | undefined,
TResponse extends any,
>(
- inputAction: ServerAction,
+ inputAction: ServerAction,
options: {
- onRunAction?: (input: InferInputType) => void;
+ onRunAction?: (input: InferInputType) => void;
onSuccess?: (data: TResponse | null) => void;
onError?: (
error: string | null,
@@ -92,7 +91,7 @@ export const useAction = <
const [isRunning, startTransition] = useTransition();
const runAction = useCallback(
- async (input: InferInputType) => {
+ async (input: InferInputType) => {
startTransition(async () => {
dispatch({
type: 'RUN_ACTION',
diff --git a/apps/resources/lib/serverActions/server.ts b/apps/resources/lib/serverActions/server.ts
index 8795d071..b4f9ffb5 100644
--- a/apps/resources/lib/serverActions/server.ts
+++ b/apps/resources/lib/serverActions/server.ts
@@ -7,15 +7,13 @@ import {
type MaybePromise = Promise | T;
-export type InferInputType<
- TInputSchema extends z.ZodTypeAny,
- TInput extends TInputSchema | undefined,
-> = z.ZodTypeAny extends TInput ? void : z.input;
+export type InferInputType =
+ z.ZodTypeAny extends TInputSchema ? void : z.infer;
export type InferValidationErrors =
z.inferFlattenedErrors['fieldErrors'];
-interface Result {
+interface Result {
data: TResponse | null;
error: string | null;
validationErrors: InferValidationErrors | null;
@@ -23,10 +21,9 @@ interface Result {
export type ServerAction<
TInputSchema extends z.ZodTypeAny,
- TInput extends TInputSchema | undefined,
- TResponse,
+ TResponse extends any,
> = (
- input: InferInputType,
+ input: InferInputType,
) => Promise> | void;
export const createActionClient = (createClientOpts?: {
@@ -34,7 +31,6 @@ export const createActionClient = (createClientOpts?: {
}) => {
const actionBuilder = <
TInputSchema extends z.ZodTypeAny,
- TInput extends TInputSchema | undefined,
TResponse extends any,
>(actionBuilderOpts: {
input?: TInputSchema;
@@ -43,7 +39,7 @@ export const createActionClient = (createClientOpts?: {
ctx: Context;
}) => MaybePromise | MaybePromise;
}) => {
- const createAction: ServerAction = async (
+ const createAction: ServerAction = async (
input,
) => {
try {
@@ -82,7 +78,6 @@ export const createActionClient = (createClientOpts?: {
isNextRedirectError(errorMessage) ||
isNextNotFoundError(errorMessage)
) {
- console.log('is next errror');
throw error;
}
diff --git a/apps/resources/lib/tracking.ts b/apps/resources/lib/tracking.ts
index 5865a80b..301489c7 100644
--- a/apps/resources/lib/tracking.ts
+++ b/apps/resources/lib/tracking.ts
@@ -1,8 +1,8 @@
import { ContentType } from './resources';
interface TrackingEvents {
- 'Download Resources': {};
- 'Resource Suggestion': {};
+ 'Download Resources': null;
+ 'Resource Suggestion': null;
'Copy Resource Link': {
link: string;
};
@@ -28,7 +28,7 @@ interface TrackingEvents {
'Uncaught error': {
message: string;
};
- 'Newsletter Signup': {};
+ 'Newsletter Signup': null;
'Filter resources by type': {
type: string;
};
@@ -41,17 +41,19 @@ interface TrackingEvents {
'Sort resources': {
by: string;
};
- 'Toggle filter resources by likes': {};
- 'Toggle filter resources by comments': {};
+ 'Toggle filter resources by likes': null;
+ 'Toggle filter resources by comments': null;
'Show more resources': {
count: number;
};
- 'Open CO2 Badge': {};
+ 'Open CO2 Badge': null;
}
export const track = (
event: TEventKey,
- data: TrackingEvents[TEventKey],
+ ...data: TrackingEvents[TEventKey] extends null
+ ? []
+ : [TrackingEvents[TEventKey]]
) => {
splitbee.track(event, data);
};
diff --git a/apps/resources/lib/utils/utils.test.ts b/apps/resources/lib/utils/utils.test.ts
index 2d046f35..be423edd 100644
--- a/apps/resources/lib/utils/utils.test.ts
+++ b/apps/resources/lib/utils/utils.test.ts
@@ -100,7 +100,6 @@ describe('getBaseUrl', () => {
process.env.NEXT_PUBLIC_VERCEL_ENV = '';
process.env.NEXT_PUBLIC_VERCEL_URL = '';
process.env.PORT = '3000';
- console.log(process.env.NEXT_PUBLIC_VERCEL_URL);
const baseUrl = getBaseUrl();
expect(baseUrl).toBe('http://localhost:3000');
});