Skip to content

Commit ecca49d

Browse files
committed
Merge branch 'release/0.12.0'
2 parents 4e3a4b8 + 723f21f commit ecca49d

File tree

16 files changed

+162
-79
lines changed

16 files changed

+162
-79
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
15+
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11"]
1616
extras-required: [".", ".[redis]"]
1717

1818
services:

CHANGES.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Version 0.12.0 (2022-11-03)
2+
---------------------------
3+
Adds Domain Session ID and Domain Session Index to Subject class (#282) (Thanks to @cpnat)
4+
Add support for Python 3.11 (#286)
5+
Change default protocol to HTTPS in the Emitter (#14)
6+
Change default method to POST in the Emitter (#289)
7+
Update Docker base image (#283) (Thanks to @cpnat)
8+
19
Version 0.11.0 (2022-10-06)
210
---------------------------
311
Update README file (#264)

Dockerfile

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
FROM centos:8
2-
RUN cd /etc/yum.repos.d/
3-
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
4-
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
1+
FROM debian:bullseye-slim
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev \
4+
libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \
5+
mecab-ipadic-utf8 git ca-certificates
56

6-
RUN yum -y install wget
7-
RUN yum install -y epel-release
8-
RUN yum -y install git tar gcc make bzip2 openssl openssl-devel patch gcc-c++ libffi-devel sqlite-devel
9-
RUN git clone https://github.com/yyuu/pyenv.git ~/.pyenv
107
ENV HOME /root
118
ENV PYENV_ROOT $HOME/.pyenv
129
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
10+
RUN git clone --depth=1 https://github.com/pyenv/pyenv.git $PYENV_ROOT
11+
RUN git clone --depth=1 https://github.com/pyenv/pyenv-virtualenv.git $PYENV_ROOT/plugins/pyenv-virtualenv
1312

14-
RUN pyenv install 3.5.10 && pyenv install 3.6.14 && pyenv install 3.7.11 && pyenv install 3.8.11 && pyenv install 3.9.6 && pyenv install 3.10.1
15-
RUN git clone https://github.com/pyenv/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
13+
RUN pyenv install 3.5.10 && pyenv install 3.6.14 && pyenv install 3.7.11 && pyenv install 3.8.11 && pyenv install 3.9.6 && pyenv install 3.10.1 && pyenv install 3.11.0
1614

1715
WORKDIR /app
1816
COPY . .

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.11'
31+
release = '0.12'
3232

3333

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

examples/app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def main():
1919

2020
t = Tracker(e, s)
2121

22-
print("Sending events to " + collector_url)
22+
print("Sending events to " + e.endpoint)
2323

2424
t.track_page_view("https://www.snowplow.io", "Homepage")
2525
t.track_page_ping("https://www.snowplow.io", "Homepage")
@@ -32,6 +32,7 @@ def main():
3232
)
3333
)
3434
t.track_struct_event("shop", "add-to-basket", None, "pcs", 2)
35+
t.flush()
3536

3637

3738
if __name__ == "__main__":

run-tests.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,23 @@ function deploy {
116116
pip install -r requirements-test.txt
117117
source deactivate
118118
fi
119+
120+
# pyenv install 3.11.0
121+
if [ ! -e ~/.pyenv/versions/tracker311 ]; then
122+
pyenv virtualenv 3.11.0 tracker311
123+
pyenv activate tracker311
124+
pip install .
125+
pip install -r requirements-test.txt
126+
source deactivate
127+
fi
128+
129+
if [ ! -e ~/.pyenv/versions/tracker311redis ]; then
130+
pyenv virtualenv 3.11.0 tracker311redis
131+
pyenv activate tracker311redis
132+
pip install .[redis]
133+
pip install -r requirements-test.txt
134+
source deactivate
135+
fi
119136
}
120137

121138

@@ -167,6 +184,15 @@ function run_tests {
167184
pyenv activate tracker310redis
168185
pytest
169186
source deactivate
187+
188+
pyenv activate tracker311
189+
pytest
190+
source deactivate
191+
192+
pyenv activate tracker311redis
193+
pytest
194+
source deactivate
195+
170196
}
171197

172198
function refresh_deploy {
@@ -182,6 +208,8 @@ function refresh_deploy {
182208
pyenv uninstall -f tracker39redis
183209
pyenv uninstall -f tracker310
184210
pyenv uninstall -f tracker310redis
211+
pyenv uninstall -f tracker311
212+
pyenv uninstall -f tracker311redis
185213
}
186214

187215

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
setup(
3939
name="snowplow-tracker",
40-
version="0.11.0",
40+
version="0.12.0",
4141
author=authors_str,
4242
author_email=authors_email_str,
4343
packages=[
@@ -63,6 +63,7 @@
6363
"Programming Language :: Python :: 3.8",
6464
"Programming Language :: Python :: 3.9",
6565
"Programming Language :: Python :: 3.10",
66+
"Programming Language :: Python :: 3.11",
6667
"Operating System :: OS Independent",
6768
],
6869
install_requires=["requests>=2.25.1,<3.0", "typing_extensions>=3.7.4"],

snowplow_tracker/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
# License: Apache License Version 2.0
2020
# """
2121

22-
__version_info__ = (0, 11, 0)
22+
__version_info__ = (0, 12, 0)
2323
__version__ = ".".join(str(x) for x in __version_info__)
2424
__build_version__ = __version__ + ""

snowplow_tracker/celery/celery_emitter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(
5252
endpoint: str,
5353
protocol: HttpProtocol = "http",
5454
port: Optional[int] = None,
55-
method: Method = "get",
55+
method: Method = "post",
5656
buffer_size: Optional[int] = None,
5757
byte_limit: Optional[int] = None) -> None:
5858
super(CeleryEmitter, self).__init__(endpoint, protocol, port, method, buffer_size, None, None, byte_limit)

snowplow_tracker/emitters.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,22 @@ class Emitter(object):
5151
def __init__(
5252
self,
5353
endpoint: str,
54-
protocol: HttpProtocol = "http",
54+
protocol: HttpProtocol = "https",
5555
port: Optional[int] = None,
56-
method: Method = "get",
56+
method: Method = "post",
5757
buffer_size: Optional[int] = None,
5858
on_success: Optional[SuccessCallback] = None,
5959
on_failure: Optional[FailureCallback] = None,
6060
byte_limit: Optional[int] = None,
6161
request_timeout: Optional[Union[float, Tuple[float, float]]] = None) -> None:
6262
"""
63-
:param endpoint: The collector URL. Don't include "http://" - this is done automatically.
63+
:param endpoint: The collector URL. If protocol is not set in endpoint it will automatically set to "https://" - this is done automatically.
6464
:type endpoint: string
65-
:param protocol: The protocol to use - http or https. Defaults to http.
65+
:param protocol: The protocol to use - http or https. Defaults to https.
6666
:type protocol: protocol
6767
:param port: The collector port to connect to
6868
:type port: int | None
69-
:param method: The HTTP request method
69+
:param method: The HTTP request method. Defaults to post.
7070
:type method: method
7171
:param buffer_size: The maximum number of queued events before the buffer is flushed. Default is 10.
7272
:type buffer_size: int | None
@@ -116,9 +116,9 @@ def __init__(
116116
@staticmethod
117117
def as_collector_uri(
118118
endpoint: str,
119-
protocol: HttpProtocol = "http",
119+
protocol: HttpProtocol = "https",
120120
port: Optional[int] = None,
121-
method: Method = "get") -> str:
121+
method: Method = "post") -> str:
122122
"""
123123
:param endpoint: The raw endpoint provided by the user
124124
:type endpoint: string
@@ -133,6 +133,11 @@ def as_collector_uri(
133133
if len(endpoint) < 1:
134134
raise ValueError("No endpoint provided.")
135135

136+
if endpoint.split("://")[0] in PROTOCOLS:
137+
endpoint_arr = endpoint.split("://")
138+
protocol = endpoint_arr[0]
139+
endpoint = endpoint_arr[1]
140+
136141
if method == "get":
137142
path = "/i"
138143
else:
@@ -148,7 +153,7 @@ def input(self, payload: PayloadDict) -> None:
148153
If the maximum size has been reached, flushes the buffer.
149154
150155
:param payload: The name-value pairs for the event
151-
:type payload: dict(string:\*)
156+
:type payload: dict(string:\\*)
152157
"""
153158
with self.lock:
154159
if self.bytes_queued is not None:
@@ -207,7 +212,7 @@ def http_post(self, data: str) -> bool:
207212
def http_get(self, payload: PayloadDict) -> bool:
208213
"""
209214
:param payload: The event properties
210-
:type payload: dict(string:\*)
215+
:type payload: dict(string:\\*)
211216
"""
212217
logger.info("Sending GET request to %s..." % self.endpoint)
213218
logger.debug("Payload: %s" % payload)
@@ -242,7 +247,7 @@ def is_good_status_code(status_code: int) -> bool:
242247
def send_events(self, evts: PayloadDictList) -> None:
243248
"""
244249
:param evts: Array of events to be sent
245-
:type evts: list(dict(string:\*))
250+
:type evts: list(dict(string:\\*))
246251
"""
247252
if len(evts) > 0:
248253
logger.info("Attempting to send %s events" % len(evts))
@@ -307,7 +312,7 @@ def attach_sent_timestamp(events: PayloadDictList) -> None:
307312
as `stm` param
308313
309314
:param events: Array of events to be sent
310-
:type events: list(dict(string:\*))
315+
:type events: list(dict(string:\\*))
311316
:rtype: None
312317
"""
313318
def update(e: PayloadDict) -> None:
@@ -327,7 +332,7 @@ def __init__(
327332
endpoint: str,
328333
protocol: HttpProtocol = "http",
329334
port: Optional[int] = None,
330-
method: Method = "get",
335+
method: Method = "post",
331336
buffer_size: Optional[int] = None,
332337
on_success: Optional[SuccessCallback] = None,
333338
on_failure: Optional[FailureCallback] = None,

snowplow_tracker/payload.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def add_dict(self, dict_: PayloadDict, base64: bool = False) -> None:
5454
Add a dict of name value pairs to the Payload object
5555
5656
:param dict_: Dictionary to be added to the Payload
57-
:type dict_: dict(string:\*)
57+
:type dict_: dict(string:\\*)
5858
"""
5959
for f in dict_:
6060
self.add(f, dict_[f])
@@ -70,7 +70,7 @@ def add_json(
7070
Add an encoded or unencoded JSON to the payload
7171
7272
:param dict_: Custom context for the event
73-
:type dict_: dict(string:\*) | None
73+
:type dict_: dict(string:\\*) | None
7474
:param encode_base64: If the payload is base64 encoded
7575
:type encode_base64: bool
7676
:param type_when_encoded: Name of the field when encode_base64 is set

snowplow_tracker/subject.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,26 @@ def set_domain_user_id(self, duid: str) -> 'Subject':
123123
self.standard_nv_pairs["duid"] = duid
124124
return self
125125

126+
def set_domain_session_id(self, sid: str) -> 'Subject':
127+
"""
128+
Set the domain session ID
129+
:param sid: Domain session ID
130+
:type sid: string
131+
:rtype: subject
132+
"""
133+
self.standard_nv_pairs["sid"] = sid
134+
return self
135+
136+
def set_domain_session_index(self, vid: int) -> 'Subject':
137+
"""
138+
Set the domain session Index
139+
:param vid: Domain session Index
140+
:type vid: int
141+
:rtype: subject
142+
"""
143+
self.standard_nv_pairs["vid"] = vid
144+
return self
145+
126146
def set_ip_address(self, ip: str) -> 'Subject':
127147
"""
128148
Set the domain user ID

0 commit comments

Comments
 (0)