{"id":15758037,"url":"https://github.com/12joan/not-analytics","last_synced_at":"2025-04-30T21:10:31.216Z","repository":{"id":37012389,"uuid":"219962443","full_name":"12joan/not-analytics","owner":"12joan","description":"don't be creepy.","archived":false,"fork":false,"pushed_at":"2025-04-21T06:18:22.000Z","size":124,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-21T07:38:31.998Z","etag":null,"topics":["data","metrics","privacy"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/12joan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2019-11-06T09:42:50.000Z","updated_at":"2025-04-21T06:18:25.000Z","dependencies_parsed_at":"2024-01-09T21:31:38.433Z","dependency_job_id":"7f541f1b-55d6-4ddd-b892-21be2c59495e","html_url":"https://github.com/12joan/not-analytics","commit_stats":{"total_commits":86,"total_committers":5,"mean_commits":17.2,"dds":0.2906976744186046,"last_synced_commit":"5e0a34a9017a3f371b3b902f3fcf19f345c54f59"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/12joan%2Fnot-analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/12joan%2Fnot-analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/12joan%2Fnot-analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/12joan%2Fnot-analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/12joan","download_url":"https://codeload.github.com/12joan/not-analytics/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251782776,"owners_count":21642987,"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":["data","metrics","privacy"],"created_at":"2024-10-04T09:41:52.115Z","updated_at":"2025-04-30T21:10:31.185Z","avatar_url":"https://github.com/12joan.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# not Analytics\n\ndon't be creepy. \n\n## Usage with Docker\n\n```bash\ngit clone https://github.com/12joan/not-analytics.git\ncd not-analytics\ndocker-compose up -d --build \n```\n\n## Registering an App\n\nAccess the Rails console using `docker-compose exec web rails c`.\n\n```ruby\napp_id = SecureRandom.hex\n# =\u003e \"87f7ac80212a68dd80ae3ad3341fda42\"\n\nApp.create(id: app_id, name: 'My App')\n```\n\nOptionally, specify a secret key to protect against replay attacks.\n\n```ruby\nkey = Base64.encode64(SecureRandom.random_bytes(32))\n# =\u003e \"aIT90JS5/wA2m8fBVDqHCH0ajNWgkUelFceaNNr1D3g=\\n\" \n\nApp.create(id: app_id, name: 'My App', key: key)\n```\n\n## Record a hit\n\nHits can be recorded using the [not Analytics Client](https://github.com/12joan/not-analytics-client).\n\nAlternatively, you can record hits manually using `curl`.\n\n```bash\ncurl \\\n  https://hit.example.com/ \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n    \"hit\": {\n      \"app_id\": \"87f7ac80212a68dd80ae3ad3341fda42\",\n      \"event\": \"/some/path\"\n    }\n  }'\n```\n\nIf a key was specified for the App, the request must be accompanied by a non-reusable nonce, and must be signed using AES-256-GCM.\n\n```ruby\nkey = \"aIT90JS5/wA2m8fBVDqHCH0ajNWgkUelFceaNNr1D3g=\\n\"\n\nnonce = SecureRandom.hex\n# =\u003e \"6e550d9746e27c1e7a37e8d5f2e63269\"\n\nevent = 'some/path'\n\ncipher = OpenSSL::Cipher.new('aes-256-gcm')\ncipher.encrypt\ncipher.key = Base64.decode64(key)\n\n{\n  iv: cipher.random_iv,\n  signature: cipher.update(\"#{nonce}:#{event}\") + cipher.final,\n  auth_tag: cipher.auth_tag,\n}.transform_values { |v| Base64.encode64(v) }\n# =\u003e {:iv=\u003e\"jrBi3VbhyE699L/2\\n\", :signature=\u003e\"1HdXQ+M3Fz1BzOVi7cw=\\n\", :auth_tag=\u003e\"rQuKyXuXZY91zLlsSQJBlg==\\n\"}\n```\n\n```bash\ncurl \\\n  https://hit.example.com/ \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n    \"hit\": {\n      \"app_id\": \"87f7ac80212a68dd80ae3ad3341fda42\",\n      \"event\": \"/some/path\",\n      \"nonce\": \"6e550d9746e27c1e7a37e8d5f2e63269\",\n      \"signature\": \"1HdXQ+M3Fz1BzOVi7cw=\",\n      \"iv\": \"jrBi3VbhyE699L/2\",\n      \"auth_tag\": \"rQuKyXuXZY91zLlsSQJBlg==\"\n    }\n  }'\n```\n\n## Reading hit data\n\nIn order to read hit data using the JSON API, your App must have a `read_token`.\n\n```ruby\nSecureRandom.hex.tap do |read_token|\n  my_app.update(read_token: read_token)\nend\n# =\u003e \"b304226509dc998ba0c82b5b1bc49a5d\"\n```\n\nYou can then use this token in requests to `/apps/:app_id` and `apps/:app_id/hits` as follows.\n\nApp data\n\n```bash\ncurl \\\n  -X GET \\\n  https://hit.example.com/apps/87f7ac80212a68dd80ae3ad3341fda42 \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n    \"token\": \"b304226509dc998ba0c82b5b1bc49a5d\"\n  }'\n```\n\nHit data\n\n```bash\ncurl \\\n  -X GET \\\n  https://hit.example.com/apps/87f7ac80212a68dd80ae3ad3341fda42/hits \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n    \"token\": \"b304226509dc998ba0c82b5b1bc49a5d\",\n    \"start_date\": \"2020-09-01\",\n    \"end_date\": \"2020-09-31\",\n    \"period\": \"day\"\n  }'\n```\n\nThe time period can be any one of:\n\n- hour\n- day\n- week\n- month\n- quarter\n- year\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F12joan%2Fnot-analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F12joan%2Fnot-analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F12joan%2Fnot-analytics/lists"}