Skip to content

Commit

Permalink
Merge pull request #4 from miermans/release/1.0.0a2
Browse files Browse the repository at this point in the history
Release/1.0.0a2
  • Loading branch information
mmiermans committed Jul 4, 2022
2 parents 7c2d0ff + d96bc42 commit 3e690ea
Show file tree
Hide file tree
Showing 15 changed files with 810 additions and 909 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Version 1.0.0a2 (2022-06-01)
--------------------------
Breaking: Emitter and Tracker leverage asyncio. `Tracker.track_*` calls must now be awaited.
Breaking: Remove AsyncEmitter. Use `asyncio.gather` instead.

Version 1.0.0a1 (2022-06-01)
--------------------------
Breaking: Drop support for Python < 3.7
Expand Down
48 changes: 31 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,41 +1,55 @@
======================================================
Python Analytics for Snowplow
asyncio Python Analytics for Snowplow
======================================================
.. image:: https://img.shields.io/static/v1?style=flat&label=Snowplow&message=Early%20Release&color=014477&labelColor=9ba0aa&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAeFBMVEVMaXGXANeYANeXANZbAJmXANeUANSQAM+XANeMAMpaAJhZAJeZANiXANaXANaOAM2WANVnAKWXANZ9ALtmAKVaAJmXANZaAJlXAJZdAJxaAJlZAJdbAJlbAJmQAM+UANKZANhhAJ+EAL+BAL9oAKZnAKVjAKF1ALNBd8J1AAAAKHRSTlMAa1hWXyteBTQJIEwRgUh2JjJon21wcBgNfmc+JlOBQjwezWF2l5dXzkW3/wAAAHpJREFUeNokhQOCA1EAxTL85hi7dXv/E5YPCYBq5DeN4pcqV1XbtW/xTVMIMAZE0cBHEaZhBmIQwCFofeprPUHqjmD/+7peztd62dWQRkvrQayXkn01f/gWp2CrxfjY7rcZ5V7DEMDQgmEozFpZqLUYDsNwOqbnMLwPAJEwCopZxKttAAAAAElFTkSuQmCC
:alt: Early Release
:target: https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/tracker-maintenance-classification/
.. image:: https://github.com/snowplow/snowplow-python-tracker/actions/workflows/ci.yml/badge.svg
.. image:: https://github.com/miermans/aio-snowplow-python-tracker/actions/workflows/ci.yml/badge.svg
:alt: Build Status
:target: https://github.com/snowplow/snowplow-python-tracker/actions
.. image:: https://img.shields.io/coveralls/github/snowplow/snowplow-python-tracker
:target: https://github.com/miermans/aio-snowplow-python-tracker/actions
.. image:: https://coveralls.io/repos/github/miermans/aio-snowplow-python-tracker/badge.svg?branch=main
:alt: Test Coverage
:target: https://coveralls.io/github/snowplow/snowplow-python-tracker?branch=master
:target: https://coveralls.io/github/miermans/aio-snowplow-python-tracker?branch=main
.. image:: http://img.shields.io/badge/license-Apache--2-blue.svg?style=flat
:target: http://www.apache.org/licenses/LICENSE-2.0

|
.. image:: https://img.shields.io/pypi/v/snowplow-tracker
.. image:: https://img.shields.io/pypi/v/aio-snowplow-tracker
:alt: Pypi Snowplow Tracker
:target: https://pypi.org/project/snowplow-tracker/
.. image:: https://img.shields.io/pypi/pyversions/snowplow-tracker
:target: https://pypi.org/project/aio-snowplow-tracker/
.. image:: https://img.shields.io/pypi/pyversions/aio-snowplow-tracker
:alt: Python Versions
:target: https://pypi.org/project/snowplow-tracker/
.. image:: https://img.shields.io/pypi/dm/snowplow-tracker
:target: https://pypi.org/project/aio-snowplow-tracker/
.. image:: https://img.shields.io/pypi/dm/aio-snowplow-tracker
:alt: Monthly Downloads
:target: https://pypi.org/project/snowplow-tracker/
:target: https://pypi.org/project/aio-snowplow-tracker/


