Skip to content

Commit

Permalink
Set GA credentials via ENV file
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpopus committed Apr 16, 2023
1 parent 4eb03ac commit f2b12ab
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions demo/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ MONGODB_URI=
PAYLOAD_SECRET=

PLAUSIBLE_API_KEY=
PLAUSIBLE_SITE_ID=
PLAUSIBLE_HOST=

GOOGLE_PROPERTY_ID=
GOOGLE_CREDENTIALS_FILE="./ga_credentials.json"
GOOGLE_APPLICATION_CREDENTIALS=
2 changes: 1 addition & 1 deletion demo/src/payload.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const plausibleProvider: PlausibleProvider = {

const googleProvider: GoogleProvider = {
source: "google",
credentials: GOOGLE_CREDENTIALS_FILE,
//credentials: GOOGLE_CREDENTIALS_FILE,
propertyId: GOOGLE_PROPERTY_ID,
};

Expand Down
2 changes: 1 addition & 1 deletion src/providers/google/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type ClientOptions = {};

function client(provider: GoogleProvider, options?: ClientOptions) {
const analyticsDataClient = new BetaAnalyticsDataClient({
keyFilename: provider.credentials,
...(provider.credentials ? { keyFilename: provider.credentials } : {}),
});

return {
Expand Down
2 changes: 1 addition & 1 deletion src/types/providers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export interface PlausibleProvider {

interface GoogleProvider {
source: "google";
credentials: string;
propertyId: string;
credentials?: string;
}

0 comments on commit f2b12ab

Please sign in to comment.