Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

fix: ensure we have envs for gsc sync

Carl-Gerhard Lindesvärd6e1daf2c761d
diff --git a/packages/db/src/gsc.ts b/packages/db/src/gsc.ts
index eb6240e41..f6e27cfcb 100644
--- a/packages/db/src/gsc.ts
+++ b/packages/db/src/gsc.ts
@@ -14,9 +14,15 @@ export interface GscSite {
async function refreshGscToken(
refreshToken: string
): Promise<{ accessToken: string; expiresAt: Date }> {
+ if (!process.env.GOOGLE_CLIENT_ID || !process.env.GOOGLE_CLIENT_SECRET) {
+ throw new Error(
+ 'GOOGLE_CLIENT_ID or GOOGLE_CLIENT_SECRET is not set in this environment'
+ );
+ }
+
const params = new URLSearchParams({
- client_id: process.env.GOOGLE_CLIENT_ID ?? '',
- client_secret: process.env.GOOGLE_CLIENT_SECRET ?? '',
+ client_id: process.env.GOOGLE_CLIENT_ID,
+ client_secret: process.env.GOOGLE_CLIENT_SECRET,
refresh_token: refreshToken,
grant_type: 'refresh_token',
});