Skip to content

Commit 310d7ef

Browse files
committed
Merge in master branch
2 parents b01701e + c8e4c56 commit 310d7ef

File tree

12 files changed

+69
-48
lines changed

12 files changed

+69
-48
lines changed

.github/workflows/create_jira.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Create Jira Ticket
2+
3+
on:
4+
issues:
5+
types:
6+
- opened
7+
8+
jobs:
9+
create_jira:
10+
name: Create Jira Ticket
11+
runs-on: ubuntu-latest
12+
environment: IssueTracker
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@master
16+
- name: Login
17+
uses: atlassian/gajira-login@master
18+
env:
19+
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
20+
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
21+
JIRA_API_TOKEN: ${{ secrets.JIRA_TOKEN }}
22+
JIRA_EPIC_KEY: ${{ secrets.JIRA_EPIC_KEY }}
23+
JIRA_PROJECT: ${{ secrets.JIRA_PROJECT }}
24+
25+
- name: Create
26+
id: create
27+
uses: atlassian/gajira-create@master
28+
with:
29+
project: ${{ secrets.JIRA_PROJECT }}
30+
issuetype: Bug
31+
summary: |
32+
[${{ github.event.repository.name }}] (${{ github.event.issue.number }}): ${{ github.event.issue.title }}
33+
description: |
34+
Github Link: ${{ github.event.issue.html_url }}
35+
${{ github.event.issue.body }}
36+
fields: '{"parent": {"key": "${{ secrets.JIRA_EPIC_KEY }}"}}'
37+
38+
- name: Log created issue
39+
run: echo "Issue ${{ steps.create.outputs.issue }} was created"

.github/workflows/main.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ jobs:
1414
- name: Install Python 3
1515
uses: actions/setup-python@v3
1616
with:
17-
python-version: 3.7
17+
python-version: 3.9
1818
- name: Install dependencies
1919
run: |
2020
python -m pip install --upgrade pip
2121
pip install -r requirements.txt
2222
pip install python-dateutil backoff monotonic
2323
pip install --user .
24-
sudo pip install pylint==2.8.0 flake8 mock==3.0.5 python-dateutil aiohttp==3.9.1
24+
sudo pip install pylint==3.3.1 flake8 mock==3.0.5 python-dateutil aiohttp==3.9.1
2525
- name: Run tests
2626
run: python -m unittest discover -s segment
2727

@@ -41,17 +41,11 @@ jobs:
4141
# runs-on: ubuntu-latest
4242
# strategy:
4343
# matrix:
44-
# python: ['3.7', '3.8', '3.9', '3.10', '3.11']
44+
# python: ['3.9', '3.10', '3.11']
4545
# coverage: [false]
4646
# experimental: [false]
4747
# include:
4848
# # Run code coverage.
49-
# - python: '3.7'
50-
# coverage: true
51-
# experimental: false
52-
# - python: '3.8'
53-
# coverage: true
54-
# experimental: false
5549
# - python: '3.9'
5650
# coverage: true
5751
# experimental: false

.github/workflows/tests.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,6 @@ jobs:
1919
- name: Checkout
2020
uses: actions/checkout@v4
2121

22-
- name: Run with setup-python 3.7
23-
uses: actions/setup-python@v5
24-
with:
25-
python-version: '3.7'
26-
- name: Setup required modules
27-
run: python -m pip install -r requirements.txt
28-
- name: Run tests
29-
run: python -m unittest discover -s segment
30-
31-
- name: Run with setup-python 3.8
32-
uses: actions/setup-python@v5
33-
with:
34-
python-version: '3.8'
35-
- name: Setup required modules
36-
run: python -m pip install -r requirements.txt
37-
- name: Run tests
38-
run: python -m unittest discover -s segment
39-
4022
- name: Run with setup-python 3.9
4123
uses: actions/setup-python@v5
4224
with:

