Skip to content

Commit e962e83

Browse files
committed
Merge branch 'release/0.13.0'
2 parents ecca49d + 65539bd commit e962e83

30 files changed

+2624
-1193
lines changed

.github/workflows/cd.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ jobs:
2121
- name: Get tag and tracker versions
2222
id: version
2323
run: |
24-
echo ::set-output name=TAG_VERSION::${GITHUB_REF#refs/*/}
25-
echo "##[set-output name=PYTHON_TRACKER_VERSION;]$(python setup.py --version)"
24+
echo "TAG_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
25+
echo "PYTHON_TRACKER_VERSION=$(python setup.py --version)" >> $GITHUB_OUTPUT
2626
2727
- name: Fail if version mismatch
2828
if: ${{ steps.version.outputs.TAG_VERSION != steps.version.outputs.PYTHON_TRACKER_VERSION }}

CHANGES.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
Version 0.13.0 (2023-01-24)
2+
---------------------------
3+
Adds Snowplow Interface (#295)
4+
Adds retry for failed events (#296)
5+
Adds customisable retry codes (#297)
6+
Adds EventStore with max limit (#309)
7+
Adds Snowplow Example App (#302)
8+
Fix Collector URL with trailing '/' (#300)
9+
Rename unstruct_event to self_describing_event (#298)
10+
Upgrade `set-output` in cd (#294)
11+
112
Version 0.12.0 (2022-11-03)
213
---------------------------
314
Adds Domain Session ID and Domain Session Index to Subject class (#282) (Thanks to @cpnat)

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2013-2022 Snowplow Analytics Ltd.
189+
Copyright 2013-2023 Snowplow Analytics Ltd.
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Assuming [docker](https://www.docker.com/) is installed
4747
Copyright and license
4848
---------------------
4949

50-
The Snowplow Python Tracker is copyright 2013-2022 Snowplow Analytics
50+
The Snowplow Python Tracker is copyright 2013-2023 Snowplow Analytics
5151
Ltd.
5252

5353
Licensed under the [Apache License, Version

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
# -- Project information -----------------------------------------------------
2525

2626
project = 'Snowplow Python Tracker'
27-
copyright = '2022, Alex Dean, Paul Boocock, Matus Tomlein, Jack Keene'
27+
copyright = "2023, Alex Dean, Paul Boocock, Matus Tomlein, Jack Keene"
2828
author = 'Alex Dean, Paul Boocock, Matus Tomlein, Jack Keene'
2929

3030
# The full version, including alpha/beta/rc tags
31-
release = '0.12'
31+
release = "0.13"
3232

3333

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

examples/snowplow_app.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import sys
2+
from snowplow_tracker import (
3+
Snowplow,
4+
EmitterConfiguration,
5+
Subject,
6+
TrackerConfiguration,
7+
SelfDescribingJson,
8+
)
9+
10+
11+
def get_url_from_args():
12+
if len(sys.argv) != 2:
13+
raise ValueError("Collector Endpoint is required")
14+
return sys.argv[1]
15+
16+
17+
def main():
18+
19+
collector_url = get_url_from_args()
20+
# Configure Emitter
21+
custom_retry_codes = {500: False, 401: True}
22+
emitter_config = EmitterConfiguration(batch_size=5, custom_retry_codes=custom_retry_codes)
23+
24+
# Configure Tracker
25+
tracker_config = TrackerConfiguration(encode_base64=True)
26+
27+
# Initialise subject
28+
subject = Subject()
29+
subject.set_user_id("uid")
30+
31+
Snowplow.create_tracker(
32+
namespace="ns",
33+
endpoint=collector_url,
34+
app_id="app1",
35+
subject=subject,
36+
tracker_config=tracker_config,
37+
emitter_config=emitter_config,
38+
)
39+
40+
tracker = Snowplow.get_tracker("ns")
41+
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")
46+
47+
tracker.track_self_describing_event(
48+
SelfDescribingJson(
49+
"iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1",
50+
{"targetUrl": "example.com"},
51+
)
52+
)
53+
tracker.track_struct_event("shop", "add-to-basket", None, "pcs", 2)
54+
55+
tracker.flush()
56+
57+
58+
if __name__ == "__main__":
59+
main()

setup.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# setup.py
33

4-
# Copyright (c) 2013-2022 Snowplow Analytics Ltd. All rights reserved.
4+
# Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved.
55

66
# This program is licensed to you under the Apache License Version 2.0,
77
# and you may not use this file except in compliance with the Apache License
@@ -13,11 +13,7 @@
1313
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
1414
# express or implied. See the Apache License Version 2.0 for the specific
1515
# language governing permissions and limitations there under.
16-
17-
# Authors: Anuj More, Alex Dean, Fred Blundun, Paul Boocock
18-
# Copyright: Copyright (c) 2013-2022 Snowplow Analytics Ltd
19-
# License: Apache License Version 2.0
20-
#
16+
# """
2117

2218
#!/usr/bin/env python
2319
# -*- coding: utf-8 -*-
@@ -37,7 +33,7 @@
3733

3834
setup(
3935
name="snowplow-tracker",
40-
version="0.12.0",
36+
version="0.13.0",
4137
author=authors_str,
4238
author_email=authors_email_str,
4339
packages=[

snowplow_tracker/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
from snowplow_tracker.emitters import logger, Emitter, AsyncEmitter
44
from snowplow_tracker.self_describing_json import SelfDescribingJson
55
from snowplow_tracker.tracker import Tracker
6+
from snowplow_tracker.emitter_configuration import EmitterConfiguration
7+
from snowplow_tracker.tracker_configuration import TrackerConfiguration
8+
from snowplow_tracker.snowplow import Snowplow
69
from snowplow_tracker.contracts import disable_contracts, enable_contracts
10+
from snowplow_tracker.event_store import EventStore
711

812
# celery extra
913
from .celery import CeleryEmitter

snowplow_tracker/_version.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# """
22
# _version.py
33

4-
# Copyright (c) 2013-2022 Snowplow Analytics Ltd. All rights reserved.
4+
# Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved.
55

66
# This program is licensed to you under the Apache License Version 2.0,
77
# and you may not use this file except in compliance with the Apache License
@@ -13,12 +13,8 @@
1313
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
1414
# express or implied. See the Apache License Version 2.0 for the specific
1515
# language governing permissions and limitations there under.
16-
17-
# Authors: Anuj More, Alex Dean, Fred Blundun, Paul Boocock
18-
# Copyright: Copyright (c) 2013-2022 Snowplow Analytics Ltd
19-
# License: Apache License Version 2.0
2016
# """
2117

22-
__version_info__ = (0, 12, 0)
18+
__version_info__ = (0, 13, 0)
2319
__version__ = ".".join(str(x) for x in __version_info__)
2420
__build_version__ = __version__ + ""

snowplow_tracker/celery/celery_emitter.py

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# """
22
# celery_emitter.py
33

4-
# Copyright (c) 2013-2022 Snowplow Analytics Ltd. All rights reserved.
4+
# Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved.
55

66
# This program is licensed to you under the Apache License Version 2.0,
77
# and you may not use this file except in compliance with the Apache License
@@ -13,10 +13,6 @@
1313
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
1414
# express or implied. See the Apache License Version 2.0 for the specific
1515
# language governing permissions and limitations there under.
16-
17-
# Authors: Anuj More, Alex Dean, Fred Blundun, Paul Boocock
18-
# Copyright: Copyright (c) 2013-2022 Snowplow Analytics Ltd
19-
# License: Apache License Version 2.0
2016
# """
2117

2218
import logging
@@ -39,27 +35,32 @@
3935

4036
class CeleryEmitter(Emitter):
4137
"""
42-
Uses a Celery worker to send HTTP requests asynchronously.
43-
Works like the base Emitter class,
44-
but on_success and on_failure callbacks cannot be set.
38+
Uses a Celery worker to send HTTP requests asynchronously.
39+
Works like the base Emitter class,
40+
but on_success and on_failure callbacks cannot be set.
4541
"""
42+
4643
if _CELERY_OPT:
4744

4845
celery_app = None
4946

5047
def __init__(
51-
self,
52-
endpoint: str,
53-
protocol: HttpProtocol = "http",
54-
port: Optional[int] = None,
55-
method: Method = "post",
56-
buffer_size: Optional[int] = None,
57-
byte_limit: Optional[int] = None) -> None:
58-
super(CeleryEmitter, self).__init__(endpoint, protocol, port, method, buffer_size, None, None, byte_limit)
48+
self,
49+
endpoint: str,
50+
protocol: HttpProtocol = "http",
51+
port: Optional[int] = None,
52+
method: Method = "post",
53+
batch_size: Optional[int] = None,
54+
byte_limit: Optional[int] = None,
55+
) -> None:
56+
super(CeleryEmitter, self).__init__(
57+
endpoint, protocol, port, method, batch_size, None, None, byte_limit
58+
)
5959

6060
try:
6161
# Check whether a custom Celery configuration module named "snowplow_celery_config" exists
6262
import snowplow_celery_config
63+
6364
self.celery_app = Celery()
6465
self.celery_app.config_from_object(snowplow_celery_config)
6566
except ImportError:
@@ -80,6 +81,10 @@ def async_flush(self) -> None:
8081

8182
else:
8283

83-
def __new__(cls, *args: Any, **kwargs: Any) -> 'CeleryEmitter':
84-
logger.error("CeleryEmitter is not available. Please install snowplow-tracker with celery extra dependency.")
85-
raise RuntimeError('CeleryEmitter is not available. To use: `pip install snowplow-tracker[celery]`')
84+
def __new__(cls, *args: Any, **kwargs: Any) -> "CeleryEmitter":
85+
logger.error(
86+
"CeleryEmitter is not available. Please install snowplow-tracker with celery extra dependency."
87+
)
88+
raise RuntimeError(
89+
"CeleryEmitter is not available. To use: `pip install snowplow-tracker[celery]`"
90+
)

0 commit comments

Comments
 (0)