Skip to content

Fix peer connection previous-connect analytics scope - #1763

Draft
rahul-lohra wants to merge 1 commit into
developfrom
improvement/rahullohra/correct-pc-connected-analytics
Draft

Fix peer connection previous-connect analytics scope#1763
rahul-lohra wants to merge 1 commit into
developfrom
improvement/rahullohra/correct-pc-connected-analytics

Conversation

@rahul-lohra

@rahul-lohra rahul-lohra commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Goal

Closes #AND-1368

Ensure wasPreviouslyConnected is reported only for the relevant peer connection role within the current call analytics lifecycle, instead of leaking cached state from previous calls.

Implementation

Moved peer connection “ever connected” tracking out of the client-level reporter state and into PeerConnectionAnalyticsStateHolder, so the value is scoped to peer connection analytics for the current call. PeerConnectionAnalytics now updates publisher/subscriber connected state when a CONNECTED event is observed and passes the role-specific wasPrevConnected value into ClientEventReporter.

🎨 UI Changes

None

Testing

  • first connection attempts report wasPrevConnected = false
  • reconnects after a successful connection report wasPrevConnected = true
  • publisher and subscriber previous-connect state are tracked independently
  • reporter tests use the explicit wasPrevConnected input instead of relying on cached client-level state
  • Verify manually in backend logs

Summary by CodeRabbit

  • Analytics

    • Improved peer-connection analytics to accurately identify whether publisher and subscriber connections have previously connected.
    • Reconnection events now report the correct prior-connection status for clearer connection lifecycle insights.
  • Tests

    • Added coverage for initial connections, failures, reconnects, and publisher/subscriber-specific connection states.

@rahul-lohra rahul-lohra self-assigned this Aug 6, 2026
@rahul-lohra
rahul-lohra requested a review from a team as a code owner August 6, 2026 12:11
@rahul-lohra rahul-lohra added the pr:improvement Enhances an existing feature or code label Aug 6, 2026
@rahul-lohra rahul-lohra changed the title Fix peer connection previous-connect analytics scope [AND-1368] Fix peer connection previous-connect analytics scope Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@rahul-lohra rahul-lohra changed the title [AND-1368] Fix peer connection previous-connect analytics scope Fix peer connection previous-connect analytics scope Aug 6, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a74cc922-bdca-4dfd-9950-3d74d8b064d0

📥 Commits

Reviewing files that changed from the base of the PR and between b1ba57b and 624431a.

📒 Files selected for processing (5)
  • stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/analytics/call/observer/PeerConnectionAnalytics.kt
  • stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/analytics/call/observer/PeerConnectionAnalyticsStateHolder.kt
  • stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/analytics/reporting/ClientEventReporter.kt
  • stream-video-android-core/src/test/kotlin/io/getstream/video/android/core/analytics/call/observer/PeerConnectionAnalyticsTest.kt
  • stream-video-android-core/src/test/kotlin/io/getstream/video/android/core/analytics/reporting/ClientEventReporterTest.kt

Walkthrough

Peer connection analytics now tracks publisher and subscriber connection history separately. The role-specific state is passed to event reporting, which no longer stores its own connection-history map. Tests cover initial connections, failures, connected states, and publisher reconnects.

Changes

Peer connection history tracking

Layer / File(s) Summary
Track role-specific connection history
stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/analytics/call/observer/PeerConnectionAnalytics.kt, stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/analytics/call/observer/PeerConnectionAnalyticsStateHolder.kt
The state holder stores separate publisher and subscriber connection flags. PeerConnectionAnalytics updates and reads the flag for the current role.
Pass previous connection state to reporting
stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/analytics/reporting/ClientEventReporter.kt
ClientEventReporter receives wasPrevConnected from the observer and removes its local peer connection history tracking.
Validate initial and reconnect events
stream-video-android-core/src/test/kotlin/io/getstream/video/android/core/analytics/call/observer/PeerConnectionAnalyticsTest.kt, stream-video-android-core/src/test/kotlin/io/getstream/video/android/core/analytics/reporting/ClientEventReporterTest.kt
Tests verify role-specific values for initial, failed, connected, and reconnecting states.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PeerConnectionAnalytics
  participant StateHolder
  participant ClientEventReporter
  PeerConnectionAnalytics->>StateHolder: update role when connection reaches CONNECTED
  PeerConnectionAnalytics->>StateHolder: read role-specific ever-connected state
  PeerConnectionAnalytics->>ClientEventReporter: report state with wasPrevConnected
  ClientEventReporter->>ClientEventReporter: handle connecting state
Loading

Suggested reviewers: aleksandar-apostolov

Poem

A rabbit tracks each stream with care,
Publisher, subscriber, flags laid bare.
First hops say false, reconnects say true,
Reports carry the state they knew.
Analytics burrows cleanly through!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the fix to peer connection previous-connect analytics scope.
Description check ✅ Passed The description covers the goal, implementation, testing, and absence of UI changes, but omits repository checklists and GIF details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch improvement/rahullohra/correct-pc-connected-analytics

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-video-android-core 12.29 MB 12.29 MB 0.00 MB 🟢
stream-video-android-ui-xml 5.70 MB 5.70 MB 0.00 MB 🟢
stream-video-android-ui-compose 6.19 MB 6.19 MB 0.00 MB 🟢

@sonarqubecloud

sonarqubecloud Bot commented Aug 6, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@rahul-lohra
rahul-lohra marked this pull request as draft August 6, 2026 12:25
@PratimMallick PratimMallick added pr:bug Fixes a bug and removed pr:improvement Enhances an existing feature or code labels Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:bug Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants