From e23676683eb60ccbfcdee31e281aaae271d2b2b2 Mon Sep 17 00:00:00 2001 From: Dustin Byrne Date: Tue, 11 Aug 2026 14:38:36 -0400 Subject: [PATCH] feat: publish posthog with compatibility crate --- .github/workflows/ci.yaml | 9 +- .github/workflows/release.yml | 285 ++++++- .../changesets/cantankerous-count-kullervo.md | 2 +- .../changesets/chivalrous-prince-aurelien.md | 2 +- .sampo/changesets/remove-v0-capture.md | 2 +- .sampo/changesets/rename-posthog.md | 5 + .sampo/config.toml | 4 +- CHANGELOG.md | 2 +- Cargo.lock | 11 +- Cargo.toml | 6 +- README.md | 6 +- RELEASING.md | 10 +- api/public-api.txt | 758 +++++++++--------- compliance/adapter/Cargo.toml | 4 +- compliance/adapter/src/main.rs | 10 +- crates/posthog-rs/Cargo.toml | 23 + crates/posthog-rs/README.md | 5 + crates/posthog-rs/src/lib.rs | 3 + crates/posthog-rs/tests/reexports.rs | 9 + docs/migration-0.x-to-1.0.md | 18 +- examples/advanced_config.rs | 14 +- examples/error_tracking.rs | 4 +- examples/evaluate_flags.rs | 4 +- examples/feature_flags.rs | 8 +- examples/local_evaluation.rs | 6 +- scripts/check-compatibility-crate.sh | 35 + scripts/check-public-api.sh | 4 +- src/client/async_client.rs | 16 +- src/client/blocking.rs | 16 +- src/client/common.rs | 2 +- src/client/mod.rs | 2 +- src/error_tracking.rs | 26 +- src/lib.rs | 8 +- tests/test.rs | 12 +- tests/test_alias.rs | 20 +- tests/test_async.rs | 16 +- tests/test_blocking.rs | 8 +- tests/test_capture.rs | 18 +- tests/test_capture_ai.rs | 10 +- tests/test_capture_ai_global.rs | 20 +- tests/test_capture_blocking.rs | 14 +- tests/test_capture_immediate.rs | 14 +- tests/test_error_tracking.rs | 36 +- tests/test_evaluate_flags.rs | 80 +- tests/test_group_identify.rs | 20 +- tests/test_local_evaluation.rs | 12 +- tests/test_minimal_flag_called_events.rs | 6 +- tests/test_on_error.rs | 44 +- tests/test_panic_global.rs | 22 +- tests/test_tls_no_provider.rs | 6 +- tests/test_transport.rs | 4 +- 51 files changed, 997 insertions(+), 684 deletions(-) create mode 100644 .sampo/changesets/rename-posthog.md create mode 100644 crates/posthog-rs/Cargo.toml create mode 100644 crates/posthog-rs/README.md create mode 100644 crates/posthog-rs/src/lib.rs create mode 100644 crates/posthog-rs/tests/reexports.rs create mode 100755 scripts/check-compatibility-crate.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b7021923..0e7858dd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -92,7 +92,7 @@ jobs: cache-key: tls-no-provider command: >- cargo build --verbose --no-default-features --features async-client,error-tracking,tls-no-provider - && ! cargo tree --package posthog-rs --edges normal --invert aws-lc-sys --no-default-features --features async-client,error-tracking,tls-no-provider + && ! cargo tree --package posthog --edges normal --invert aws-lc-sys --no-default-features --features async-client,error-tracking,tls-no-provider steps: - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -143,8 +143,8 @@ jobs: restore-keys: | ${{ runner.os }}-cargo- - - name: Publish dry run - run: cargo publish --dry-run --locked + - name: Workspace publish dry run + run: cargo publish --workspace --dry-run --locked --package posthog --package posthog-rs test: name: ${{ matrix.name }} @@ -159,6 +159,9 @@ jobs: - name: Unit test (workspace) cache-key: workspace command: cargo test --workspace --verbose + - name: Compatibility crate + cache-key: compatibility-crate + command: scripts/check-compatibility-crate.sh && cargo test --verbose --package posthog-rs --all-features && cargo check --verbose --package posthog-rs --no-default-features - name: Unit test (blocking client) cache-key: blocking-client command: cargo test --verbose --no-default-features diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 195ffd2d..d18d1530 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,7 +44,7 @@ jobs: notify-approval-needed: name: Notify Slack - Approval Needed needs: check-changesets - if: needs.check-changesets.outputs.has-changesets == 'true' + if: needs.check-changesets.outputs.has-changesets == 'true' && github.run_attempt == 1 uses: posthog/.github/.github/workflows/notify-approval-needed.yml@5fc4680761e8ac29a61b212756230eba0e276d8c with: slack_channel_id: ${{ vars.SLACK_APPROVALS_CLIENT_LIBRARIES_CHANNEL_ID }} @@ -57,7 +57,11 @@ jobs: name: Release and publish needs: [check-changesets, notify-approval-needed] runs-on: ubuntu-latest - if: always() && needs.check-changesets.outputs.has-changesets == 'true' + if: >- + always() && + needs.check-changesets.result == 'success' && + (needs.check-changesets.outputs.has-changesets == 'true' || + github.run_attempt > 1) environment: "Release" permissions: contents: write @@ -65,7 +69,7 @@ jobs: id-token: write steps: - name: Notify Slack - Approved - if: needs.notify-approval-needed.outputs.slack_ts != '' + if: needs.notify-approval-needed.outputs.slack_ts != '' && github.run_attempt == 1 uses: posthog/.github/.github/actions/slack-thread-reply@cb0979b67dcd585828b61ac45927eef4da8f6287 # main with: slack_bot_token: ${{ secrets.SLACK_CLIENT_LIBRARIES_BOT_TOKEN }} @@ -88,6 +92,59 @@ jobs: fetch-depth: 0 token: ${{ steps.releaser.outputs.token }} + - name: Locate prepared release on retry + id: retry-release + env: + RUN_ATTEMPT: ${{ github.run_attempt }} + RUN_ID: ${{ github.run_id }} + TRIGGER_SHA: ${{ github.sha }} + run: | + echo "is-resume=false" >> "$GITHUB_OUTPUT" + if [ "$RUN_ATTEMPT" -le 1 ]; then + exit 0 + fi + + git fetch origin main --tags + if ! git merge-base --is-ancestor "$TRIGGER_SHA" origin/main; then + echo "The original workflow commit is no longer on main; continuing as a normal retry" + exit 0 + fi + + release_commit="" + release_version="" + while IFS= read -r commit; do + if ! git log -1 --format=%B "$commit" | + grep -Fx "Release-Workflow-Run: ${RUN_ID}" >/dev/null; then + continue + fi + subject=$(git log -1 --pretty=%s "$commit") + case "$subject" in + "chore: Release v"*" [skip ci]") + version=${subject#"chore: Release v"} + version=${version%" [skip ci]"} + manifest_version=$(git show "$commit:Cargo.toml" | grep '^version = ' | head -1 | sed 's/version = "\(.*\)"/\1/') + shim_version=$(git show "$commit:crates/posthog-rs/Cargo.toml" | grep '^version = ' | head -1 | sed 's/version = "\(.*\)"/\1/') + if [ "$manifest_version" = "$version" ] && + [ "$shim_version" = "$version" ] && + git show "$commit:CHANGELOG.md" | grep "^## ${version} " >/dev/null; then + release_commit="$commit" + release_version="$version" + break + fi + ;; + esac + done < <(git rev-list --reverse --first-parent "$TRIGGER_SHA..origin/main") + + if [ -z "$release_commit" ]; then + echo "No prepared release commit found; continuing as a normal retry" + exit 0 + fi + + git switch -C main "$release_commit" + echo "is-resume=true" >> "$GITHUB_OUTPUT" + echo "release-commit=$release_commit" >> "$GITHUB_OUTPUT" + echo "Resuming release ${release_version} from ${release_commit}" + - name: Install Rust uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # v1.93.1 with: @@ -99,13 +156,14 @@ jobs: uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ~/.cargo/bin/sampo - key: sampo-${{ runner.os }}-${{ runner.arch }} + key: sampo-0.19.0-${{ runner.os }}-${{ runner.arch }} - name: Install Sampo CLI if: steps.cache-sampo.outputs.cache-hit != 'true' - run: cargo install sampo + run: cargo install sampo --version 0.19.0 --locked - name: Prepare release with Sampo + if: steps.retry-release.outputs.is-resume != 'true' id: sampo-release env: GITHUB_TOKEN: ${{ steps.releaser.outputs.token }} @@ -115,6 +173,7 @@ jobs: echo "new_version=$new_version" >> "$GITHUB_OUTPUT" - name: Check for changes + if: steps.retry-release.outputs.is-resume != 'true' id: check-changes run: | if git diff --quiet; then @@ -127,57 +186,217 @@ jobs: - name: Commit release changes if: steps.check-changes.outputs.committed == 'true' + id: release-commit uses: planetscale/ghcommit-action@a6b150b81dca5dd027baa898604418eec9e11465 with: - commit_message: "chore: Release v${{ steps.sampo-release.outputs.new_version }} [skip ci]" + commit_message: | + chore: Release v${{ steps.sampo-release.outputs.new_version }} [skip ci] + + Release-Workflow-Run: ${{ github.run_id }} repo: ${{ github.repository }} branch: main env: GITHUB_TOKEN: ${{ steps.releaser.outputs.token }} - # ghcommit-action commits via the GitHub API, so the local working - # tree still has dirty files. Discard them (already committed remotely) - # and pull, otherwise cargo publish fails with "files contain changes - # not yet committed". + # ghcommit-action commits via the GitHub API, so the local working tree + # still has dirty files. Discard them and check out the exact release + # commit; main may advance while the release is awaiting approval. - name: Sync local repository if: steps.check-changes.outputs.committed == 'true' - run: git checkout -- . && git pull origin main + env: + RELEASE_COMMIT: ${{ steps.release-commit.outputs.commit-hash }} + run: | + git checkout -- . + git fetch origin main + git switch -C main "$RELEASE_COMMIT" + if ! git merge-base --is-ancestor "$RELEASE_COMMIT" origin/main; then + echo "Release commit does not belong to the main branch" >&2 + exit 1 + fi - - name: Publish dry-run - if: steps.check-changes.outputs.committed == 'true' - run: cargo publish --workspace --dry-run + - name: Resolve release details + id: release-details + env: + RESUME_MODE: ${{ steps.retry-release.outputs.is-resume }} + PREPARED_VERSION: ${{ steps.sampo-release.outputs.new_version }} + COMMITTED: ${{ steps.check-changes.outputs.committed }} + run: | + if [ "$RESUME_MODE" = "true" ]; then + version=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/') + expected_subject="chore: Release v${version} [skip ci]" + actual_subject=$(git log -1 --pretty=%s) + if [ "$actual_subject" != "$expected_subject" ]; then + echo "Retry target is not the release commit for v${version}" >&2 + exit 1 + fi + if ! grep -q "^## ${version} " CHANGELOG.md; then + echo "CHANGELOG.md does not contain a release entry for ${version}" >&2 + exit 1 + fi + if git show-ref --verify --quiet "refs/tags/${version}"; then + tag_sha=$(git rev-list -n 1 "$version") + if [ "$tag_sha" != "$(git rev-parse HEAD)" ]; then + echo "Tag ${version} does not point to the retry commit" >&2 + exit 1 + fi + fi + should_publish=true + else + version="$PREPARED_VERSION" + should_publish="$COMMITTED" + fi + + if [ -z "$version" ]; then + echo "Could not resolve the release version" >&2 + exit 1 + fi + + canonical_version=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/') + shim_version=$(grep '^version = ' crates/posthog-rs/Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/') + if [ "$canonical_version" != "$version" ] || [ "$shim_version" != "$version" ]; then + echo "posthog and posthog-rs versions are not synchronized at ${version}" >&2 + exit 1 + fi + + echo "version=$version" >> "$GITHUB_OUTPUT" + echo "should-publish=$should_publish" >> "$GITHUB_OUTPUT" + + - name: Workspace publish dry-run + if: steps.release-details.outputs.should-publish == 'true' + run: cargo publish --workspace --dry-run --locked --package posthog --package posthog-rs + + - name: Check crates.io release state + if: steps.release-details.outputs.should-publish == 'true' + id: registry + env: + RESUME_MODE: ${{ steps.retry-release.outputs.is-resume }} + VERSION: ${{ steps.release-details.outputs.version }} + run: | + check_crate() { + local name="$1" + local code + if ! code=$(curl --silent --show-error --location \ + --retry 3 --retry-all-errors \ + --header "User-Agent: posthog-rs-release-workflow" \ + --output /dev/null --write-out '%{http_code}' \ + "https://crates.io/api/v1/crates/${name}/${VERSION}"); then + echo "Failed to check crates.io for ${name}@${VERSION}" >&2 + return 1 + fi + case "$code" in + 200) echo true ;; + 404) echo false ;; + *) + echo "Unexpected crates.io response ${code} for ${name}@${VERSION}" >&2 + return 1 + ;; + esac + } + + posthog_rs_exists=$(check_crate posthog-rs) + posthog_exists=$(check_crate posthog) + echo "posthog_rs_exists=$posthog_rs_exists" >> "$GITHUB_OUTPUT" + echo "posthog_exists=$posthog_exists" >> "$GITHUB_OUTPUT" + + if [ "$RESUME_MODE" != "true" ] && \ + { [ "$posthog_rs_exists" = "true" ] || [ "$posthog_exists" = "true" ]; }; then + echo "Release version ${VERSION} already exists on crates.io" >&2 + exit 1 + fi - name: Authenticate with crates.io - if: steps.check-changes.outputs.committed == 'true' + if: >- + steps.release-details.outputs.should-publish == 'true' && + (steps.registry.outputs.posthog_rs_exists != 'true' || + steps.registry.outputs.posthog_exists != 'true') uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1.0.5 id: crates-auth - - name: Configure git identity - if: steps.check-changes.outputs.committed == 'true' - run: | - git config user.name "posthog-rs-releaser[bot]" - git config user.email "posthog-rs-releaser[bot]@users.noreply.github.com" + - name: Publish posthog + if: steps.release-details.outputs.should-publish == 'true' && steps.registry.outputs.posthog_exists != 'true' + env: + CARGO_REGISTRY_TOKEN: ${{ steps.crates-auth.outputs.token }} + run: cargo publish --locked --package posthog - - name: Publish with Sampo - if: steps.check-changes.outputs.committed == 'true' + - name: Publish posthog-rs compatibility crate + if: steps.release-details.outputs.should-publish == 'true' && steps.registry.outputs.posthog_rs_exists != 'true' env: - GITHUB_TOKEN: ${{ steps.releaser.outputs.token }} CARGO_REGISTRY_TOKEN: ${{ steps.crates-auth.outputs.token }} - run: sampo publish + RETRY_TIMES: 20 + RETRY_WAIT_SECONDS: 5 + run: | + for attempt in $(seq 1 "$RETRY_TIMES"); do + if cargo publish --locked --package posthog-rs; then + exit 0 + fi + if [ "$attempt" -eq "$RETRY_TIMES" ]; then + exit 1 + fi + echo "posthog-rs publication failed while the crates.io index may still be updating; retrying in ${RETRY_WAIT_SECONDS}s" + sleep "$RETRY_WAIT_SECONDS" + done + + - name: Ensure release tags + if: steps.release-details.outputs.should-publish == 'true' + env: + VERSION: ${{ steps.release-details.outputs.version }} + run: | + head_sha=$(git rev-parse HEAD) + ensure_tag() { + local tag="$1" + if git show-ref --verify --quiet "refs/tags/${tag}"; then + tag_sha=$(git rev-list -n 1 "$tag") + if [ "$tag_sha" != "$head_sha" ]; then + echo "Tag ${tag} does not point to the release commit" >&2 + exit 1 + fi + else + git tag "$tag" + fi + } + + ensure_tag "$VERSION" + ensure_tag "posthog-rs-v${VERSION}" + git push origin "refs/tags/${VERSION}" "refs/tags/posthog-rs-v${VERSION}" - name: Create GitHub Release - if: steps.check-changes.outputs.committed == 'true' + if: steps.release-details.outputs.should-publish == 'true' env: GITHUB_TOKEN: ${{ steps.releaser.outputs.token }} - NEW_VERSION: ${{ steps.sampo-release.outputs.new_version }} + NEW_VERSION: ${{ steps.release-details.outputs.version }} run: | + release_sha=$(git rev-parse HEAD) CHANGELOG_ENTRY=$(awk -v defText="see CHANGELOG.md" '/^## /{if (flag) exit; flag=1; next} flag; END{if (!flag) print defText}' CHANGELOG.md | sed '/[^[:space:]]/,$!d' | tac | sed '/[^[:space:]]/,$!d' | tac) - gh release create "$NEW_VERSION" --target main --notes "$CHANGELOG_ENTRY" + create_error=$(mktemp) + for attempt in $(seq 1 5); do + if gh release create "$NEW_VERSION" \ + --target "$release_sha" \ + --notes "$CHANGELOG_ENTRY" 2>"$create_error"; then + rm -f "$create_error" + echo "Created GitHub Release ${NEW_VERSION}" + exit 0 + fi + + if gh release view "$NEW_VERSION" >/dev/null 2>&1; then + rm -f "$create_error" + echo "GitHub Release ${NEW_VERSION} exists after a failed create response" + exit 0 + fi + + if [ "$attempt" -eq 5 ]; then + cat "$create_error" >&2 + rm -f "$create_error" + exit 1 + fi + + echo "GitHub Release ${NEW_VERSION} is not visible after a failed create response; retrying" + sleep 2 + done - name: Dispatch posthog upgrade for posthog-rs - if: steps.check-changes.outputs.committed == 'true' + if: steps.release-details.outputs.should-publish == 'true' env: - PACKAGE_VERSION: ${{ steps.sampo-release.outputs.new_version }} + PACKAGE_VERSION: ${{ steps.release-details.outputs.version }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | curl -f -sS -X POST \ @@ -207,9 +426,9 @@ jobs: "sdk": "posthog-rs", "jobName": "release", "packageName": "posthog-rs", - "packageVersion": "${{ steps.sampo-release.outputs.new_version || 'unknown' }}", + "packageVersion": "${{ steps.release-details.outputs.version || steps.sampo-release.outputs.new_version || 'unknown' }}", "actionUrl": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}", - "alertText": ":rotating_light: Failed to release posthog-rs@${{ steps.sampo-release.outputs.new_version }} :rotating_light:", + "alertText": ":rotating_light: Failed to release posthog-rs/posthog@${{ steps.release-details.outputs.version || steps.sampo-release.outputs.new_version || 'unknown' }} :rotating_light:", "alertContext": "The release workflow failed before completion." } @@ -220,7 +439,7 @@ jobs: slack_bot_token: ${{ secrets.SLACK_CLIENT_LIBRARIES_BOT_TOKEN }} slack_channel_id: ${{ vars.SLACK_APPROVALS_CLIENT_LIBRARIES_CHANNEL_ID }} thread_ts: ${{ needs.notify-approval-needed.outputs.slack_ts }} - message: "❌ Failed to release `posthog-rs@${{ steps.sampo-release.outputs.new_version }}`! " + message: "❌ Failed to release `posthog-rs/posthog@${{ steps.release-details.outputs.version || steps.sampo-release.outputs.new_version || 'unknown' }}`! " emoji_reaction: "x" notify-released: @@ -238,5 +457,5 @@ jobs: slack_bot_token: ${{ secrets.SLACK_CLIENT_LIBRARIES_BOT_TOKEN }} slack_channel_id: ${{ vars.SLACK_APPROVALS_CLIENT_LIBRARIES_CHANNEL_ID }} thread_ts: ${{ needs.notify-approval-needed.outputs.slack_ts }} - message: "🚀 posthog-rs released successfully!" + message: "🚀 posthog and posthog-rs released successfully!" emoji_reaction: "rocket" diff --git a/.sampo/changesets/cantankerous-count-kullervo.md b/.sampo/changesets/cantankerous-count-kullervo.md index 95dff749..a8362573 100644 --- a/.sampo/changesets/cantankerous-count-kullervo.md +++ b/.sampo/changesets/cantankerous-count-kullervo.md @@ -1,5 +1,5 @@ --- -cargo/posthog-rs: major +cargo/posthog: major --- Remove deprecated feature flag methods and the `personal_api_key` builder alias, and rename `LocalEvaluationConfig::personal_api_key` to `secret_key`. diff --git a/.sampo/changesets/chivalrous-prince-aurelien.md b/.sampo/changesets/chivalrous-prince-aurelien.md index 252b418f..b4ca244b 100644 --- a/.sampo/changesets/chivalrous-prince-aurelien.md +++ b/.sampo/changesets/chivalrous-prince-aurelien.md @@ -1,5 +1,5 @@ --- -cargo/posthog-rs: major +cargo/posthog: major --- Mark EvaluateFlagsOptions as non-exhaustive so new options can be added without breaking future minor releases. diff --git a/.sampo/changesets/remove-v0-capture.md b/.sampo/changesets/remove-v0-capture.md index 32f7913d..029d3607 100644 --- a/.sampo/changesets/remove-v0-capture.md +++ b/.sampo/changesets/remove-v0-capture.md @@ -1,5 +1,5 @@ --- -cargo/posthog-rs: major +cargo/posthog: major --- Remove the legacy V0 capture pipeline. Capture V1 (`POST /i/v1/analytics/events`) is now the only capture implementation and the `capture-v1` Cargo feature has been removed. diff --git a/.sampo/changesets/rename-posthog.md b/.sampo/changesets/rename-posthog.md new file mode 100644 index 00000000..b0cd3d33 --- /dev/null +++ b/.sampo/changesets/rename-posthog.md @@ -0,0 +1,5 @@ +--- +cargo/posthog: patch +--- + +Publish the SDK implementation as `posthog` and keep `posthog-rs` as a compatibility crate that re-exports it. diff --git a/.sampo/config.toml b/.sampo/config.toml index c2b0295b..a097651a 100644 --- a/.sampo/config.toml +++ b/.sampo/config.toml @@ -3,7 +3,8 @@ version = 1 [git] default_branch = "main" -short_tags = "posthog-rs" # Tag with v1.2.3 rather than posthog-rs-v1.2.3 +short_tags = "posthog" +short_tags_format = "{version}" # Preserve the existing bare release tags [github] repository = "posthog/posthog-rs" @@ -14,4 +15,5 @@ repository = "posthog/posthog-rs" # show_acknowledgments = true (default) [packages] +fixed = [["cargo/posthog", "cargo/posthog-rs"]] ignore = ["compliance/*"] diff --git a/CHANGELOG.md b/CHANGELOG.md index ffbed159..6e74a6ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# posthog-rs +# posthog ## 0.25.4 — 2026-08-31 diff --git a/Cargo.lock b/Cargo.lock index 4f5112ad..7784ee9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1624,7 +1624,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" [[package]] -name = "posthog-rs" +name = "posthog" version = "0.25.4" dependencies = [ "backtrace", @@ -1652,6 +1652,13 @@ dependencies = [ "zstd", ] +[[package]] +name = "posthog-rs" +version = "0.25.4" +dependencies = [ + "posthog", +] + [[package]] name = "potential_utf" version = "0.1.6" @@ -1998,7 +2005,7 @@ version = "0.1.0" dependencies = [ "axum", "chrono", - "posthog-rs", + "posthog", "serde", "serde_json", "tokio", diff --git a/Cargo.toml b/Cargo.toml index f3502606..e2ea6bd8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "posthog-rs" +name = "posthog" license = "MIT" version = "0.25.4" authors = ["PostHog "] -description = "The official Rust client for Posthog (https://posthog.com/)." +description = "The official Rust SDK for PostHog (https://posthog.com/)." repository = "https://github.com/posthog/posthog-rs" edition = "2018" rust-version = "1.78.0" @@ -59,4 +59,4 @@ tls = ["reqwest/rustls"] tls-no-provider = ["reqwest/rustls-no-provider"] [workspace] -members = [".", "compliance/adapter"] +members = [".", "compliance/adapter", "crates/posthog-rs"] diff --git a/README.md b/README.md index 453e4c78..b6729992 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # PostHog Rust -[![Crates.io](https://img.shields.io/crates/v/posthog-rs.svg)](https://crates.io/crates/posthog-rs) -[![Documentation](https://docs.rs/posthog-rs/badge.svg)](https://docs.rs/posthog-rs) +[![Crates.io](https://img.shields.io/crates/v/posthog.svg)](https://crates.io/crates/posthog) +[![Documentation](https://docs.rs/posthog/badge.svg)](https://docs.rs/posthog) -The official Rust SDK for [PostHog](https://posthog.com). See the main [PostHog docs](https://posthog.com/docs) for more information. +The official Rust SDK for [PostHog](https://posthog.com), published as [`posthog`](https://crates.io/crates/posthog). The former [`posthog-rs`](https://crates.io/crates/posthog-rs) package remains available as a compatibility crate that re-exports `posthog`. See the main [PostHog docs](https://posthog.com/docs) for more information. Upgrading from a 0.x release? Read the [1.0 migration guide](docs/migration-0.x-to-1.0.md). diff --git a/RELEASING.md b/RELEASING.md index c17483de..c8ebd74f 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,6 +1,6 @@ # Releasing -This repository uses [Sampo](https://github.com/bruits/sampo) for versioning, changelogs, and publishing to crates.io. +This repository uses [Sampo](https://github.com/bruits/sampo) for versioning and changelogs, then publishes the workspace crates to crates.io in dependency order. 1. When making changes, include a changeset: `sampo add` - Prefer letting `sampo add` create the file for you. @@ -8,7 +8,7 @@ This repository uses [Sampo](https://github.com/bruits/sampo) for versioning, ch ```md --- - cargo/posthog-rs: patch + cargo/posthog: patch --- ``` @@ -16,6 +16,10 @@ This repository uses [Sampo](https://github.com/bruits/sampo) for versioning, ch 2. Create a PR with your changes and the changeset file 3. Merge to `main` (no release label required) -4. Approve the release in Slack when prompted — this triggers version bump, crates.io publish, git tag, and GitHub Release +4. Approve the release in Slack when prompted — this triggers the version bump, publishes the `posthog` implementation followed by the `posthog-rs` compatibility crate, creates the git tags, and creates the GitHub Release You can also trigger a release manually via the workflow's `workflow_dispatch` trigger (still requires pending changesets). + +If a release fails, use **Re-run failed jobs** on that workflow run. The retry locates the exact release commit created by the original attempt, validates both packages, skips crate versions already on crates.io, and completes any missing publication, tag, or GitHub Release. + +Both crates must configure crates.io Trusted Publishing for the `PostHog/posthog-rs` repository, `release.yml` workflow, and `Release` environment. The single short-lived CI token can then publish both packages. diff --git a/api/public-api.txt b/api/public-api.txt index b2338bed..ac9f474b 100644 --- a/api/public-api.txt +++ b/api/public-api.txt @@ -1,383 +1,383 @@ # This file is generated by `scripts/check-public-api.sh --update`. # Do not edit manually. -# Public API scope: exported Rust API for the posthog-rs crate with public-facing features enabled. +# Public API scope: exported Rust API for the posthog crate with public-facing features enabled. # Test-only harness features are omitted. -pub mod posthog_rs -pub enum posthog_rs::CaptureCompression -pub posthog_rs::CaptureCompression::Br -pub posthog_rs::CaptureCompression::Deflate -pub posthog_rs::CaptureCompression::Gzip -pub posthog_rs::CaptureCompression::Zstd -#[non_exhaustive] pub enum posthog_rs::ClientOptionsBuilderError -pub posthog_rs::ClientOptionsBuilderError::UninitializedField(&'static str) -pub posthog_rs::ClientOptionsBuilderError::ValidationError(alloc::string::String) -impl core::convert::From for posthog_rs::ClientOptionsBuilderError -pub fn posthog_rs::ClientOptionsBuilderError::from(alloc::string::String) -> Self -impl core::convert::From for posthog_rs::ClientOptionsBuilderError -pub fn posthog_rs::ClientOptionsBuilderError::from(derive_builder::error::UninitializedFieldError) -> Self -impl core::error::Error for posthog_rs::ClientOptionsBuilderError -impl core::fmt::Display for posthog_rs::ClientOptionsBuilderError -pub fn posthog_rs::ClientOptionsBuilderError::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result -#[non_exhaustive] pub enum posthog_rs::Endpoint -pub posthog_rs::Endpoint::Capture -pub posthog_rs::Endpoint::CaptureAi -pub posthog_rs::Endpoint::Flags -pub posthog_rs::Endpoint::LocalEvaluation -impl posthog_rs::Endpoint -pub fn posthog_rs::Endpoint::path(&self) -> &str -impl core::fmt::Display for posthog_rs::Endpoint -pub fn posthog_rs::Endpoint::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result -#[non_exhaustive] pub enum posthog_rs::Error -pub posthog_rs::Error::AlreadyInitialized -pub posthog_rs::Error::BadRequest(alloc::string::String) -pub posthog_rs::Error::BillingLimitExceeded(alloc::string::String) -pub posthog_rs::Error::Connection(alloc::string::String) -pub posthog_rs::Error::InconclusiveMatch(alloc::string::String) -pub posthog_rs::Error::InvalidTimestamp(alloc::string::String) -pub posthog_rs::Error::NotInitialized -pub posthog_rs::Error::PanicHookAlreadyInstalled -pub posthog_rs::Error::RateLimit -pub posthog_rs::Error::Serialization(alloc::string::String) -pub posthog_rs::Error::ServerError -pub posthog_rs::Error::ServerError::message: alloc::string::String -pub posthog_rs::Error::ServerError::status: u16 -pub posthog_rs::Error::Unauthorized -impl core::error::Error for posthog_rs::Error -impl core::fmt::Display for posthog_rs::Error -pub fn posthog_rs::Error::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result -#[non_exhaustive] pub enum posthog_rs::ErrorTrackingOptionsBuilderError -pub posthog_rs::ErrorTrackingOptionsBuilderError::UninitializedField(&'static str) -pub posthog_rs::ErrorTrackingOptionsBuilderError::ValidationError(alloc::string::String) -impl core::convert::From for posthog_rs::ErrorTrackingOptionsBuilderError -pub fn posthog_rs::ErrorTrackingOptionsBuilderError::from(alloc::string::String) -> Self -impl core::convert::From for posthog_rs::ErrorTrackingOptionsBuilderError -pub fn posthog_rs::ErrorTrackingOptionsBuilderError::from(derive_builder::error::UninitializedFieldError) -> Self -impl core::error::Error for posthog_rs::ErrorTrackingOptionsBuilderError -impl core::fmt::Display for posthog_rs::ErrorTrackingOptionsBuilderError -pub fn posthog_rs::ErrorTrackingOptionsBuilderError::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result -#[non_exhaustive] pub enum posthog_rs::EventStatus -pub posthog_rs::EventStatus::Drop -pub posthog_rs::EventStatus::Ok -pub posthog_rs::EventStatus::Retry -pub posthog_rs::EventStatus::Unknown -pub posthog_rs::EventStatus::Warning -#[non_exhaustive] pub enum posthog_rs::FeatureFlagsResponse -pub posthog_rs::FeatureFlagsResponse::Legacy -pub posthog_rs::FeatureFlagsResponse::Legacy::errors: core::option::Option> -pub posthog_rs::FeatureFlagsResponse::Legacy::feature_flag_payloads: std::collections::hash::map::HashMap -pub posthog_rs::FeatureFlagsResponse::Legacy::feature_flags: std::collections::hash::map::HashMap -pub posthog_rs::FeatureFlagsResponse::V2 -pub posthog_rs::FeatureFlagsResponse::V2::errors_while_computing_flags: bool -pub posthog_rs::FeatureFlagsResponse::V2::flags: std::collections::hash::map::HashMap -pub posthog_rs::FeatureFlagsResponse::V2::minimal_flag_called_events: bool -pub posthog_rs::FeatureFlagsResponse::V2::quota_limited: bool -pub posthog_rs::FeatureFlagsResponse::V2::request_id: core::option::Option -impl posthog_rs::FeatureFlagsResponse -pub fn posthog_rs::FeatureFlagsResponse::normalize(self) -> (std::collections::hash::map::HashMap, std::collections::hash::map::HashMap) -pub enum posthog_rs::FlagValue -pub posthog_rs::FlagValue::Boolean(bool) -pub posthog_rs::FlagValue::String(alloc::string::String) -impl core::default::Default for posthog_rs::FlagValue -pub fn posthog_rs::FlagValue::default() -> Self -#[non_exhaustive] pub enum posthog_rs::PostHogError<'a> -pub posthog_rs::PostHogError::Capture(posthog_rs::CaptureFailure<'a>) -pub posthog_rs::PostHogError::FeatureFlags(posthog_rs::FlagsFailure<'a>) -pub posthog_rs::PostHogError::LocalEvaluation(posthog_rs::LocalEvaluationFailure<'a>) -pub struct posthog_rs::AsyncFlagPoller -impl posthog_rs::AsyncFlagPoller -pub async fn posthog_rs::AsyncFlagPoller::is_running(&self) -> bool -pub async fn posthog_rs::AsyncFlagPoller::load_flags(&self) -> core::result::Result<(), posthog_rs::Error> -pub fn posthog_rs::AsyncFlagPoller::new(posthog_rs::LocalEvaluationConfig, posthog_rs::FlagCache) -> Self -pub async fn posthog_rs::AsyncFlagPoller::start(&mut self) -pub async fn posthog_rs::AsyncFlagPoller::stop(&mut self) -impl core::ops::drop::Drop for posthog_rs::AsyncFlagPoller -pub fn posthog_rs::AsyncFlagPoller::drop(&mut self) -pub struct posthog_rs::BeforeSendHook(_) -impl posthog_rs::BeforeSendHook -pub fn posthog_rs::BeforeSendHook::new(F) -> Self where F: core::ops::function::FnMut(posthog_rs::Event) -> core::option::Option + core::marker::Send + 'static -#[non_exhaustive] pub struct posthog_rs::CaptureErrorResponse -pub posthog_rs::CaptureErrorResponse::error: alloc::string::String -pub posthog_rs::CaptureErrorResponse::error_description: core::option::Option -pub posthog_rs::CaptureErrorResponse::error_uri: core::option::Option -pub struct posthog_rs::CaptureExceptionOptions -impl posthog_rs::CaptureExceptionOptions -pub fn posthog_rs::CaptureExceptionOptions::distinct_id>(self, S) -> Self -pub fn posthog_rs::CaptureExceptionOptions::fingerprint>(self, S) -> Self -pub fn posthog_rs::CaptureExceptionOptions::group, I: core::convert::Into>(self, N, I) -> Self -pub fn posthog_rs::CaptureExceptionOptions::level>(self, S) -> Self -pub fn posthog_rs::CaptureExceptionOptions::new() -> Self -pub fn posthog_rs::CaptureExceptionOptions::property, V: serde_core::ser::Serialize>(self, K, V) -> core::result::Result -pub fn posthog_rs::CaptureExceptionOptions::trace_context, S: core::convert::Into>(self, T, S) -> Self -#[non_exhaustive] pub struct posthog_rs::CaptureFailure<'a> -impl<'a> posthog_rs::CaptureFailure<'a> -pub fn posthog_rs::CaptureFailure<'a>::attempt(&self) -> u32 -pub fn posthog_rs::CaptureFailure<'a>::endpoint(&self) -> posthog_rs::Endpoint -pub fn posthog_rs::CaptureFailure<'a>::error(&self) -> core::option::Option<&posthog_rs::Error> -pub fn posthog_rs::CaptureFailure<'a>::error_response(&self) -> core::option::Option<&posthog_rs::CaptureErrorResponse> -pub fn posthog_rs::CaptureFailure<'a>::event_count(&self) -> usize -pub fn posthog_rs::CaptureFailure<'a>::event_results(&self) -> &std::collections::hash::map::HashMap -pub fn posthog_rs::CaptureFailure<'a>::historical_migration(&self) -> bool -pub fn posthog_rs::CaptureFailure<'a>::request_id(&self) -> core::option::Option<&uuid::Uuid> -pub fn posthog_rs::CaptureFailure<'a>::status(&self) -> core::option::Option -#[non_exhaustive] pub struct posthog_rs::CaptureResponse -pub posthog_rs::CaptureResponse::results: std::collections::hash::map::HashMap -#[non_exhaustive] pub struct posthog_rs::CaptureSummary -impl posthog_rs::CaptureSummary -pub fn posthog_rs::CaptureSummary::all_persisted(&self) -> bool -pub fn posthog_rs::CaptureSummary::event_results(&self) -> &std::collections::hash::map::HashMap -pub fn posthog_rs::CaptureSummary::not_persisted(&self) -> usize -pub fn posthog_rs::CaptureSummary::submitted(&self) -> usize -pub struct posthog_rs::Client -impl posthog_rs::Client -pub fn posthog_rs::Client::alias, D: core::convert::Into>(&self, P, D) -pub fn posthog_rs::Client::capture(&self, posthog_rs::Event) -pub fn posthog_rs::Client::capture_ai(&self, posthog_rs::Event) -pub fn posthog_rs::Client::capture_ai_batch(&self, alloc::vec::Vec, bool) -pub async fn posthog_rs::Client::capture_ai_batch_immediate(&self, alloc::vec::Vec, bool) -> core::result::Result -pub async fn posthog_rs::Client::capture_ai_immediate(&self, posthog_rs::Event) -> core::result::Result -pub fn posthog_rs::Client::capture_batch(&self, alloc::vec::Vec, bool) -pub async fn posthog_rs::Client::capture_batch_immediate(&self, alloc::vec::Vec, bool) -> core::result::Result -pub async fn posthog_rs::Client::capture_exception(&self, &E) -> core::result::Result<(), posthog_rs::Error> where E: core::error::Error + ?core::marker::Sized -pub async fn posthog_rs::Client::capture_exception_with(&self, &E, posthog_rs::CaptureExceptionOptions) -> core::result::Result<(), posthog_rs::Error> where E: core::error::Error + ?core::marker::Sized -pub async fn posthog_rs::Client::capture_immediate(&self, posthog_rs::Event) -> core::result::Result -pub fn posthog_rs::Client::evaluate_feature_flag_locally(&self, &posthog_rs::FeatureFlag, &str, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap>) -> core::result::Result -pub async fn posthog_rs::Client::evaluate_flags>(&self, S, posthog_rs::EvaluateFlagsOptions) -> core::result::Result -pub async fn posthog_rs::Client::flush(&self) -pub fn posthog_rs::Client::group_identify, K: core::convert::Into, P: serde_core::ser::Serialize>(&self, T, K, P) -> core::result::Result<(), posthog_rs::Error> -pub async fn posthog_rs::Client::shutdown(&self) -impl core::ops::drop::Drop for posthog_rs::Client -pub fn posthog_rs::Client::drop(&mut self) -pub struct posthog_rs::ClientOptions -impl posthog_rs::ClientOptions -pub fn posthog_rs::ClientOptions::is_disabled(&self) -> bool -impl core::convert::From<&str> for posthog_rs::ClientOptions -pub fn posthog_rs::ClientOptions::from(&str) -> Self -impl core::convert::From<(&str, &str)> for posthog_rs::ClientOptions -pub fn posthog_rs::ClientOptions::from((&str, &str)) -> Self -pub struct posthog_rs::ClientOptionsBuilder -impl posthog_rs::ClientOptionsBuilder -pub fn posthog_rs::ClientOptionsBuilder::api_key(&mut self, alloc::string::String) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::capture_ai_compression(&mut self, posthog_rs::CaptureCompression) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::capture_ai_max_queue_size(&mut self, usize) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::capture_compression(&mut self, posthog_rs::CaptureCompression) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::disable_geoip(&mut self, bool) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::disabled(&mut self, bool) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::enable_local_evaluation(&mut self, bool) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::error_tracking(&mut self, posthog_rs::ErrorTrackingOptions) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::feature_flags_request_max_retries(&mut self, u32) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::feature_flags_request_timeout_seconds(&mut self, u64) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::flush_at(&mut self, usize) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::flush_interval_ms(&mut self, u64) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::host>(&mut self, VALUE) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::is_server(&mut self, bool) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::local_evaluation_only(&mut self, bool) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::max_batch_size(&mut self, usize) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::max_capture_attempts(&mut self, u32) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::max_queue_size(&mut self, usize) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::poll_interval_seconds(&mut self, u64) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::request_timeout_seconds(&mut self, u64) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::retry_initial_backoff_ms(&mut self, u64) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::retry_max_backoff_ms(&mut self, u64) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::secret_key>(&mut self, VALUE) -> &mut Self -pub fn posthog_rs::ClientOptionsBuilder::shutdown_timeout_ms(&mut self, u64) -> &mut Self -impl posthog_rs::ClientOptionsBuilder -pub fn posthog_rs::ClientOptionsBuilder::before_send(&mut self, F) -> &mut Self where F: core::ops::function::FnMut(posthog_rs::Event) -> core::option::Option + core::marker::Send + 'static -pub fn posthog_rs::ClientOptionsBuilder::build(&self) -> core::result::Result -pub fn posthog_rs::ClientOptionsBuilder::on_error(&mut self, F) -> &mut Self where F: core::ops::function::Fn(&posthog_rs::PostHogError<'_>) + core::marker::Send + core::marker::Sync + 'static -impl core::default::Default for posthog_rs::ClientOptionsBuilder -pub fn posthog_rs::ClientOptionsBuilder::default() -> Self -pub struct posthog_rs::Cohort -pub posthog_rs::Cohort::properties: serde_json::value::Value -pub struct posthog_rs::CohortDefinition -pub posthog_rs::CohortDefinition::id: alloc::string::String -pub posthog_rs::CohortDefinition::properties: serde_json::value::Value -impl posthog_rs::CohortDefinition -pub fn posthog_rs::CohortDefinition::new(alloc::string::String, alloc::vec::Vec) -> Self -pub fn posthog_rs::CohortDefinition::parse_properties(&self) -> alloc::vec::Vec -pub struct posthog_rs::EndpointManager -impl posthog_rs::EndpointManager -pub fn posthog_rs::EndpointManager::api_host(&self) -> alloc::string::String -pub fn posthog_rs::EndpointManager::base_host(&self) -> &str -pub fn posthog_rs::EndpointManager::build_custom_url(&self, &str) -> alloc::string::String -pub fn posthog_rs::EndpointManager::build_local_eval_url(&self, &str) -> alloc::string::String -pub fn posthog_rs::EndpointManager::build_url(&self, posthog_rs::Endpoint) -> alloc::string::String -pub fn posthog_rs::EndpointManager::determine_server_host(&str) -> alloc::string::String -pub fn posthog_rs::EndpointManager::new(alloc::string::String) -> Self -pub fn posthog_rs::EndpointManager::raw_host(&self) -> &str -pub struct posthog_rs::ErrorTrackingOptions -impl core::default::Default for posthog_rs::ErrorTrackingOptions -pub fn posthog_rs::ErrorTrackingOptions::default() -> Self -pub struct posthog_rs::ErrorTrackingOptionsBuilder -impl posthog_rs::ErrorTrackingOptionsBuilder -pub fn posthog_rs::ErrorTrackingOptionsBuilder::build(&self) -> core::result::Result -pub fn posthog_rs::ErrorTrackingOptionsBuilder::capture_panics(&mut self, bool) -> &mut Self -pub fn posthog_rs::ErrorTrackingOptionsBuilder::capture_stacktrace(&mut self, bool) -> &mut Self -pub fn posthog_rs::ErrorTrackingOptionsBuilder::in_app_exclude_paths(&mut self, alloc::vec::Vec) -> &mut Self -pub fn posthog_rs::ErrorTrackingOptionsBuilder::in_app_include_paths(&mut self, alloc::vec::Vec) -> &mut Self -impl posthog_rs::ErrorTrackingOptionsBuilder -pub fn posthog_rs::ErrorTrackingOptionsBuilder::trace_context_provider(&mut self, F) -> &mut Self where F: core::ops::function::Fn() -> core::option::Option + core::marker::Send + core::marker::Sync + 'static -impl core::default::Default for posthog_rs::ErrorTrackingOptionsBuilder -pub fn posthog_rs::ErrorTrackingOptionsBuilder::default() -> Self -#[non_exhaustive] pub struct posthog_rs::EvaluateFlagsOptions -pub posthog_rs::EvaluateFlagsOptions::disable_geoip: core::option::Option -pub posthog_rs::EvaluateFlagsOptions::flag_keys: core::option::Option> -pub posthog_rs::EvaluateFlagsOptions::group_properties: core::option::Option>> -pub posthog_rs::EvaluateFlagsOptions::groups: core::option::Option> -pub posthog_rs::EvaluateFlagsOptions::only_evaluate_locally: bool -pub posthog_rs::EvaluateFlagsOptions::person_properties: core::option::Option> -pub struct posthog_rs::EvaluationContext<'a> -pub posthog_rs::EvaluationContext::cohorts: &'a std::collections::hash::map::HashMap -pub posthog_rs::EvaluationContext::distinct_id: &'a str -pub posthog_rs::EvaluationContext::flags: &'a std::collections::hash::map::HashMap -pub posthog_rs::EvaluationContext::group_properties: &'a std::collections::hash::map::HashMap> -pub posthog_rs::EvaluationContext::group_type_mapping: &'a std::collections::hash::map::HashMap -pub posthog_rs::EvaluationContext::groups: &'a std::collections::hash::map::HashMap -pub struct posthog_rs::Event -impl posthog_rs::Event -pub fn posthog_rs::Event::add_group(&mut self, &str, &str) -pub fn posthog_rs::Event::distinct_id(&self) -> &str -pub fn posthog_rs::Event::event_name(&self) -> &str -pub fn posthog_rs::Event::insert_prop, P: serde_core::ser::Serialize>(&mut self, K, P) -> core::result::Result<(), posthog_rs::Error> -pub fn posthog_rs::Event::new>(S, S) -> Self -pub fn posthog_rs::Event::new_anon>(S) -> Self -pub fn posthog_rs::Event::properties(&self) -> &std::collections::hash::map::HashMap -pub fn posthog_rs::Event::remove_prop(&mut self, &str) -> core::option::Option -pub fn posthog_rs::Event::set_timestamp(&mut self, chrono::datetime::DateTime) -> core::result::Result<(), posthog_rs::Error> where Tz: chrono::offset::TimeZone -pub fn posthog_rs::Event::set_uuid(&mut self, uuid::Uuid) -pub fn posthog_rs::Event::with_flags(&mut self, &posthog_rs::FeatureFlagEvaluations) -> &mut Self -#[non_exhaustive] pub struct posthog_rs::EventResult -pub posthog_rs::EventResult::details: core::option::Option -pub posthog_rs::EventResult::result: posthog_rs::EventStatus -pub struct posthog_rs::FeatureFlag -pub posthog_rs::FeatureFlag::active: bool -pub posthog_rs::FeatureFlag::filters: posthog_rs::FeatureFlagFilters -pub posthog_rs::FeatureFlag::has_experiment: core::option::Option -pub posthog_rs::FeatureFlag::key: alloc::string::String -pub struct posthog_rs::FeatureFlagCondition -pub posthog_rs::FeatureFlagCondition::aggregation_group_type_index: core::option::Option -pub posthog_rs::FeatureFlagCondition::properties: alloc::vec::Vec -pub posthog_rs::FeatureFlagCondition::rollout_percentage: core::option::Option -pub posthog_rs::FeatureFlagCondition::variant: core::option::Option -pub struct posthog_rs::FeatureFlagEvaluations -impl posthog_rs::FeatureFlagEvaluations -pub fn posthog_rs::FeatureFlagEvaluations::get_flag(&self, &str) -> core::option::Option -pub fn posthog_rs::FeatureFlagEvaluations::get_flag_payload(&self, &str) -> core::option::Option -pub fn posthog_rs::FeatureFlagEvaluations::is_enabled(&self, &str) -> bool -pub fn posthog_rs::FeatureFlagEvaluations::keys(&self) -> alloc::vec::Vec -pub fn posthog_rs::FeatureFlagEvaluations::only(&self, &[&str]) -> Self -pub fn posthog_rs::FeatureFlagEvaluations::only_accessed(&self) -> Self -impl core::fmt::Debug for posthog_rs::FeatureFlagEvaluations -pub fn posthog_rs::FeatureFlagEvaluations::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result -pub struct posthog_rs::FeatureFlagFilters -pub posthog_rs::FeatureFlagFilters::aggregation_group_type_index: core::option::Option -pub posthog_rs::FeatureFlagFilters::early_exit: bool -pub posthog_rs::FeatureFlagFilters::groups: alloc::vec::Vec -pub posthog_rs::FeatureFlagFilters::multivariate: core::option::Option -pub posthog_rs::FeatureFlagFilters::payloads: std::collections::hash::map::HashMap -pub struct posthog_rs::FlagCache -impl posthog_rs::FlagCache -pub fn posthog_rs::FlagCache::clear(&self) -pub fn posthog_rs::FlagCache::get_all_cohorts(&self) -> std::collections::hash::map::HashMap -pub fn posthog_rs::FlagCache::get_all_flags(&self) -> alloc::vec::Vec -pub fn posthog_rs::FlagCache::get_cohort(&self, &str) -> core::option::Option -pub fn posthog_rs::FlagCache::get_cohort_definitions(&self) -> std::collections::hash::map::HashMap -pub fn posthog_rs::FlagCache::get_flag(&self, &str) -> core::option::Option -pub fn posthog_rs::FlagCache::get_flags_map(&self) -> std::collections::hash::map::HashMap -pub fn posthog_rs::FlagCache::get_group_type_mapping(&self) -> std::collections::hash::map::HashMap -pub fn posthog_rs::FlagCache::minimal_flag_called_events(&self) -> bool -pub fn posthog_rs::FlagCache::new() -> Self -pub fn posthog_rs::FlagCache::update(&self, posthog_rs::LocalEvaluationResponse) -impl core::default::Default for posthog_rs::FlagCache -pub fn posthog_rs::FlagCache::default() -> Self -#[non_exhaustive] pub struct posthog_rs::FlagDetail -pub posthog_rs::FlagDetail::enabled: bool -pub posthog_rs::FlagDetail::key: alloc::string::String -pub posthog_rs::FlagDetail::metadata: core::option::Option -pub posthog_rs::FlagDetail::reason: core::option::Option -pub posthog_rs::FlagDetail::variant: core::option::Option -#[non_exhaustive] pub struct posthog_rs::FlagMetadata -pub posthog_rs::FlagMetadata::description: core::option::Option -pub posthog_rs::FlagMetadata::has_experiment: core::option::Option -pub posthog_rs::FlagMetadata::id: u64 -pub posthog_rs::FlagMetadata::payload: core::option::Option -pub posthog_rs::FlagMetadata::version: u32 -pub struct posthog_rs::FlagPoller -impl posthog_rs::FlagPoller -pub fn posthog_rs::FlagPoller::load_flags(&self) -> core::result::Result<(), posthog_rs::Error> -pub fn posthog_rs::FlagPoller::new(posthog_rs::LocalEvaluationConfig, posthog_rs::FlagCache) -> Self -pub fn posthog_rs::FlagPoller::start(&mut self) -pub fn posthog_rs::FlagPoller::stop(&mut self) -impl core::ops::drop::Drop for posthog_rs::FlagPoller -pub fn posthog_rs::FlagPoller::drop(&mut self) -#[non_exhaustive] pub struct posthog_rs::FlagReason -pub posthog_rs::FlagReason::code: alloc::string::String -pub posthog_rs::FlagReason::condition_index: core::option::Option -pub posthog_rs::FlagReason::description: core::option::Option -#[non_exhaustive] pub struct posthog_rs::FlagsFailure<'a> -impl<'a> posthog_rs::FlagsFailure<'a> -pub fn posthog_rs::FlagsFailure<'a>::body(&self) -> core::option::Option<&str> -pub fn posthog_rs::FlagsFailure<'a>::distinct_id(&self) -> core::option::Option<&str> -pub fn posthog_rs::FlagsFailure<'a>::endpoint(&self) -> &str -pub fn posthog_rs::FlagsFailure<'a>::error(&self) -> &posthog_rs::Error -pub fn posthog_rs::FlagsFailure<'a>::status(&self) -> core::option::Option -pub struct posthog_rs::InconclusiveMatchError -pub posthog_rs::InconclusiveMatchError::message: alloc::string::String -impl posthog_rs::InconclusiveMatchError -pub fn posthog_rs::InconclusiveMatchError::new(&str) -> Self -impl core::error::Error for posthog_rs::InconclusiveMatchError -impl core::fmt::Display for posthog_rs::InconclusiveMatchError -pub fn posthog_rs::InconclusiveMatchError::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result -pub struct posthog_rs::LocalEvaluationConfig -pub posthog_rs::LocalEvaluationConfig::api_host: alloc::string::String -pub posthog_rs::LocalEvaluationConfig::poll_interval: core::time::Duration -pub posthog_rs::LocalEvaluationConfig::project_api_key: alloc::string::String -pub posthog_rs::LocalEvaluationConfig::request_timeout: core::time::Duration -pub posthog_rs::LocalEvaluationConfig::secret_key: alloc::string::String -#[non_exhaustive] pub struct posthog_rs::LocalEvaluationFailure<'a> -impl<'a> posthog_rs::LocalEvaluationFailure<'a> -pub fn posthog_rs::LocalEvaluationFailure<'a>::error(&self) -> &posthog_rs::Error -pub fn posthog_rs::LocalEvaluationFailure<'a>::status(&self) -> core::option::Option -#[non_exhaustive] pub struct posthog_rs::LocalEvaluationResponse -pub posthog_rs::LocalEvaluationResponse::cohorts: std::collections::hash::map::HashMap -pub posthog_rs::LocalEvaluationResponse::flags: alloc::vec::Vec -pub posthog_rs::LocalEvaluationResponse::group_type_mapping: std::collections::hash::map::HashMap -pub posthog_rs::LocalEvaluationResponse::minimal_flag_called_events: bool -impl posthog_rs::LocalEvaluationResponse -pub fn posthog_rs::LocalEvaluationResponse::new(alloc::vec::Vec) -> Self -pub struct posthog_rs::LocalEvaluator -impl posthog_rs::LocalEvaluator -pub fn posthog_rs::LocalEvaluator::cache(&self) -> &posthog_rs::FlagCache -pub fn posthog_rs::LocalEvaluator::evaluate_all_flags(&self, &str, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap>) -> std::collections::hash::map::HashMap> -pub fn posthog_rs::LocalEvaluator::evaluate_flag(&self, &str, &str, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap>) -> core::result::Result, posthog_rs::InconclusiveMatchError> -pub fn posthog_rs::LocalEvaluator::evaluate_flag_simple(&self, &str, &str, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap>) -> core::result::Result, posthog_rs::InconclusiveMatchError> -pub fn posthog_rs::LocalEvaluator::new(posthog_rs::FlagCache) -> Self -pub struct posthog_rs::MultivariateFilter -pub posthog_rs::MultivariateFilter::variants: alloc::vec::Vec -pub struct posthog_rs::MultivariateVariant -pub posthog_rs::MultivariateVariant::key: alloc::string::String -pub posthog_rs::MultivariateVariant::rollout_percentage: f64 -pub struct posthog_rs::Property -pub posthog_rs::Property::key: alloc::string::String -pub posthog_rs::Property::operator: alloc::string::String -pub posthog_rs::Property::property_type: core::option::Option -pub posthog_rs::Property::value: serde_json::value::Value -pub struct posthog_rs::TraceContext -impl posthog_rs::TraceContext -pub fn posthog_rs::TraceContext::new, S: core::convert::Into>(T, S) -> Self -pub const posthog_rs::DEFAULT_HOST: &str -pub const posthog_rs::EU_INGESTION_ENDPOINT: &str -pub const posthog_rs::US_INGESTION_ENDPOINT: &str -pub fn posthog_rs::capture(posthog_rs::Event) -pub fn posthog_rs::capture_ai(posthog_rs::Event) -pub async fn posthog_rs::capture_exception(&E) -> core::result::Result<(), posthog_rs::Error> where E: core::error::Error + ?core::marker::Sized -pub async fn posthog_rs::capture_exception_with(&E, posthog_rs::CaptureExceptionOptions) -> core::result::Result<(), posthog_rs::Error> where E: core::error::Error + ?core::marker::Sized -pub async fn posthog_rs::client>(C) -> posthog_rs::Client -pub fn posthog_rs::disable_global() -pub async fn posthog_rs::flush() -pub fn posthog_rs::global_is_disabled() -> bool -pub async fn posthog_rs::init_global>(C) -> core::result::Result<(), posthog_rs::Error> -pub fn posthog_rs::match_feature_flag(&posthog_rs::FeatureFlag, &str, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap>, &std::collections::hash::map::HashMap) -> core::result::Result -pub fn posthog_rs::match_feature_flag_with_context(&posthog_rs::FeatureFlag, &std::collections::hash::map::HashMap, &posthog_rs::EvaluationContext<'_>) -> core::result::Result -pub fn posthog_rs::match_property_with_context(&posthog_rs::Property, &std::collections::hash::map::HashMap, &posthog_rs::EvaluationContext<'_>) -> core::result::Result -pub async fn posthog_rs::shutdown() +pub mod posthog +pub enum posthog::CaptureCompression +pub posthog::CaptureCompression::Br +pub posthog::CaptureCompression::Deflate +pub posthog::CaptureCompression::Gzip +pub posthog::CaptureCompression::Zstd +#[non_exhaustive] pub enum posthog::ClientOptionsBuilderError +pub posthog::ClientOptionsBuilderError::UninitializedField(&'static str) +pub posthog::ClientOptionsBuilderError::ValidationError(alloc::string::String) +impl core::convert::From for posthog::ClientOptionsBuilderError +pub fn posthog::ClientOptionsBuilderError::from(alloc::string::String) -> Self +impl core::convert::From for posthog::ClientOptionsBuilderError +pub fn posthog::ClientOptionsBuilderError::from(derive_builder::error::UninitializedFieldError) -> Self +impl core::error::Error for posthog::ClientOptionsBuilderError +impl core::fmt::Display for posthog::ClientOptionsBuilderError +pub fn posthog::ClientOptionsBuilderError::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result +#[non_exhaustive] pub enum posthog::Endpoint +pub posthog::Endpoint::Capture +pub posthog::Endpoint::CaptureAi +pub posthog::Endpoint::Flags +pub posthog::Endpoint::LocalEvaluation +impl posthog::Endpoint +pub fn posthog::Endpoint::path(&self) -> &str +impl core::fmt::Display for posthog::Endpoint +pub fn posthog::Endpoint::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result +#[non_exhaustive] pub enum posthog::Error +pub posthog::Error::AlreadyInitialized +pub posthog::Error::BadRequest(alloc::string::String) +pub posthog::Error::BillingLimitExceeded(alloc::string::String) +pub posthog::Error::Connection(alloc::string::String) +pub posthog::Error::InconclusiveMatch(alloc::string::String) +pub posthog::Error::InvalidTimestamp(alloc::string::String) +pub posthog::Error::NotInitialized +pub posthog::Error::PanicHookAlreadyInstalled +pub posthog::Error::RateLimit +pub posthog::Error::Serialization(alloc::string::String) +pub posthog::Error::ServerError +pub posthog::Error::ServerError::message: alloc::string::String +pub posthog::Error::ServerError::status: u16 +pub posthog::Error::Unauthorized +impl core::error::Error for posthog::Error +impl core::fmt::Display for posthog::Error +pub fn posthog::Error::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result +#[non_exhaustive] pub enum posthog::ErrorTrackingOptionsBuilderError +pub posthog::ErrorTrackingOptionsBuilderError::UninitializedField(&'static str) +pub posthog::ErrorTrackingOptionsBuilderError::ValidationError(alloc::string::String) +impl core::convert::From for posthog::ErrorTrackingOptionsBuilderError +pub fn posthog::ErrorTrackingOptionsBuilderError::from(alloc::string::String) -> Self +impl core::convert::From for posthog::ErrorTrackingOptionsBuilderError +pub fn posthog::ErrorTrackingOptionsBuilderError::from(derive_builder::error::UninitializedFieldError) -> Self +impl core::error::Error for posthog::ErrorTrackingOptionsBuilderError +impl core::fmt::Display for posthog::ErrorTrackingOptionsBuilderError +pub fn posthog::ErrorTrackingOptionsBuilderError::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result +#[non_exhaustive] pub enum posthog::EventStatus +pub posthog::EventStatus::Drop +pub posthog::EventStatus::Ok +pub posthog::EventStatus::Retry +pub posthog::EventStatus::Unknown +pub posthog::EventStatus::Warning +#[non_exhaustive] pub enum posthog::FeatureFlagsResponse +pub posthog::FeatureFlagsResponse::Legacy +pub posthog::FeatureFlagsResponse::Legacy::errors: core::option::Option> +pub posthog::FeatureFlagsResponse::Legacy::feature_flag_payloads: std::collections::hash::map::HashMap +pub posthog::FeatureFlagsResponse::Legacy::feature_flags: std::collections::hash::map::HashMap +pub posthog::FeatureFlagsResponse::V2 +pub posthog::FeatureFlagsResponse::V2::errors_while_computing_flags: bool +pub posthog::FeatureFlagsResponse::V2::flags: std::collections::hash::map::HashMap +pub posthog::FeatureFlagsResponse::V2::minimal_flag_called_events: bool +pub posthog::FeatureFlagsResponse::V2::quota_limited: bool +pub posthog::FeatureFlagsResponse::V2::request_id: core::option::Option +impl posthog::FeatureFlagsResponse +pub fn posthog::FeatureFlagsResponse::normalize(self) -> (std::collections::hash::map::HashMap, std::collections::hash::map::HashMap) +pub enum posthog::FlagValue +pub posthog::FlagValue::Boolean(bool) +pub posthog::FlagValue::String(alloc::string::String) +impl core::default::Default for posthog::FlagValue +pub fn posthog::FlagValue::default() -> Self +#[non_exhaustive] pub enum posthog::PostHogError<'a> +pub posthog::PostHogError::Capture(posthog::CaptureFailure<'a>) +pub posthog::PostHogError::FeatureFlags(posthog::FlagsFailure<'a>) +pub posthog::PostHogError::LocalEvaluation(posthog::LocalEvaluationFailure<'a>) +pub struct posthog::AsyncFlagPoller +impl posthog::AsyncFlagPoller +pub async fn posthog::AsyncFlagPoller::is_running(&self) -> bool +pub async fn posthog::AsyncFlagPoller::load_flags(&self) -> core::result::Result<(), posthog::Error> +pub fn posthog::AsyncFlagPoller::new(posthog::LocalEvaluationConfig, posthog::FlagCache) -> Self +pub async fn posthog::AsyncFlagPoller::start(&mut self) +pub async fn posthog::AsyncFlagPoller::stop(&mut self) +impl core::ops::drop::Drop for posthog::AsyncFlagPoller +pub fn posthog::AsyncFlagPoller::drop(&mut self) +pub struct posthog::BeforeSendHook(_) +impl posthog::BeforeSendHook +pub fn posthog::BeforeSendHook::new(F) -> Self where F: core::ops::function::FnMut(posthog::Event) -> core::option::Option + core::marker::Send + 'static +#[non_exhaustive] pub struct posthog::CaptureErrorResponse +pub posthog::CaptureErrorResponse::error: alloc::string::String +pub posthog::CaptureErrorResponse::error_description: core::option::Option +pub posthog::CaptureErrorResponse::error_uri: core::option::Option +pub struct posthog::CaptureExceptionOptions +impl posthog::CaptureExceptionOptions +pub fn posthog::CaptureExceptionOptions::distinct_id>(self, S) -> Self +pub fn posthog::CaptureExceptionOptions::fingerprint>(self, S) -> Self +pub fn posthog::CaptureExceptionOptions::group, I: core::convert::Into>(self, N, I) -> Self +pub fn posthog::CaptureExceptionOptions::level>(self, S) -> Self +pub fn posthog::CaptureExceptionOptions::new() -> Self +pub fn posthog::CaptureExceptionOptions::property, V: serde_core::ser::Serialize>(self, K, V) -> core::result::Result +pub fn posthog::CaptureExceptionOptions::trace_context, S: core::convert::Into>(self, T, S) -> Self +#[non_exhaustive] pub struct posthog::CaptureFailure<'a> +impl<'a> posthog::CaptureFailure<'a> +pub fn posthog::CaptureFailure<'a>::attempt(&self) -> u32 +pub fn posthog::CaptureFailure<'a>::endpoint(&self) -> posthog::Endpoint +pub fn posthog::CaptureFailure<'a>::error(&self) -> core::option::Option<&posthog::Error> +pub fn posthog::CaptureFailure<'a>::error_response(&self) -> core::option::Option<&posthog::CaptureErrorResponse> +pub fn posthog::CaptureFailure<'a>::event_count(&self) -> usize +pub fn posthog::CaptureFailure<'a>::event_results(&self) -> &std::collections::hash::map::HashMap +pub fn posthog::CaptureFailure<'a>::historical_migration(&self) -> bool +pub fn posthog::CaptureFailure<'a>::request_id(&self) -> core::option::Option<&uuid::Uuid> +pub fn posthog::CaptureFailure<'a>::status(&self) -> core::option::Option +#[non_exhaustive] pub struct posthog::CaptureResponse +pub posthog::CaptureResponse::results: std::collections::hash::map::HashMap +#[non_exhaustive] pub struct posthog::CaptureSummary +impl posthog::CaptureSummary +pub fn posthog::CaptureSummary::all_persisted(&self) -> bool +pub fn posthog::CaptureSummary::event_results(&self) -> &std::collections::hash::map::HashMap +pub fn posthog::CaptureSummary::not_persisted(&self) -> usize +pub fn posthog::CaptureSummary::submitted(&self) -> usize +pub struct posthog::Client +impl posthog::Client +pub fn posthog::Client::alias, D: core::convert::Into>(&self, P, D) +pub fn posthog::Client::capture(&self, posthog::Event) +pub fn posthog::Client::capture_ai(&self, posthog::Event) +pub fn posthog::Client::capture_ai_batch(&self, alloc::vec::Vec, bool) +pub async fn posthog::Client::capture_ai_batch_immediate(&self, alloc::vec::Vec, bool) -> core::result::Result +pub async fn posthog::Client::capture_ai_immediate(&self, posthog::Event) -> core::result::Result +pub fn posthog::Client::capture_batch(&self, alloc::vec::Vec, bool) +pub async fn posthog::Client::capture_batch_immediate(&self, alloc::vec::Vec, bool) -> core::result::Result +pub async fn posthog::Client::capture_exception(&self, &E) -> core::result::Result<(), posthog::Error> where E: core::error::Error + ?core::marker::Sized +pub async fn posthog::Client::capture_exception_with(&self, &E, posthog::CaptureExceptionOptions) -> core::result::Result<(), posthog::Error> where E: core::error::Error + ?core::marker::Sized +pub async fn posthog::Client::capture_immediate(&self, posthog::Event) -> core::result::Result +pub fn posthog::Client::evaluate_feature_flag_locally(&self, &posthog::FeatureFlag, &str, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap>) -> core::result::Result +pub async fn posthog::Client::evaluate_flags>(&self, S, posthog::EvaluateFlagsOptions) -> core::result::Result +pub async fn posthog::Client::flush(&self) +pub fn posthog::Client::group_identify, K: core::convert::Into, P: serde_core::ser::Serialize>(&self, T, K, P) -> core::result::Result<(), posthog::Error> +pub async fn posthog::Client::shutdown(&self) +impl core::ops::drop::Drop for posthog::Client +pub fn posthog::Client::drop(&mut self) +pub struct posthog::ClientOptions +impl posthog::ClientOptions +pub fn posthog::ClientOptions::is_disabled(&self) -> bool +impl core::convert::From<&str> for posthog::ClientOptions +pub fn posthog::ClientOptions::from(&str) -> Self +impl core::convert::From<(&str, &str)> for posthog::ClientOptions +pub fn posthog::ClientOptions::from((&str, &str)) -> Self +pub struct posthog::ClientOptionsBuilder +impl posthog::ClientOptionsBuilder +pub fn posthog::ClientOptionsBuilder::api_key(&mut self, alloc::string::String) -> &mut Self +pub fn posthog::ClientOptionsBuilder::capture_ai_compression(&mut self, posthog::CaptureCompression) -> &mut Self +pub fn posthog::ClientOptionsBuilder::capture_ai_max_queue_size(&mut self, usize) -> &mut Self +pub fn posthog::ClientOptionsBuilder::capture_compression(&mut self, posthog::CaptureCompression) -> &mut Self +pub fn posthog::ClientOptionsBuilder::disable_geoip(&mut self, bool) -> &mut Self +pub fn posthog::ClientOptionsBuilder::disabled(&mut self, bool) -> &mut Self +pub fn posthog::ClientOptionsBuilder::enable_local_evaluation(&mut self, bool) -> &mut Self +pub fn posthog::ClientOptionsBuilder::error_tracking(&mut self, posthog::ErrorTrackingOptions) -> &mut Self +pub fn posthog::ClientOptionsBuilder::feature_flags_request_max_retries(&mut self, u32) -> &mut Self +pub fn posthog::ClientOptionsBuilder::feature_flags_request_timeout_seconds(&mut self, u64) -> &mut Self +pub fn posthog::ClientOptionsBuilder::flush_at(&mut self, usize) -> &mut Self +pub fn posthog::ClientOptionsBuilder::flush_interval_ms(&mut self, u64) -> &mut Self +pub fn posthog::ClientOptionsBuilder::host>(&mut self, VALUE) -> &mut Self +pub fn posthog::ClientOptionsBuilder::is_server(&mut self, bool) -> &mut Self +pub fn posthog::ClientOptionsBuilder::local_evaluation_only(&mut self, bool) -> &mut Self +pub fn posthog::ClientOptionsBuilder::max_batch_size(&mut self, usize) -> &mut Self +pub fn posthog::ClientOptionsBuilder::max_capture_attempts(&mut self, u32) -> &mut Self +pub fn posthog::ClientOptionsBuilder::max_queue_size(&mut self, usize) -> &mut Self +pub fn posthog::ClientOptionsBuilder::poll_interval_seconds(&mut self, u64) -> &mut Self +pub fn posthog::ClientOptionsBuilder::request_timeout_seconds(&mut self, u64) -> &mut Self +pub fn posthog::ClientOptionsBuilder::retry_initial_backoff_ms(&mut self, u64) -> &mut Self +pub fn posthog::ClientOptionsBuilder::retry_max_backoff_ms(&mut self, u64) -> &mut Self +pub fn posthog::ClientOptionsBuilder::secret_key>(&mut self, VALUE) -> &mut Self +pub fn posthog::ClientOptionsBuilder::shutdown_timeout_ms(&mut self, u64) -> &mut Self +impl posthog::ClientOptionsBuilder +pub fn posthog::ClientOptionsBuilder::before_send(&mut self, F) -> &mut Self where F: core::ops::function::FnMut(posthog::Event) -> core::option::Option + core::marker::Send + 'static +pub fn posthog::ClientOptionsBuilder::build(&self) -> core::result::Result +pub fn posthog::ClientOptionsBuilder::on_error(&mut self, F) -> &mut Self where F: core::ops::function::Fn(&posthog::PostHogError<'_>) + core::marker::Send + core::marker::Sync + 'static +impl core::default::Default for posthog::ClientOptionsBuilder +pub fn posthog::ClientOptionsBuilder::default() -> Self +pub struct posthog::Cohort +pub posthog::Cohort::properties: serde_json::value::Value +pub struct posthog::CohortDefinition +pub posthog::CohortDefinition::id: alloc::string::String +pub posthog::CohortDefinition::properties: serde_json::value::Value +impl posthog::CohortDefinition +pub fn posthog::CohortDefinition::new(alloc::string::String, alloc::vec::Vec) -> Self +pub fn posthog::CohortDefinition::parse_properties(&self) -> alloc::vec::Vec +pub struct posthog::EndpointManager +impl posthog::EndpointManager +pub fn posthog::EndpointManager::api_host(&self) -> alloc::string::String +pub fn posthog::EndpointManager::base_host(&self) -> &str +pub fn posthog::EndpointManager::build_custom_url(&self, &str) -> alloc::string::String +pub fn posthog::EndpointManager::build_local_eval_url(&self, &str) -> alloc::string::String +pub fn posthog::EndpointManager::build_url(&self, posthog::Endpoint) -> alloc::string::String +pub fn posthog::EndpointManager::determine_server_host(&str) -> alloc::string::String +pub fn posthog::EndpointManager::new(alloc::string::String) -> Self +pub fn posthog::EndpointManager::raw_host(&self) -> &str +pub struct posthog::ErrorTrackingOptions +impl core::default::Default for posthog::ErrorTrackingOptions +pub fn posthog::ErrorTrackingOptions::default() -> Self +pub struct posthog::ErrorTrackingOptionsBuilder +impl posthog::ErrorTrackingOptionsBuilder +pub fn posthog::ErrorTrackingOptionsBuilder::build(&self) -> core::result::Result +pub fn posthog::ErrorTrackingOptionsBuilder::capture_panics(&mut self, bool) -> &mut Self +pub fn posthog::ErrorTrackingOptionsBuilder::capture_stacktrace(&mut self, bool) -> &mut Self +pub fn posthog::ErrorTrackingOptionsBuilder::in_app_exclude_paths(&mut self, alloc::vec::Vec) -> &mut Self +pub fn posthog::ErrorTrackingOptionsBuilder::in_app_include_paths(&mut self, alloc::vec::Vec) -> &mut Self +impl posthog::ErrorTrackingOptionsBuilder +pub fn posthog::ErrorTrackingOptionsBuilder::trace_context_provider(&mut self, F) -> &mut Self where F: core::ops::function::Fn() -> core::option::Option + core::marker::Send + core::marker::Sync + 'static +impl core::default::Default for posthog::ErrorTrackingOptionsBuilder +pub fn posthog::ErrorTrackingOptionsBuilder::default() -> Self +#[non_exhaustive] pub struct posthog::EvaluateFlagsOptions +pub posthog::EvaluateFlagsOptions::disable_geoip: core::option::Option +pub posthog::EvaluateFlagsOptions::flag_keys: core::option::Option> +pub posthog::EvaluateFlagsOptions::group_properties: core::option::Option>> +pub posthog::EvaluateFlagsOptions::groups: core::option::Option> +pub posthog::EvaluateFlagsOptions::only_evaluate_locally: bool +pub posthog::EvaluateFlagsOptions::person_properties: core::option::Option> +pub struct posthog::EvaluationContext<'a> +pub posthog::EvaluationContext::cohorts: &'a std::collections::hash::map::HashMap +pub posthog::EvaluationContext::distinct_id: &'a str +pub posthog::EvaluationContext::flags: &'a std::collections::hash::map::HashMap +pub posthog::EvaluationContext::group_properties: &'a std::collections::hash::map::HashMap> +pub posthog::EvaluationContext::group_type_mapping: &'a std::collections::hash::map::HashMap +pub posthog::EvaluationContext::groups: &'a std::collections::hash::map::HashMap +pub struct posthog::Event +impl posthog::Event +pub fn posthog::Event::add_group(&mut self, &str, &str) +pub fn posthog::Event::distinct_id(&self) -> &str +pub fn posthog::Event::event_name(&self) -> &str +pub fn posthog::Event::insert_prop, P: serde_core::ser::Serialize>(&mut self, K, P) -> core::result::Result<(), posthog::Error> +pub fn posthog::Event::new>(S, S) -> Self +pub fn posthog::Event::new_anon>(S) -> Self +pub fn posthog::Event::properties(&self) -> &std::collections::hash::map::HashMap +pub fn posthog::Event::remove_prop(&mut self, &str) -> core::option::Option +pub fn posthog::Event::set_timestamp(&mut self, chrono::datetime::DateTime) -> core::result::Result<(), posthog::Error> where Tz: chrono::offset::TimeZone +pub fn posthog::Event::set_uuid(&mut self, uuid::Uuid) +pub fn posthog::Event::with_flags(&mut self, &posthog::FeatureFlagEvaluations) -> &mut Self +#[non_exhaustive] pub struct posthog::EventResult +pub posthog::EventResult::details: core::option::Option +pub posthog::EventResult::result: posthog::EventStatus +pub struct posthog::FeatureFlag +pub posthog::FeatureFlag::active: bool +pub posthog::FeatureFlag::filters: posthog::FeatureFlagFilters +pub posthog::FeatureFlag::has_experiment: core::option::Option +pub posthog::FeatureFlag::key: alloc::string::String +pub struct posthog::FeatureFlagCondition +pub posthog::FeatureFlagCondition::aggregation_group_type_index: core::option::Option +pub posthog::FeatureFlagCondition::properties: alloc::vec::Vec +pub posthog::FeatureFlagCondition::rollout_percentage: core::option::Option +pub posthog::FeatureFlagCondition::variant: core::option::Option +pub struct posthog::FeatureFlagEvaluations +impl posthog::FeatureFlagEvaluations +pub fn posthog::FeatureFlagEvaluations::get_flag(&self, &str) -> core::option::Option +pub fn posthog::FeatureFlagEvaluations::get_flag_payload(&self, &str) -> core::option::Option +pub fn posthog::FeatureFlagEvaluations::is_enabled(&self, &str) -> bool +pub fn posthog::FeatureFlagEvaluations::keys(&self) -> alloc::vec::Vec +pub fn posthog::FeatureFlagEvaluations::only(&self, &[&str]) -> Self +pub fn posthog::FeatureFlagEvaluations::only_accessed(&self) -> Self +impl core::fmt::Debug for posthog::FeatureFlagEvaluations +pub fn posthog::FeatureFlagEvaluations::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result +pub struct posthog::FeatureFlagFilters +pub posthog::FeatureFlagFilters::aggregation_group_type_index: core::option::Option +pub posthog::FeatureFlagFilters::early_exit: bool +pub posthog::FeatureFlagFilters::groups: alloc::vec::Vec +pub posthog::FeatureFlagFilters::multivariate: core::option::Option +pub posthog::FeatureFlagFilters::payloads: std::collections::hash::map::HashMap +pub struct posthog::FlagCache +impl posthog::FlagCache +pub fn posthog::FlagCache::clear(&self) +pub fn posthog::FlagCache::get_all_cohorts(&self) -> std::collections::hash::map::HashMap +pub fn posthog::FlagCache::get_all_flags(&self) -> alloc::vec::Vec +pub fn posthog::FlagCache::get_cohort(&self, &str) -> core::option::Option +pub fn posthog::FlagCache::get_cohort_definitions(&self) -> std::collections::hash::map::HashMap +pub fn posthog::FlagCache::get_flag(&self, &str) -> core::option::Option +pub fn posthog::FlagCache::get_flags_map(&self) -> std::collections::hash::map::HashMap +pub fn posthog::FlagCache::get_group_type_mapping(&self) -> std::collections::hash::map::HashMap +pub fn posthog::FlagCache::minimal_flag_called_events(&self) -> bool +pub fn posthog::FlagCache::new() -> Self +pub fn posthog::FlagCache::update(&self, posthog::LocalEvaluationResponse) +impl core::default::Default for posthog::FlagCache +pub fn posthog::FlagCache::default() -> Self +#[non_exhaustive] pub struct posthog::FlagDetail +pub posthog::FlagDetail::enabled: bool +pub posthog::FlagDetail::key: alloc::string::String +pub posthog::FlagDetail::metadata: core::option::Option +pub posthog::FlagDetail::reason: core::option::Option +pub posthog::FlagDetail::variant: core::option::Option +#[non_exhaustive] pub struct posthog::FlagMetadata +pub posthog::FlagMetadata::description: core::option::Option +pub posthog::FlagMetadata::has_experiment: core::option::Option +pub posthog::FlagMetadata::id: u64 +pub posthog::FlagMetadata::payload: core::option::Option +pub posthog::FlagMetadata::version: u32 +pub struct posthog::FlagPoller +impl posthog::FlagPoller +pub fn posthog::FlagPoller::load_flags(&self) -> core::result::Result<(), posthog::Error> +pub fn posthog::FlagPoller::new(posthog::LocalEvaluationConfig, posthog::FlagCache) -> Self +pub fn posthog::FlagPoller::start(&mut self) +pub fn posthog::FlagPoller::stop(&mut self) +impl core::ops::drop::Drop for posthog::FlagPoller +pub fn posthog::FlagPoller::drop(&mut self) +#[non_exhaustive] pub struct posthog::FlagReason +pub posthog::FlagReason::code: alloc::string::String +pub posthog::FlagReason::condition_index: core::option::Option +pub posthog::FlagReason::description: core::option::Option +#[non_exhaustive] pub struct posthog::FlagsFailure<'a> +impl<'a> posthog::FlagsFailure<'a> +pub fn posthog::FlagsFailure<'a>::body(&self) -> core::option::Option<&str> +pub fn posthog::FlagsFailure<'a>::distinct_id(&self) -> core::option::Option<&str> +pub fn posthog::FlagsFailure<'a>::endpoint(&self) -> &str +pub fn posthog::FlagsFailure<'a>::error(&self) -> &posthog::Error +pub fn posthog::FlagsFailure<'a>::status(&self) -> core::option::Option +pub struct posthog::InconclusiveMatchError +pub posthog::InconclusiveMatchError::message: alloc::string::String +impl posthog::InconclusiveMatchError +pub fn posthog::InconclusiveMatchError::new(&str) -> Self +impl core::error::Error for posthog::InconclusiveMatchError +impl core::fmt::Display for posthog::InconclusiveMatchError +pub fn posthog::InconclusiveMatchError::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result +pub struct posthog::LocalEvaluationConfig +pub posthog::LocalEvaluationConfig::api_host: alloc::string::String +pub posthog::LocalEvaluationConfig::poll_interval: core::time::Duration +pub posthog::LocalEvaluationConfig::project_api_key: alloc::string::String +pub posthog::LocalEvaluationConfig::request_timeout: core::time::Duration +pub posthog::LocalEvaluationConfig::secret_key: alloc::string::String +#[non_exhaustive] pub struct posthog::LocalEvaluationFailure<'a> +impl<'a> posthog::LocalEvaluationFailure<'a> +pub fn posthog::LocalEvaluationFailure<'a>::error(&self) -> &posthog::Error +pub fn posthog::LocalEvaluationFailure<'a>::status(&self) -> core::option::Option +#[non_exhaustive] pub struct posthog::LocalEvaluationResponse +pub posthog::LocalEvaluationResponse::cohorts: std::collections::hash::map::HashMap +pub posthog::LocalEvaluationResponse::flags: alloc::vec::Vec +pub posthog::LocalEvaluationResponse::group_type_mapping: std::collections::hash::map::HashMap +pub posthog::LocalEvaluationResponse::minimal_flag_called_events: bool +impl posthog::LocalEvaluationResponse +pub fn posthog::LocalEvaluationResponse::new(alloc::vec::Vec) -> Self +pub struct posthog::LocalEvaluator +impl posthog::LocalEvaluator +pub fn posthog::LocalEvaluator::cache(&self) -> &posthog::FlagCache +pub fn posthog::LocalEvaluator::evaluate_all_flags(&self, &str, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap>) -> std::collections::hash::map::HashMap> +pub fn posthog::LocalEvaluator::evaluate_flag(&self, &str, &str, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap>) -> core::result::Result, posthog::InconclusiveMatchError> +pub fn posthog::LocalEvaluator::evaluate_flag_simple(&self, &str, &str, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap>) -> core::result::Result, posthog::InconclusiveMatchError> +pub fn posthog::LocalEvaluator::new(posthog::FlagCache) -> Self +pub struct posthog::MultivariateFilter +pub posthog::MultivariateFilter::variants: alloc::vec::Vec +pub struct posthog::MultivariateVariant +pub posthog::MultivariateVariant::key: alloc::string::String +pub posthog::MultivariateVariant::rollout_percentage: f64 +pub struct posthog::Property +pub posthog::Property::key: alloc::string::String +pub posthog::Property::operator: alloc::string::String +pub posthog::Property::property_type: core::option::Option +pub posthog::Property::value: serde_json::value::Value +pub struct posthog::TraceContext +impl posthog::TraceContext +pub fn posthog::TraceContext::new, S: core::convert::Into>(T, S) -> Self +pub const posthog::DEFAULT_HOST: &str +pub const posthog::EU_INGESTION_ENDPOINT: &str +pub const posthog::US_INGESTION_ENDPOINT: &str +pub fn posthog::capture(posthog::Event) +pub fn posthog::capture_ai(posthog::Event) +pub async fn posthog::capture_exception(&E) -> core::result::Result<(), posthog::Error> where E: core::error::Error + ?core::marker::Sized +pub async fn posthog::capture_exception_with(&E, posthog::CaptureExceptionOptions) -> core::result::Result<(), posthog::Error> where E: core::error::Error + ?core::marker::Sized +pub async fn posthog::client>(C) -> posthog::Client +pub fn posthog::disable_global() +pub async fn posthog::flush() +pub fn posthog::global_is_disabled() -> bool +pub async fn posthog::init_global>(C) -> core::result::Result<(), posthog::Error> +pub fn posthog::match_feature_flag(&posthog::FeatureFlag, &str, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap, &std::collections::hash::map::HashMap>, &std::collections::hash::map::HashMap) -> core::result::Result +pub fn posthog::match_feature_flag_with_context(&posthog::FeatureFlag, &std::collections::hash::map::HashMap, &posthog::EvaluationContext<'_>) -> core::result::Result +pub fn posthog::match_property_with_context(&posthog::Property, &std::collections::hash::map::HashMap, &posthog::EvaluationContext<'_>) -> core::result::Result +pub async fn posthog::shutdown() diff --git a/compliance/adapter/Cargo.toml b/compliance/adapter/Cargo.toml index 66a6ebbc..e1861aa7 100644 --- a/compliance/adapter/Cargo.toml +++ b/compliance/adapter/Cargo.toml @@ -6,10 +6,10 @@ publish = false [features] default = ["async-client"] -async-client = ["posthog-rs/async-client"] +async-client = ["posthog/async-client"] [dependencies] -posthog-rs = { path = "../..", default-features = false, features = ["test-harness"] } +posthog = { path = "../..", default-features = false, features = ["test-harness"] } axum = "0.8" tokio = { version = "1", features = ["full"] } serde = { version = "1", features = ["derive"] } diff --git a/compliance/adapter/src/main.rs b/compliance/adapter/src/main.rs index 00cad7e1..6fb27b1c 100644 --- a/compliance/adapter/src/main.rs +++ b/compliance/adapter/src/main.rs @@ -11,7 +11,7 @@ use axum::{ use serde::{Deserialize, Serialize}; use tokio::sync::Mutex; -use posthog_rs::{CaptureCompression, Client, ClientOptionsBuilder, EvaluateFlagsOptions, Event}; +use posthog::{CaptureCompression, Client, ClientOptionsBuilder, EvaluateFlagsOptions, Event}; const SUPPORTS_PARALLEL: bool = true; @@ -138,14 +138,14 @@ fn compression_capability(c: CaptureCompression) -> &'static str { } } -async fn build_client(options: posthog_rs::ClientOptions) -> Client { +async fn build_client(options: posthog::ClientOptions) -> Client { #[cfg(feature = "async-client")] { - posthog_rs::client(options).await + posthog::client(options).await } #[cfg(not(feature = "async-client"))] { - posthog_rs::client(options) + posthog::client(options) } } @@ -153,7 +153,7 @@ async fn evaluate_flags( client: &Client, distinct_id: String, options: EvaluateFlagsOptions, -) -> Result { +) -> Result { #[cfg(feature = "async-client")] { client.evaluate_flags(distinct_id, options).await diff --git a/crates/posthog-rs/Cargo.toml b/crates/posthog-rs/Cargo.toml new file mode 100644 index 00000000..716a73e3 --- /dev/null +++ b/crates/posthog-rs/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "posthog-rs" +license = "MIT" +version = "0.25.4" +authors = ["PostHog "] +description = "Compatibility package for the official PostHog Rust SDK; use posthog for new projects." +repository = "https://github.com/posthog/posthog-rs" +readme = "README.md" +edition = "2018" +rust-version = "1.78.0" + +[dependencies] +posthog = { path = "../..", version = "0.25.4", default-features = false } + +[features] +default = ["posthog/default"] +async-client = ["posthog/async-client"] +e2e-test = ["posthog/e2e-test"] +error-tracking = ["posthog/error-tracking"] +test-harness = ["posthog/test-harness"] +tokio = ["posthog/tokio"] +tls = ["posthog/tls"] +tls-no-provider = ["posthog/tls-no-provider"] diff --git a/crates/posthog-rs/README.md b/crates/posthog-rs/README.md new file mode 100644 index 00000000..9ce4a796 --- /dev/null +++ b/crates/posthog-rs/README.md @@ -0,0 +1,5 @@ +# `posthog-rs` compatibility crate + +The PostHog Rust SDK is now published as [`posthog`](https://crates.io/crates/posthog). This package preserves the former `posthog-rs` package name by forwarding its features and re-exporting the canonical crate. + +Existing applications can continue using `posthog_rs`. New applications should depend on and import `posthog` directly. diff --git a/crates/posthog-rs/src/lib.rs b/crates/posthog-rs/src/lib.rs new file mode 100644 index 00000000..26ded193 --- /dev/null +++ b/crates/posthog-rs/src/lib.rs @@ -0,0 +1,3 @@ +#![doc = include_str!("../README.md")] + +pub use posthog::*; diff --git a/crates/posthog-rs/tests/reexports.rs b/crates/posthog-rs/tests/reexports.rs new file mode 100644 index 00000000..93f468cf --- /dev/null +++ b/crates/posthog-rs/tests/reexports.rs @@ -0,0 +1,9 @@ +use std::any::TypeId; + +#[test] +fn reexports_canonical_types() { + assert_eq!( + TypeId::of::(), + TypeId::of::() + ); +} diff --git a/docs/migration-0.x-to-1.0.md b/docs/migration-0.x-to-1.0.md index ee48acb6..6cd616c4 100644 --- a/docs/migration-0.x-to-1.0.md +++ b/docs/migration-0.x-to-1.0.md @@ -1,6 +1,6 @@ -# Migrating from posthog-rs 0.x to 1.0 +# Migrating from posthog-rs 0.x to posthog 1.0 -Version 1.0 makes the V1 analytics endpoint the SDK's only capture path and removes APIs that were already deprecated in 0.x. This guide describes the changes currently staged on the `v1` branch. +Version 1.0 publishes the SDK under the canonical `posthog` package and import name, makes the V1 analytics endpoint the only capture path, and removes APIs that were already deprecated in 0.x. The `posthog-rs` package remains as a compatibility crate, so existing applications can upgrade without changing package or import names. This guide uses the canonical `posthog` name for 1.0 examples. ## Cargo features @@ -11,17 +11,17 @@ Remove `capture-v1` from your dependency features. Capture no longer needs a fea posthog-rs = { version = "0.25", features = ["capture-v1"] } # 1.0 -posthog-rs = "1" +posthog = "1" ``` The default features are the async client, error tracking, and TLS. Use `default-features = false` for the blocking client and explicitly enable a TLS feature when sending to an HTTPS endpoint. ```toml # Async client with error tracking and TLS -posthog-rs = "1" +posthog = "1" # Blocking client with TLS -posthog-rs = { version = "1", default-features = false, features = ["tls"] } +posthog = { version = "1", default-features = false, features = ["tls"] } ``` TLS was previously enabled even with `default-features = false`. In 1.0, choose `tls` to use reqwest's default Rustls provider, or choose `tls-no-provider` when the application installs a process-level Rustls `CryptoProvider`. The latter avoids pulling in `aws-lc-rs` from this SDK, but constructing a client before installing a provider will panic. Cargo features are additive, so `tls-no-provider` only avoids the built-in provider when no dependency enables `tls`. @@ -36,7 +36,7 @@ All event-producing SDK paths now use the same capture endpoint, including error ### AI events -Use the new `capture_ai` family for LLM analytics events (`$ai_generation`, `$ai_span`, `$ai_trace`, `$ai_embedding`, and the other `$ai_*` names PostHog's LLM analytics product defines). `capture_ai`, `capture_ai_batch`, `capture_ai_immediate`, `capture_ai_batch_immediate`, and the global `posthog_rs::capture_ai` mirror their analytics counterparts but post to `/i/v1/ai/events` on their own background lane, batched by size, with the backend's 8 MiB per-event ceiling applied locally. The lane has its own options: `capture_ai_compression` (unset sends AI bodies uncompressed; set `CaptureCompression::Zstd`, the best fit for large JSON) and `capture_ai_max_queue_size` (default 1000). +Use the new `capture_ai` family for LLM analytics events (`$ai_generation`, `$ai_span`, `$ai_trace`, `$ai_embedding`, and the other `$ai_*` names PostHog's LLM analytics product defines). `capture_ai`, `capture_ai_batch`, `capture_ai_immediate`, `capture_ai_batch_immediate`, and the global `posthog::capture_ai` mirror their analytics counterparts but post to `/i/v1/ai/events` on their own background lane, batched by size, with the backend's 8 MiB per-event ceiling applied locally. The lane has its own options: `capture_ai_compression` (unset sends AI bodies uncompressed; set `CaptureCompression::Zstd`, the best fit for large JSON) and `capture_ai_max_queue_size` (default 1000). `capture` never reroutes by event name. Sending an AI event through `capture` worked on the V0 path because the backend diverted it; on the V1 analytics endpoint the backend will refuse it as a per-event `drop` once both lanes enforce their event sets, and it will not be ingested. Move those calls to `capture_ai`. Custom events that merely start with `$ai_` and are not PostHog AI event names stay on `capture`. @@ -63,7 +63,7 @@ Rename `V1ErrorResponse` to `CaptureErrorResponse`: let response: Option<&posthog_rs::V1ErrorResponse> = failure.error_response(); // 1.0 -let response: Option<&posthog_rs::CaptureErrorResponse> = failure.error_response(); +let response: Option<&posthog::CaptureErrorResponse> = failure.error_response(); ``` ## Feature flags @@ -78,7 +78,7 @@ The deprecated single-flag methods have been removed: Call `evaluate_flags` once and read from the returned snapshot instead: ```rust -use posthog_rs::EvaluateFlagsOptions; +use posthog::EvaluateFlagsOptions; let flags = client .evaluate_flags("user-123", EvaluateFlagsOptions::default()) @@ -107,7 +107,7 @@ options.flag_keys = Some(vec!["new-checkout".to_string()]); Use `secret_key` terminology throughout configuration. The builder's deprecated `personal_api_key` alias has been removed, and `LocalEvaluationConfig::personal_api_key` is now `secret_key`. ```rust -let options = posthog_rs::ClientOptionsBuilder::default() +let options = posthog::ClientOptionsBuilder::default() .api_key("phc_project_token") .secret_key("phs_project_secret") .enable_local_evaluation(true) diff --git a/examples/advanced_config.rs b/examples/advanced_config.rs index 7158713b..4d69342a 100644 --- a/examples/advanced_config.rs +++ b/examples/advanced_config.rs @@ -3,7 +3,7 @@ /// Shows different ways to configure the PostHog Rust SDK for various use cases. /// /// Run with: cargo run --example advanced_config --features async-client -use posthog_rs::{ClientOptionsBuilder, PostHogError, EU_INGESTION_ENDPOINT}; +use posthog::{ClientOptionsBuilder, PostHogError, EU_INGESTION_ENDPOINT}; #[cfg(feature = "async-client")] #[tokio::main] @@ -12,17 +12,17 @@ async fn main() -> Result<(), Box> { // 1. SIMPLEST: Just an API key (uses US endpoint by default) println!("1. Basic client (US region):"); - let _basic = posthog_rs::client("phc_test_api_key").await; + let _basic = posthog::client("phc_test_api_key").await; println!(" → Created with default settings\n"); // 2. REGIONAL: EU data residency println!("2. EU region client:"); - let _eu = posthog_rs::client(("phc_test_api_key", EU_INGESTION_ENDPOINT)).await; + let _eu = posthog::client(("phc_test_api_key", EU_INGESTION_ENDPOINT)).await; println!(" → Data stays in EU (GDPR compliant)\n"); // 3. SELF-HOSTED: Your own PostHog instance println!("3. Self-hosted instance:"); - let _custom = posthog_rs::client(("phc_test_api_key", "https://analytics.mycompany.com")).await; + let _custom = posthog::client(("phc_test_api_key", "https://analytics.mycompany.com")).await; println!(" → Uses your private PostHog deployment\n"); // 4. PRODUCTION: Common production settings @@ -34,7 +34,7 @@ async fn main() -> Result<(), Box> { .disable_geoip(true) // Disable automatic geoip enrichment .build()?; - let _prod = posthog_rs::client(production_config).await; + let _prod = posthog::client(production_config).await; println!(" → Optimized for production workloads\n"); // 5. HIGH-PERFORMANCE: Local flag evaluation @@ -47,7 +47,7 @@ async fn main() -> Result<(), Box> { .feature_flags_request_timeout_seconds(3) .build()?; - let _perf = posthog_rs::client(performance_config).await; + let _perf = posthog::client(performance_config).await; println!(" → Evaluates flags locally (100x faster)\n"); // 6. OBSERVABILITY: react to terminal network failures with `on_error`. @@ -86,7 +86,7 @@ async fn main() -> Result<(), Box> { }) .build()?; - let _observable = posthog_rs::client(observable_config).await; + let _observable = posthog::client(observable_config).await; println!(" → Surfaces terminal capture/flags/poller failures\n"); println!("Configuration examples complete!"); diff --git a/examples/error_tracking.rs b/examples/error_tracking.rs index 287b2eb6..a265e375 100644 --- a/examples/error_tracking.rs +++ b/examples/error_tracking.rs @@ -6,10 +6,10 @@ #[cfg(all(feature = "async-client", feature = "error-tracking"))] #[tokio::main] async fn main() -> Result<(), Box> { - use posthog_rs::{client, CaptureExceptionOptions}; + use posthog::{client, CaptureExceptionOptions}; let api_key = std::env::var("POSTHOG_API_KEY")?; - let host = std::env::var("POSTHOG_HOST").unwrap_or_else(|_| posthog_rs::DEFAULT_HOST.into()); + let host = std::env::var("POSTHOG_HOST").unwrap_or_else(|_| posthog::DEFAULT_HOST.into()); let client = client((api_key.as_str(), host.as_str())).await; let error = std::io::Error::other("checkout failed"); diff --git a/examples/evaluate_flags.rs b/examples/evaluate_flags.rs index aa0a5ef0..8a9c9774 100644 --- a/examples/evaluate_flags.rs +++ b/examples/evaluate_flags.rs @@ -10,7 +10,7 @@ /// Run: /// export POSTHOG_API_TOKEN=phc_your_key /// cargo run --example evaluate_flags --features async-client -use posthog_rs::{EvaluateFlagsOptions, Event}; +use posthog::{EvaluateFlagsOptions, Event}; #[cfg(feature = "async-client")] #[tokio::main] @@ -20,7 +20,7 @@ async fn main() { "demo_api_key".to_string() }); - let client = posthog_rs::client(api_key.as_str()).await; + let client = posthog::client(api_key.as_str()).await; let user_id = "user-123"; diff --git a/examples/feature_flags.rs b/examples/feature_flags.rs index 5c80daa7..6b6ec05a 100644 --- a/examples/feature_flags.rs +++ b/examples/feature_flags.rs @@ -8,7 +8,7 @@ //! cargo run --example feature_flags --features async-client #[cfg(feature = "async-client")] -use posthog_rs::{EvaluateFlagsOptions, FlagValue}; +use posthog::{EvaluateFlagsOptions, FlagValue}; #[cfg(feature = "async-client")] use serde_json::json; #[cfg(feature = "async-client")] @@ -25,7 +25,7 @@ async fn main() { let client = if api_key == "demo_api_key" { create_demo_client().await } else { - posthog_rs::client(api_key.as_str()).await + posthog::client(api_key.as_str()).await }; let user_id = "user-123"; @@ -73,9 +73,9 @@ async fn main() { } #[cfg(feature = "async-client")] -async fn create_demo_client() -> posthog_rs::Client { +async fn create_demo_client() -> posthog::Client { println!("API calls will fail in demo mode, but the example shows the API shape.\n"); - posthog_rs::client(("demo_key", "https://demo.posthog.com")).await + posthog::client(("demo_key", "https://demo.posthog.com")).await } #[cfg(not(feature = "async-client"))] diff --git a/examples/local_evaluation.rs b/examples/local_evaluation.rs index 0810460b..d8fb8fd6 100644 --- a/examples/local_evaluation.rs +++ b/examples/local_evaluation.rs @@ -8,7 +8,7 @@ //! cargo run --example local_evaluation --features async-client #[cfg(feature = "async-client")] -use posthog_rs::{ClientOptionsBuilder, EvaluateFlagsOptions}; +use posthog::{ClientOptionsBuilder, EvaluateFlagsOptions}; #[cfg(feature = "async-client")] use serde_json::json; #[cfg(feature = "async-client")] @@ -32,7 +32,7 @@ async fn main() { .poll_interval_seconds(30) .build() .unwrap(); - posthog_rs::client(options).await + posthog::client(options).await }; let api_client = { @@ -40,7 +40,7 @@ async fn main() { .api_key(api_key) .build() .unwrap(); - posthog_rs::client(options).await + posthog::client(options).await }; println!("Fetching flag definitions for local evaluation..."); diff --git a/scripts/check-compatibility-crate.sh b/scripts/check-compatibility-crate.sh new file mode 100755 index 00000000..285346d4 --- /dev/null +++ b/scripts/check-compatibility-crate.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -euo pipefail + +cargo metadata --format-version 1 --no-deps | python3 -c ' +import json +import sys + +packages = {package["name"]: package for package in json.load(sys.stdin)["packages"]} +canonical = packages["posthog"] +compatibility = packages["posthog-rs"] + +canonical_version = canonical["version"] +compatibility_version = compatibility["version"] +if canonical_version != compatibility_version: + raise SystemExit( + f"posthog@{canonical_version} and posthog-rs@{compatibility_version} must have the same version" + ) + +canonical_features = set(canonical["features"]) +compatibility_features = set(compatibility["features"]) +if canonical_features != compatibility_features: + missing = sorted(canonical_features - compatibility_features) + extra = sorted(compatibility_features - canonical_features) + raise SystemExit(f"compatibility feature mismatch: missing={missing}, extra={extra}") + +for feature in sorted(canonical_features): + expected = [f"posthog/{feature}"] + actual = compatibility["features"][feature] + if actual != expected: + raise SystemExit( + f"posthog-rs feature {feature!r} must forward to {expected}, found {actual}" + ) + +print("posthog-rs version and features match posthog") +' diff --git a/scripts/check-public-api.sh b/scripts/check-public-api.sh index 1f852f28..f4dab08e 100755 --- a/scripts/check-public-api.sh +++ b/scripts/check-public-api.sh @@ -3,7 +3,7 @@ set -euo pipefail update=false snapshot_file="api/public-api.txt" -package="posthog-rs" +package="posthog" toolchain="${PUBLIC_API_TOOLCHAIN:-nightly-2026-06-12}" while [[ $# -gt 0 ]]; do @@ -60,7 +60,7 @@ trap cleanup EXIT { echo '# This file is generated by `scripts/check-public-api.sh --update`.' echo '# Do not edit manually.' - echo '# Public API scope: exported Rust API for the posthog-rs crate with public-facing features enabled.' + echo '# Public API scope: exported Rust API for the posthog crate with public-facing features enabled.' echo '# Test-only harness features are omitted.' echo # Intentionally use simplification level 3 to keep the snapshot stable diff --git a/src/client/async_client.rs b/src/client/async_client.rs index 78f8e27e..a18b1dd1 100644 --- a/src/client/async_client.rs +++ b/src/client/async_client.rs @@ -233,7 +233,7 @@ impl Client { /// /// ```no_run /// # async fn example() { - /// let client = posthog_rs::client("phc_project_api_key").await; + /// let client = posthog::client("phc_project_api_key").await; /// /// // The visitor browsed anonymously, then logged in. /// client.alias("anon-abc123", "user-42"); @@ -270,10 +270,10 @@ impl Client { /// # Examples /// /// ```no_run - /// # async fn example() -> Result<(), posthog_rs::Error> { + /// # async fn example() -> Result<(), posthog::Error> { /// use serde_json::json; /// - /// let client = posthog_rs::client("phc_project_api_key").await; + /// let client = posthog::client("phc_project_api_key").await; /// /// client.group_identify( /// "company", @@ -466,8 +466,8 @@ impl Client { /// # Examples /// /// ```no_run - /// # async fn example() -> Result<(), posthog_rs::Error> { - /// let client = posthog_rs::client("phc_project_api_key").await; + /// # async fn example() -> Result<(), posthog::Error> { + /// let client = posthog::client("phc_project_api_key").await; /// let error = std::io::Error::other("checkout failed"); /// /// client.capture_exception(&error).await?; @@ -492,10 +492,10 @@ impl Client { /// # Examples /// /// ```no_run - /// # async fn example() -> Result<(), posthog_rs::Error> { - /// use posthog_rs::CaptureExceptionOptions; + /// # async fn example() -> Result<(), posthog::Error> { + /// use posthog::CaptureExceptionOptions; /// - /// let client = posthog_rs::client("phc_project_api_key").await; + /// let client = posthog::client("phc_project_api_key").await; /// let error = std::io::Error::other("checkout failed"); /// /// client diff --git a/src/client/blocking.rs b/src/client/blocking.rs index 164cd298..4ba17742 100644 --- a/src/client/blocking.rs +++ b/src/client/blocking.rs @@ -235,7 +235,7 @@ impl Client { /// # Examples /// /// ```no_run - /// let client = posthog_rs::client("phc_project_api_key"); + /// let client = posthog::client("phc_project_api_key"); /// /// // The visitor browsed anonymously, then logged in. /// client.alias("anon-abc123", "user-42"); @@ -273,7 +273,7 @@ impl Client { /// ```no_run /// use serde_json::json; /// - /// let client = posthog_rs::client("phc_project_api_key"); + /// let client = posthog::client("phc_project_api_key"); /// /// client.group_identify( /// "company", @@ -283,7 +283,7 @@ impl Client { /// "employees": 11, /// }), /// )?; - /// # Ok::<(), posthog_rs::Error>(()) + /// # Ok::<(), posthog::Error>(()) /// ``` pub fn group_identify, K: Into, P: Serialize>( &self, @@ -434,8 +434,8 @@ impl Client { /// # Examples /// /// ```no_run - /// # fn example() -> Result<(), posthog_rs::Error> { - /// let client = posthog_rs::client("phc_project_api_key"); + /// # fn example() -> Result<(), posthog::Error> { + /// let client = posthog::client("phc_project_api_key"); /// let error = std::io::Error::other("checkout failed"); /// /// client.capture_exception(&error)?; @@ -459,10 +459,10 @@ impl Client { /// # Examples /// /// ```no_run - /// # fn example() -> Result<(), posthog_rs::Error> { - /// use posthog_rs::CaptureExceptionOptions; + /// # fn example() -> Result<(), posthog::Error> { + /// use posthog::CaptureExceptionOptions; /// - /// let client = posthog_rs::client("phc_project_api_key"); + /// let client = posthog::client("phc_project_api_key"); /// let error = std::io::Error::other("checkout failed"); /// /// client.capture_exception_with( diff --git a/src/client/common.rs b/src/client/common.rs index 5335427e..002c89e4 100644 --- a/src/client/common.rs +++ b/src/client/common.rs @@ -90,7 +90,7 @@ impl FeatureFlagEvaluationsHost for FlagEventHost { fn log_warning(&self, message: &str) { // Surface filter-helper misuse via tracing — users can silence these - // with their tracing-subscriber level filter (e.g. `posthog_rs=error`). + // with their tracing-subscriber level filter (e.g. `posthog=error`). warn!("{message}"); } } diff --git a/src/client/mod.rs b/src/client/mod.rs index f0525187..9ef27812 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -111,7 +111,7 @@ pub(crate) fn get_default_user_agent() -> String { /// # Example /// /// ```ignore -/// use posthog_rs::ClientOptionsBuilder; +/// use posthog::ClientOptionsBuilder; /// /// let options = ClientOptionsBuilder::default() /// .api_key("your-project-api-key".to_string()) diff --git a/src/error_tracking.rs b/src/error_tracking.rs index 7c0810e9..de534bfd 100644 --- a/src/error_tracking.rs +++ b/src/error_tracking.rs @@ -96,7 +96,7 @@ const PANIC_FLUSH_TIMEOUT: std::time::Duration = std::time::Duration::from_milli /// # Examples /// /// ``` -/// use posthog_rs::{ErrorTrackingOptionsBuilder, TraceContext}; +/// use posthog::{ErrorTrackingOptionsBuilder, TraceContext}; /// /// let options = ErrorTrackingOptionsBuilder::default() /// .capture_stacktrace(true) @@ -383,7 +383,7 @@ fn build_panic_event( /// # Examples /// /// ``` -/// use posthog_rs::CaptureExceptionOptions; +/// use posthog::CaptureExceptionOptions; /// /// let options = CaptureExceptionOptions::new() /// .distinct_id("user-123") @@ -395,7 +395,7 @@ fn build_panic_event( /// ) /// .fingerprint("checkout-error") /// .level("warning"); -/// # Ok::<(), posthog_rs::Error>(()) +/// # Ok::<(), posthog::Error>(()) /// ``` #[derive(Clone, Debug, Default)] pub struct CaptureExceptionOptions { @@ -1344,7 +1344,7 @@ fn is_panic_dispatcher_frame(function: &str) -> bool { fn is_internal_capture_frame(function: &str) -> bool { // Demanglers differ on qualified-path rendering across toolchain versions: // older output is `Exception::from_error`, newer output wraps the type as - // `::from_error::`. Strip the + // `::from_error::`. Strip the // angle brackets before matching so both forms hit. let function: String = function.replace(['<', '>'], ""); function.starts_with("backtrace::") @@ -1632,7 +1632,7 @@ fn default_in_app_function(function: &str) -> bool { | "futures_core" | "futures_util" | "log" - | "posthog_rs" + | "posthog" | "reqwest" | "std" | "stable_eyre" @@ -2172,8 +2172,8 @@ mod tests { "rust_begin_unwind", "__rust_try", "backtrace::backtrace::trace", - "posthog_rs::error_tracking::capture_panic", - "posthog_rs::error_tracking::install_hook::{{closure}}", + "posthog::error_tracking::capture_panic", + "posthog::error_tracking::install_hook::{{closure}}", "core::ops::function::FnOnce::call_once", "tokio::runtime::task::raw::poll", "futures_util::future::FutureExt::poll", @@ -2233,10 +2233,10 @@ mod tests { // `::method::` — the strip must catch both, or an SDK // frame survives at the crash-site end of the canonical order. for name in [ - "posthog_rs::error_tracking::Exception::from_error", - "::from_error::", - "::from_message", - "::capture_exception::", + "posthog::error_tracking::Exception::from_error", + "::from_error::", + "::from_message", + "::capture_exception::", ] { assert!(is_internal_capture_frame(name), "should strip {name:?}"); } @@ -2575,9 +2575,7 @@ mod tests { assert!(options.is_in_app_frame(None, Some("checkout_service::submit"))); assert!(!options.is_in_app_frame(None, Some("std::rt::lang_start"))); assert!(!options.is_in_app_frame(None, Some("core::ops::function::FnOnce::call_once"))); - assert!( - !options.is_in_app_frame(None, Some("posthog_rs::client::Client::capture_exception")) - ); + assert!(!options.is_in_app_frame(None, Some("posthog::client::Client::capture_exception"))); assert!(!options.is_in_app_frame(None, Some("_main"))); let options = ErrorTrackingOptionsBuilder::default() diff --git a/src/lib.rs b/src/lib.rs index 1291e455..ad9d247e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,15 +9,15 @@ //! //! # Getting started //! -//! Add `posthog-rs` to your `Cargo.toml`, then initialize a client with your +//! Add `posthog` to your `Cargo.toml`, then initialize a client with your //! project API key. //! //! ```no_run -//! use posthog_rs::{client, EvaluateFlagsOptions, Event}; +//! use posthog::{client, EvaluateFlagsOptions, Event}; //! //! #[cfg(feature = "async-client")] //! #[tokio::main] -//! async fn main() -> Result<(), posthog_rs::Error> { +//! async fn main() -> Result<(), posthog::Error> { //! let api_key = std::env::var("POSTHOG_API_KEY") //! .expect("set POSTHOG_API_KEY to your PostHog project API key"); //! @@ -44,7 +44,7 @@ //! } //! //! #[cfg(not(feature = "async-client"))] -//! fn main() -> Result<(), posthog_rs::Error> { +//! fn main() -> Result<(), posthog::Error> { //! let api_key = std::env::var("POSTHOG_API_KEY") //! .expect("set POSTHOG_API_KEY to your PostHog project API key"); //! diff --git a/tests/test.rs b/tests/test.rs index f29bdbe8..3e6e5c78 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -5,7 +5,7 @@ async fn get_client_async() { dotenv().ok(); // Load the .env file // see https://us.posthog.com/project/115809/ for the e2e project - use posthog_rs::Event; + use posthog::Event; use std::collections::HashMap; let api_key = match std::env::var("POSTHOG_RS_E2E_TEST_API_KEY") { @@ -15,7 +15,7 @@ async fn get_client_async() { return; } }; - let client = posthog_rs::client(api_key.as_str()).await; + let client = posthog::client(api_key.as_str()).await; let mut child_map = HashMap::new(); child_map.insert("child_key1", "child_value1"); @@ -35,7 +35,7 @@ fn get_client_blocking() { dotenv().ok(); // Load the .env file // see https://us.posthog.com/project/115809/ for the e2e project - use posthog_rs::Event; + use posthog::Event; use std::collections::HashMap; let api_key = match std::env::var("POSTHOG_RS_E2E_TEST_API_KEY") { @@ -45,7 +45,7 @@ fn get_client_blocking() { return; } }; - let client = posthog_rs::client(api_key.as_str()); + let client = posthog::client(api_key.as_str()); let mut child_map = HashMap::new(); child_map.insert("child_key1", "child_value1"); @@ -64,7 +64,7 @@ async fn get_client_v1_async() { use dotenv::dotenv; dotenv().ok(); - use posthog_rs::{ClientOptionsBuilder, Event}; + use posthog::{ClientOptionsBuilder, Event}; use std::collections::HashMap; let api_key = match std::env::var("POSTHOG_RS_E2E_TEST_API_KEY") { @@ -79,7 +79,7 @@ async fn get_client_v1_async() { .api_key(api_key) .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; let mut child_map = HashMap::new(); child_map.insert("child_key1", "child_value1"); diff --git a/tests/test_alias.rs b/tests/test_alias.rs index a388d44d..c82b572e 100644 --- a/tests/test_alias.rs +++ b/tests/test_alias.rs @@ -97,9 +97,9 @@ const BLANK_IDS: [&str; 2] = ["", " "]; mod blocking { use super::*; - fn create_test_client(base_url: String) -> posthog_rs::Client { - let options: posthog_rs::ClientOptions = ("test_api_key", base_url.as_str()).into(); - posthog_rs::client(options) + fn create_test_client(base_url: String) -> posthog::Client { + let options: posthog::ClientOptions = ("test_api_key", base_url.as_str()).into(); + posthog::client(options) } #[test] @@ -198,13 +198,13 @@ mod blocking { then.status(200).json_body(ok_response()); }); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .host(server.base_url()) .build() .unwrap(); assert!(options.is_disabled()); - let client = posthog_rs::client(options); + let client = posthog::client(options); client.alias(PREVIOUS_ID, DISTINCT_ID); client.flush(); @@ -216,9 +216,9 @@ mod blocking { mod async_client { use super::*; - async fn create_test_client(base_url: String) -> posthog_rs::Client { - let options: posthog_rs::ClientOptions = ("test_api_key", base_url.as_str()).into(); - posthog_rs::client(options).await + async fn create_test_client(base_url: String) -> posthog::Client { + let options: posthog::ClientOptions = ("test_api_key", base_url.as_str()).into(); + posthog::client(options).await } #[tokio::test] @@ -317,13 +317,13 @@ mod async_client { then.status(200).json_body(ok_response()); }); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .host(server.base_url()) .build() .unwrap(); assert!(options.is_disabled()); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; client.alias(PREVIOUS_ID, DISTINCT_ID); client.flush().await; diff --git a/tests/test_async.rs b/tests/test_async.rs index 9c9458c0..884dd464 100644 --- a/tests/test_async.rs +++ b/tests/test_async.rs @@ -3,9 +3,9 @@ use httpmock::prelude::*; use serde_json::json; -async fn create_test_client(base_url: String) -> posthog_rs::Client { - let options: posthog_rs::ClientOptions = ("test_api_key", base_url.as_str()).into(); - posthog_rs::client(options).await +async fn create_test_client(base_url: String) -> posthog::Client { + let options: posthog::ClientOptions = ("test_api_key", base_url.as_str()).into(); + posthog::client(options).await } #[tokio::test] @@ -20,7 +20,7 @@ async fn test_malformed_response() { let client = create_test_client(server.base_url()).await; let result = client - .evaluate_flags("test-user", posthog_rs::EvaluateFlagsOptions::default()) + .evaluate_flags("test-user", posthog::EvaluateFlagsOptions::default()) .await; assert!(result.is_err()); @@ -56,21 +56,21 @@ async fn assert_disabled_client_is_noop(api_key: Option<&str>) { })); }); - let mut options_builder = posthog_rs::ClientOptionsBuilder::default(); + let mut options_builder = posthog::ClientOptionsBuilder::default(); if let Some(api_key) = api_key { options_builder.api_key(api_key.to_string()); } let options = options_builder.host(server.base_url()).build().unwrap(); assert!(options.is_disabled()); - let client = posthog_rs::client(options).await; - let event = posthog_rs::Event::new("test_event", "user1"); + let client = posthog::client(options).await; + let event = posthog::Event::new("test_event", "user1"); client.capture(event.clone()); client.capture_batch(vec![event], false); let flags = client - .evaluate_flags("test-user", posthog_rs::EvaluateFlagsOptions::default()) + .evaluate_flags("test-user", posthog::EvaluateFlagsOptions::default()) .await .unwrap(); assert!(flags.keys().is_empty()); diff --git a/tests/test_blocking.rs b/tests/test_blocking.rs index 7995a566..2c035ead 100644 --- a/tests/test_blocking.rs +++ b/tests/test_blocking.rs @@ -31,21 +31,21 @@ fn assert_disabled_client_is_noop(api_key: Option<&str>) { })); }); - let mut options_builder = posthog_rs::ClientOptionsBuilder::default(); + let mut options_builder = posthog::ClientOptionsBuilder::default(); if let Some(api_key) = api_key { options_builder.api_key(api_key.to_string()); } let options = options_builder.host(server.base_url()).build().unwrap(); assert!(options.is_disabled()); - let client = posthog_rs::client(options); - let event = posthog_rs::Event::new("test_event", "user1"); + let client = posthog::client(options); + let event = posthog::Event::new("test_event", "user1"); client.capture(event.clone()); client.capture_batch(vec![event], false); let flags = client - .evaluate_flags("test-user", posthog_rs::EvaluateFlagsOptions::default()) + .evaluate_flags("test-user", posthog::EvaluateFlagsOptions::default()) .unwrap(); assert!(flags.keys().is_empty()); diff --git a/tests/test_capture.rs b/tests/test_capture.rs index 8d71ba3c..0f02afa8 100644 --- a/tests/test_capture.rs +++ b/tests/test_capture.rs @@ -12,10 +12,10 @@ use std::time::Duration; use httpmock::prelude::*; -use posthog_rs::{ClientOptionsBuilder, Event}; +use posthog::{ClientOptionsBuilder, Event}; use serde_json::json; -async fn create_capture_client(base_url: String) -> posthog_rs::Client { +async fn create_capture_client(base_url: String) -> posthog::Client { let options = ClientOptionsBuilder::default() .api_key("phc_test_token".to_string()) .host(base_url) @@ -26,7 +26,7 @@ async fn create_capture_client(base_url: String) -> posthog_rs::Client { .retry_max_backoff_ms(2000u64) .build() .unwrap(); - posthog_rs::client(options).await + posthog::client(options).await } // Constants required because httpmock `matches` takes bare fn pointers (no captures). @@ -482,7 +482,7 @@ async fn capture_injects_geoip_disable_when_configured() { .disable_geoip(true) .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; client.capture(Event::new("test", "user-1")); client.flush().await; @@ -590,7 +590,7 @@ async fn before_send_runs_after_capture_defaults() { }) .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; client.capture(Event::new("test", "user-1")); client.flush().await; @@ -624,7 +624,7 @@ async fn batch_before_send_runs_after_capture_defaults() { }) .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; client.capture_batch(vec![Event::new("test", "user-1")], false); client.flush().await; @@ -710,7 +710,7 @@ fn body_gunzips_to_user1(req: &HttpMockRequest) -> bool { #[tokio::test] async fn capture_sends_gzip_content_encoding() { - use posthog_rs::CaptureCompression; + use posthog::CaptureCompression; let server = MockServer::start(); let mock = server.mock(|when, then| { @@ -729,7 +729,7 @@ async fn capture_sends_gzip_content_encoding() { .capture_compression(CaptureCompression::Gzip) .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; client.capture(Event::new("test", "user-1")); client.flush().await; @@ -983,7 +983,7 @@ async fn capture_disabled_client_noop() { .disabled(true) .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; client.capture(Event::new("test", "user-1")); } diff --git a/tests/test_capture_ai.rs b/tests/test_capture_ai.rs index 1996ec48..1f538fd1 100644 --- a/tests/test_capture_ai.rs +++ b/tests/test_capture_ai.rs @@ -12,7 +12,7 @@ use std::sync::{Arc, Mutex}; use httpmock::prelude::*; -use posthog_rs::{ +use posthog::{ CaptureCompression, ClientOptionsBuilder, Endpoint, Event, EventStatus, PostHogError, }; use serde_json::json; @@ -150,8 +150,8 @@ fn all_ok(uuids: &[Uuid]) -> serde_json::Value { mod async_client { use super::*; - async fn client(builder: &mut ClientOptionsBuilder) -> posthog_rs::Client { - posthog_rs::client(builder.build().unwrap()).await + async fn client(builder: &mut ClientOptionsBuilder) -> posthog::Client { + posthog::client(builder.build().unwrap()).await } #[tokio::test] @@ -379,8 +379,8 @@ mod async_client { mod blocking { use super::*; - fn client(builder: &mut ClientOptionsBuilder) -> posthog_rs::Client { - posthog_rs::client(builder.build().unwrap()) + fn client(builder: &mut ClientOptionsBuilder) -> posthog::Client { + posthog::client(builder.build().unwrap()) } #[test] diff --git a/tests/test_capture_ai_global.rs b/tests/test_capture_ai_global.rs index 85db7839..c4f0d673 100644 --- a/tests/test_capture_ai_global.rs +++ b/tests/test_capture_ai_global.rs @@ -1,10 +1,10 @@ -//! `posthog_rs::capture_ai` on the global client rides the AI lane. +//! `posthog::capture_ai` on the global client rides the AI lane. //! //! Own integration-test binary on purpose: `init_global` sets a process-wide //! `OnceLock`, so this must not share a process with any other global test. use httpmock::prelude::*; -use posthog_rs::{CaptureCompression, ClientOptionsBuilder, Event}; +use posthog::{CaptureCompression, ClientOptionsBuilder, Event}; use serde_json::json; fn ok_mock<'a>(server: &'a MockServer, path: &str) -> httpmock::Mock<'a> { @@ -18,19 +18,19 @@ fn ok_mock<'a>(server: &'a MockServer, path: &str) -> httpmock::Mock<'a> { } #[cfg(feature = "async-client")] -fn init_and_flush(options: posthog_rs::ClientOptions, event: Event) { +fn init_and_flush(options: posthog::ClientOptions, event: Event) { futures::executor::block_on(async { - posthog_rs::init_global(options).await.unwrap(); - posthog_rs::capture_ai(event); - posthog_rs::flush().await; + posthog::init_global(options).await.unwrap(); + posthog::capture_ai(event); + posthog::flush().await; }); } #[cfg(not(feature = "async-client"))] -fn init_and_flush(options: posthog_rs::ClientOptions, event: Event) { - posthog_rs::init_global(options).unwrap(); - posthog_rs::capture_ai(event); - posthog_rs::flush(); +fn init_and_flush(options: posthog::ClientOptions, event: Event) { + posthog::init_global(options).unwrap(); + posthog::capture_ai(event); + posthog::flush(); } #[test] diff --git a/tests/test_capture_blocking.rs b/tests/test_capture_blocking.rs index 43e70758..f730dc9c 100644 --- a/tests/test_capture_blocking.rs +++ b/tests/test_capture_blocking.rs @@ -9,10 +9,10 @@ //! flushes. Wire-format assertions are unchanged from the synchronous model. use httpmock::prelude::*; -use posthog_rs::{ClientOptionsBuilder, Event}; +use posthog::{ClientOptionsBuilder, Event}; use serde_json::json; -fn create_capture_client(base_url: String) -> posthog_rs::Client { +fn create_capture_client(base_url: String) -> posthog::Client { let options = ClientOptionsBuilder::default() .api_key("phc_test_token".to_string()) .host(base_url) @@ -21,7 +21,7 @@ fn create_capture_client(base_url: String) -> posthog_rs::Client { .retry_max_backoff_ms(50u64) .build() .unwrap(); - posthog_rs::client(options) + posthog::client(options) } // Constants required because httpmock `matches` takes bare fn pointers (no captures). @@ -543,7 +543,7 @@ fn blocking_injects_geoip_disable_when_configured() { .disable_geoip(true) .build() .unwrap(); - let client = posthog_rs::client(options); + let client = posthog::client(options); client.capture(Event::new("test", "user-1")); client.flush(); @@ -624,7 +624,7 @@ fn body_gunzips_to_user1(req: &HttpMockRequest) -> bool { #[test] fn blocking_sends_gzip_content_encoding() { - use posthog_rs::CaptureCompression; + use posthog::CaptureCompression; let server = MockServer::start(); let mock = server.mock(|when, then| { @@ -643,7 +643,7 @@ fn blocking_sends_gzip_content_encoding() { .capture_compression(CaptureCompression::Gzip) .build() .unwrap(); - let client = posthog_rs::client(options); + let client = posthog::client(options); client.capture(Event::new("test", "user-1")); client.flush(); @@ -719,7 +719,7 @@ fn blocking_disabled_client_noop() { .disabled(true) .build() .unwrap(); - let client = posthog_rs::client(options); + let client = posthog::client(options); client.capture(Event::new("test", "user-1")); } diff --git a/tests/test_capture_immediate.rs b/tests/test_capture_immediate.rs index c057814c..4399e5bf 100644 --- a/tests/test_capture_immediate.rs +++ b/tests/test_capture_immediate.rs @@ -18,11 +18,11 @@ mod async_capture { use std::sync::{Arc, Mutex}; use httpmock::prelude::*; - use posthog_rs::{Client, ClientOptionsBuilder, Event, PostHogError}; + use posthog::{Client, ClientOptionsBuilder, Event, PostHogError}; use serde_json::json; async fn capture_client(base_url: String) -> Client { - posthog_rs::client( + posthog::client( ClientOptionsBuilder::default() .api_key("phc_test_token".to_string()) .host(base_url) @@ -232,7 +232,7 @@ mod async_capture { }); let (count, hook) = error_sink(); - let client = posthog_rs::client( + let client = posthog::client( ClientOptionsBuilder::default() .api_key("phc_test_token".to_string()) .host(server.base_url()) @@ -256,7 +256,7 @@ mod async_capture { #[tokio::test] async fn disabled_and_empty_are_noops() { // Disabled client: no request, default summary. - let disabled = posthog_rs::client( + let disabled = posthog::client( ClientOptionsBuilder::default() .api_key("phc_test".to_string()) .disabled(true) @@ -295,11 +295,11 @@ mod blocking { use std::sync::{Arc, Mutex}; use httpmock::prelude::*; - use posthog_rs::{Client, ClientOptionsBuilder, Event, PostHogError}; + use posthog::{Client, ClientOptionsBuilder, Event, PostHogError}; use serde_json::json; fn capture_client(base_url: String) -> Client { - posthog_rs::client( + posthog::client( ClientOptionsBuilder::default() .api_key("phc_test_token".to_string()) .host(base_url) @@ -407,7 +407,7 @@ mod blocking { let count = Arc::new(Mutex::new(0usize)); let sink = count.clone(); - let client = posthog_rs::client( + let client = posthog::client( ClientOptionsBuilder::default() .api_key("phc_test_token".to_string()) .host(server.base_url()) diff --git a/tests/test_error_tracking.rs b/tests/test_error_tracking.rs index c6cc83fe..7a9a40cb 100644 --- a/tests/test_error_tracking.rs +++ b/tests/test_error_tracking.rs @@ -86,16 +86,16 @@ fn request_has_no_stacktrace(req: &HttpMockRequest) -> bool { #[cfg(not(feature = "async-client"))] mod blocking { use super::*; - use posthog_rs::CaptureExceptionOptions; + use posthog::CaptureExceptionOptions; - fn create_test_client(base_url: String) -> posthog_rs::Client { - let options = posthog_rs::ClientOptionsBuilder::default() + fn create_test_client(base_url: String) -> posthog::Client { + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(base_url) .max_capture_attempts(1u32) .build() .unwrap(); - posthog_rs::client(options) + posthog::client(options) } #[test] @@ -160,13 +160,13 @@ mod blocking { #[test] fn disabled_capture_exception_does_not_build_exception_payload() { - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host("http://127.0.0.1:1") .disabled(true) .build() .unwrap(); - let client = posthog_rs::client(options); + let client = posthog::client(options); client.capture_exception(&PanicDisplayError).unwrap(); client @@ -193,19 +193,19 @@ mod blocking { .json_body(ok_response()); }); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url()) .max_capture_attempts(1u32) .error_tracking( - posthog_rs::ErrorTrackingOptionsBuilder::default() + posthog::ErrorTrackingOptionsBuilder::default() .capture_stacktrace(false) .build() .unwrap(), ) .build() .unwrap(); - let client = posthog_rs::client(options); + let client = posthog::client(options); client.capture_exception(&TestError).unwrap(); client.flush(); @@ -217,16 +217,16 @@ mod blocking { #[cfg(feature = "async-client")] mod async_client { use super::*; - use posthog_rs::CaptureExceptionOptions; + use posthog::CaptureExceptionOptions; - async fn create_test_client(base_url: String) -> posthog_rs::Client { - let options = posthog_rs::ClientOptionsBuilder::default() + async fn create_test_client(base_url: String) -> posthog::Client { + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(base_url) .max_capture_attempts(1u32) .build() .unwrap(); - posthog_rs::client(options).await + posthog::client(options).await } #[tokio::test] @@ -292,13 +292,13 @@ mod async_client { #[tokio::test] async fn disabled_capture_exception_does_not_build_exception_payload() { - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host("http://127.0.0.1:1") .disabled(true) .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; client.capture_exception(&PanicDisplayError).await.unwrap(); client @@ -326,19 +326,19 @@ mod async_client { .json_body(ok_response()); }); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url()) .max_capture_attempts(1u32) .error_tracking( - posthog_rs::ErrorTrackingOptionsBuilder::default() + posthog::ErrorTrackingOptionsBuilder::default() .capture_stacktrace(false) .build() .unwrap(), ) .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; client.capture_exception(&TestError).await.unwrap(); client.flush().await; diff --git a/tests/test_evaluate_flags.rs b/tests/test_evaluate_flags.rs index 34cf3816..a9bb046d 100644 --- a/tests/test_evaluate_flags.rs +++ b/tests/test_evaluate_flags.rs @@ -318,12 +318,12 @@ fn start_status_then_success_flags_server( #[cfg(not(feature = "async-client"))] mod blocking { use super::*; - use posthog_rs::{EvaluateFlagsOptions, Event, FlagValue}; + use posthog::{EvaluateFlagsOptions, Event, FlagValue}; use reqwest::header::USER_AGENT; - fn create_test_client(base_url: String) -> posthog_rs::Client { - let options: posthog_rs::ClientOptions = ("test_api_key", base_url.as_str()).into(); - posthog_rs::client(options) + fn create_test_client(base_url: String) -> posthog::Client { + let options: posthog::ClientOptions = ("test_api_key", base_url.as_str()).into(); + posthog::client(options) } #[test] @@ -354,14 +354,14 @@ mod blocking { when.method(POST).path("/flags/"); then.status(200).json_body(flags_response_fixture()); }); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url()) .enable_local_evaluation(true) .local_evaluation_only(true) .build() .unwrap(); - let client = posthog_rs::client(options); + let client = posthog::client(options); let snapshot = client .evaluate_flags("user-1", EvaluateFlagsOptions::default()) @@ -374,7 +374,7 @@ mod blocking { #[test] fn evaluate_flags_retries_transport_error_then_succeeds() { let server = start_flaky_flags_server(flags_response_fixture().to_string()); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url.clone()) .feature_flags_request_max_retries(1u32) @@ -382,7 +382,7 @@ mod blocking { .retry_max_backoff_ms(1u64) .build() .unwrap(); - let client = posthog_rs::client(options); + let client = posthog::client(options); let flags = client .evaluate_flags("user-1", EvaluateFlagsOptions::default()) @@ -395,7 +395,7 @@ mod blocking { #[test] fn evaluate_flags_returns_error_after_transport_retry_budget() { let server = start_resetting_flags_server(2); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url.clone()) .feature_flags_request_max_retries(1u32) @@ -403,13 +403,13 @@ mod blocking { .retry_max_backoff_ms(1u64) .build() .unwrap(); - let client = posthog_rs::client(options); + let client = posthog::client(options); let err = client .evaluate_flags("user-1", EvaluateFlagsOptions::default()) .expect_err("transport errors should stop after retry budget is exhausted"); - assert!(matches!(err, posthog_rs::Error::Connection(_))); + assert!(matches!(err, posthog::Error::Connection(_))); server.assert_attempts(2); } @@ -420,7 +420,7 @@ mod blocking { status, flags_response_fixture().to_string(), ); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url.clone()) .feature_flags_request_max_retries(1u32) @@ -428,7 +428,7 @@ mod blocking { .retry_max_backoff_ms(1u64) .build() .unwrap(); - let client = posthog_rs::client(options); + let client = posthog::client(options); let snapshot = client .evaluate_flags("user-1", EvaluateFlagsOptions::default()) @@ -447,7 +447,7 @@ mod blocking { when.method(POST).path("/flags/"); then.status(status).body("transient flags error"); }); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url()) .feature_flags_request_max_retries(1u32) @@ -455,7 +455,7 @@ mod blocking { .retry_max_backoff_ms(1u64) .build() .unwrap(); - let client = posthog_rs::client(options); + let client = posthog::client(options); let err = client .evaluate_flags("user-1", EvaluateFlagsOptions::default()) @@ -473,7 +473,7 @@ mod blocking { when.method(POST).path("/flags/"); then.status(500).body("boom"); }); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url()) .max_capture_attempts(3u32) @@ -481,7 +481,7 @@ mod blocking { .retry_max_backoff_ms(1u64) .build() .unwrap(); - let client = posthog_rs::client(options); + let client = posthog::client(options); let err = client .evaluate_flags("user-1", EvaluateFlagsOptions::default()) @@ -679,7 +679,7 @@ mod blocking { then.status(200).json_body(flags_response_fixture()); }); let capture_mock = capture_path_mock(&server); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url()) .secret_key("test_personal_key".to_string()) @@ -687,7 +687,7 @@ mod blocking { .poll_interval_seconds(3600) .build() .unwrap(); - let client = posthog_rs::client(options); + let client = posthog::client(options); definitions_mock.assert_calls(1); let mut evaluate_options = EvaluateFlagsOptions::default(); @@ -927,13 +927,13 @@ mod blocking { when.method(POST).path("/flags/"); then.status(200).json_body(flags_response_fixture()); }); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url()) .disabled(true) .build() .unwrap(); - let client = posthog_rs::client(options); + let client = posthog::client(options); let snapshot = client .evaluate_flags("user-1", EvaluateFlagsOptions::default()) .unwrap(); @@ -1000,12 +1000,12 @@ mod blocking { #[cfg(feature = "async-client")] mod async_tests { use super::*; - use posthog_rs::{EvaluateFlagsOptions, Event, FlagValue}; + use posthog::{EvaluateFlagsOptions, Event, FlagValue}; use reqwest::header::USER_AGENT; - async fn create_test_client(base_url: String) -> posthog_rs::Client { - let options: posthog_rs::ClientOptions = ("test_api_key", base_url.as_str()).into(); - posthog_rs::client(options).await + async fn create_test_client(base_url: String) -> posthog::Client { + let options: posthog::ClientOptions = ("test_api_key", base_url.as_str()).into(); + posthog::client(options).await } #[tokio::test] @@ -1033,14 +1033,14 @@ mod async_tests { when.method(POST).path("/flags/"); then.status(200).json_body(flags_response_fixture()); }); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url()) .enable_local_evaluation(true) .local_evaluation_only(true) .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; let snapshot = client .evaluate_flags("user-1", EvaluateFlagsOptions::default()) @@ -1054,7 +1054,7 @@ mod async_tests { #[tokio::test] async fn evaluate_flags_retries_transport_error_then_succeeds() { let server = start_flaky_flags_server(flags_response_fixture().to_string()); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url.clone()) .feature_flags_request_max_retries(1u32) @@ -1062,7 +1062,7 @@ mod async_tests { .retry_max_backoff_ms(1u64) .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; let flags = client .evaluate_flags("user-1", EvaluateFlagsOptions::default()) @@ -1076,7 +1076,7 @@ mod async_tests { #[tokio::test] async fn evaluate_flags_returns_error_after_transport_retry_budget() { let server = start_resetting_flags_server(2); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url.clone()) .feature_flags_request_max_retries(1u32) @@ -1084,14 +1084,14 @@ mod async_tests { .retry_max_backoff_ms(1u64) .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; let err = client .evaluate_flags("user-1", EvaluateFlagsOptions::default()) .await .expect_err("transport errors should stop after retry budget is exhausted"); - assert!(matches!(err, posthog_rs::Error::Connection(_))); + assert!(matches!(err, posthog::Error::Connection(_))); server.assert_attempts(2); } @@ -1102,7 +1102,7 @@ mod async_tests { status, flags_response_fixture().to_string(), ); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url.clone()) .feature_flags_request_max_retries(1u32) @@ -1110,7 +1110,7 @@ mod async_tests { .retry_max_backoff_ms(1u64) .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; let snapshot = client .evaluate_flags("user-1", EvaluateFlagsOptions::default()) @@ -1130,7 +1130,7 @@ mod async_tests { when.method(POST).path("/flags/"); then.status(status).body("transient flags error"); }); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url()) .feature_flags_request_max_retries(1u32) @@ -1138,7 +1138,7 @@ mod async_tests { .retry_max_backoff_ms(1u64) .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; let err = client .evaluate_flags("user-1", EvaluateFlagsOptions::default()) @@ -1157,7 +1157,7 @@ mod async_tests { when.method(POST).path("/flags/"); then.status(500).body("boom"); }); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url()) .max_capture_attempts(3u32) @@ -1165,7 +1165,7 @@ mod async_tests { .retry_max_backoff_ms(1u64) .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; let err = client .evaluate_flags("user-1", EvaluateFlagsOptions::default()) @@ -1270,7 +1270,7 @@ mod async_tests { then.status(200).json_body(flags_response_fixture()); }); let capture_mock = capture_path_mock(&server); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url()) .secret_key("test_personal_key".to_string()) @@ -1278,7 +1278,7 @@ mod async_tests { .poll_interval_seconds(3600) .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; definitions_mock.assert_calls(1); let mut evaluate_options = EvaluateFlagsOptions::default(); diff --git a/tests/test_group_identify.rs b/tests/test_group_identify.rs index 1404588c..10b91734 100644 --- a/tests/test_group_identify.rs +++ b/tests/test_group_identify.rs @@ -113,9 +113,9 @@ const BLANK_KEYS: [&str; 2] = ["", " "]; mod blocking { use super::*; - fn create_test_client(base_url: String) -> posthog_rs::Client { - let options: posthog_rs::ClientOptions = ("test_api_key", base_url.as_str()).into(); - posthog_rs::client(options) + fn create_test_client(base_url: String) -> posthog::Client { + let options: posthog::ClientOptions = ("test_api_key", base_url.as_str()).into(); + posthog::client(options) } #[test] @@ -239,13 +239,13 @@ mod blocking { then.status(200).json_body(ok_response()); }); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .host(server.base_url()) .build() .unwrap(); assert!(options.is_disabled()); - let client = posthog_rs::client(options); + let client = posthog::client(options); client .group_identify(GROUP_TYPE, GROUP_KEY, json!({ "name": "Awesome Inc." })) .unwrap(); @@ -259,9 +259,9 @@ mod blocking { mod async_client { use super::*; - async fn create_test_client(base_url: String) -> posthog_rs::Client { - let options: posthog_rs::ClientOptions = ("test_api_key", base_url.as_str()).into(); - posthog_rs::client(options).await + async fn create_test_client(base_url: String) -> posthog::Client { + let options: posthog::ClientOptions = ("test_api_key", base_url.as_str()).into(); + posthog::client(options).await } #[tokio::test] @@ -397,13 +397,13 @@ mod async_client { }) .await; - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .host(server.base_url()) .build() .unwrap(); assert!(options.is_disabled()); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; client .group_identify(GROUP_TYPE, GROUP_KEY, json!({ "name": "Awesome Inc." })) .unwrap(); diff --git a/tests/test_local_evaluation.rs b/tests/test_local_evaluation.rs index 08c7c877..19088263 100644 --- a/tests/test_local_evaluation.rs +++ b/tests/test_local_evaluation.rs @@ -3,8 +3,8 @@ mod common; use common::default_user_agent; use httpmock::prelude::*; #[cfg(feature = "async-client")] -use posthog_rs::{AsyncFlagPoller, ClientOptionsBuilder, EvaluateFlagsOptions}; -use posthog_rs::{ +use posthog::{AsyncFlagPoller, ClientOptionsBuilder, EvaluateFlagsOptions}; +use posthog::{ FeatureFlag, FeatureFlagCondition, FeatureFlagFilters, FlagCache, FlagPoller, FlagValue, LocalEvaluationConfig, LocalEvaluationResponse, LocalEvaluator, Property, }; @@ -415,7 +415,7 @@ async fn test_local_evaluation_with_mock_server() { .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; // Give it a moment to load initial flags tokio::time::sleep(Duration::from_millis(100)).await; @@ -489,7 +489,7 @@ async fn test_client_adds_distinct_id_for_local_evaluation_only() { .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; tokio::time::sleep(Duration::from_millis(100)).await; let flags = client @@ -582,7 +582,7 @@ async fn test_local_evaluation_returns_payloads_without_calling_flags() { .build() .unwrap(); - let client = posthog_rs::client(options).await; + let client = posthog::client(options).await; tokio::time::sleep(Duration::from_millis(100)).await; let mut options = EvaluateFlagsOptions::default(); @@ -646,7 +646,7 @@ async fn test_local_evaluation_with_mock_server_sends_default_user_agent() { .build() .unwrap(); - let _client = posthog_rs::client(options).await; + let _client = posthog::client(options).await; // Give it a moment to load initial flags tokio::time::sleep(Duration::from_millis(100)).await; diff --git a/tests/test_minimal_flag_called_events.rs b/tests/test_minimal_flag_called_events.rs index 42c245cb..2daf4b48 100644 --- a/tests/test_minimal_flag_called_events.rs +++ b/tests/test_minimal_flag_called_events.rs @@ -18,7 +18,7 @@ use std::sync::{ use std::thread; use std::time::{Duration, Instant}; -use posthog_rs::EvaluateFlagsOptions; +use posthog::EvaluateFlagsOptions; const CAPTURE_PATH: &str = "/i/v1/analytics/events"; @@ -189,8 +189,8 @@ async fn captured_flag_called_properties( ) -> serde_json::Map { let server = start_recording_server(gate); - let options: posthog_rs::ClientOptions = ("phc_test", server.base_url.as_str()).into(); - let client = posthog_rs::client(options).await; + let options: posthog::ClientOptions = ("phc_test", server.base_url.as_str()).into(); + let client = posthog::client(options).await; let snapshot = client .evaluate_flags("user-1", EvaluateFlagsOptions::default()) .await diff --git a/tests/test_on_error.rs b/tests/test_on_error.rs index ac733149..f4928d21 100644 --- a/tests/test_on_error.rs +++ b/tests/test_on_error.rs @@ -4,7 +4,7 @@ //! httpmock server and asserts the hook observes the failure. use httpmock::prelude::*; -use posthog_rs::PostHogError; +use posthog::PostHogError; use serde_json::json; use std::sync::{Arc, Mutex}; @@ -69,7 +69,7 @@ fn local_eval_sink() -> (LocalEvalSink, impl Fn(&PostHogError<'_>) + Send + 'sta #[cfg(not(feature = "async-client"))] mod blocking { use super::*; - use posthog_rs::EvaluateFlagsOptions; + use posthog::EvaluateFlagsOptions; use std::thread; use std::time::Duration; @@ -81,8 +81,8 @@ mod blocking { then.status(500).body("boom"); }); let (recorded, hook) = flags_sink(); - let client = posthog_rs::client( - posthog_rs::ClientOptionsBuilder::default() + let client = posthog::client( + posthog::ClientOptionsBuilder::default() .api_key("phc_test".to_string()) .host(server.base_url()) .on_error(hook) @@ -121,8 +121,8 @@ mod blocking { then.status(500).body("boom"); }); let (recorded, hook) = flags_sink(); - let client = posthog_rs::client( - posthog_rs::ClientOptionsBuilder::default() + let client = posthog::client( + posthog::ClientOptionsBuilder::default() .api_key("phc_test".to_string()) .host(server.base_url()) .secret_key("phx_test".to_string()) @@ -152,8 +152,8 @@ mod blocking { then.status(401).body("unauthorized"); }); let (recorded, hook) = local_eval_sink(); - let _client = posthog_rs::client( - posthog_rs::ClientOptionsBuilder::default() + let _client = posthog::client( + posthog::ClientOptionsBuilder::default() .api_key("phc_test".to_string()) .host(server.base_url()) .secret_key("phx_test".to_string()) @@ -192,7 +192,7 @@ mod blocking { // The hook needs a handle to the client that owns it; a `Weak` cell // breaks the ownership cycle (Client -> hook -> cell -> Client) so the // client still drops normally at end of test. - let cell: Arc>> = Arc::new(OnceLock::new()); + let cell: Arc>> = Arc::new(OnceLock::new()); let depth = Arc::new(AtomicUsize::new(0)); let cell_for_hook = cell.clone(); let depth_for_hook = depth.clone(); @@ -207,8 +207,8 @@ mod blocking { } }; - let client = Arc::new(posthog_rs::client( - posthog_rs::ClientOptionsBuilder::default() + let client = Arc::new(posthog::client( + posthog::ClientOptionsBuilder::default() .api_key("phc_test".to_string()) .host(server.base_url()) .on_error(hook) @@ -251,8 +251,8 @@ mod blocking { then.status(401).body("unauthorized"); }); let (recorded, hook) = local_eval_sink(); - let _client = posthog_rs::client( - posthog_rs::ClientOptionsBuilder::default() + let _client = posthog::client( + posthog::ClientOptionsBuilder::default() .api_key("phc_test".to_string()) .host(server.base_url()) .secret_key("phx_test".to_string()) @@ -281,7 +281,7 @@ mod blocking { #[cfg(feature = "async-client")] mod async_tests { use super::*; - use posthog_rs::EvaluateFlagsOptions; + use posthog::EvaluateFlagsOptions; #[tokio::test] async fn flags_failure_reports_status_endpoint_and_body() { @@ -291,8 +291,8 @@ mod async_tests { then.status(500).body("boom"); }); let (recorded, hook) = flags_sink(); - let client = posthog_rs::client( - posthog_rs::ClientOptionsBuilder::default() + let client = posthog::client( + posthog::ClientOptionsBuilder::default() .api_key("phc_test".to_string()) .host(server.base_url()) .on_error(hook) @@ -330,8 +330,8 @@ mod async_tests { then.status(500).body("boom"); }); let (recorded, hook) = flags_sink(); - let client = posthog_rs::client( - posthog_rs::ClientOptionsBuilder::default() + let client = posthog::client( + posthog::ClientOptionsBuilder::default() .api_key("phc_test".to_string()) .host(server.base_url()) .secret_key("phx_test".to_string()) @@ -366,8 +366,8 @@ mod async_tests { then.status(401).body("unauthorized"); }); let (recorded, hook) = local_eval_sink(); - let _client = posthog_rs::client( - posthog_rs::ClientOptionsBuilder::default() + let _client = posthog::client( + posthog::ClientOptionsBuilder::default() .api_key("phc_test".to_string()) .host(server.base_url()) .secret_key("phx_test".to_string()) @@ -396,8 +396,8 @@ mod async_tests { then.status(401).body("unauthorized"); }); let (recorded, hook) = local_eval_sink(); - let _client = posthog_rs::client( - posthog_rs::ClientOptionsBuilder::default() + let _client = posthog::client( + posthog::ClientOptionsBuilder::default() .api_key("phc_test".to_string()) .host(server.base_url()) .secret_key("phx_test".to_string()) diff --git a/tests/test_panic_global.rs b/tests/test_panic_global.rs index 41b5b06e..e088f697 100644 --- a/tests/test_panic_global.rs +++ b/tests/test_panic_global.rs @@ -14,9 +14,9 @@ use httpmock::prelude::*; use std::panic::{self, AssertUnwindSafe}; /// The panic site, named so the captured stack frame is matchable. Lives in -/// this test crate (not `posthog_rs`), so its frame classifies as in-app — +/// this test crate (not `posthog`), so its frame classifies as in-app — /// which the in-process unit tests can't show (a panic there originates inside -/// `posthog_rs`, which is classified out-of-app). +/// `posthog`, which is classified out-of-app). #[inline(never)] fn integration_panic_site() { panic!("integration panic boom"); @@ -54,12 +54,12 @@ fn is_panic_exception(req: &HttpMockRequest) -> bool { }); // Canonical wire order puts the crash site last. The panic hook fires nested // inside the panic runtime, so a naive reverse would leave the SDK's own hook - // plumbing (`posthog_rs::error_tracking::*`) as the tail. We strip everything - // innermost of the panic dispatcher, so no posthog_rs frame survives at all, + // plumbing (`posthog::error_tracking::*`) as the tail. We strip everything + // innermost of the panic dispatcher, so no posthog frame survives at all, // and the tail is the crash-side panic runtime rather than an SDK frame. let no_sdk_frames = !function_names .iter() - .any(|name| name.contains("posthog_rs::error_tracking")); + .any(|name| name.contains("posthog::error_tracking")); let tail_is_panic_runtime = function_names .last() .is_some_and(|name| name.contains("panicking::") || name.contains("panic_with_hook")); @@ -82,15 +82,15 @@ fn is_panic_exception(req: &HttpMockRequest) -> bool { } #[cfg(feature = "async-client")] -fn init_global_for_test(options: posthog_rs::ClientOptions) -> Result<(), posthog_rs::Error> { +fn init_global_for_test(options: posthog::ClientOptions) -> Result<(), posthog::Error> { // The async constructor only awaits under local evaluation, so a minimal // executor drives it with no Tokio runtime needed. - futures::executor::block_on(posthog_rs::init_global(options)) + futures::executor::block_on(posthog::init_global(options)) } #[cfg(not(feature = "async-client"))] -fn init_global_for_test(options: posthog_rs::ClientOptions) -> Result<(), posthog_rs::Error> { - posthog_rs::init_global(options) +fn init_global_for_test(options: posthog::ClientOptions) -> Result<(), posthog::Error> { + posthog::init_global(options) } #[test] @@ -105,11 +105,11 @@ fn init_global_installs_panic_capture_when_enabled() { // caught, expected panic doesn't print to the test output. panic::set_hook(Box::new(|_| {})); - let options = posthog_rs::ClientOptionsBuilder::default() + let options = posthog::ClientOptionsBuilder::default() .api_key("test_api_key".to_string()) .host(server.base_url()) .error_tracking( - posthog_rs::ErrorTrackingOptionsBuilder::default() + posthog::ErrorTrackingOptionsBuilder::default() .capture_panics(true) .build() .unwrap(), diff --git a/tests/test_tls_no_provider.rs b/tests/test_tls_no_provider.rs index 6ef365f8..3cdccfcd 100644 --- a/tests/test_tls_no_provider.rs +++ b/tests/test_tls_no_provider.rs @@ -5,7 +5,7 @@ //! TLS connector at client construction time and rustls panics if no provider //! is available, so successfully constructing a client is the regression check. -use posthog_rs::{ClientOptions, ClientOptionsBuilder}; +use posthog::{ClientOptions, ClientOptionsBuilder}; fn install_ring_provider() { // Ignore the result: `install_default` fails if a process-level provider @@ -25,12 +25,12 @@ fn options() -> ClientOptions { #[test] fn blocking_client_builds_with_installed_provider() { install_ring_provider(); - let _client = posthog_rs::client(options()); + let _client = posthog::client(options()); } #[cfg(feature = "async-client")] #[tokio::test] async fn async_client_builds_with_installed_provider() { install_ring_provider(); - let _client = posthog_rs::client(options()).await; + let _client = posthog::client(options()).await; } diff --git a/tests/test_transport.rs b/tests/test_transport.rs index b1e56101..fc3ed623 100644 --- a/tests/test_transport.rs +++ b/tests/test_transport.rs @@ -8,7 +8,7 @@ use std::time::Duration; use httpmock::prelude::*; -use posthog_rs::{Client, ClientOptionsBuilder, Event}; +use posthog::{Client, ClientOptionsBuilder, Event}; async fn client_with(host: String, flush_at: usize, max_attempts: u32) -> Client { let options = ClientOptionsBuilder::default() @@ -27,7 +27,7 @@ async fn client_with(host: String, flush_at: usize, max_attempts: u32) -> Client .retry_max_backoff_ms(600_000u64) .build() .unwrap(); - posthog_rs::client(options).await + posthog::client(options).await } /// Poll a mock until it has been hit `want` times (for worker-timed paths such