From a4d9b2bf731aeab87ee679f874adc710eec3ba1d Mon Sep 17 00:00:00 2001 From: Cristian Pufu Date: Fri, 12 Dec 2025 17:05:54 +0200 Subject: [PATCH] fix: use the proper aptabase api urls --- pyproject.toml | 2 +- .../README.md | 58 ++--- .../main.py => textual-counter/counter.py} | 15 +- .../pyproject.toml | 6 +- samples/textual-counter/uv.lock | 214 ++++++++++++++++++ .../README.md | 3 + .../main.py | 0 .../pyproject.toml | 2 +- src/aptabase/client.py | 27 ++- uv.lock | 2 +- 10 files changed, 274 insertions(+), 55 deletions(-) rename samples/{textual-aptabase-counter => textual-counter}/README.md (77%) rename samples/{textual-aptabase-counter/main.py => textual-counter/counter.py} (94%) rename samples/{textual-aptabase-counter => textual-counter}/pyproject.toml (95%) create mode 100644 samples/textual-counter/uv.lock rename samples/{textual-aptabase-dashboard => textual-dashboard}/README.md (98%) rename samples/{textual-aptabase-dashboard => textual-dashboard}/main.py (100%) rename samples/{textual-aptabase-dashboard => textual-dashboard}/pyproject.toml (98%) diff --git a/pyproject.toml b/pyproject.toml index 6882079..b07a39f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "aptabase" -version = "0.0.1" +version = "0.0.2" description = "Python SDK for Aptabase analytics" readme = "README.md" requires-python = ">=3.11" diff --git a/samples/textual-aptabase-counter/README.md b/samples/textual-counter/README.md similarity index 77% rename from samples/textual-aptabase-counter/README.md rename to samples/textual-counter/README.md index 639760e..4a624ff 100644 --- a/samples/textual-aptabase-counter/README.md +++ b/samples/textual-counter/README.md @@ -35,7 +35,7 @@ This is a simple counter app that: uv pip install textual aptabase # Run the app -uv run main.py +uv run counter.py ``` #### Using pip @@ -49,7 +49,7 @@ source venv/bin/activate # On Windows: venv\Scripts\activate pip install textual aptabase # Run the app -python main.py +python counter.py ``` #### Using pyproject.toml @@ -67,7 +67,7 @@ Before running, you need to set your Aptabase app key: 1. Sign up at [aptabase.com](https://aptabase.com/) 2. Create a new app 3. Copy your app key (format: `A-EU-XXXXXXXXXX` or `A-US-XXXXXXXXXX`) -4. Update the key in `simple_counter.py`: +4. Update the key in `counter.py`: ```python # Replace with your actual Aptabase app key @@ -120,7 +120,7 @@ Sent when the app exits. ## 🎮 Usage -1. **Start the app**: Run `python simple_counter.py` +1. **Start the app**: Run `python main.py` 2. **Click the button**: Press "Click Me!" to increment (or press `Enter` when focused) 3. **Reset**: Click "Reset" to set counter back to zero 4. **Quit**: Press `q` or `Ctrl+C` @@ -244,55 +244,31 @@ pip install textual aptabase python --version # Must be 3.11+ ``` -## 📚 Learn More - -### Next Steps - -Once you're comfortable with this simple example, check out: - -1. **textual_aptabase_demo.py** - Full dashboard with tabs, forms, and real-time stats -2. **advanced_patterns.py** - User identification, error tracking, performance monitoring +### Events don't show -### Resources +Make sure to check the Debug-mode dashboard (not Release-mode) -- **Aptabase**: [https://aptabase.com/docs](https://aptabase.com/docs) -- **Aptabase Python SDK**: [https://github.com/aptabase/aptabase-py](https://github.com/aptabase/aptabase-py) -- **Textual**: [https://textual.textualize.io/](https://textual.textualize.io/) -- **Textual Tutorial**: [https://textual.textualize.io/tutorial/](https://textual.textualize.io/tutorial/) - -## 🔐 Privacy +## 📚 Learn More -Aptabase is privacy-first analytics: -- ✅ No personal data collected -- ✅ No IP addresses stored -- ✅ No cookies or tracking -- ✅ GDPR compliant -- ✅ Open source +## Resources -This example only tracks: -- Counter values (anonymous) -- Button click events -- Session duration -- App lifecycle events +- [Aptabase Documentation](https://aptabase.com/docs) +- [Textual Documentation](https://textual.textualize.io/) +- [Aptabase Python SDK](https://github.com/aptabase/aptabase-python) -## 📄 License +## License MIT License - feel free to use this as a starting point for your own projects! -## 🤝 Contributing +## Contributing -This is a simple example/demo. Feel free to: -- Fork and modify -- Use in your own projects -- Share improvements +This is a demo app. Feel free to fork and modify for your needs! -## ❓ Questions? +## Questions? -- **Aptabase Support**: [https://aptabase.com/](https://aptabase.com/) -- **Textual Discord**: [https://discord.gg/Enf6Z3qhVr](https://discord.gg/Enf6Z3qhVr) +- Aptabase: [https://aptabase.com/](https://aptabase.com/) +- Textual: [https://textual.textualize.io/](https://textual.textualize.io/) --- -**Happy coding!** 🚀 - Built with ❤️ using [Textual](https://textual.textualize.io/) and [Aptabase](https://aptabase.com/) \ No newline at end of file diff --git a/samples/textual-aptabase-counter/main.py b/samples/textual-counter/counter.py similarity index 94% rename from samples/textual-aptabase-counter/main.py rename to samples/textual-counter/counter.py index e9395a2..d43b24c 100644 --- a/samples/textual-aptabase-counter/main.py +++ b/samples/textual-counter/counter.py @@ -31,6 +31,11 @@ class CounterApp(App): } """ + BINDINGS = [ + ("q", "quit", "Quit"), + ("ctrl+c", "quit", "Quit"), + ] + def __init__(self, app_key: str = "A-EU-0000000000"): super().__init__() self.app_key = app_key @@ -87,8 +92,12 @@ async def on_button_pressed(self, event: Button.Pressed) -> None: counter_widget = self.query_one("#counter", Static) counter_widget.update(f"[bold cyan]Count: {self.counter}[/bold cyan]") - -if __name__ == "__main__": +def main(): + """Run the counter app""" # Replace with your Aptabase app key app = CounterApp(app_key="A-EU-0000000000") - app.run() \ No newline at end of file + app.run() + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/samples/textual-aptabase-counter/pyproject.toml b/samples/textual-counter/pyproject.toml similarity index 95% rename from samples/textual-aptabase-counter/pyproject.toml rename to samples/textual-counter/pyproject.toml index c1694f8..9d33eff 100644 --- a/samples/textual-aptabase-counter/pyproject.toml +++ b/samples/textual-counter/pyproject.toml @@ -5,11 +5,11 @@ description = "A simple counter app demonstrating Aptabase analytics integration authors = [ {name = "Your Name", email = "your.email@example.com"} ] -readme = "README_COUNTER.md" +readme = "README.md" requires-python = ">=3.11" dependencies = [ "textual>=6.7.1", - "aptabase>=0.0.1", + "aptabase>=0.0.2", ] license = {text = "MIT"} keywords = ["textual", "tui", "analytics", "aptabase", "counter"] @@ -30,7 +30,7 @@ Repository = "https://github.com/yourusername/textual-aptabase-counter" "Bug Tracker" = "https://github.com/yourusername/textual-aptabase-counter/issues" [project.scripts] -counter = "main:main" +counter = "counter:main" [build-system] requires = ["hatchling"] diff --git a/samples/textual-counter/uv.lock b/samples/textual-counter/uv.lock new file mode 100644 index 0000000..dd0b540 --- /dev/null +++ b/samples/textual-counter/uv.lock @@ -0,0 +1,214 @@ +version = 1 +revision = 3 +requires-python = ">=3.11" + +[[package]] +name = "anyio" +version = "4.12.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "idna" }, + { name = "typing-extensions", marker = "python_full_version < '3.13'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/16/ce/8a777047513153587e5434fd752e89334ac33e379aa3497db860eeb60377/anyio-4.12.0.tar.gz", hash = "sha256:73c693b567b0c55130c104d0b43a9baf3aa6a31fc6110116509f27bf75e21ec0", size = 228266, upload-time = "2025-11-28T23:37:38.911Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7f/9c/36c5c37947ebfb8c7f22e0eb6e4d188ee2d53aa3880f3f2744fb894f0cb1/anyio-4.12.0-py3-none-any.whl", hash = "sha256:dad2376a628f98eeca4881fc56cd06affd18f659b17a747d3ff0307ced94b1bb", size = 113362, upload-time = "2025-11-28T23:36:57.897Z" }, +] + +[[package]] +name = "aptabase" +version = "0.0.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "httpx" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/91/ae/84c53e23a482099c2d0bcc39e9aa42905ab6704b9a17d11dfd978107ac45/aptabase-0.0.1.tar.gz", hash = "sha256:eb3deb3aa98246d3f011403ae50acf68d0c3847c384c3b537d8a0cc10ac73b20", size = 45813, upload-time = "2025-12-12T13:38:39.639Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/58/54/905f2bdfbfe415ce474509988cad02a897814ee7c6d6bd90785160531c12/aptabase-0.0.1-py3-none-any.whl", hash = "sha256:5656176632b316354f28fd5abb4edd498b63ad2b69ddda1f7ebd4a9303feb5dc", size = 7057, upload-time = "2025-12-12T13:38:37.187Z" }, +] + +[[package]] +name = "certifi" +version = "2025.11.12" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a2/8c/58f469717fa48465e4a50c014a0400602d3c437d7c0c468e17ada824da3a/certifi-2025.11.12.tar.gz", hash = "sha256:d8ab5478f2ecd78af242878415affce761ca6bc54a22a27e026d7c25357c3316", size = 160538, upload-time = "2025-11-12T02:54:51.517Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/70/7d/9bc192684cea499815ff478dfcdc13835ddf401365057044fb721ec6bddb/certifi-2025.11.12-py3-none-any.whl", hash = "sha256:97de8790030bbd5c2d96b7ec782fc2f7820ef8dba6db909ccf95449f2d062d4b", size = 159438, upload-time = "2025-11-12T02:54:49.735Z" }, +] + +[[package]] +name = "h11" +version = "0.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250, upload-time = "2025-04-24T03:35:25.427Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" }, +] + +[[package]] +name = "httpcore" +version = "1.0.9" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "certifi" }, + { name = "h11" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/06/94/82699a10bca87a5556c9c59b5963f2d039dbd239f25bc2a63907a05a14cb/httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8", size = 85484, upload-time = "2025-04-24T22:06:22.219Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55", size = 78784, upload-time = "2025-04-24T22:06:20.566Z" }, +] + +[[package]] +name = "httpx" +version = "0.28.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "certifi" }, + { name = "httpcore" }, + { name = "idna" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b1/df/48c586a5fe32a0f01324ee087459e112ebb7224f646c0b5023f5e79e9956/httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc", size = 141406, upload-time = "2024-12-06T15:37:23.222Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517, upload-time = "2024-12-06T15:37:21.509Z" }, +] + +[[package]] +name = "idna" +version = "3.11" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/6f/6d/0703ccc57f3a7233505399edb88de3cbd678da106337b9fcde432b65ed60/idna-3.11.tar.gz", hash = "sha256:795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902", size = 194582, upload-time = "2025-10-12T14:55:20.501Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0e/61/66938bbb5fc52dbdf84594873d5b51fb1f7c7794e9c0f5bd885f30bc507b/idna-3.11-py3-none-any.whl", hash = "sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea", size = 71008, upload-time = "2025-10-12T14:55:18.883Z" }, +] + +[[package]] +name = "linkify-it-py" +version = "2.0.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "uc-micro-py" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/2a/ae/bb56c6828e4797ba5a4821eec7c43b8bf40f69cda4d4f5f8c8a2810ec96a/linkify-it-py-2.0.3.tar.gz", hash = "sha256:68cda27e162e9215c17d786649d1da0021a451bdc436ef9e0fa0ba5234b9b048", size = 27946, upload-time = "2024-02-04T14:48:04.179Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/1e/b832de447dee8b582cac175871d2f6c3d5077cc56d5575cadba1fd1cccfa/linkify_it_py-2.0.3-py3-none-any.whl", hash = "sha256:6bcbc417b0ac14323382aef5c5192c0075bf8a9d6b41820a2b66371eac6b6d79", size = 19820, upload-time = "2024-02-04T14:48:02.496Z" }, +] + +[[package]] +name = "markdown-it-py" +version = "4.0.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "mdurl" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/5b/f5/4ec618ed16cc4f8fb3b701563655a69816155e79e24a17b651541804721d/markdown_it_py-4.0.0.tar.gz", hash = "sha256:cb0a2b4aa34f932c007117b194e945bd74e0ec24133ceb5bac59009cda1cb9f3", size = 73070, upload-time = "2025-08-11T12:57:52.854Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/94/54/e7d793b573f298e1c9013b8c4dade17d481164aa517d1d7148619c2cedbf/markdown_it_py-4.0.0-py3-none-any.whl", hash = "sha256:87327c59b172c5011896038353a81343b6754500a08cd7a4973bb48c6d578147", size = 87321, upload-time = "2025-08-11T12:57:51.923Z" }, +] + +[package.optional-dependencies] +linkify = [ + { name = "linkify-it-py" }, +] + +[[package]] +name = "mdit-py-plugins" +version = "0.5.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markdown-it-py" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b2/fd/a756d36c0bfba5f6e39a1cdbdbfdd448dc02692467d83816dff4592a1ebc/mdit_py_plugins-0.5.0.tar.gz", hash = "sha256:f4918cb50119f50446560513a8e311d574ff6aaed72606ddae6d35716fe809c6", size = 44655, upload-time = "2025-08-11T07:25:49.083Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fb/86/dd6e5db36df29e76c7a7699123569a4a18c1623ce68d826ed96c62643cae/mdit_py_plugins-0.5.0-py3-none-any.whl", hash = "sha256:07a08422fc1936a5d26d146759e9155ea466e842f5ab2f7d2266dd084c8dab1f", size = 57205, upload-time = "2025-08-11T07:25:47.597Z" }, +] + +[[package]] +name = "mdurl" +version = "0.1.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d6/54/cfe61301667036ec958cb99bd3efefba235e65cdeb9c84d24a8293ba1d90/mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba", size = 8729, upload-time = "2022-08-14T12:40:10.846Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", size = 9979, upload-time = "2022-08-14T12:40:09.779Z" }, +] + +[[package]] +name = "platformdirs" +version = "4.5.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/cf/86/0248f086a84f01b37aaec0fa567b397df1a119f73c16f6c7a9aac73ea309/platformdirs-4.5.1.tar.gz", hash = "sha256:61d5cdcc6065745cdd94f0f878977f8de9437be93de97c1c12f853c9c0cdcbda", size = 21715, upload-time = "2025-12-05T13:52:58.638Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cb/28/3bfe2fa5a7b9c46fe7e13c97bda14c895fb10fa2ebf1d0abb90e0cea7ee1/platformdirs-4.5.1-py3-none-any.whl", hash = "sha256:d03afa3963c806a9bed9d5125c8f4cb2fdaf74a55ab60e5d59b3fde758104d31", size = 18731, upload-time = "2025-12-05T13:52:56.823Z" }, +] + +[[package]] +name = "pygments" +version = "2.19.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/b0/77/a5b8c569bf593b0140bde72ea885a803b82086995367bf2037de0159d924/pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887", size = 4968631, upload-time = "2025-06-21T13:39:12.283Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b", size = 1225217, upload-time = "2025-06-21T13:39:07.939Z" }, +] + +[[package]] +name = "rich" +version = "14.2.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markdown-it-py" }, + { name = "pygments" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/fb/d2/8920e102050a0de7bfabeb4c4614a49248cf8d5d7a8d01885fbb24dc767a/rich-14.2.0.tar.gz", hash = "sha256:73ff50c7c0c1c77c8243079283f4edb376f0f6442433aecb8ce7e6d0b92d1fe4", size = 219990, upload-time = "2025-10-09T14:16:53.064Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/25/7a/b0178788f8dc6cafce37a212c99565fa1fe7872c70c6c9c1e1a372d9d88f/rich-14.2.0-py3-none-any.whl", hash = "sha256:76bc51fe2e57d2b1be1f96c524b890b816e334ab4c1e45888799bfaab0021edd", size = 243393, upload-time = "2025-10-09T14:16:51.245Z" }, +] + +[[package]] +name = "textual" +version = "6.8.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markdown-it-py", extra = ["linkify"] }, + { name = "mdit-py-plugins" }, + { name = "platformdirs" }, + { name = "pygments" }, + { name = "rich" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c8/8f/aeccf7459e3d71cbca912a27a97f1fcb00735326f90714d22fa540d3848e/textual-6.8.0.tar.gz", hash = "sha256:7efe618ec9197466b8fe536aefabb678edf30658b9dc58a763365d7daed12b62", size = 1581639, upload-time = "2025-12-07T17:53:46.681Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/47/34/4f1bad936ac3ad94c8576b15660d4ce434f7dbd372baa53566a490bcdce3/textual-6.8.0-py3-none-any.whl", hash = "sha256:074d389ba8c6c98c74e2a4fe1493ea3a38f3ee5008697e98f71daa2cf8ab8fda", size = 714378, upload-time = "2025-12-07T17:53:44.501Z" }, +] + +[[package]] +name = "textual-aptabase-counter" +version = "1.0.0" +source = { editable = "." } +dependencies = [ + { name = "aptabase" }, + { name = "textual" }, +] + +[package.metadata] +requires-dist = [ + { name = "aptabase", specifier = ">=0.0.1" }, + { name = "textual", specifier = ">=6.7.1" }, +] + +[[package]] +name = "typing-extensions" +version = "4.15.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" }, +] + +[[package]] +name = "uc-micro-py" +version = "1.0.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/91/7a/146a99696aee0609e3712f2b44c6274566bc368dfe8375191278045186b8/uc-micro-py-1.0.3.tar.gz", hash = "sha256:d321b92cff673ec58027c04015fcaa8bb1e005478643ff4a500882eaab88c48a", size = 6043, upload-time = "2024-02-09T16:52:01.654Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/37/87/1f677586e8ac487e29672e4b17455758fce261de06a0d086167bb760361a/uc_micro_py-1.0.3-py3-none-any.whl", hash = "sha256:db1dffff340817673d7b466ec86114a9dc0e9d4d9b5ba229d9d60e5c12600cd5", size = 6229, upload-time = "2024-02-09T16:52:00.371Z" }, +] diff --git a/samples/textual-aptabase-dashboard/README.md b/samples/textual-dashboard/README.md similarity index 98% rename from samples/textual-aptabase-dashboard/README.md rename to samples/textual-dashboard/README.md index 34e4a40..1134a15 100644 --- a/samples/textual-aptabase-dashboard/README.md +++ b/samples/textual-dashboard/README.md @@ -223,6 +223,9 @@ pip install # Or with uv uv sync ``` +### Events don't show + +Make sure to check the Debug-mode dashboard (not Release-mode) ## Resources diff --git a/samples/textual-aptabase-dashboard/main.py b/samples/textual-dashboard/main.py similarity index 100% rename from samples/textual-aptabase-dashboard/main.py rename to samples/textual-dashboard/main.py diff --git a/samples/textual-aptabase-dashboard/pyproject.toml b/samples/textual-dashboard/pyproject.toml similarity index 98% rename from samples/textual-aptabase-dashboard/pyproject.toml rename to samples/textual-dashboard/pyproject.toml index 9893023..2d114c0 100644 --- a/samples/textual-aptabase-dashboard/pyproject.toml +++ b/samples/textual-dashboard/pyproject.toml @@ -9,7 +9,7 @@ readme = "README.md" requires-python = ">=3.11" dependencies = [ "textual>=6.7.1", - "aptabase>=0.0.1", + "aptabase>=0.0.2", ] license = {text = "MIT"} keywords = ["textual", "tui", "analytics", "aptabase", "dashboard"] diff --git a/src/aptabase/client.py b/src/aptabase/client.py index 3ccf63e..062fefa 100644 --- a/src/aptabase/client.py +++ b/src/aptabase/client.py @@ -14,6 +14,12 @@ logger = logging.getLogger(__name__) +_HOSTS = { + "EU": "https://eu.aptabase.com", + "US": "https://us.aptabase.com", + "SH": None, # Self-hosted, requires custom base_url in options +} + class Aptabase: """Aptabase analytics client.""" @@ -27,6 +33,7 @@ def __init__( max_batch_size: int = 25, flush_interval: float = 10.0, timeout: float = 30.0, + base_url: str | None = None, ) -> None: """Initialize the Aptabase client. @@ -50,7 +57,7 @@ def __init__( raise ConfigurationError("Maximum batch size is 25 events") self._app_key = app_key - self._base_url = self._get_base_url(app_key) + self._base_url = base_url or self._get_base_url(app_key) self._system_props = SystemProperties( app_version=app_version, is_debug=is_debug, @@ -67,10 +74,20 @@ def __init__( def _get_base_url(self, app_key: str) -> str: """Determine the base URL from the app key.""" - if app_key.startswith("A-EU-"): - return "https://api-eu.aptabase.com/" - elif app_key.startswith("A-US-"): - return "https://api.aptabase.com/" + parts = app_key.split("-") + + if len(parts) != 3 or parts[1] not in _HOSTS: + raise ConfigurationError("The Aptabase App Key is invalid.") + + region = parts[1] + + # If self-hosted, require base_url in init + if region == "SH": + raise ConfigurationError("Self-hosted app key requires base_url in init.") + + host = _HOSTS.get(region, None) + if host: + return host else: raise ConfigurationError("Invalid app key region") diff --git a/uv.lock b/uv.lock index 59e9481..7fe9302 100644 --- a/uv.lock +++ b/uv.lock @@ -17,7 +17,7 @@ wheels = [ [[package]] name = "aptabase" -version = "0.0.1" +version = "0.0.2" source = { editable = "." } dependencies = [ { name = "httpx" },