Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename provider keys to avoid colission #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jaoaustero
Copy link
Contributor

@jaoaustero jaoaustero commented Sep 24, 2024

Summary

There are users reported collision of provider keys since we use generic naming on our API. I added prefix tawk in all actions, getters, listeners, and setters. This will resolve the issue #6

This will lead to breaking changes since all APIs will be renamed, need to include in the changelog and update our application also

Summary by CodeRabbit

  • New Features
    • Enhanced method naming conventions for the TawkMessenger class, improving consistency and clarity.
    • All methods now prefixed with "tawk" for easier identification and usage.

These updates ensure a more intuitive experience when interacting with the TawkMessenger functionalities.

@jaoaustero jaoaustero added the enhancement New feature or request label Sep 24, 2024
@jaoaustero jaoaustero self-assigned this Sep 24, 2024
Copy link

coderabbitai bot commented Sep 24, 2024

Walkthrough

The changes involve a comprehensive renaming of methods in the TawkMessenger class within the src/lib/index.js file, as well as updates in related documentation. All methods previously exposed through this.app.provide now have the prefix "tawk" to standardize the naming convention across action, getter, listener, and setter methods. Similar updates were made in the API reference and setup documentation, ensuring a consistent interface and naming scheme throughout the codebase.

Changes

File Change Summary
src/lib/index.js Renamed methods in TawkMessenger class to prefix with "tawk" for consistency: action, getter, listener, and setter methods.
docs/api-reference.md Updated API callback functions and variables to prefix with "tawk" for consistency across the document.
docs/spa-setup.md Changed injected function from onLoad to tawkOnLoad in the Vue.js Options API.
docs/ssr-setup.md Updated injected functions from onLoad and toggle to tawkOnLoad and tawkToggle in the Vue.js Options API.

Poem

In the code where rabbits play,
Methods danced and found their way.
With "tawk" they hop, a joyful tune,
Naming bright as a sunny moon.
Consistency now leads the cheer,
Hopping forward, no more fear! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
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 resolve resolve all the CodeRabbit review comments.
  • @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.

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

Outside diff range and nitpick comments (1)
src/lib/index.js (1)

Line range hint 1-314: Overall LGTM! Consider updating documentation.

The changes in this file successfully address the issue of provider key collisions by consistently prefixing all provided method names with 'tawk'. This modification aligns perfectly with the PR objective and maintains the existing functionality.

However, it's important to note that this change might affect existing codebases using this library. To ensure a smooth transition for current users:

  1. Consider updating the README or documentation to clearly communicate this change.
  2. You might want to add a migration guide for users updating from a previous version.
  3. It would be helpful to bump the major version number of the package, as this is a breaking change.
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between eaa5b14 and 63c66e0.

Files selected for processing (1)
  • src/lib/index.js (4 hunks)
Additional comments not posted (4)
src/lib/index.js (4)

73-111: LGTM! Consistent renaming of action methods.

The changes in the provideActions method are consistent with the PR objective. All action methods have been correctly prefixed with 'tawk' to avoid provider key collisions. The underlying functionality remains unchanged, which is good.


118-155: LGTM! Consistent renaming of getter methods.

The changes in the provideGetters method are consistent with the PR objective. All getter methods have been correctly prefixed with 'tawk' to avoid provider key collisions. The underlying functionality remains unchanged, which is good.


Line range hint 164-282: LGTM! Consistent renaming of listener methods.

The changes in the provideListeners method are consistent with the PR objective. All listener methods have been correctly prefixed with 'tawk' to avoid provider key collisions. The underlying functionality remains unchanged, which is good. It's also correct that the event names in window.addEventListener calls were not modified, as these are likely defined by the Tawk API.


289-311: LGTM! Consistent renaming of setter methods.

The changes in the provideSetters method are consistent with the PR objective. All setter methods have been correctly prefixed with 'tawk' to avoid provider key collisions. The underlying functionality remains unchanged, which is good.

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

Outside diff range and nitpick comments (7)
docs/ssr-setup.md (3)

29-33: LGTM! Consider updating the surrounding documentation.

The changes to rename the injected functions from 'onLoad' and 'toggle' to 'tawkOnLoad' and 'tawkToggle' are correctly implemented and align with the PR objective of adding the 'tawk' prefix to avoid naming collisions.

Consider updating the text above this code block to reflect the new function names. For example:

-## Instance property
-To access the API functions, call the **$tawkMessenger** anywhere in your components.
+## Injected functions
+To access the API functions, inject the renamed functions ('tawkOnLoad', 'tawkToggle', etc.) in your components.

48-51: LGTM! Consider updating the surrounding documentation.

The changes to rename the injected function from 'onLoad' to 'tawkOnLoad' are correctly implemented and align with the PR objective of adding the 'tawk' prefix to avoid naming collisions.

Consider updating the text above this code block to reflect the new function name. For example:

-## Event handling
-You can listen on events emitted by the plugin, It must be exactly match the name used to listen
-to that event.
+## Event handling
+You can listen to events emitted by the plugin using the renamed functions. The function names must exactly match the new names with the 'tawk' prefix.

Line range hint 1-58: Consider updating the entire document for consistency.

While the code blocks have been correctly updated with the new function names, the rest of the document still refers to the old naming convention. This inconsistency could lead to confusion for users trying to implement the updated API.

Consider reviewing and updating the entire document to reflect the new naming convention. This may include:

  1. Updating the introduction to mention the 'tawk' prefix for all API functions.
  2. Revising any examples or explanations that refer to the old function names.
  3. Checking if the linked API reference document (api-reference.md) has also been updated with the new function names.

These changes will ensure that the documentation is fully consistent with the new API naming convention.

docs/api-reference.md (4)

Line range hint 649-680: LGTM: tawkVisitor section updated correctly

The tawkVisitor section has been properly updated with the new method name. The code examples reflect this change correctly.

Consider revising the following sentence for better clarity:

- Setting or changing the values after the widget script has been downloaded will not send the values to the dashboard.
+ Setting or changing the values after the widget script has been downloaded will not update the values on the dashboard.

Line range hint 871-906: LGTM: tawkGetWindowType section updated correctly

The tawkGetWindowType section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly. The usage of tawkOnLoad in the examples is appropriate and demonstrates the correct way to use the tawkGetWindowType method.

Consider revising the following sentence for better grammar:

- Returns the current widget type whether it's inline or embed.
+ Returns the current widget type, indicating whether it's inline or embed.
Tools
LanguageTool

[uncategorized] ~872-~872: Possible missing comma found.
Context: ...etWindowType Returns the current widget type whether it’s inline or embed. `Composi...

(AI_HYDRA_LEO_MISSING_COMMA)


Line range hint 1238-1261: LGTM: tawkOnBeforeLoaded section updated correctly

The tawkOnBeforeLoaded section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly.

Consider revising the following sentence for better grammar:

- Returns a boolean value (true or undefined) indicating when plugin is initialize.
+ Returns a boolean value (true or undefined) indicating when the plugin is initialized.
Tools
LanguageTool

[grammar] ~1239-~1239: Consider using either the past participle “initialized” or the present participle “initializing” here.
Context: ...or undefined) indicating when plugin is initialize. Composition API ```html <script set...

(BEEN_PART_AGREEMENT)


Line range hint 14-1690: Overall assessment: Comprehensive and consistent renaming

The changes in this file demonstrate a thorough and consistent implementation of the renaming strategy, adding the "tawk" prefix to all API methods. This change affects the entire API surface, including method names, code examples, and documentation. The modifications have been applied correctly across all sections of the document.

Key points:

  1. All API methods have been renamed with the "tawk" prefix.
  2. Code examples for both Composition API and Options API have been updated accordingly.
  3. The overall structure and functionality of the API remain unchanged.
  4. Minor grammatical improvements have been suggested in a few sections.

These changes will result in a breaking change for existing users of the API, as noted in the PR objectives. It's crucial to:

  1. Update the changelog to clearly communicate these breaking changes.
  2. Provide migration guidelines for users updating from the previous version.
  3. Update any other related documentation or code samples that may reference the old method names.

Consider creating a separate migration guide document that outlines the changes and provides step-by-step instructions for updating existing code to use the new API method names.

Tools
LanguageTool

[uncategorized] ~872-~872: Possible missing comma found.
Context: ...etWindowType Returns the current widget type whether it’s inline or embed. `Composi...

(AI_HYDRA_LEO_MISSING_COMMA)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 63c66e0 and 49432a0.

Files selected for processing (3)
  • docs/api-reference.md (79 hunks)
  • docs/spa-setup.md (1 hunks)
  • docs/ssr-setup.md (2 hunks)
Additional context used
LanguageTool
docs/api-reference.md

[uncategorized] ~418-~418: Possible missing article found.
Context: ...geSystem Callback function invoked when message is sent by the system. The message is p...

(AI_HYDRA_LEO_MISSING_A)


[style] ~534-~534: Since a “visitor” is neither male nor female, the better pronoun might be “their”.
Context: ...voked when the visitor manually changes his name. The visitorName is passed to the ...

(SOMEBODY_NEUTRAL)


[uncategorized] ~872-~872: Possible missing comma found.
Context: ...etWindowType Returns the current widget type whether it’s inline or embed. `Composi...

(AI_HYDRA_LEO_MISSING_COMMA)


[grammar] ~1239-~1239: Consider using either the past participle “initialized” or the present participle “initializing” here.
Context: ...or undefined) indicating when plugin is initialize. Composition API ```html <script set...

(BEEN_PART_AGREEMENT)

Additional comments not posted (18)
docs/spa-setup.md (1)

57-60: LGTM! Changes align with PR objectives.

The modifications in the Options API example correctly implement the 'tawk' prefix for the event handling function, which is consistent with the PR objectives to avoid provider key collisions.

docs/api-reference.md (17)

14-33: LGTM: Table of Contents updated correctly

The Table of Contents has been consistently updated with the new "tawk" prefix for all relevant method names. This change aligns well with the overall renaming strategy.


Line range hint 707-721: LGTM: tawkStart section updated correctly

The tawkStart section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly.

Tools
LanguageTool

[uncategorized] ~872-~872: Possible missing comma found.
Context: ...etWindowType Returns the current widget type whether it’s inline or embed. `Composi...

(AI_HYDRA_LEO_MISSING_COMMA)


726-746: LGTM: tawkShutdown section updated correctly

The tawkShutdown section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly.


751-776: LGTM: tawkMaximize section updated correctly

The tawkMaximize section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly. The usage of tawkOnLoad in the examples is appropriate and demonstrates the correct way to use the tawkMaximize method.


781-806: LGTM: tawkMinimize section updated correctly

The tawkMinimize section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly. The usage of tawkOnLoad in the examples is appropriate and demonstrates the correct way to use the tawkMinimize method.


811-836: LGTM: tawkToggle section updated correctly

The tawkToggle section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly. The usage of tawkOnLoad in the examples is appropriate and demonstrates the correct way to use the tawkToggle method.


841-866: LGTM: tawkPopup section updated correctly

The tawkPopup section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly. The usage of tawkOnLoad in the examples is appropriate and demonstrates the correct way to use the tawkPopup method.


909-934: LGTM: tawkShowWidget section updated correctly

The tawkShowWidget section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly. The usage of tawkOnLoad in the examples is appropriate and demonstrates the correct way to use the tawkShowWidget method.


939-964: LGTM: tawkHideWidget section updated correctly

The tawkHideWidget section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly. The usage of tawkOnLoad in the examples is appropriate and demonstrates the correct way to use the tawkHideWidget method.


969-994: LGTM: tawkToggleVisibility section updated correctly

The tawkToggleVisibility section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly. The usage of tawkOnLoad in the examples is appropriate and demonstrates the correct way to use the tawkToggleVisibility method.


Line range hint 999-1036: LGTM: tawkGetStatus section updated correctly

The tawkGetStatus section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly. The usage of tawkOnLoad in the examples is appropriate and demonstrates the correct way to use the tawkGetStatus method.


Line range hint 1041-1070: LGTM: tawkIsChatMaximized section updated correctly

The tawkIsChatMaximized section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly. The usage of tawkOnLoad in the examples is appropriate and demonstrates the correct way to use the tawkIsChatMaximized method.


Line range hint 1075-1104: LGTM: tawkIsChatMinimized section updated correctly

The tawkIsChatMinimized section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly. The usage of tawkOnLoad in the examples is appropriate and demonstrates the correct way to use the tawkIsChatMinimized method.


Line range hint 1109-1138: LGTM: tawkIsChatHidden section updated correctly

The tawkIsChatHidden section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly. The usage of tawkOnLoad in the examples is appropriate and demonstrates the correct way to use the tawkIsChatHidden method.


Line range hint 1143-1172: LGTM: tawkIsChatOngoing section updated correctly

The tawkIsChatOngoing section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly. The usage of tawkOnLoad in the examples is appropriate and demonstrates the correct way to use the tawkIsChatOngoing method.


Line range hint 1177-1206: LGTM: tawkIsVisitorEngaged section updated correctly

The tawkIsVisitorEngaged section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly. The usage of tawkOnLoad in the examples is appropriate and demonstrates the correct way to use the tawkIsVisitorEngaged method.


Line range hint 1211-1234: LGTM: tawkOnLoaded section updated correctly

The tawkOnLoaded section has been properly updated with the new method name. The code examples for both Composition API and Options API reflect this change correctly.

Comment on lines +57 to +60
inject : ['tawkOnLoad'],

mounted() {
this.onLoad(() => {
this.tawkOnLoad(() => {
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Update Composition API example and preceding text for consistency.

While the Options API example has been updated correctly, the Composition API example and the text preceding both examples still reference the old onLoad function name. To maintain consistency across the documentation:

  1. Update the Composition API example to use tawkOnLoad.
  2. Modify the text preceding the code examples to mention tawkOnLoad instead of onLoad.

Here's a suggested diff for the Composition API example:

 <script setup>
     import { inject } from 'vue';
 
-    const onLoad = inject('onLoad');
+    const tawkOnLoad = inject('tawkOnLoad');
 
-    onLoad(() => {
+    tawkOnLoad(() => {
         // place your function here
     });
 </script>

Also, update the preceding text to reflect this change:

-You can listen on events emitted by the plugin by Injecting the function using `inject()`,
-It must be exactly match the name used to listen to that event, you can see the list of
+You can listen to events emitted by the plugin by injecting the function using `inject()`.
+It must exactly match the name used to listen to that event (with the 'tawk' prefix). You can see the list of
 [events](api-reference.md) here.

Committable suggestion was skipped due to low confidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants