Skip to content

[WEB-4277] Update Inkeep to cxkit 0.5.36#2493

Merged
matt423 merged 1 commit intomainfrom
web-4277-upgrade-inkeep
Mar 26, 2025
Merged

[WEB-4277] Update Inkeep to cxkit 0.5.36#2493
matt423 merged 1 commit intomainfrom
web-4277-upgrade-inkeep

Conversation

@matt423
Copy link
Member

@matt423 matt423 commented Mar 25, 2025

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 inkeep integration in the src/external-scripts directory. The changes simplify the configuration required for inkeepChat, 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 inkeepChat Configuration:

  • src/external-scripts/inkeep.ts: The inkeepChat function now only requires an apiKey parameter instead of apiKey, integrationId, and organizationId. The script loader URL has been updated to a newer version, and additional attributes like crossOrigin have been added.

User Identification Process:

  • src/external-scripts/inkeep.ts: The inkeepChatIdentifyUser function now uses update instead of render and updates the userProperties with id instead of userId.
  • src/external-scripts/inkeep.test.ts: Corresponding test cases have been updated to reflect these changes, ensuring the correct function (update instead of render) is called.

Global TypeScript Declarations:

AI Chat Settings Refactor:

  • src/external-scripts/inkeep.ts: The structure of aiChatSettings has been revised to include new properties like organizationDisplayName, aiAssistantAvatar, and getHelpOptions. The loadInkeepSearch function has been updated to use the new configuration format.

Test Updates:

  • src/external-scripts/inkeep.test.ts: Test cases for inkeepChat have been updated to reflect the new function signature, removing the integrationId and organizationId parameters.

Checklist

  • Commits have been rebased.
  • Linting has been run against the changed file(s).

Summary by CodeRabbit

  • Chores
    • Removed unused configuration options from environment examples.
  • Refactor
    • Streamlined chat integration to initialize using only essential parameters for a more efficient setup.
  • Tests
    • Updated test cases to validate the simplified integration process.

@coderabbitai
Copy link

coderabbitai bot commented Mar 25, 2025

Walkthrough

The pull request removes outdated Inkeep integration identifiers from multiple configuration sources. Environment variable declarations, GraphQL schema fields, and site metadata properties for inkeepIntegrationId and inkeepOrganizationId have been eliminated. Additionally, the external scripts module has been refactored: function signatures now accept only an apiKey, tests have been updated accordingly, and new global types and utility functions have been introduced. These changes streamline the configuration and external script integration without altering existing component logic.

Changes

File(s) Change Summary
.env.example, data/.../create-graphql-schema-customization.ts, gatsby-config.ts, src/.../GlobalLoading.tsx, src/hooks/use-site-metadata.ts Removed inkeepIntegrationId and inkeepOrganizationId from environment variables, GraphQL schemas, site metadata, and query destructuring.
src/external-scripts/index.ts, src/external-scripts/inkeep.ts, src/external-scripts/inkeep.test.ts Refactored external script integration by updating function signatures to only use apiKey, modifying test calls and assertions, updating the script loader version/options, and adding new types and utility functions for search and source transformation.

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
Loading
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 } } }
Loading

Possibly related PRs

Poem

I'm a rabbit with a keen eye for code,
Hopping past old IDs that once strode.
With symbols and scripts now neat and bright,
I nibble on bugs and debug through the night.
A joyful twitch—our changes feel just right!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ably-ci ably-ci temporarily deployed to ably-docs-web-4277-upgr-ucos2w March 25, 2025 16:44 Inactive
Upgrade Inkeep to latest version and apply migration changes.
@matt423 matt423 force-pushed the web-4277-upgrade-inkeep branch from 60bd185 to a2726d0 Compare March 25, 2025 16:55
@matt423 matt423 temporarily deployed to ably-docs-web-4277-upgr-ucos2w March 25, 2025 16:55 Inactive
@matt423 matt423 marked this pull request as ready for review March 25, 2025 17:00
@matt423
Copy link
Member Author

matt423 commented Mar 25, 2025

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Mar 25, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 0

🧹 Nitpick comments (1)
src/external-scripts/inkeep.ts (1)

86-96: Introduced SourceItem interface.
This structure is properly typed, though you may consider making title optional if it can be undefined.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 14b71ad and a2726d0.

📒 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.
Passing undefined here tests the early-return condition in inkeepChat; this behavior is properly validated.


22-22: Ensuring Inkeep loads when apiKey is present.
This addition correctly checks that scriptLoader is called once a valid apiKey is provided.


31-32: Switched from render to update for 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 when user is missing, matching the revised logic in inkeepChatIdentifyUser().


44-44: Updated assertion to new userProperties structure.
Ensures userProperties.id is set properly instead of the older userId. Matches the refactor in the main code.

src/external-scripts/inkeep.ts (14)

3-4: Single-parameter function signature for inkeepChat.
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.36 is aligned with the PR goal; no concerns found.


12-12: Added crossOrigin: 'anonymous'.
Ensures the script follows best practices when loading from a different origin.


14-14: Calling inkeepOnLoad(apiKey).
Switching to a single argument for onload is consistent with the simplified configuration.


19-46: Extended global Window interface declarations.
Declaring HubSpotConversations, inkeepWidget, and Inkeep helps 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: New getHelpOptions property for AI chat.
This clearly defines pinned call-to-action items, aligning with the new design.


98-131: transformSource function for URL-based tab assignment.
Implementation is robust with a try/catch, preventing errors in misformatted URLs.


133-139: prefilledSearchText to capture query param.
Graceful fallback to '' when window is unavailable ensures SSR safety.


141-145: searchSettings updated with defaultQuery.
Pulling a dynamic query from the URL fosters a more personalized search experience.


147-165: inkeepOnLoad: builds config and initializes ChatButton.
Combining aiChatSettings and searchSettings in baseSettings streamlines the Inkeep widget setup.


167-179: loadInkeepSearch for on-page search bar.
Integration seamlessly extends the config for Inkeep’s search.


190-194: Switch to .update() with userProperties.id.
Reflects the new user identification approach, replacing userId with userProperties.id.


199-199: Default export of inkeepChat.
Continued use of the default export for easy imports throughout the codebase.

@matt423 matt423 requested a review from a team March 25, 2025 17:12
@matt423 matt423 temporarily deployed to ably-docs-web-4277-upgr-ucos2w March 25, 2025 17:14 Inactive
Copy link
Member

@kennethkalmer kennethkalmer left a comment

Choose a reason for hiding this comment

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

:shipit:

@kennethkalmer kennethkalmer changed the title chore: Update Inkeep to cxkit 0.5.36 [WEB-4277] Update Inkeep to cxkit 0.5.36 Mar 26, 2025
@matt423 matt423 merged commit 1c09fd9 into main Mar 26, 2025
5 checks passed
@matt423 matt423 deleted the web-4277-upgrade-inkeep branch March 26, 2025 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants