Skip to content

chg: re-initialize analytics#2137

Merged
synoet merged 1 commit intomainfrom
synoet/initialize-analytics
Mar 23, 2026
Merged

chg: re-initialize analytics#2137
synoet merged 1 commit intomainfrom
synoet/initialize-analytics

Conversation

@synoet
Copy link
Copy Markdown
Contributor

@synoet synoet commented Mar 23, 2026

No description provided.

@synoet synoet requested a review from a team as a code owner March 23, 2026 23:02
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 23, 2026

Walkthrough

The createAnalytics factory function has been modified to invoke initializeProviders() immediately upon its definition. This change shifts the timing of provider initialization from lazy loading on first track/identify call to eager initialization during analytics construction. The modification adds two lines and preserves existing guard conditions and provider initialization logic.

Poem

🐰 Early morning, providers wake,
No more waiting for first track,
Analytics ready from the start,
Swift and steady, right on track! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to evaluate whether the description relates to the changeset. Add a description explaining why analytics providers need to be re-initialized earlier in the construction flow and any implications of this timing change.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 're-initialize analytics' is clearly related to the main change, which moves analytics provider initialization from on-demand to immediate initialization during construction.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 synoet/initialize-analytics

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

@github-actions
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@dev-rb dev-rb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@js/app/packages/app/lib/analytics/analytics.ts`:
- Around line 60-61: The current eager call to initializeProviders() during
construction can permanently leave analytics uninitialized because tryInitialize
swallows errors; change the pattern so initializeProviders() is idempotent and
only marks initialization as complete on success, and modify track(...) and
identify(...) to call initializeProviders()/tryInitialize() on each use if not
yet successfully initialized (retry-on-use) instead of assuming init ran once;
ensure tryInitialize returns/propagates failure state (or a boolean) and that
any initialization flag (e.g., isInitialized) is set only after successful
provider setup so transient errors do not disable future attempts.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 153c1c5c-10a8-4a96-82e1-4eea8421e537

📥 Commits

Reviewing files that changed from the base of the PR and between 9118029 and a8a9caa.

📒 Files selected for processing (1)
  • js/app/packages/app/lib/analytics/analytics.ts

@synoet synoet merged commit 787095c into main Mar 23, 2026
27 checks passed
@synoet synoet deleted the synoet/initialize-analytics branch March 23, 2026 23:08
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.

2 participants