[WEB-4277] Update Inkeep to cxkit 0.5.36#2493
Conversation
WalkthroughThe pull request removes outdated Inkeep integration identifiers from multiple configuration sources. Environment variable declarations, GraphQL schema fields, and site metadata properties for Changes
Sequence Diagram(s)sequenceDiagram
participant C as Client
participant IC as inkeepChat Function
participant SL as Script Loader
participant WL as Widget Loader
C->>IC: Call inkeepChat(apiKey)
IC->>SL: Load script (@inkeep/cxkit-js@0.5.36) with crossOrigin
SL-->>IC: Script loaded
IC->>WL: Call inkeepOnLoad(apiKey) to initialize widget
sequenceDiagram
participant U as User Update Trigger
participant IW as window.inkeepWidget
U->>IW: Call inkeepChatIdentifyUser({ user })
IW-->>U: Update widget with { baseSettings: { userProperties: { id } } }
Possibly related PRs
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Upgrade Inkeep to latest version and apply migration changes.
60bd185 to
a2726d0
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/external-scripts/inkeep.ts (1)
86-96: IntroducedSourceIteminterface.
This structure is properly typed, though you may consider makingtitleoptional if it can be undefined.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
.env.example(0 hunks)data/onCreateNode/create-graphql-schema-customization.ts(0 hunks)gatsby-config.ts(0 hunks)src/components/GlobalLoading/GlobalLoading.tsx(0 hunks)src/external-scripts/index.ts(1 hunks)src/external-scripts/inkeep.test.ts(2 hunks)src/external-scripts/inkeep.ts(3 hunks)src/hooks/use-site-metadata.ts(0 hunks)
💤 Files with no reviewable changes (5)
- src/hooks/use-site-metadata.ts
- src/components/GlobalLoading/GlobalLoading.tsx
- .env.example
- data/onCreateNode/create-graphql-schema-customization.ts
- gatsby-config.ts
🧰 Additional context used
🧬 Code Definitions (1)
src/external-scripts/inkeep.test.ts (1)
src/external-scripts/inkeep.ts (1)
inkeepChatIdentifyUser(185-197)
🔇 Additional comments (20)
src/external-scripts/index.ts (1)
48-48: Use of single-parameter inkeepChat is consistent with the updated integration.
The removal of extra parameters aligns well with the new CxKit requirements and simplifies usage.src/external-scripts/inkeep.test.ts (5)
14-14: Correct handling of undefined apiKey.
Passingundefinedhere tests the early-return condition ininkeepChat; this behavior is properly validated.
22-22: Ensuring Inkeep loads when apiKey is present.
This addition correctly checks thatscriptLoaderis called once a validapiKeyis provided.
31-32: Switched fromrendertoupdatefor inkeepWidget in test mocks.
Reflects the production change where the Inkeep widget now uses.update(). This ensures the test aligns with the new method signature.
36-36: Verifying undefined user scenario.
Passing an empty object confirms no update call is made whenuseris missing, matching the revised logic ininkeepChatIdentifyUser().
44-44: Updated assertion to new userProperties structure.
EnsuresuserProperties.idis set properly instead of the olderuserId. Matches the refactor in the main code.src/external-scripts/inkeep.ts (14)
3-4: Single-parameter function signature forinkeepChat.
This accurately shifts the integration to use only an API key, removing the now-obsolete parameters.
8-8: Updated script loader URL to the new CxKit version.
Using@inkeep/cxkit-js@0.5.36is aligned with the PR goal; no concerns found.
12-12: AddedcrossOrigin: 'anonymous'.
Ensures the script follows best practices when loading from a different origin.
14-14: CallinginkeepOnLoad(apiKey).
Switching to a single argument for onload is consistent with the simplified configuration.
19-46: Extended globalWindowinterface declarations.
DeclaringHubSpotConversations,inkeepWidget, andInkeephelps TypeScript track these global objects.
59-61: Added new AI chat settings (displayName, avatar).
These additions are consistent with the updated Inkeep AI capabilities.
62-81: NewgetHelpOptionsproperty for AI chat.
This clearly defines pinned call-to-action items, aligning with the new design.
98-131:transformSourcefunction for URL-based tab assignment.
Implementation is robust with a try/catch, preventing errors in misformatted URLs.
133-139:prefilledSearchTextto capture query param.
Graceful fallback to''whenwindowis unavailable ensures SSR safety.
141-145:searchSettingsupdated with defaultQuery.
Pulling a dynamic query from the URL fosters a more personalized search experience.
147-165:inkeepOnLoad: builds config and initializes ChatButton.
CombiningaiChatSettingsandsearchSettingsinbaseSettingsstreamlines the Inkeep widget setup.
167-179:loadInkeepSearchfor on-page search bar.
Integration seamlessly extends the config for Inkeep’s search.
190-194: Switch to.update()withuserProperties.id.
Reflects the new user identification approach, replacinguserIdwithuserProperties.id.
199-199: Default export ofinkeepChat.
Continued use of the default export for easy imports throughout the codebase.
Description
Upgrade Inkeep to CxKit version 0.5.36 and apply migration changes.
Review APP setup to test
Copilot Summary
This pull request includes significant updates to the
inkeepintegration in thesrc/external-scriptsdirectory. The changes simplify the configuration required forinkeepChat, update the script loader URL, and modify the user identification process. Additionally, it introduces new global TypeScript declarations and refactors the AI chat settings.Major Changes:
Simplification of
inkeepChatConfiguration:src/external-scripts/inkeep.ts: TheinkeepChatfunction now only requires anapiKeyparameter instead ofapiKey,integrationId, andorganizationId. The script loader URL has been updated to a newer version, and additional attributes likecrossOriginhave been added.User Identification Process:
src/external-scripts/inkeep.ts: TheinkeepChatIdentifyUserfunction now usesupdateinstead ofrenderand updates theuserPropertieswithidinstead ofuserId.src/external-scripts/inkeep.test.ts: Corresponding test cases have been updated to reflect these changes, ensuring the correct function (updateinstead ofrender) is called.Global TypeScript Declarations:
src/external-scripts/inkeep.ts: New global interfaces forwindowproperties related toHubSpotConversationsandinkeepWidgethave been declared.AI Chat Settings Refactor:
src/external-scripts/inkeep.ts: The structure ofaiChatSettingshas been revised to include new properties likeorganizationDisplayName,aiAssistantAvatar, andgetHelpOptions. TheloadInkeepSearchfunction has been updated to use the new configuration format.Test Updates:
src/external-scripts/inkeep.test.ts: Test cases forinkeepChathave been updated to reflect the new function signature, removing theintegrationIdandorganizationIdparameters.Checklist
Summary by CodeRabbit