intempt 2.0.0__tar.gz → 2.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- intempt-2.1.0/.github/workflows/autopr.yaml +30 -0
- intempt-2.1.0/.github/workflows/blu-bot-pipeline-caller.yml +18 -0
- {intempt-2.0.0 → intempt-2.1.0}/.github/workflows/e2e.yml +2 -2
- intempt-2.1.0/.github/workflows/ff-merge.yml +15 -0
- {intempt-2.0.0 → intempt-2.1.0}/.github/workflows/release.yml +2 -2
- {intempt-2.0.0 → intempt-2.1.0}/.github/workflows/tests.yml +6 -6
- {intempt-2.0.0 → intempt-2.1.0}/CHANGELOG.md +24 -0
- {intempt-2.0.0 → intempt-2.1.0}/PKG-INFO +2 -2
- {intempt-2.0.0 → intempt-2.1.0}/README.md +1 -1
- {intempt-2.0.0 → intempt-2.1.0}/src/intempt/__init__.py +1 -1
- {intempt-2.0.0 → intempt-2.1.0}/src/intempt/_buffer.py +3 -3
- {intempt-2.0.0 → intempt-2.1.0}/src/intempt/_client.py +8 -4
- {intempt-2.0.0 → intempt-2.1.0}/src/intempt/_config.py +17 -0
- {intempt-2.0.0 → intempt-2.1.0}/tests/test_bare_sample.py +4 -0
- {intempt-2.0.0 → intempt-2.1.0}/tests/test_buffer.py +63 -0
- {intempt-2.0.0 → intempt-2.1.0}/tests/test_client.py +11 -2
- {intempt-2.0.0 → intempt-2.1.0}/tests/test_config.py +30 -0
- {intempt-2.0.0 → intempt-2.1.0}/tests/test_flags.py +13 -0
- {intempt-2.0.0 → intempt-2.1.0}/tests/test_thresholds.py +1 -1
- intempt-2.0.0/.github/CODEOWNERS +0 -17
- {intempt-2.0.0 → intempt-2.1.0}/.gitignore +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/ARCHITECTURE.md +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/LICENSE +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/NOTICE +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/docs/CONVENTIONS.md +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/docs/TESTING.md +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/examples/README.md +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/examples/bare/send.py +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/examples/basic/app.py +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/pyproject.toml +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/scripts/check-no-local-bucketing.mjs +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/scripts/e2e.py +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/scripts/mutation_gate.py +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/scripts/no-local-bucketing-allow.json +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/src/intempt/_errors.py +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/src/intempt/_flags.py +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/src/intempt/_transport.py +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/src/intempt/_util.py +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/tests/__init__.py +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/tests/conftest.py +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/tests/test_bucketing_guard.py +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/tests/test_credential_guard.py +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/tests/test_example_app.py +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/tests/test_messages.py +0 -0
- {intempt-2.0.0 → intempt-2.1.0}/tests/test_transport.py +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Create Pull Request from Staging to Main
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- staging
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
create_pr:
|
|
10
|
+
runs-on: intempt-ubuntu-github-runner
|
|
11
|
+
steps:
|
|
12
|
+
- name: Checkout code
|
|
13
|
+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
14
|
+
with:
|
|
15
|
+
fetch-depth: 0
|
|
16
|
+
|
|
17
|
+
- name: Run the Action
|
|
18
|
+
uses: devops-infra/action-pull-request@e66e2ba93519dc63b9884a26e620e2fd0cffab2c # v0.5.5
|
|
19
|
+
with:
|
|
20
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
21
|
+
source_branch: staging
|
|
22
|
+
target_branch: main
|
|
23
|
+
title: 'Merge Staging into Main'
|
|
24
|
+
body: 'Automatically created pull request to merge changes from staging into main.'
|
|
25
|
+
reviewer: ${{ vars.REVIEWERS }}
|
|
26
|
+
assignee: ${{ vars.REVIEWERS }}
|
|
27
|
+
draft: false
|
|
28
|
+
get_diff: true
|
|
29
|
+
ignore_users: "dependabot"
|
|
30
|
+
allow_no_diff: false
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: blu-bot-pipeline
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request_target:
|
|
5
|
+
types: [labeled]
|
|
6
|
+
|
|
7
|
+
concurrency:
|
|
8
|
+
group: blu-bot-pipeline-${{ github.repository }}-${{ github.event.pull_request.number }}
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
pipeline:
|
|
12
|
+
if: github.event.label.name == 'admin-release'
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
pull-requests: write
|
|
16
|
+
uses: intempt/.github/.github/workflows/blu-bot-pipeline.yml@main
|
|
17
|
+
secrets:
|
|
18
|
+
BLU_BOT_PRIVATE_KEY: ${{ secrets.BLU_BOT_PRIVATE_KEY }}
|
|
@@ -36,7 +36,7 @@ permissions:
|
|
|
36
36
|
|
|
37
37
|
jobs:
|
|
38
38
|
e2e:
|
|
39
|
-
runs-on: ubuntu-
|
|
39
|
+
runs-on: intempt-ubuntu-github-runner
|
|
40
40
|
steps:
|
|
41
41
|
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
42
42
|
|
|
@@ -73,4 +73,4 @@ jobs:
|
|
|
73
73
|
INTEMPT_E2E_FEED_ID: ${{ secrets.INTEMPT_E2E_FEED_ID }}
|
|
74
74
|
INTEMPT_E2E_FEED_FIELDS: ${{ secrets.INTEMPT_E2E_FEED_FIELDS }}
|
|
75
75
|
INTEMPT_E2E_PRODUCT_ID: ${{ secrets.INTEMPT_E2E_PRODUCT_ID }}
|
|
76
|
-
run: python scripts/e2e.py
|
|
76
|
+
run: python scripts/e2e.py
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
name: ff-merge
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request_target:
|
|
5
|
+
types: [labeled]
|
|
6
|
+
|
|
7
|
+
concurrency:
|
|
8
|
+
group: ff-merge-${{ github.repository }}
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
ff-merge:
|
|
12
|
+
if: github.event.label.name == 'ff-merge'
|
|
13
|
+
uses: intempt/.github/.github/workflows/ff-merge.yml@main
|
|
14
|
+
secrets:
|
|
15
|
+
FF_BOT_PRIVATE_KEY: ${{ secrets.FF_BOT_PRIVATE_KEY }}
|
|
@@ -28,7 +28,7 @@ permissions:
|
|
|
28
28
|
|
|
29
29
|
jobs:
|
|
30
30
|
publish:
|
|
31
|
-
runs-on: ubuntu-
|
|
31
|
+
runs-on: intempt-ubuntu-github-runner
|
|
32
32
|
environment: pypi
|
|
33
33
|
permissions:
|
|
34
34
|
contents: write # create the GitHub Release
|
|
@@ -77,4 +77,4 @@ jobs:
|
|
|
77
77
|
run: |
|
|
78
78
|
gh release create "$GITHUB_REF_NAME" \
|
|
79
79
|
--title "$GITHUB_REF_NAME" \
|
|
80
|
-
--generate-notes
|
|
80
|
+
--generate-notes
|
|
@@ -15,10 +15,10 @@ jobs:
|
|
|
15
15
|
# internally consistent. Runs without install so it cannot be skipped.
|
|
16
16
|
bucketing:
|
|
17
17
|
name: Server-only bucketing
|
|
18
|
-
runs-on: ubuntu-
|
|
18
|
+
runs-on: intempt-ubuntu-github-runner
|
|
19
19
|
steps:
|
|
20
|
-
- uses: actions/checkout@v4
|
|
21
|
-
- uses: actions/setup-node@v4
|
|
20
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
21
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
|
22
22
|
with:
|
|
23
23
|
node-version: 22
|
|
24
24
|
- name: No SDK derives buckets locally (R36)
|
|
@@ -27,7 +27,7 @@ jobs:
|
|
|
27
27
|
GUARD_SRC: src
|
|
28
28
|
|
|
29
29
|
test:
|
|
30
|
-
runs-on: ubuntu-
|
|
30
|
+
runs-on: intempt-ubuntu-github-runner
|
|
31
31
|
strategy:
|
|
32
32
|
fail-fast: false
|
|
33
33
|
matrix:
|
|
@@ -60,7 +60,7 @@ jobs:
|
|
|
60
60
|
#
|
|
61
61
|
# 3.12 specifically: mutmut needs libcst, and libcst has no prebuilt wheel
|
|
62
62
|
# for 3.14 yet, so it tries to compile Rust and fails.
|
|
63
|
-
runs-on: ubuntu-
|
|
63
|
+
runs-on: intempt-ubuntu-github-runner
|
|
64
64
|
steps:
|
|
65
65
|
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
66
66
|
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5
|
|
@@ -94,4 +94,4 @@ jobs:
|
|
|
94
94
|
with:
|
|
95
95
|
name: mutation-report
|
|
96
96
|
path: mutants/
|
|
97
|
-
retention-days: 14
|
|
97
|
+
retention-days: 14
|
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.1.0 — unreleased
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- **`source_id` is validated at init** (INT-7455). It must be a positive 64-bit
|
|
8
|
+
integer as a string of digits (`^[1-9][0-9]{0,18}$`, at most
|
|
9
|
+
9223372036854775807), which is what the API parses. A value such as `"abc"`,
|
|
10
|
+
`"0"` or a 20-digit id used to pass init and then fail every track and consent
|
|
11
|
+
call; it now raises.
|
|
12
|
+
- **Consent is sent while opted out** (INT-7437, ruling D-5). After `opt_out()`
|
|
13
|
+
consent records were dropped silently, so a person who had opted out could not
|
|
14
|
+
withdraw consent. Grant and revoke are now sent regardless of opt-out, as the
|
|
15
|
+
client SDKs do; tracking writes stay suppressed.
|
|
16
|
+
- **A flag's detail reason no longer reads `reason` off the choose response**
|
|
17
|
+
(INT-7457). choose-api never sends one; the reason is the fixed `UNANSWERED`,
|
|
18
|
+
as intempt-php already reports. No public effect.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- **Buffer drop diagnostics no longer raise `KeyError` from a stdlib logger**
|
|
23
|
+
(INT-7440). They passed `extra={"name": ...}`, a reserved `LogRecord` key, so
|
|
24
|
+
with ERROR enabled (the default) `track()` on a stopped buffer or full queue,
|
|
25
|
+
and `flush()` on a single-event 413, raised. The key is now `event_name`.
|
|
26
|
+
|
|
3
27
|
## 2.0.0 — 2026-09-03
|
|
4
28
|
|
|
5
29
|
### Removed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: intempt
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: Intempt Python SDK — server-side. Data in, decisions out.
|
|
5
5
|
Project-URL: Homepage, https://intempt.com
|
|
6
6
|
Project-URL: Source, https://github.com/intempt/intempt-python
|
|
@@ -179,7 +179,7 @@ like it just happened. The reverse mistake fails loudly.
|
|
|
179
179
|
## Opting out
|
|
180
180
|
|
|
181
181
|
```python
|
|
182
|
-
intempt.opt_out() # suppresses track, batch
|
|
182
|
+
intempt.opt_out() # suppresses track, batch and commerce; consent is still sent
|
|
183
183
|
intempt.opt_in()
|
|
184
184
|
```
|
|
185
185
|
|
|
@@ -152,7 +152,7 @@ like it just happened. The reverse mistake fails loudly.
|
|
|
152
152
|
## Opting out
|
|
153
153
|
|
|
154
154
|
```python
|
|
155
|
-
intempt.opt_out() # suppresses track, batch
|
|
155
|
+
intempt.opt_out() # suppresses track, batch and commerce; consent is still sent
|
|
156
156
|
intempt.opt_in()
|
|
157
157
|
```
|
|
158
158
|
|
|
@@ -109,13 +109,13 @@ class Buffer:
|
|
|
109
109
|
if self._stopped:
|
|
110
110
|
self._logger.error(
|
|
111
111
|
"[intempt] batching is stopped; event dropped",
|
|
112
|
-
extra={"
|
|
112
|
+
extra={"event_name": event.get("name")},
|
|
113
113
|
)
|
|
114
114
|
return
|
|
115
115
|
if len(self._queue) >= self._options.max_queue:
|
|
116
116
|
self._logger.error(
|
|
117
117
|
"[intempt] batch queue full; event dropped",
|
|
118
|
-
extra={"
|
|
118
|
+
extra={"event_name": event.get("name"), "max_queue": self._options.max_queue},
|
|
119
119
|
)
|
|
120
120
|
return
|
|
121
121
|
self._queue.append(event)
|
|
@@ -240,7 +240,7 @@ class Buffer:
|
|
|
240
240
|
|
|
241
241
|
self._logger.error(
|
|
242
242
|
"[intempt] single event too large; dropping",
|
|
243
|
-
extra={"
|
|
243
|
+
extra={"event_name": batch[0].get("name") if batch else None},
|
|
244
244
|
)
|
|
245
245
|
with self._lock:
|
|
246
246
|
del self._queue[:1]
|
|
@@ -52,9 +52,9 @@ class Consent:
|
|
|
52
52
|
if not _present(user_id) and not _present(profile_id):
|
|
53
53
|
raise IntemptConfigError(f"{name}: user_id must be a non-empty string")
|
|
54
54
|
|
|
55
|
+
# Deliberately NOT gated on opt-out (ruling D-5, INT-7437): a withdrawal must reach the
|
|
56
|
+
# server precisely when the person has opted out. intempt-js consent() does the same.
|
|
55
57
|
self._client._assert_open()
|
|
56
|
-
if not self._client.is_opted_in():
|
|
57
|
-
return
|
|
58
58
|
|
|
59
59
|
config = self._client._config
|
|
60
60
|
if profile_id and not config.source_id:
|
|
@@ -309,7 +309,9 @@ class Intempt:
|
|
|
309
309
|
body = choice.get("body")
|
|
310
310
|
return FlagDetail(
|
|
311
311
|
value=default_value if body is None else body,
|
|
312
|
-
|
|
312
|
+
# Not read off the wire (INT-7457): ExperienceApiChoose carries only
|
|
313
|
+
# name/group/body, so a "reason" key could only come from a fixture.
|
|
314
|
+
reason=UNANSWERED,
|
|
313
315
|
)
|
|
314
316
|
return FlagDetail(value=default_value, reason=UNANSWERED)
|
|
315
317
|
|
|
@@ -452,7 +454,9 @@ class Intempt:
|
|
|
452
454
|
self._opted_in = True
|
|
453
455
|
|
|
454
456
|
def opt_out(self) -> None:
|
|
455
|
-
"""Suppress all outbound writes: track, batch
|
|
457
|
+
"""Suppress all outbound tracking writes: track, batch and commerce.
|
|
458
|
+
|
|
459
|
+
Consent is still sent, so a withdrawal reaches the server (ruling D-5).
|
|
456
460
|
|
|
457
461
|
``recommend()`` is unaffected — it sends an identifier the caller already
|
|
458
462
|
holds and returns a decision rather than storing anything.
|
|
@@ -7,6 +7,7 @@ Licensed under the Apache License, Version 2.0.
|
|
|
7
7
|
from __future__ import annotations
|
|
8
8
|
|
|
9
9
|
import logging
|
|
10
|
+
import re
|
|
10
11
|
from collections.abc import Mapping
|
|
11
12
|
from dataclasses import dataclass, field, replace
|
|
12
13
|
from typing import Any
|
|
@@ -96,6 +97,18 @@ def _split_host(host: str) -> tuple[str, int | None]:
|
|
|
96
97
|
return hostname, port
|
|
97
98
|
|
|
98
99
|
|
|
100
|
+
_LONG_MAX = "9223372036854775807"
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _is_positive_long(value: str) -> bool:
|
|
104
|
+
# The backend parses source_id as a Java long and requires it > 0 (INT-7455). fullmatch, not
|
|
105
|
+
# match: "$" also matches before a trailing newline. [0-9], not \d: \d accepts non-ASCII
|
|
106
|
+
# digits. Equal-length digit strings order lexicographically exactly as numerically.
|
|
107
|
+
return re.fullmatch(r"[1-9][0-9]{0,18}", value) is not None and (
|
|
108
|
+
len(value) < len(_LONG_MAX) or value <= _LONG_MAX
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
|
|
99
112
|
def resolve_config(**options: Any) -> ResolvedConfig:
|
|
100
113
|
"""Validate and normalise constructor options."""
|
|
101
114
|
for name in ("org", "project", "api_key"):
|
|
@@ -110,6 +123,10 @@ def resolve_config(**options: Any) -> ResolvedConfig:
|
|
|
110
123
|
source_id = str(source_id)
|
|
111
124
|
if not source_id.strip():
|
|
112
125
|
raise IntemptConfigError('Intempt: "source_id" must not be empty when provided')
|
|
126
|
+
if not _is_positive_long(source_id):
|
|
127
|
+
raise IntemptConfigError(
|
|
128
|
+
'Intempt: "source_id" must be a positive 64-bit integer, as a string of digits'
|
|
129
|
+
)
|
|
113
130
|
|
|
114
131
|
# None means "not supplied, use the default". An explicit empty string is a
|
|
115
132
|
# mistake and is refused rather than quietly becoming the default.
|
|
@@ -10,6 +10,7 @@ Licensed under the Apache License, Version 2.0.
|
|
|
10
10
|
|
|
11
11
|
from __future__ import annotations
|
|
12
12
|
|
|
13
|
+
import os
|
|
13
14
|
import subprocess
|
|
14
15
|
import sys
|
|
15
16
|
|
|
@@ -38,6 +39,9 @@ def run(server: object, **overrides: str) -> subprocess.CompletedProcess[str]:
|
|
|
38
39
|
"INTEMPT_USER_ID": USER,
|
|
39
40
|
"INTEMPT_HOST": server.host, # type: ignore[attr-defined]
|
|
40
41
|
"INTEMPT_SCHEME": "http",
|
|
42
|
+
# setup-python on a self-hosted runner installs a shared-libpython
|
|
43
|
+
# interpreter that only finds libpython through LD_LIBRARY_PATH.
|
|
44
|
+
"LD_LIBRARY_PATH": os.environ.get("LD_LIBRARY_PATH", ""),
|
|
41
45
|
}
|
|
42
46
|
env.update(overrides)
|
|
43
47
|
env = {k: v for k, v in env.items() if v != ""}
|
|
@@ -7,8 +7,11 @@ whether a reduced width recovers.
|
|
|
7
7
|
|
|
8
8
|
from __future__ import annotations
|
|
9
9
|
|
|
10
|
+
import logging
|
|
10
11
|
import time
|
|
11
12
|
|
|
13
|
+
import pytest
|
|
14
|
+
|
|
12
15
|
from intempt import BatchOptions, IntemptApiError
|
|
13
16
|
from intempt._buffer import Buffer
|
|
14
17
|
from tests.conftest import Reply
|
|
@@ -483,3 +486,63 @@ class TestOptOutGate:
|
|
|
483
486
|
|
|
484
487
|
names = [e["name"] for r in server.requests for e in r.body["track"]]
|
|
485
488
|
assert names == ["after"]
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
class TestStdlibLoggerExtra:
|
|
492
|
+
"""INT-7440. ``RecordingLogger`` accepts any ``extra``; a real ``logging.Logger`` refuses a
|
|
493
|
+
key that collides with a LogRecord attribute (``name``) with a KeyError, which escaped
|
|
494
|
+
``track()``. These cases therefore need the stdlib logger, not the fixture."""
|
|
495
|
+
|
|
496
|
+
@staticmethod
|
|
497
|
+
def _buffer(stdlib_logger, *, size=10, max_queue=100, send=None):
|
|
498
|
+
return Buffer(
|
|
499
|
+
options=BatchOptions(
|
|
500
|
+
size=size, flush_ms=60_000, max_queue=max_queue, flush_on_exit=False
|
|
501
|
+
),
|
|
502
|
+
max_request_events=50,
|
|
503
|
+
logger=stdlib_logger,
|
|
504
|
+
send=send or (lambda _events: None),
|
|
505
|
+
sleep=RecordedSleep(),
|
|
506
|
+
)
|
|
507
|
+
|
|
508
|
+
@pytest.fixture
|
|
509
|
+
def stdlib_logger(self, caplog):
|
|
510
|
+
caplog.set_level(logging.ERROR, logger="intempt.int7440")
|
|
511
|
+
return logging.getLogger("intempt.int7440")
|
|
512
|
+
|
|
513
|
+
def test_enqueue_on_a_stopped_buffer_logs_instead_of_raising(self, stdlib_logger, caplog):
|
|
514
|
+
buffer = self._buffer(stdlib_logger)
|
|
515
|
+
buffer.close()
|
|
516
|
+
|
|
517
|
+
buffer.enqueue(event("late"))
|
|
518
|
+
|
|
519
|
+
assert [r.event_name for r in caplog.records] == ["late"]
|
|
520
|
+
|
|
521
|
+
def test_enqueue_on_a_full_queue_logs_instead_of_raising(self, stdlib_logger, caplog):
|
|
522
|
+
# Another thread tracking while a full batch is in flight: the batch stays queued until
|
|
523
|
+
# the send returns, so the arrival finds the queue at max_queue.
|
|
524
|
+
late: list[str] = []
|
|
525
|
+
|
|
526
|
+
def send(_events):
|
|
527
|
+
if not late:
|
|
528
|
+
late.append("over")
|
|
529
|
+
buffer.enqueue(event("over"))
|
|
530
|
+
|
|
531
|
+
buffer = self._buffer(stdlib_logger, size=2, max_queue=2, send=send)
|
|
532
|
+
|
|
533
|
+
buffer.enqueue(event("a"))
|
|
534
|
+
buffer.enqueue(event("b"))
|
|
535
|
+
|
|
536
|
+
assert buffer.size == 0
|
|
537
|
+
full = [r for r in caplog.records if "queue full" in r.getMessage()]
|
|
538
|
+
assert [(r.event_name, r.max_queue) for r in full] == [("over", 2)]
|
|
539
|
+
|
|
540
|
+
def test_a_single_event_413_is_dropped_and_logged(self, stdlib_logger, caplog):
|
|
541
|
+
buffer = self._buffer(stdlib_logger, send=failing(413))
|
|
542
|
+
|
|
543
|
+
buffer.enqueue(event("huge"))
|
|
544
|
+
buffer.flush()
|
|
545
|
+
|
|
546
|
+
assert buffer.size == 0
|
|
547
|
+
dropped = [r for r in caplog.records if "single event too large" in r.getMessage()]
|
|
548
|
+
assert [r.event_name for r in dropped] == ["huge"]
|
|
@@ -226,15 +226,24 @@ class TestRecommend:
|
|
|
226
226
|
|
|
227
227
|
|
|
228
228
|
class TestPrivacy:
|
|
229
|
-
def
|
|
229
|
+
def test_opt_out_suppresses_every_tracking_write(self, client, server):
|
|
230
230
|
c = client()
|
|
231
231
|
c.opt_out()
|
|
232
232
|
c.track("purchase", user_id="u1")
|
|
233
233
|
c.identify(user_id="u1")
|
|
234
|
-
c.consent.grant(user_id="u1")
|
|
235
234
|
c.ecommerce.ordered(user_id="u1", products=[{"product_id": "a"}])
|
|
236
235
|
assert server.requests == []
|
|
237
236
|
|
|
237
|
+
def test_opt_out_still_sends_consent_grant_and_revoke(self, client, server):
|
|
238
|
+
# Ruling D-5 (INT-7437): consent is the person's own instruction, so a withdrawal must
|
|
239
|
+
# reach the server precisely when they have opted out. intempt-js does not gate it either.
|
|
240
|
+
c = client()
|
|
241
|
+
c.opt_out()
|
|
242
|
+
c.consent.grant(user_id="u1")
|
|
243
|
+
c.consent.revoke(user_id="u1")
|
|
244
|
+
assert [r.path for r in server.requests] == [CONSENT_PATH, CONSENT_PATH]
|
|
245
|
+
assert [r.body["action"] for r in server.requests] == ["accept", "reject"]
|
|
246
|
+
|
|
238
247
|
def test_opt_in_restores_sending(self, client, server):
|
|
239
248
|
c = client()
|
|
240
249
|
c.opt_out()
|
|
@@ -56,6 +56,36 @@ class TestSourceId:
|
|
|
56
56
|
def test_absent_when_not_provided(self):
|
|
57
57
|
assert resolve_config(**base()).source_id is None
|
|
58
58
|
|
|
59
|
+
# INT-7455: the backend parses source_id as a positive Java long; anything else failed every
|
|
60
|
+
# call silently instead of failing construction.
|
|
61
|
+
@pytest.mark.parametrize(
|
|
62
|
+
"source_id",
|
|
63
|
+
[
|
|
64
|
+
"abc",
|
|
65
|
+
"12a",
|
|
66
|
+
"0",
|
|
67
|
+
"01",
|
|
68
|
+
"-5",
|
|
69
|
+
" 1",
|
|
70
|
+
"1\n",
|
|
71
|
+
"1.5",
|
|
72
|
+
"\u0661\u0662",
|
|
73
|
+
"9223372036854775808",
|
|
74
|
+
"12345678901234567890",
|
|
75
|
+
-5,
|
|
76
|
+
True,
|
|
77
|
+
],
|
|
78
|
+
)
|
|
79
|
+
def test_rejects_anything_but_a_positive_long(self, source_id):
|
|
80
|
+
with pytest.raises(
|
|
81
|
+
IntemptConfigError, match='"source_id" must be a positive 64-bit integer'
|
|
82
|
+
):
|
|
83
|
+
resolve_config(**base(source_id=source_id))
|
|
84
|
+
|
|
85
|
+
@pytest.mark.parametrize("source_id", ["1", "1841503112918048768", "9223372036854775807"])
|
|
86
|
+
def test_accepts_a_positive_long_and_keeps_every_digit(self, source_id):
|
|
87
|
+
assert resolve_config(**base(source_id=source_id)).source_id == source_id
|
|
88
|
+
|
|
59
89
|
|
|
60
90
|
class TestHostAndPort:
|
|
61
91
|
def test_splits_host_and_port(self):
|
|
@@ -11,6 +11,7 @@ import json
|
|
|
11
11
|
import pytest
|
|
12
12
|
|
|
13
13
|
from intempt import FlagContext, IntemptConfigError
|
|
14
|
+
from intempt._flags import UNANSWERED
|
|
14
15
|
from tests.conftest import ORG, PROJECT, SOURCE, Reply
|
|
15
16
|
|
|
16
17
|
CTX = FlagContext(user_id="u-1", profile_id="p-1")
|
|
@@ -193,6 +194,18 @@ class TestVariation:
|
|
|
193
194
|
|
|
194
195
|
assert c.variation("checkout_v2", CTX, False) is True
|
|
195
196
|
|
|
197
|
+
def test_a_wire_reason_is_ignored(self, client, server):
|
|
198
|
+
# INT-7457: ExperienceApiChoose carries only name/group/body, so a "reason" key can only
|
|
199
|
+
# come from a fixture. Reading it made an unreachable branch look live; the reason is
|
|
200
|
+
# fixed, as in intempt-php.
|
|
201
|
+
server.expect(_choices({"name": "checkout_v2", "body": True, "reason": "targeted"}))
|
|
202
|
+
c = client()
|
|
203
|
+
|
|
204
|
+
detail = c._variation_detail("checkout_v2", CTX, False)
|
|
205
|
+
|
|
206
|
+
assert detail.value is True
|
|
207
|
+
assert detail.reason == UNANSWERED
|
|
208
|
+
|
|
196
209
|
def test_returns_the_default_when_the_served_body_is_null(self, client, server):
|
|
197
210
|
# NOT the holdout case, which cannot be asserted: a held-back person's experience is
|
|
198
211
|
# absent from the response entirely rather than present with a cause. Telling a holdout
|
|
@@ -324,7 +324,7 @@ class TestQueueBound:
|
|
|
324
324
|
]
|
|
325
325
|
assert extras, "the operator needs the cap that was hit"
|
|
326
326
|
assert extras[-1]["max_queue"] == 1
|
|
327
|
-
assert extras[-1]["
|
|
327
|
+
assert extras[-1]["event_name"] == "dropped"
|
|
328
328
|
finally:
|
|
329
329
|
release.set()
|
|
330
330
|
producer.join(5)
|
intempt-2.0.0/.github/CODEOWNERS
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# CODEOWNERS — who approves a PR in this repo.
|
|
2
|
-
#
|
|
3
|
-
# Generated from The Merge Gate §02 (rev 2), the reviewed per-repo merge policy.
|
|
4
|
-
# Repo write access does NOT equal merge rights. This file decides who approves.
|
|
5
|
-
#
|
|
6
|
-
# lane auto if clean
|
|
7
|
-
# approvals 1
|
|
8
|
-
# primary @beska0013
|
|
9
|
-
# backup @romchik2612
|
|
10
|
-
#
|
|
11
|
-
# Default owner for every path.
|
|
12
|
-
* @beska0013 @romchik2612
|
|
13
|
-
|
|
14
|
-
# CI and release surface. Changing what runs on merge changes the gate itself,
|
|
15
|
-
# so it is listed explicitly rather than inherited from the default line.
|
|
16
|
-
/.github/ @beska0013 @romchik2612
|
|
17
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|