Skip to content

Commit f2b12ab

Browse files
committed
Set GA credentials via ENV file
1 parent 4eb03ac commit f2b12ab

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

demo/.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@ MONGODB_URI=
22
PAYLOAD_SECRET=
33

44
PLAUSIBLE_API_KEY=
5+
PLAUSIBLE_SITE_ID=
6+
PLAUSIBLE_HOST=
7+
8+
GOOGLE_PROPERTY_ID=
9+
GOOGLE_CREDENTIALS_FILE="./ga_credentials.json"
10+
GOOGLE_APPLICATION_CREDENTIALS=

demo/src/payload.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const plausibleProvider: PlausibleProvider = {
2525

2626
const googleProvider: GoogleProvider = {
2727
source: "google",
28-
credentials: GOOGLE_CREDENTIALS_FILE,
28+
//credentials: GOOGLE_CREDENTIALS_FILE,
2929
propertyId: GOOGLE_PROPERTY_ID,
3030
};
3131

src/providers/google/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type ClientOptions = {};
77

88
function client(provider: GoogleProvider, options?: ClientOptions) {
99
const analyticsDataClient = new BetaAnalyticsDataClient({
10-
keyFilename: provider.credentials,
10+
...(provider.credentials ? { keyFilename: provider.credentials } : {}),
1111
});
1212

1313
return {

src/types/providers.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ export interface PlausibleProvider {
77

88
interface GoogleProvider {
99
source: "google";
10-
credentials: string;
1110
propertyId: string;
11+
credentials?: string;
1212
}

0 commit comments

Comments
 (0)