Overview
########

Add analytics to your Python apps and Python games with the Snowplow_ event tracker for Python_.
This is a fork of to the official `Snowplow Python Tracker`_ that applies asyncio_ for high-performance event tracking.

.. _Snowplow: http://snowplowanalytics.com
.. _Python: http://python.org
.. _`Snowplow Python Tracker`: https://github.com/snowplow/snowplow-python-tracker
.. _asyncio: https://realpython.com/async-io-python/

With this tracker you can collect event data from your Python-based applications, games or Python web servers/frameworks.

Example
#############

.. code-block:: python
from snowplow_tracker import Tracker, Emitter, Subject
import asyncio
async def main():
e = Emitter('d3rkrsqld9gmqf.cloudfront.net')
s = Subject().set_user_id('5432')
t = Tracker(e, subject=s, app_id='example-app')
await t.track_page_view('http://example.com', 'Example Page')
asyncio.run(main())
Find out more
#############

Expand Down
6 changes: 3 additions & 3 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pytest==4.6.11; python_version < '3.10.0'
pytest==6.2.5; python_version >= '3.10.0'
pytest==7.1.2
attrs==21.2.0
httmock==1.4.0
pytest-aiohttp==1.0.4
freezegun==1.1.0
pytest-cov
coveralls==3.3.1
fakeredis==1.7.0
asynctest==0.13.0; python_version < '3.8.0'
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

setup(
name='aio-snowplow-tracker',
version='1.0.0a1',
version='1.0.0a2',
author=authors_str,
author_email=authors_email_str,
packages=['snowplow_tracker', 'snowplow_tracker.test', 'snowplow_tracker.redis', 'snowplow_tracker.celery'],
Expand All @@ -68,8 +68,8 @@
],

install_requires=[
"requests>=2.25.1,<3.0",
"typing_extensions>=3.7.4"
"aiohttp>=3.0.0",
"typing_extensions>=3.7.4,<4.0.0"
],

extras_require={
Expand Down
2 changes: 1 addition & 1 deletion snowplow_tracker/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from snowplow_tracker._version import __version__
from snowplow_tracker.subject import Subject
from snowplow_tracker.emitters import logger, Emitter, AsyncEmitter
from snowplow_tracker.emitters import logger, Emitter
from snowplow_tracker.self_describing_json import SelfDescribingJson
from snowplow_tracker.tracker import Tracker
from snowplow_tracker.contracts import disable_contracts, enable_contracts
Expand Down
20 changes: 20 additions & 0 deletions snowplow_tracker/_timer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import asyncio


class Timer:
"""
@see https://stackoverflow.com/a/45430833
"""

def __init__(self, timeout, callback, args):
self._timeout = timeout
self._callback = callback
self._args = args
self._task = asyncio.ensure_future(self._job())

async def _job(self):
await asyncio.sleep(self._timeout)
await self._callback(*self._args)

def cancel(self):
self._task.cancel()
2 changes: 1 addition & 1 deletion snowplow_tracker/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
License: Apache License Version 2.0
"""

__version_info__ = (1, 0, '0a1')
__version_info__ = (1, 0, '0a2')
__version__ = ".".join(str(x) for x in __version_info__)
__build_version__ = __version__ + ''
4 changes: 2 additions & 2 deletions snowplow_tracker/celery/celery_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def flush(self) -> None:
self.async_flush.delay()
logger.info("Scheduled a Celery task to flush the event queue")

def async_flush(self) -> None:
super(CeleryEmitter, self).flush()
async def async_flush(self) -> None:
await super(CeleryEmitter, self).flush()

else:

Expand Down

0 comments on commit 3e690ea

Please sign in to comment.