Skip to content

Commit

Permalink
Add logging to SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
petrvecera committed Dec 14, 2024
1 parent 783ec42 commit 41dde55
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pages/api/appUpdateRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { NextApiRequest, NextApiResponse } from "next";
import { Octokit } from "octokit";

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
console.log(`SSR - /api/appUpdateRoute`);

const octokit = new Octokit();
const response = await octokit.request("GET /repos/{owner}/{repo}/releases/latest", {
owner: "cohstats",
Expand Down
2 changes: 2 additions & 0 deletions pages/api/getLatestPatchMapStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { getStatsData } from "../../src/apis/coh3stats-api";
import { maps } from "../../src/coh3/coh3-data";

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
console.log(`SSR - /api/getLatestPatchMapStats`);

try {
const statsPatchSelector = config.statsPatchSelector;
const fromTimeStamp = getGMTTimeStamp(new Date(statsPatchSelector[config.latestPatch].from));
Expand Down
2 changes: 2 additions & 0 deletions pages/api/getNodeVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const systemInfo = {
};

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
console.log(`SSR - /api/getNodeVersion`);

try {
res.setHeader("Cache-Control", "public").status(200).json({
nodeVersion: process.version,
Expand Down
2 changes: 2 additions & 0 deletions pages/api/playerExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const xff = `${req.headers["x-forwarded-for"]}`;
const { profileIDs, types } = query;

logger.log(`SSR - /api/playerExport, profileIDs: ${profileIDs}, types: ${types}`);

if (!profileIDs) {
return res.status(400).json({ error: "profile id param is missing" });
}
Expand Down
3 changes: 3 additions & 0 deletions pages/api/topLeaderboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
try {
const query = req.query;
const { race } = query;

console.log(`SSR - /api/topLeaderboards, race: ${race}`);

const data = await getTop1v1LeaderBoards(race as raceType);

res.setHeader("Cache-Control", "public, max-age=60").status(200).json(data);
Expand Down
2 changes: 2 additions & 0 deletions pages/desktop-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export const getServerSideProps: GetServerSideProps<any> = async ({ res }) => {
},
});

console.log(`SSR - /desktop-app`);

let downloadURL = "https://github.com/cohstats/coh3-stats-desktop-app/releases/latest"; // fallback in case request fails
let downloadCount = 0;
let version = "";
Expand Down
2 changes: 2 additions & 0 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const getServerSideProps: GetServerSideProps<any> = async ({ req, res })
let steamNewsData: COH3SteamNewsType | null = null;
let youtubeData: YouTubeVideo[] | null = null;

console.log(`SSR - /`);

try {
const [
PromisedTwitchStreams,
Expand Down
4 changes: 4 additions & 0 deletions pages/leaderboards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export const getServerSideProps: GetServerSideProps = async ({ query, res }) =>
const sortByToFetch = sortById[sortBy as "wins" | "elo"] || 1;
const regionToFetch = (region as LeaderboardRegionTypes) || null;

console.log(
`SSR - /leaderboards, race: ${raceToFetch}, type: ${typeToFetch}, platform: ${platformToFetch}, region: ${regionToFetch}`,
);

let startNumber: number | undefined;
if (start) {
const number = Number(start);
Expand Down
2 changes: 2 additions & 0 deletions pages/news.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import SteamNewsPage from "../screens/news";
export const getServerSideProps: GetServerSideProps<any> = async ({ res }) => {
let COH3SteamNews = null;

console.log(`SSR - /news`);

try {
COH3SteamNews = await getCOH3SteamNews();

Expand Down
2 changes: 2 additions & 0 deletions pages/players/[...playerID].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ export const getServerSideProps: GetServerSideProps<any, { playerID: string }> =
const isReplaysPage = view === "replays";
// const viewStandings = view === "standings";

console.log(`SSR - /players/${playerID}, view: ${view}`);

let playerData = null;
let playerStatsData = null;
let error = null;
Expand Down
2 changes: 2 additions & 0 deletions pages/stats/achievements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export const getServerSideProps: GetServerSideProps<any, { playerID: string }> =
}) => {
const xff = `${req.headers["x-forwarded-for"]}`;

console.log(`SSR - /stats/achievements`);

let error = null;
let globalAchievements = null;

Expand Down
2 changes: 2 additions & 0 deletions pages/stats/leaderboards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export const getServerSideProps: GetServerSideProps = async ({ res }) => {
let error = null;
let leaderBoardStats = null;

console.log(`SSR - /stats/leaderboards`);

try {
leaderBoardStats = await calculateLeaderboardStats();

Expand Down
2 changes: 2 additions & 0 deletions pages/stats/players.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ export const getServerSideProps: GetServerSideProps = async ({ res }) => {
let countries = null;
let historyData = null;

console.log(`SSR - /stats/players`);

try {
const docRef = doc(getFirestore(), "stats", "player-stats");
const docHistoryRef = doc(getFirestore(), "stats", "player-stats-history");
Expand Down

0 comments on commit 41dde55

Please sign in to comment.