{"id":23895537,"url":"https://github.com/michimani/export-pv-rank","last_synced_at":"2026-05-03T21:31:19.372Z","repository":{"id":42720069,"uuid":"278847209","full_name":"michimani/export-pv-rank","owner":"michimani","description":"This is a AWS CDK application that fetch page views from Google Analytics and export ranking data as a JSON file to Amazon S3 bucket.","archived":false,"fork":false,"pushed_at":"2023-07-18T22:50:01.000Z","size":1778,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-02T02:43:10.687Z","etag":null,"topics":["aws-cdk","google-analytics-api","python","typescript"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michimani.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-07-11T11:22:14.000Z","updated_at":"2022-03-27T11:13:17.000Z","dependencies_parsed_at":"2025-09-02T02:44:43.414Z","dependency_job_id":null,"html_url":"https://github.com/michimani/export-pv-rank","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/michimani/export-pv-rank","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michimani%2Fexport-pv-rank","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michimani%2Fexport-pv-rank/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michimani%2Fexport-pv-rank/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michimani%2Fexport-pv-rank/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michimani","download_url":"https://codeload.github.com/michimani/export-pv-rank/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michimani%2Fexport-pv-rank/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32586186,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-cdk","google-analytics-api","python","typescript"],"created_at":"2025-01-04T15:57:43.857Z","updated_at":"2026-05-03T21:31:19.353Z","avatar_url":"https://github.com/michimani.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"export-pv-rank\n---\n\nThis is a AWS CDK application that fetch page views from Google Analytics and export ranking data as a JSON file to Amazon S3 bucket.\n\n# Features\n\n- Get report from Google Analytics via Google Analytics Reporting API.\n- Generate PV ranking.\n- Export it as a JSON object to an Amazon S3 bucket.\n- Use Amazon EventBridge scheduling rules to do this on a regular basis.\n\n![Architecture](./docs/architecture.jpg)\n\n# Preparing\n\n## Install tools\n\n- AWS CLI\n\n  ```bash\n  $ aws --version\n  aws-cli/1.22.82 Python/3.9.10 Darwin/21.4.0 botocore/1.24.27\n  ```\n  \n  Or, version 2.x.\n\n  ```bash\n  $ aws --version\n  aws-cli/2.4.29 Python/3.8.8 Darwin/21.4.0 exe/x86_64 prompt/off\n  ```\n- jq\n\n  ```bash\n  $ jq --version\n  jq-1.6\n  ```\n\n## Generate Google service account key\n\nGenerate Google service account key, and export JSON file to the local machine as the name `client_secrets.json`.\n\nPlease see the links below for more information.\n\n- [Creating and managing service account keys | Cloud IAM Documentation](https://cloud.google.com/iam/docs/creating-managing-service-account-keys)\n\n## Setup project\n\n1. Clone this repository\n\n    ```bash\n    $ git clone https://github.com/michimani/export-pv-rank.git\n    $ cd export-pv-rank\n    ```\n\n2. Install npm modules\n\n    ```bash\n    $ npm install\n    ...\n    ```\n3. Install Python packages\n\n    ```bash\n    $ pip3 install --upgrade -r ./lambda/requirements.txt\n    ```\n\n4. Create S3 bucket for CDK\n\n    If this is your first time using the CDK in your AWS account and region, run the following command.\n    \n    ```bash\n    $ cdk bootstrap\n    ```\n\n5. Copy client_secrets.json\n\n   Copy the Googel service account key you exported above to the project root directory.\n   \n   ```bash\n   $ cp /path/to/your/key/client_secrets.json ./\n   ```\n\n6. Put Google service accoutn key to SSM parameter store\n\n    ```bash\n    $ aws ssm put-parameter \\\n    --name google-client-secret \\\n    --type SecureString \\\n    --value \"$(jq -c \u003c ./client_secrets.json)\"\n    ```\n\n7. Create config file\n\n    ```bash\n    $  stack-config.json.sample stack-config.json\n    ```\n    \n    - `lambda.env`\n      - `client_secret_ssm_key` : SSM parameter store key for Google service account key.\n      - `view_id` : ID of Google Analytics view.\n      - `out_s3_bucket` : S3 bucket name for export PV ranking JSON file. This bucket must already exist.\n      - `out_json_key` : S3 object key for PV ranking JSON.\n      - `site_base_url` : Your site base url. (e.g. https://michimani.net)\n    - `event_bridge`\n      - `cron_expression` : Expression of cron for EventBridge rule.\n\n# Run at local\n\nOutput PV ranking JSON to standard output.\n\n```bash\n$ sh ./scripts/run_at_local.sh\nRunning at local...\n```\n   \n# Deloying\n\n1. Create directory for Lambda deploy package\n\n    ```bash\n    $ pip3 install --upgrade -r ./lambda/requirements.txt -t ./lambda/dist/ \\\n    \u0026\u0026 cp -f ./lambda/src/fetch_rank.py ./lambda/dist/\n    ```\n2. Generate CloudFormation template\n\n    ```bash\n    $ cdk synth\n    ```\n\n3. Deploy\n\n    ```bash\n    $ cdk deploy\n    ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichimani%2Fexport-pv-rank","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichimani%2Fexport-pv-rank","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichimani%2Fexport-pv-rank/lists"}