Minimal Snowplow Tracker
minimal-snowplow-tracker is a Python library that provides a minimal event tracker for Snowplow analytics. It is a fork of the original `snowplow-python-tracker` (v0.8.0), stripped down to include only basic emitters and support for structured and unstructured event tracking. Last released in 2018 as version 0.0.2, it is primarily maintained as an internal dependency for projects like dbt-core for anonymous usage tracking, rather than an actively developed standalone library.
Warnings
- breaking This library (version 0.0.2) is a highly minimal fork of the original `snowplow-python-tracker` (v0.8.0). It has removed all emitters except the basic one and all tracking event methods except for structured and unstructured events. Functionality available in newer versions of the official `snowplow-tracker` will not be present.
- gotcha The `minimal-snowplow-tracker` package, when installed, exposes its functionality under the `snowplow_tracker` Python module namespace. This creates a direct import conflict if the official, actively maintained `snowplow-tracker` library is also installed in the same environment, as both will try to provide modules under the same `snowplow_tracker` path.
- deprecated `minimal-snowplow-tracker` was last updated in October 2018 and officially supports Python up to 3.7. It is not actively maintained as a public library and is significantly behind the upstream `snowplow-python-tracker`. Using it with newer Python versions might lead to compatibility issues.
- gotcha The PyPI page for `minimal-snowplow-tracker` points to the `snowplow/snowplow-python-tracker` GitHub repository for its 'Contributing quickstart', which describes a testing setup and not a typical application usage. This reinforces that `minimal-snowplow-tracker` is not designed for direct end-user application integration, and its documentation is not for its specific minimal feature set.
Install
-
pip install minimal-snowplow-tracker
Imports
- Tracker
from snowplow_tracker import Tracker
- Emitter
from snowplow_tracker import Emitter
Quickstart
import os
from snowplow_tracker import Tracker, Emitter
from snowplow_tracker.self_describing_json import SelfDescribingJson
# Replace with your Snowplow Collector endpoint
COLLECTOR_URL = os.environ.get('SNOWPLOW_COLLECTOR_URL', 'http://localhost:9090')
# Initialize an emitter to send events to the collector
emitter = Emitter(COLLECTOR_URL)
# Initialize the tracker with a namespace and application ID
tracker = Tracker(emitters=[emitter], namespace='my_app_namespace', app_id='my-python-app')
# Track a structured event
tracker.track_struct_event(
category='example_category',
action='example_action',
label='example_label',
property='example_property',
value=1.0
)
# Track an unstructured event with a self-describing JSON schema
example_schema = 'iglu:com.example_company/example_event/jsonschema/1-0-0'
example_data = {
'event_detail': 'This is an unstructured event',
'session_id': 'abc-123'
}
unstructured_event = SelfDescribingJson(example_schema, example_data)
tracker.track_unstruct_event(unstructured_event)
print(f"Events sent to {COLLECTOR_URL} using minimal-snowplow-tracker.")
# In a real application, you might want to gracefully close the emitter or ensure all events are sent.
# For simple scripts, events are often sent synchronously or on program exit.