Skip to content

Comments

feat: add furion sdk#26

Merged
kagol merged 2 commits intodevfrom
kagol/add-furion-sdk
Feb 11, 2026
Merged

feat: add furion sdk#26
kagol merged 2 commits intodevfrom
kagol/add-furion-sdk

Conversation

@kagol
Copy link
Member

@kagol kagol commented Feb 10, 2026

Summary by CodeRabbit

  • New Features
    • Integrated Furion SDK (v3.6.56) into the site; the SDK is now automatically loaded and initialized during application startup.
    • Runtime configuration for the SDK is applied on load so it is ready for use as the app initializes.

@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

Walkthrough

Adds a Furion SDK injector and invokes it from the VitePress theme's enhanceApp hook so the SDK script is dynamically appended and configured during app initialization.

Changes

Cohort / File(s) Summary
Theme Initialization
/.vitepress/theme/index.ts
Imported insertFurion and added a call to insertFurion() inside the exported theme's enhanceApp so the SDK loads at app startup.
Furion SDK Injection
/.vitepress/theme/insert-furion.ts
New file exporting insertFurion() which sets window.__fr.config (appId, setting, hashMode, smartJsErr) and injects the Furion CDN script element into document.body.

Sequence Diagram(s)

sequenceDiagram
    participant App as VitePress Theme (enhanceApp)
    participant Browser as Browser Runtime
    participant Window as window
    participant CDN as Furion CDN (https://res.hc-cdn.com)

    App->>Browser: call insertFurion()
    Browser->>Window: set __fr.config (appId, setting, hashMode, smartJsErr)
    Browser->>CDN: create <script src=".../furion-cdn.min.js">
    Browser->>Browser: append script to document.body
    CDN-->>Browser: load & execute Furion SDK
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I hopped into theme at dawn,
Planted a script on the lawn,
Furion wakes with a gentle chime,
Configured and loaded just in time,
Hooray — the site hums on! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add furion sdk' accurately and concisely describes the main change—adding the Furion SDK to the project through new imports and initialization code.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kagol/add-furion-sdk

No actionable comments were generated in the recent review. 🎉


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 and usage tips.

Copy link

@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

🤖 Fix all issues with AI agents
In @.vitepress/theme/insert-furion.ts:
- Around line 2-16: The insertFurion function currently accesses window and
document unguarded which breaks VitePress SSR; modify insertFurion to first
check for a browser environment (e.g. typeof window !== 'undefined' && typeof
document !== 'undefined') and return early if false, and only run the IIFE that
references window[n], document.createElement, document.body, insertBefore, etc.,
when the guard passes so no server-side ReferenceError occurs.
🧹 Nitpick comments (3)
.vitepress/theme/insert-furion.ts (3)

6-6: Hardcoded appId should be externalized.

Embedding the monitoring app ID directly in source code makes it harder to manage across environments (dev/staging/prod) and exposes the identifier in the public repository. Consider using a VitePress environment variable (e.g., import.meta.env.VITE_FURION_APP_ID).


1-1: Prefer proper typing over @ts-ignore.

You can augment the Window interface instead of suppressing the type error:

declare global {
  interface Window {
    __fr: { config?: Record<string, unknown> }
  }
}

This gives you type safety on window.__fr without needing the ignore directive.


3-16: No guard against duplicate script injection.

If insertFurion is called more than once (e.g., during HMR), a duplicate <script> tag will be appended. Consider adding an idempotency check.

♻️ Example idempotency guard
 export function insertFurion() {
   if (typeof window === 'undefined') return
+  if (document.querySelector('script[data-furion]')) return
 
   !(function (x: string, n: string) {
     ...
     let o = document.createElement('script')
+    o.setAttribute('data-furion', '')
     o.src = x

@kagol kagol merged commit fe5389f into dev Feb 11, 2026
1 of 2 checks passed
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.

1 participant