Skip to content

Commit

Permalink
Add PostHog
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Maksimov committed Jan 10, 2024
1 parent bf26ee8 commit 3d9338d
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions flatpak/com.github.tenderowl.frog.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"python3-pytesseract.json",
"python3-pyzbar.json",
"python3-gTTS.json",
"python3-posthog.json",
{
"name" : "frog",
"builddir" : true,
Expand Down
54 changes: 54 additions & 0 deletions flatpak/python3-posthog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "python3-posthog",
"buildsystem": "simple",
"build-commands": [
"pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"posthog\" --no-build-isolation"
],
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/df/73/b6e24bd22e6720ca8ee9a85a0c4a2971af8497d8f3193fa05390cbd46e09/backoff-2.2.1-py3-none-any.whl",
"sha256": "63579f9a0628e06278f7e47b7d7d5b6ce20dc65c5e96a6f3ca99a6adca0396e8"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/64/62/428ef076be88fa93716b576e4a01f919d25968913e817077a386fcbe4f42/certifi-2023.11.17-py3-none-any.whl",
"sha256": "e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/63/09/c1bc53dab74b1816a00d8d030de5bf98f724c52c1635e07681d312f20be8/charset-normalizer-3.3.2.tar.gz",
"sha256": "f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/c2/e7/a82b05cf63a603df6e68d59ae6a68bf5064484a0718ea5033660af4b54a9/idna-3.6-py3-none-any.whl",
"sha256": "c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/9a/67/7e8406a29b6c45be7af7740456f7f37025f0506ae2e05fb9009a53946860/monotonic-1.6-py2.py3-none-any.whl",
"sha256": "68687e19a14f11f26d140dd5c86f3dba4bf5df58003000ed467e0e2a69bca96c"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/3b/82/441cb77a43499661228048dcd0d21e0ae3235b442d0f1b9b606e29c2a5ed/posthog-3.1.0-py2.py3-none-any.whl",
"sha256": "acd033530bdfc275dce5587f205f62378991ecb9b7cd5479e79c7f4ac575d319"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/36/7a/87837f39d0296e723bb9b62bbb257d0355c7f6128853c78955f57342a56d/python_dateutil-2.8.2-py2.py3-none-any.whl",
"sha256": "961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/70/8e/0e2d847013cb52cd35b38c009bb167a1a26b2ce6cd6965bf26b47bc0bf44/requests-2.31.0-py3-none-any.whl",
"sha256": "58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/96/94/c31f58c7a7f470d5665935262ebd7455c7e4c7782eb525658d3dbf4b9403/urllib3-2.1.0-py3-none-any.whl",
"sha256": "55901e917a5896a349ff771be919f8bd99aff50b79fe58fec595eb37bbc56bb3"
}
]
}
2 changes: 2 additions & 0 deletions frog/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from frog.config import RESOURCE_PREFIX, APP_ID
from frog.language_manager import language_manager
from frog.services.clipboard_service import clipboard_service
from frog.services.posthog import posthog
from frog.services.screenshot_service import ScreenshotService
from frog.settings import Settings
from frog.window import FrogWindow
Expand Down Expand Up @@ -125,6 +126,7 @@ def on_preferences(self, _action, _param) -> None:
self.get_active_window().show_preferences()

def on_github_star(self, _action, _param) -> None:
posthog.capture('github_star', 'github_star_activated')
launcher: Gtk.UriLauncher = Gtk.UriLauncher()
launcher.set_uri('https://github.com/TenderOwl/Frog')
launcher.launch(callback=self._on_github_star)
Expand Down
3 changes: 3 additions & 0 deletions frog/services/posthog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from posthog import Posthog

posthog = Posthog(project_api_key='phc_mggXA1JbzpJR95H9RO5yNVIh6kVDliVjD5hOjiaXkj6', host='https://us.posthog.com')
2 changes: 2 additions & 0 deletions frog/widgets/language_popover.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

from frog.config import RESOURCE_PREFIX
from frog.language_manager import language_manager
from frog.services.posthog import posthog
from frog.settings import Settings
from frog.types.language_item import LanguageItem
from frog.widgets.language_popover_row import LanguagePopoverRow
Expand Down Expand Up @@ -102,6 +103,7 @@ def _on_language_activate(self, _: Gtk.ListBox, row: LanguagePopoverRow):
self.emit('language-changed', item)
self.active_language = item.code
language_manager.active_language = item
posthog.capture(item.code, 'language-activated')
self.popdown()

@Gtk.Template.Callback()
Expand Down

0 comments on commit 3d9338d

Please sign in to comment.