Skip to content

🐛 fix(analytics): respect capture consent across providers - #9

Merged
sudongyuer merged 2 commits into
lobehub:masterfrom
AmAzing129:fix/analytics-capture-consent
Jul 30, 2026
Merged

🐛 fix(analytics): respect capture consent across providers#9
sudongyuer merged 2 commits into
lobehub:masterfrom
AmAzing129:fix/analytics-capture-consent

Conversation

@AmAzing129

Copy link
Copy Markdown
Contributor

Summary

  • add a captureEnabled configuration and runtime setter to the analytics manager
  • synchronize PostHog opt-in/opt-out, GA4 strict opt-out, and deferred X Ads initialization
  • sync consent before React provider initialization while keeping reset available for identity cleanup
  • document the consent-aware integration and add regression coverage

Tests

  • bun run ci
  • CI=1 bun run test
  • bun run build

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.14208% with 40 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@9f73688). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/providers/posthog-node.ts 42.10% 11 Missing ⚠️
src/manager.ts 74.28% 9 Missing ⚠️
src/providers/ga4.ts 83.33% 7 Missing and 1 partial ⚠️
src/react/provider.tsx 0.00% 6 Missing ⚠️
src/providers/posthog.ts 87.87% 3 Missing and 1 partial ⚠️
src/providers/xads.ts 96.15% 1 Missing ⚠️
src/server.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master       #9   +/-   ##
=========================================
  Coverage          ?   31.42%           
=========================================
  Files             ?       25           
  Lines             ?     2049           
  Branches          ?      182           
=========================================
  Hits              ?      644           
  Misses            ?     1395           
  Partials          ?       10           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new

pkg-pr-new Bot commented Jul 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@lobehub/analytics@9

commit: 388b07e

@sudongyuer
sudongyuer merged commit d54eb0f into lobehub:master Jul 30, 2026
5 checks passed
github-actions Bot pushed a commit that referenced this pull request Jul 30, 2026
### [Version 1.6.4](v1.6.3...v1.6.4)
<sup>Released on **2026-07-30**</sup>

#### 🐛 Bug Fixes

- **analytics**: Respect capture consent across providers.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's fixed

* **analytics**: Respect capture consent across providers, closes [#9](#9) ([d54eb0f](d54eb0f))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
@lobehubbot

Copy link
Copy Markdown
Member

🎉 This PR is included in version 1.6.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants