Skip to content

Commit

Permalink
Merge branch 'release/0.12.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Keene committed Nov 4, 2022
2 parents 4e3a4b8 + 723f21f commit ecca49d
Show file tree
Hide file tree
Showing 16 changed files with 162 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11"]
extras-required: [".", ".[redis]"]

services:
Expand Down
8 changes: 8 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Version 0.12.0 (2022-11-03)
---------------------------
Adds Domain Session ID and Domain Session Index to Subject class (#282) (Thanks to @cpnat)
Add support for Python 3.11 (#286)
Change default protocol to HTTPS in the Emitter (#14)
Change default method to POST in the Emitter (#289)
Update Docker base image (#283) (Thanks to @cpnat)

Version 0.11.0 (2022-10-06)
---------------------------
Update README file (#264)
Expand Down
18 changes: 8 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
FROM centos:8
RUN cd /etc/yum.repos.d/
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
FROM debian:bullseye-slim

RUN apt-get update && apt-get install -y --no-install-recommends make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev \
libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \
mecab-ipadic-utf8 git ca-certificates

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

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
RUN git clone https://github.com/pyenv/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
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

WORKDIR /app
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
author = 'Alex Dean, Paul Boocock, Matus Tomlein, Jack Keene'

# The full version, including alpha/beta/rc tags
release = '0.11'
release = '0.12'


# -- General configuration ---------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion examples/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def main():

t = Tracker(e, s)

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

t.track_page_view("https://www.snowplow.io", "Homepage")
t.track_page_ping("https://www.snowplow.io", "Homepage")
Expand All @@ -32,6 +32,7 @@ def main():
)
)
t.track_struct_event("shop", "add-to-basket", None, "pcs", 2)
t.flush()


if __name__ == "__main__":
Expand Down
28 changes: 28 additions & 0 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,23 @@ function deploy {
pip install -r requirements-test.txt
source deactivate
fi

# pyenv install 3.11.0
if [ ! -e ~/.pyenv/versions/tracker311 ]; then
pyenv virtualenv 3.11.0 tracker311
pyenv activate tracker311
pip install .
pip install -r requirements-test.txt
source deactivate
fi

if [ ! -e ~/.pyenv/versions/tracker311redis ]; then
pyenv virtualenv 3.11.0 tracker311redis
pyenv activate tracker311redis
pip install .[redis]
pip install -r requirements-test.txt
source deactivate
fi
}


Expand Down Expand Up @@ -167,6 +184,15 @@ function run_tests {
pyenv activate tracker310redis
pytest
source deactivate

pyenv activate tracker311
pytest
source deactivate

pyenv activate tracker311redis
pytest
source deactivate

}

function refresh_deploy {
Expand All @@ -182,6 +208,8 @@ function refresh_deploy {
pyenv uninstall -f tracker39redis
pyenv uninstall -f tracker310
pyenv uninstall -f tracker310redis
pyenv uninstall -f tracker311
pyenv uninstall -f tracker311redis
}


Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

setup(
name="snowplow-tracker",
version="0.11.0",
version="0.12.0",
author=authors_str,
author_email=authors_email_str,
packages=[
Expand All @@ -63,6 +63,7 @@
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Operating System :: OS Independent",
],
install_requires=["requests>=2.25.1,<3.0", "typing_extensions>=3.7.4"],
Expand Down
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__ = (0, 11, 0)
__version_info__ = (0, 12, 0)
__version__ = ".".join(str(x) for x in __version_info__)
__build_version__ = __version__ + ""
2 changes: 1 addition & 1 deletion snowplow_tracker/celery/celery_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(
endpoint: str,
protocol: HttpProtocol = "http",
port: Optional[int] = None,
method: Method = "get",
method: Method = "post",
buffer_size: Optional[int] = None,
byte_limit: Optional[int] = None) -> None:
super(CeleryEmitter, self).__init__(endpoint, protocol, port, method, buffer_size, None, None, byte_limit)
Expand Down
29 changes: 17 additions & 12 deletions snowplow_tracker/emitters.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ class Emitter(object):
def __init__(
self,
endpoint: str,
protocol: HttpProtocol = "http",
protocol: HttpProtocol = "https",
port: Optional[int] = None,
method: Method = "get",
method: Method = "post",
buffer_size: Optional[int] = None,
on_success: Optional[SuccessCallback] = None,
on_failure: Optional[FailureCallback] = None,
byte_limit: Optional[int] = None,
request_timeout: Optional[Union[float, Tuple[float, float]]] = None) -> None:
"""
:param endpoint: The collector URL. Don't include "http://" - this is done automatically.
:param endpoint: The collector URL. If protocol is not set in endpoint it will automatically set to "https://" - this is done automatically.
:type endpoint: string
:param protocol: The protocol to use - http or https. Defaults to http.
:param protocol: The protocol to use - http or https. Defaults to https.
:type protocol: protocol
:param port: The collector port to connect to
:type port: int | None
:param method: The HTTP request method
:param method: The HTTP request method. Defaults to post.
:type method: method
:param buffer_size: The maximum number of queued events before the buffer is flushed. Default is 10.
:type buffer_size: int | None
Expand Down Expand Up @@ -116,9 +116,9 @@ def __init__(
@staticmethod
def as_collector_uri(
endpoint: str,
protocol: HttpProtocol = "http",
protocol: HttpProtocol = "https",
port: Optional[int] = None,
method: Method = "get") -> str:
method: Method = "post") -> str:
"""
:param endpoint: The raw endpoint provided by the user
:type endpoint: string
Expand All @@ -133,6 +133,11 @@ def as_collector_uri(
if len(endpoint) < 1:
raise ValueError("No endpoint provided.")

if endpoint.split("://")[0] in PROTOCOLS:
endpoint_arr = endpoint.split("://")
protocol = endpoint_arr[0]
endpoint = endpoint_arr[1]

if method == "get":
path = "/i"
else:
Expand All @@ -148,7 +153,7 @@ def input(self, payload: PayloadDict) -> None:
If the maximum size has been reached, flushes the buffer.
:param payload: The name-value pairs for the event
:type payload: dict(string:\*)
:type payload: dict(string:\\*)
"""
with self.lock:
if self.bytes_queued is not None:
Expand Down Expand Up @@ -207,7 +212,7 @@ def http_post(self, data: str) -> bool:
def http_get(self, payload: PayloadDict) -> bool:
"""
:param payload: The event properties
:type payload: dict(string:\*)
:type payload: dict(string:\\*)
"""
logger.info("Sending GET request to %s..." % self.endpoint)
logger.debug("Payload: %s" % payload)
Expand Down Expand Up @@ -242,7 +247,7 @@ def is_good_status_code(status_code: int) -> bool:
def send_events(self, evts: PayloadDictList) -> None:
"""
:param evts: Array of events to be sent
:type evts: list(dict(string:\*))
:type evts: list(dict(string:\\*))
"""
if len(evts) > 0:
logger.info("Attempting to send %s events" % len(evts))
Expand Down Expand Up @@ -307,7 +312,7 @@ def attach_sent_timestamp(events: PayloadDictList) -> None:
as `stm` param
:param events: Array of events to be sent
:type events: list(dict(string:\*))
:type events: list(dict(string:\\*))
:rtype: None
"""
def update(e: PayloadDict) -> None:
Expand All @@ -327,7 +332,7 @@ def __init__(
endpoint: str,
protocol: HttpProtocol = "http",
port: Optional[int] = None,
method: Method = "get",
method: Method = "post",
buffer_size: Optional[int] = None,
on_success: Optional[SuccessCallback] = None,
on_failure: Optional[FailureCallback] = None,
Expand Down
4 changes: 2 additions & 2 deletions snowplow_tracker/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def add_dict(self, dict_: PayloadDict, base64: bool = False) -> None:
Add a dict of name value pairs to the Payload object
:param dict_: Dictionary to be added to the Payload
:type dict_: dict(string:\*)
:type dict_: dict(string:\\*)
"""
for f in dict_:
self.add(f, dict_[f])
Expand All @@ -70,7 +70,7 @@ def add_json(
Add an encoded or unencoded JSON to the payload
:param dict_: Custom context for the event
:type dict_: dict(string:\*) | None
:type dict_: dict(string:\\*) | None
:param encode_base64: If the payload is base64 encoded
:type encode_base64: bool
:param type_when_encoded: Name of the field when encode_base64 is set
Expand Down
20 changes: 20 additions & 0 deletions snowplow_tracker/subject.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,26 @@ def set_domain_user_id(self, duid: str) -> 'Subject':
self.standard_nv_pairs["duid"] = duid
return self

def set_domain_session_id(self, sid: str) -> 'Subject':
"""
Set the domain session ID
:param sid: Domain session ID
:type sid: string
:rtype: subject
"""
self.standard_nv_pairs["sid"] = sid
return self

def set_domain_session_index(self, vid: int) -> 'Subject':
"""
Set the domain session Index
:param vid: Domain session Index
:type vid: int
:rtype: subject
"""
self.standard_nv_pairs["vid"] = vid
return self

def set_ip_address(self, ip: str) -> 'Subject':
"""
Set the domain user ID
Expand Down
Loading

0 comments on commit ecca49d

Please sign in to comment.