Skip to content

Commit becee2c

Browse files
authored
fix: Tracking linked experiments
Fixes for tracking linked experiments
2 parents 352b115 + ae38b25 commit becee2c

File tree

3 files changed

+46
-44
lines changed

3 files changed

+46
-44
lines changed

.github/workflows/update-sdk-versions.yml

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ name: Update SDK Version
33
on:
44
release:
55
types: [published] # Triggers when a release is published
6-
workflow_dispatch: {} # Manual trigger without inputs
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'Version to update (leave empty to use latest release)'
10+
required: false
11+
type: string
712

813
jobs:
914
update-versions:
@@ -13,59 +18,54 @@ jobs:
1318
pull-requests: write
1419

1520
steps:
21+
- name: Debug Release Info
22+
if: github.event_name == 'release'
23+
run: |
24+
echo "Release event detected!"
25+
echo "Event action: ${{ github.event.action }}"
26+
echo "Release tag: ${{ github.event.release.tag_name }}"
27+
echo "Release name: ${{ github.event.release.name }}"
28+
echo "Is prerelease: ${{ github.event.release.prerelease }}"
29+
echo "Is draft: ${{ github.event.release.draft }}"
30+
1631
- name: Get Latest Release
1732
id: latest_release
1833
run: |
19-
LATEST_TAG=$(gh api repos/growthbook/growthbook-python/releases/latest --jq .tag_name)
20-
echo "version=${LATEST_TAG#v}" >> $GITHUB_OUTPUT
34+
if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ inputs.version }}" ]; then
35+
echo "Using manually specified version: ${{ inputs.version }}"
36+
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
37+
elif [ "${{ github.event_name }}" == "release" ]; then
38+
echo "Using release event version: ${{ github.event.release.tag_name }}"
39+
VERSION="${{ github.event.release.tag_name }}"
40+
echo "version=${VERSION#v}" >> $GITHUB_OUTPUT
41+
else
42+
echo "Getting latest release from API..."
43+
LATEST_TAG=$(gh api repos/growthbook/growthbook-python/releases/latest --jq .tag_name)
44+
echo "version=${LATEST_TAG#v}" >> $GITHUB_OUTPUT
45+
fi
2146
env:
2247
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2348

24-
- name: Update SDK Versions Repository
25-
env:
26-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
- name: Trigger Update in Main GrowthBook Repository
2750
run: |
2851
# Get version from latest release
2952
VERSION=${{ steps.latest_release.outputs.version }}
53+
echo "Triggering update for version: $VERSION"
3054
3155
# Validate version format (semver)
3256
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
3357
echo "Error: Version '$VERSION' is not in semantic versioning format (x.y.z)"
3458
exit 1
3559
fi
3660
37-
# Remove directory if it exists and clone fresh
38-
rm -rf growthbook || true
39-
git clone https://github.com/growthbook/growthbook.git || {
40-
echo "Failed to clone repository"
41-
exit 1
42-
}
43-
cd growthbook/packages/shared/src/sdk-versioning/sdk-versions
44-
45-
# Check if version already exists
46-
if jq -e --arg v "$VERSION" '.versions[] | select(.version == $v)' python.json > /dev/null; then
47-
echo "Version $VERSION already exists in python.json"
48-
exit 0 # Exit successfully since this is not an error condition
49-
fi
50-
51-
# Create a new branch
52-
git checkout -b update-python-sdk-${VERSION}
53-
54-
# Update the JSON file
55-
jq --arg v "$VERSION" \
56-
'.versions = ([{"version": $v}] + .versions)' \
57-
python.json > python.json.tmp && mv python.json.tmp python.json
58-
59-
# Commit and push changes
60-
git config user.name "github-actions"
61-
git config user.email "[email protected]"
62-
git add python.json
63-
git commit -m "chore: update Python SDK to ${VERSION}"
64-
git push origin update-python-sdk-${VERSION}
65-
66-
# Create Pull Request
67-
gh pr create \
68-
--title "Update Python SDK to ${VERSION}" \
69-
--body "Automated PR to update Python SDK version to ${VERSION} in capabilities matrix" \
70-
--repo growthbook/growthbook \
71-
--base main
61+
# Trigger repository_dispatch event in the main GrowthBook repo
62+
gh api repos/growthbook/growthbook/dispatches \
63+
--method POST \
64+
--field event_type='update-sdk-version' \
65+
--field client_payload='{"version":"'$VERSION'","sdk":"python","source_repo":"growthbook/growthbook-python"}'
66+
67+
echo "✅ Successfully triggered update workflow in growthbook/growthbook"
68+
echo "📋 Version: $VERSION"
69+
echo "🔗 Check progress at: https://github.com/growthbook/growthbook/actions"
70+
env:
71+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

growthbook/core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ def getBucketRanges(
413413
def eval_feature(
414414
key: str,
415415
evalContext: EvaluationContext = None,
416-
callback_subscription: Callable[[Experiment, Result], None] = None
416+
callback_subscription: Callable[[Experiment, Result], None] = None,
417+
tracking_cb: Callable[[Experiment, Result], None] = None
417418
) -> FeatureResult:
418419
"""Core feature evaluation logic as a standalone function"""
419420

@@ -506,7 +507,7 @@ def eval_feature(
506507
minBucketVersion=rule.minBucketVersion,
507508
)
508509

509-
result = run_experiment(experiment=exp, featureId=key, evalContext=evalContext)
510+
result = run_experiment(experiment=exp, featureId=key, evalContext=evalContext, tracking_cb=tracking_cb)
510511

511512
if callback_subscription:
512513
callback_subscription(exp, result)

growthbook/growthbook.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,8 @@ def _get_eval_context(self) -> EvaluationContext:
708708
def eval_feature(self, key: str) -> FeatureResult:
709709
return core_eval_feature(key=key,
710710
evalContext=self._get_eval_context(),
711-
callback_subscription=self._fireSubscriptions
711+
callback_subscription=self._fireSubscriptions,
712+
tracking_cb=self._track
712713
)
713714

714715
# @deprecated, use get_all_results

0 commit comments

Comments
 (0)