Skip to content

Commit 751f342

Browse files
committed
fix: auth on matomo api
1 parent 95791f2 commit 751f342

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/services/stats/stats.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@ import { getProductCountByCategory } from "../../db/product"
33
import { getDoneAPIUploadCount, getDoneFileUploadCount } from "../../db/upload"
44

55
const getVisits = async () => {
6+
const params = new URLSearchParams()
7+
params.append("token_auth", process.env.MATOMO_API_TOKEN as string)
68
return axios
7-
.post<
8-
[{ nb_visits: number }]
9-
>(`${process.env.NEXT_PUBLIC_MATOMO_SITE_URL}?idSite=${process.env.NEXT_PUBLIC_MATOMO_SITE_ID}&method=VisitsSummary.get&format=JSON&module=API&period=year&date=today&showColumns=nb_visits&filter_limit=-1&flat=1`)
9+
.post<[{ nb_visits: number }]>(
10+
`${process.env.NEXT_PUBLIC_MATOMO_SITE_URL}?idSite=${process.env.NEXT_PUBLIC_MATOMO_SITE_ID}&method=VisitsSummary.get&format=JSON&module=API&period=year&date=today&showColumns=nb_visits&filter_limit=-1&flat=1`,
11+
params,
12+
{
13+
headers: {
14+
"Content-Type": "application/x-www-form-urlencoded",
15+
},
16+
},
17+
)
1018
.then((response) => response.data)
1119
}
1220

0 commit comments

Comments
 (0)