HISTORY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 2.3.3 / 2024-10-07
2+
- Update time handling and OAuth
3+
4+
# 2.3.2 / 2024-02-15
5+
- Updating version to create a release wheel without the outdated /analytics files
6+
17
# 2.3.1 / 2024-02-07
28
- Fixing dependency for JWT
39

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
analytics-python is a python client for [Segment](https://segment.com)
1212

13+
### ⚠️ Maintenance ⚠️
14+
This library is in maintenance mode. It will send data as intended, but receive no new feature support and only critical maintenance updates from Segment.
15+
1316
<div align="center">
1417
<img src="https://user-images.githubusercontent.com/16131737/53616895-a1142d80-3b99-11e9-8e0e-594c0b0dcdc9.png"/>
1518
<p><b><i>You can't fix what you can't measure</i></b></p>

requirements.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
backoff==2.2.1
2-
cryptography==41.0.3
3-
flake8==3.7.9
2+
cryptography==44.0.0
3+
flake8==7.1.1
44
mock==2.0.0
5-
PyJWT==2.8.0
6-
pylint==2.8.0
5+
pylint==3.3.3
6+
PyJWT==2.10.1
77
python-dateutil==2.8.2
8-
requests==2.31.0
8+
requests==2.32.3

segment/analytics/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def _enqueue(self, msg):
267267
"""Push a new `msg` onto the queue, return `(success, msg)`"""
268268
timestamp = msg['timestamp']
269269
if timestamp is None:
270-
timestamp = datetime.utcnow().replace(tzinfo=tzutc())
270+
timestamp = datetime.now(tz=tzutc())
271271
message_id = msg.get('messageId')
272272
if message_id is None:
273273
message_id = uuid4()

segment/analytics/oauth_manager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ def _poller_loop(self):
152152

153153
elif response.status_code == 429:
154154
self.retry_count += 1
155-
rate_limit_reset_timestamp = None
155+
rate_limit_reset_time = None
156156
try:
157-
rate_limit_reset_timestamp = int(response.headers.get("X-RateLimit-Reset"))
157+
rate_limit_reset_time = int(response.headers.get("X-RateLimit-Reset"))
158158
except Exception as e:
159159
self.log.error("OAuth rate limit response did not have a valid rest time: {} | {}".format(response, e))
160-
if rate_limit_reset_timestamp:
161-
refresh_timer_ms = rate_limit_reset_timestamp - time.time() * 1000
160+
if rate_limit_reset_time:
161+
refresh_timer_ms = rate_limit_reset_time * 1000
162162
else:
163163
refresh_timer_ms = 5 * 1000
164164

segment/analytics/request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def post(write_key, host=None, gzip=False, timeout=15, proxies=None, oauth_manag
1818
log = logging.getLogger('segment')
1919
body = kwargs
2020
if not "sentAt" in body.keys():
21-
body["sentAt"] = datetime.utcnow().replace(tzinfo=tzutc()).isoformat()
21+
body["sentAt"] = datetime.now(tz=tzutc()).isoformat()
2222
body["writeKey"] = write_key
2323
url = remove_trailing_slash(host or 'https://api.segment.io') + '/v1/batch'
2424
auth = None

segment/analytics/test/test_oauth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def json(self):
5555
elif kwargs['url'] == 'http://127.0.0.1:400/token':
5656
return MockResponse({"reason": "test_reason", "json_data" : {"error":"unrecoverable", "error_description":"nah"}}, 400)
5757
elif kwargs['url'] == 'http://127.0.0.1:429/token':
58-
return MockResponse({"reason": "test_reason", "headers" : {"X-RateLimit-Reset": time.time()*1000 + 2000}}, 429)
58+
return MockResponse({"reason": "test_reason", "headers" : {"X-RateLimit-Reset": 234}}, 429)
5959
elif kwargs['url'] == 'http://127.0.0.1:500/token':
6060
return MockResponse({"reason": "test_reason", "json_data" : {"error":"recoverable", "error_description":"nah"}}, 500)
6161
elif kwargs['url'] == 'http://127.0.0.1:501/token':
@@ -106,7 +106,7 @@ def test_oauth_fail_with_retries(self, mock_post):
106106
def test_oauth_rate_limit_delay(self, mock_sleep, mock_post):
107107
manager = segment.analytics.oauth_manager.OauthManager("id", privatekey, "keyid", "http://127.0.0.1:429")
108108
manager._poller_loop()
109-
self.assertTrue(mock_sleep.call_args[0][0] > 1.9 and mock_sleep.call_args[0][0] <= 2.0)
109+
mock_sleep.assert_called_with(234)
110110

111111
class TestOauthIntegration(unittest.TestCase):
112112
def fail(self, e, batch=[]):
@@ -152,4 +152,4 @@ def test_oauth_integration_fail_bad_key(self, mock_post):
152152
self.assertTrue(self.failed)
153153

154154
if __name__ == '__main__':
155-
unittest.main()
155+
unittest.main()

0 commit comments

Comments
 (0)