Skip to content

Commit

Permalink
πŸ› fix google credential issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mickm3n committed Jul 9, 2024
1 parent d0af29f commit 751a951
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scripts/fetch_google_analytics_view_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
)
import json
import re
import os

PATH_FILTER_PATTERNS = [
re.compile("/blog/.+"),
Expand All @@ -21,7 +22,12 @@ def get_view_count_dict(property_id="278031395"):
"""Runs a simple report on a Google Analytics 4 property."""
# Using a default constructor instructs the client to use the credentials
# specified in GOOGLE_APPLICATION_CREDENTIALS environment variable.
client = BetaAnalyticsDataClient()
# Load the service account info from the environment variable
service_account_info = json.loads(os.getenv("GOOGLE_APPLICATION_CREDENTIALS_JSON"))

# Create a client using the service account info
client = BetaAnalyticsDataClient.from_service_account_info(service_account_info)

view_count_dict = dict()

request = RunReportRequest(
Expand Down

0 comments on commit 751a951

Please sign in to comment.