Skip to content

Commit 8ecfd30

Browse files
committed
chore: organize type imports/exports
1 parent ad26b91 commit 8ecfd30

File tree

6 files changed

+20
-36
lines changed

6 files changed

+20
-36
lines changed

app/api/ab-config/route.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,7 @@ import { NextResponse } from "next/server"
22

33
import { IS_PREVIEW_DEPLOY } from "@/lib/utils/env"
44

5-
type MatomoExperiment = {
6-
idexperiment: string
7-
name: string
8-
status: string
9-
start_date?: string
10-
end_date?: string
11-
variations: Array<{
12-
name: string
13-
percentage: number
14-
}>
15-
}
16-
17-
type ABTestConfig = {
18-
id: string
19-
enabled: boolean
20-
variants: Array<{
21-
name: string
22-
weight: number
23-
}>
24-
}
5+
import type { ABTestConfig, MatomoExperiment } from "@/lib/ab-testing/types"
256

267
const isExperimentActive = (experiment: MatomoExperiment): boolean => {
278
const now = new Date()
@@ -119,6 +100,7 @@ export async function GET() {
119100
]
120101

121102
config[exp.name] = {
103+
name: exp.name,
122104
id: exp.idexperiment,
123105
enabled: isExperimentActive(exp),
124106
variants,

src/components/AB/ClientABTestWrapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { IS_PREVIEW_DEPLOY, IS_PROD } from "@/lib/utils/env"
44

55
import { useIsClient } from "@/hooks/useIsClient"
66
import { useLocalStorage } from "@/hooks/useLocalStorage"
7-
import { ABTestVariants } from "@/lib/ab-testing/types"
7+
import type { ABTestVariants } from "@/lib/ab-testing/types"
88

99
type ClientABTestWrapperProps = {
1010
testKey: string

src/components/AB/TestWrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactNode } from "react"
1+
import type { ReactNode } from "react"
22

33
import { IS_PREVIEW_DEPLOY, IS_PROD } from "@/lib/utils/env"
44

@@ -7,7 +7,7 @@ import { ABTestDebugPanel } from "./TestDebugPanel"
77
import { ABTestTracker } from "./TestTracker"
88

99
import { getABTestAssignment } from "@/lib/ab-testing/server"
10-
import { ABTestVariants } from "@/lib/ab-testing/types"
10+
import type { ABTestVariants } from "@/lib/ab-testing/types"
1111

1212
type ABTestWrapperProps = {
1313
testKey: string

src/lib/ab-testing/index.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/lib/ab-testing/server.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { SITE_URL } from "@/lib/constants"
22

3-
import { ABTestAssignment, ABTestConfig } from "./types"
3+
import type { ABTestAssignment, ABTestConfig } from "./types"
44

5-
export const getABTestConfigs = async (): Promise<
6-
Record<string, ABTestConfig>
7-
> => {
5+
const getABTestConfigs = async (): Promise<Record<string, ABTestConfig>> => {
86
try {
97
const response = await fetch(`${SITE_URL}/api/ab-config`, {
108
next: { revalidate: 3600 },

src/lib/ab-testing/types.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
import { ReactNode } from "react"
1+
import type { ReactNode } from "react"
2+
3+
export type MatomoExperiment = {
4+
idexperiment: string
5+
name: string
6+
status: string
7+
start_date?: string
8+
end_date?: string
9+
variations: {
10+
name: string
11+
percentage: number
12+
}[]
13+
}
214

315
export type ABTestConfig = {
416
name: string

0 commit comments

Comments
 (0)