Skip to content

Fix iOS analytics observing after refresh#227

Open
mmaatttt wants to merge 1 commit into
mainfrom
fix/analytics-observer-after-refresh
Open

Fix iOS analytics observing after refresh#227
mmaatttt wants to merge 1 commit into
mainfrom
fix/analytics-observer-after-refresh

Conversation

@mmaatttt
Copy link
Copy Markdown
Contributor

@mmaatttt mmaatttt commented May 21, 2026

In the case of a hard refresh that recreates the AppcuesReactNative (and thus the Implementation swift class), the result was a new AnalyticsDelegate, but the guard in setup() returning early before the new delegate gets wired up. I've added a specific check and handling for analyticsDelegate.implementation == nil in the guard.

An easy way to test this is in an Expo app with expo-dev-client: open the developer menu and select "Reload".

This may resolve #192 which had a similar issue where the observer worked for Android but not iOS. However that issue didn't mention any refreshing.

Summary by CodeRabbit

  • Bug Fixes
    • Improved analytics stability and reliability during repeated initialization cycles. Enhanced delegate handling ensures consistent state management and prevents potential data collection issues. The system now safely maintains and reconfigures analytics components when initialization is attempted multiple times, providing more robust behavior throughout the entire application lifecycle.

Review Change Stack

@mmaatttt mmaatttt requested a review from iujames May 21, 2026 20:43
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 99149524-8d4b-418e-950a-4ce02bdaa5b8

📥 Commits

Reviewing files that changed from the base of the PR and between 6c762db and 8694b9d.

📒 Files selected for processing (1)
  • ios/Implementation.swift

📝 Walkthrough

Walkthrough

This PR updates Implementation.setup() to safely handle repeated initialization calls. When Implementation.implementation is already initialized, the method now re-wires the internal analyticsDelegate references before returning early, ensuring delegate linkage remains current. Previously, the method would return without updating the delegate, potentially leaving orphaned or stale delegate connections on subsequent setup calls.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing iOS analytics observing after a refresh by re-wiring the delegate during repeated initialization.
Linked Issues check ✅ Passed The PR fixes a critical bug preventing analytics event observation on iOS (issue #192), enabling proper delegate wiring after refresh so events like flow_completed can be captured.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the analytics delegate linkage issue after refresh, with no unrelated modifications present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 fix/analytics-observer-after-refresh

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Event Tracking?

2 participants