Skip to content

Commit f722a96

Browse files
committed
Merge branch 'release/1.0.0'
2 parents 033c780 + d4fd76b commit f722a96

33 files changed

+1801
-1158
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@ jobs:
1313
strategy:
1414
matrix:
1515
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11"]
16-
extras-required: [".", ".[redis]"]
17-
18-
services:
19-
redis:
20-
image: redis
21-
options: >-
22-
--health-cmd "redis-cli ping"
23-
--health-interval 10s
24-
--health-timeout 5s
25-
--health-retries 5
26-
ports:
27-
- 6379:6379
2816

2917
steps:
3018
- name: Checkout
@@ -42,7 +30,7 @@ jobs:
4230
- name: Install dependencies
4331
run: |
4432
python -m pip install --upgrade "${{ env.pip_v }}" setuptools wheel
45-
python -m pip install -e ${{ matrix.extras-required }}
33+
python -m pip install -e .
4634
python -m pip install -r requirements-test.txt
4735
4836
- name: Build
@@ -59,6 +47,12 @@ jobs:
5947
cd tracker_api_example
6048
python app.py "localhost:9090"
6149
50+
- name: Snowplow Demo
51+
run: |
52+
cd examples
53+
cd snowplow_api_example
54+
python snowplow_app.py "localhost:9090"
55+
6256
- name: Coveralls
6357
uses: AndreMiras/coveralls-python-action@develop
6458
with:

CHANGES.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
Version 1.0.0 (2023-06-16)
2+
--------------------------
3+
Remove Redis and Celery Emitters (#335)
4+
Make tracker namespace mandatory (#337)
5+
Track function to return event_id (#338)
6+
Fix namespace assignment in Snowplow API (#341)
7+
Refactor track_xxx() methods (#343)
8+
Update payload builder to combine event subjects (#347)
9+
110
Version 0.15.0 (2023-04-19)
211
---------------------------
312
Use Requests Session for sending eventss (#221)

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
author = 'Alex Dean, Paul Boocock, Matus Tomlein, Jack Keene'
2929

3030
# The full version, including alpha/beta/rc tags
31-
release = "0.15"
31+
release = "1.0.0"
3232

3333

3434
# -- General configuration ---------------------------------------------------

examples/redis_example/redis_app.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
from snowplow_tracker import Tracker
1+
from snowplow_tracker import (
2+
Tracker,
3+
ScreenView,
4+
PagePing,
5+
PageView,
6+
SelfDescribing,
7+
StructuredEvent,
8+
SelfDescribingJson,
9+
)
210
from snowplow_tracker.typing import PayloadDict
311
import json
412
import redis
@@ -49,11 +57,30 @@ def sync_flush(self) -> None:
4957
def main():
5058
emitter = RedisEmitter()
5159

52-
t = Tracker(emitter)
60+
t = Tracker(namespace="snowplow_tracker", emitters=emitter)
5361

54-
t.track_page_view("https://www.snowplow.io", "Homepage")
55-
t.track_page_ping("https://www.snowplow.io", "Homepage")
56-
t.track_link_click("https://www.snowplow.io")
62+
page_view = PageView(page_url="https://www.snowplow.io", page_title="Homepage")
63+
t.track(page_view)
64+
65+
page_ping = PagePing(page_url="https://www.snowplow.io", page_title="Homepage")
66+
t.track(page_ping)
67+
68+
link_click = SelfDescribing(
69+
SelfDescribingJson(
70+
"iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1",
71+
{"targetUrl": "https://www.snowplow.io"},
72+
)
73+
)
74+
t.track(link_click)
75+
76+
id = t.get_uuid()
77+
screen_view = ScreenView(id_=id, name="name")
78+
t.track(screen_view)
79+
80+
struct_event = StructuredEvent(
81+
category="shop", action="add-to-basket", property_="pcs", value=2
82+
)
83+
t.track(struct_event)
5784

5885

5986
if __name__ == "__main__":

examples/snowplow_api_example/snowplow_app.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
Subject,
66
TrackerConfiguration,
77
SelfDescribingJson,
8+
PagePing,
9+
PageView,
10+
ScreenView,
11+
SelfDescribing,
12+
StructuredEvent,
813
)
914

1015

@@ -15,11 +20,12 @@ def get_url_from_args():
1520

1621

1722
def main():
18-
1923
collector_url = get_url_from_args()
2024
# Configure Emitter
2125
custom_retry_codes = {500: False, 401: True}
22-
emitter_config = EmitterConfiguration(batch_size=5, custom_retry_codes=custom_retry_codes)
26+
emitter_config = EmitterConfiguration(
27+
batch_size=5, custom_retry_codes=custom_retry_codes
28+
)
2329

2430
# Configure Tracker
2531
tracker_config = TrackerConfiguration(encode_base64=True)
@@ -39,19 +45,28 @@ def main():
3945

4046
tracker = Snowplow.get_tracker("ns")
4147

42-
tracker.track_page_view("https://www.snowplow.io", "Homepage")
43-
tracker.track_page_ping("https://www.snowplow.io", "Homepage")
44-
tracker.track_link_click("https://www.snowplow.io/about")
45-
tracker.track_page_view("https://www.snowplow.io/about", "About")
48+
page_view = PageView(page_url="https://www.snowplow.io", page_title="Homepage")
49+
tracker.track(page_view)
50+
51+
page_ping = PagePing(page_url="https://www.snowplow.io", page_title="Homepage")
52+
tracker.track(page_ping)
4653

47-
tracker.track_self_describing_event(
54+
link_click = SelfDescribing(
4855
SelfDescribingJson(
4956
"iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1",
50-
{"targetUrl": "example.com"},
57+
{"targetUrl": "https://www.snowplow.io"},
5158
)
5259
)
53-
tracker.track_struct_event("shop", "add-to-basket", None, "pcs", 2)
60+
tracker.track(link_click)
5461

62+
id = tracker.get_uuid()
63+
screen_view = ScreenView(id_=id, name="name")
64+
tracker.track(screen_view)
65+
66+
struct_event = StructuredEvent(
67+
category="shop", action="add-to-basket", property_="pcs", value=2
68+
)
69+
tracker.track(struct_event)
5570
tracker.flush()
5671

5772

examples/tracker_api_example/app.py

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
Emitter,
55
Subject,
66
SelfDescribingJson,
7+
PageView,
8+
PagePing,
9+
SelfDescribing,
10+
ScreenView,
11+
StructuredEvent,
712
)
813
import sys
914

@@ -22,21 +27,48 @@ def main():
2227
s = Subject().set_platform("pc")
2328
s.set_lang("en").set_user_id("test_user")
2429

25-
t = Tracker(e, s)
30+
t = Tracker(namespace="snowplow_tracker", emitters=e, subject=s)
2631

2732
print("Sending events to " + e.endpoint)
2833

29-
t.track_page_view("https://www.snowplow.io", "Homepage")
30-
t.track_page_ping("https://www.snowplow.io", "Homepage")
31-
t.track_link_click("https://www.snowplow.io")
34+
event_subject = Subject()
35+
event_subject.set_color_depth(10)
3236

33-
t.track_self_describing_event(
37+
page_view = PageView(
38+
page_url="https://www.snowplow.io",
39+
page_title="Homepage",
40+
event_subject=event_subject,
41+
)
42+
t.track(page_view)
43+
44+
page_ping = PagePing(
45+
page_url="https://www.snowplow.io",
46+
page_title="Homepage",
47+
event_subject=t.subject,
48+
)
49+
t.track(page_ping)
50+
51+
link_click = SelfDescribing(
3452
SelfDescribingJson(
3553
"iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1",
36-
{"targetUrl": "example.com"},
37-
)
54+
{"targetUrl": "https://www.snowplow.io"},
55+
),
56+
event_subject=t.subject,
57+
)
58+
t.track(link_click)
59+
60+
id = t.get_uuid()
61+
screen_view = ScreenView(id_=id, name="name", event_subject=t.subject)
62+
t.track(screen_view)
63+
64+
struct_event = StructuredEvent(
65+
category="shop",
66+
action="add-to-basket",
67+
property_="pcs",
68+
value=2,
69+
event_subject=t.subject,
3870
)
39-
t.track_struct_event("shop", "add-to-basket", None, "pcs", 2)
71+
t.track(struct_event)
4072
t.flush()
4173

4274

requirements-test.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ httmock==1.4.0
55
freezegun==1.1.0
66
pytest-cov
77
coveralls==3.3.1
8-
fakeredis==1.7.0

0 commit comments

Comments
 (0)