{"id":29099923,"url":"https://github.com/bcc-code/analytics-test-webhook","last_synced_at":"2025-06-28T17:38:00.178Z","repository":{"id":253980444,"uuid":"845114857","full_name":"bcc-code/analytics-test-webhook","owner":"bcc-code","description":"[BCC Media] Store webhook data for a short period of time","archived":false,"fork":false,"pushed_at":"2024-08-20T16:21:36.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-20T18:45:11.728Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","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/bcc-code.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}},"created_at":"2024-08-20T15:57:07.000Z","updated_at":"2024-08-20T18:45:16.170Z","dependencies_parsed_at":"2024-08-21T04:45:57.639Z","dependency_job_id":null,"html_url":"https://github.com/bcc-code/analytics-test-webhook","commit_stats":null,"previous_names":["andreasgangso/analytics-test-webhook"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bcc-code/analytics-test-webhook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcc-code%2Fanalytics-test-webhook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcc-code%2Fanalytics-test-webhook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcc-code%2Fanalytics-test-webhook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcc-code%2Fanalytics-test-webhook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bcc-code","download_url":"https://codeload.github.com/bcc-code/analytics-test-webhook/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcc-code%2Fanalytics-test-webhook/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262471042,"owners_count":23316603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2025-06-28T17:37:49.297Z","updated_at":"2025-06-28T17:38:00.172Z","avatar_url":"https://github.com/bcc-code.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Dumb webhook storage\n\nThis is a simple Go service designed to receive arbitrary JSON data via a webhook and store it in memory.\nIt's retrievable via an API_KEY protected endpoint.\n\n## Deployment\n\n```sh\ngcloud run deploy # And just follow the steps. Allow anonymous access when asked.\n```\n\n## Features\n\n- **Webhook Endpoint**: Accepts POST requests with JSON payloads at an endpoint identified by a unique `id`.\n- **In-Memory Data Storage**: Stores the received JSON data in memory, associated with the given `id`.\n- **Automatic Data Expiry**: Clears the stored data for an `id` if no data is received within the last 10 minutes before processing a new request.\n- **Data Retrieval**: Provides a GET endpoint to retrieve all stored data for a specific `id`, protected by an API key.\n\n## Use Case\n\nThis service is particularly useful for scenarios like end-to-end (E2E) testing where you need to verify that certain events or data points are being sent to a specific endpoint. For example, you could integrate this service with tools like RudderStack or SegmentIO during your CI/CD pipeline to validate that expected analytics events are received during test runs.\n\n## Endpoints\n\n- `POST /webhook/:id` - Receives JSON data on the specified `id`.\n- `GET /get_data/:id?api_key=your_api_key` - Retrieves all data received for the specified `id`, protected by an API key.\n\n## Environment Variables\n\n- `API_KEY` - The API key required to access the `GET /get_data/:id` endpoint.\n\n## Example Usage\n\nBelow is an example shell script (`example_usage.sh`) demonstrating how to use the service:\n\n```bash\n#!/bin/bash\n\n# Set the API key for accessing the data\nAPI_KEY=\"your_api_key\"\n\n# Define the ID for the webhook\nWEBHOOK_ID=\"test-webhook\"\n\n# Send a POST request to the webhook with some JSON data\ncurl -X POST -H \"Content-Type: application/json\"      -d '{\"event\": \"test_event\", \"value\": 42}'      http://localhost:8080/webhook/$WEBHOOK_ID\n\n# Retrieve the stored data for the webhook\ncurl -G -H \"Content-Type: application/json\"      --data-urlencode \"api_key=$API_KEY\"      http://localhost:8080/get_data/$WEBHOOK_ID\n```\n\n## Running the Service\n\n1. Set the `API_KEY` environment variable before running the service:\n   ```bash\n   export API_KEY=your_api_key\n   ```\n2. Run the service:\n   ```bash\n   go run main.go\n   ```\n3. Use the example shell script to send data to the webhook and retrieve it.\n\n## Notes\n\n- Ensure that the `API_KEY` environment variable is set and matches the key used in your requests to protect access to the stored data.\n- The service clears data for an `id` if no data has been received in the last 10 minutes when a new request is processed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcc-code%2Fanalytics-test-webhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbcc-code%2Fanalytics-test-webhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcc-code%2Fanalytics-test-webhook/lists"}