-
Notifications
You must be signed in to change notification settings - Fork 165
feat: Migrate CommandBar HelpHub SDK for Documentation Site #1391
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,24 +60,37 @@ | |
| <!-- End of Doc Search Embed Code --> | ||
|
|
||
| <script> | ||
| const commandbarSegment = IS_GITOPS_DOC_COOKIE_SET ? '43836ac3': '3033bf7f' | ||
|
|
||
| var o=commandbarSegment,n=["Object.assign","Symbol","Symbol.for"].join("%2C"),a=window;function r(o,n){void 0===n&&(n=!1),"complete"!==document.readyState&&window.addEventListener("load",r.bind(null,o,n),{capture:!1,once:!0});var a=document.createElement("script");a.type="text/javascript",a.async=n,a.src=o,document.head.appendChild(a)}function t(){var n;if(void 0===a.CommandBar){delete a.__CommandBarBootstrap__;var t=Symbol.for("CommandBar::configuration"),e=Symbol.for("CommandBar::orgConfig"),i=Symbol.for("CommandBar::disposed"),c=Symbol.for("CommandBar::isProxy"),m=Symbol.for("CommandBar::queue"),d=Symbol.for("CommandBar::unwrap"),l=Symbol.for("CommandBar::eventSubscriptions"),s=[],u=localStorage.getItem("commandbar.lc"),f=u&&u.includes("local")?"http://localhost:8000":"https://api.commandbar.com",p=Object.assign(((n={})[t]={uuid:o},n[e]={},n[i]=!1,n[c]=!0,n[m]=new Array,n[d]=function(){return p},n[l]=void 0,n),a.CommandBar),b=["addCommand","boot","addEventSubscriber","addRecordAction","setFormFactor"],y=p;Object.assign(p,{shareCallbacks:function(){return{}},shareContext:function(){return{}}}),a.CommandBar=new Proxy(p,{get:function(o,n){return n in y?p[n]:"then"!==n?b.includes(n)?function(){var o=Array.prototype.slice.call(arguments);return new Promise((function(a,r){o.unshift(n,a,r),p[m].push(o)}))}:function(){var o=Array.prototype.slice.call(arguments);o.unshift(n),p[m].push(o)}:void 0}}),null!==u&&s.push("lc=".concat(u)),s.push("version=2"),r("".concat(f,"/latest/").concat(o,"?").concat(s.join("&")),!0)}}void 0===Object.assign||"undefined"==typeof Symbol||void 0===Symbol.for?(a.__CommandBarBootstrap__=t,r("https://polyfill.io/v3/polyfill.min.js?version=3.101.0&callback=__CommandBarBootstrap__&features="+n)):t(); | ||
| window.CommandBar.setThemeMode('dark_mode') | ||
| window.CommandBar.boot( | ||
| "", | ||
| {}, | ||
| { canOpenEditor: false, products: ["help_hub"] } | ||
| ); | ||
|
|
||
| document.addEventListener("keydown", function (event) { | ||
| const isMac = navigator.userAgent.includes('Mac'); | ||
| if ((event.key === "k") && ((isMac && event.metaKey) || (!isMac && event.ctrlKey))) { | ||
| event.preventDefault(); | ||
| window.CommandBar.openHelpHub(); | ||
| setTimeout(() => { | ||
| document.querySelector('input[data-testid=helphub-input]').focus() | ||
| }, 100); | ||
| const apiKey = '42885a887590b9e28cce52518224850b'; | ||
|
|
||
| const amplitudeScript = document.createElement('script'); | ||
| amplitudeScript.src = `https://cdn.amplitude.com/script/${apiKey}.engagement.js`; | ||
|
|
||
| amplitudeScript.onload = async function() { | ||
| if (typeof window.engagement !== 'undefined') { | ||
| window.engagement.init(apiKey); | ||
|
|
||
| const userId = 'docs-site-user'; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to verify whether Amplitude offers any features that allow user customization. |
||
| await window.engagement.boot({ | ||
| user: { | ||
| user_id: userId, | ||
| }, | ||
| }); | ||
|
|
||
| document.addEventListener("keydown", function (event) { | ||
| const isMac = navigator.userAgent.includes('Mac'); | ||
| if ((event.key === "k") && ((isMac && event.metaKey) || (!isMac && event.ctrlKey))) { | ||
| event.preventDefault(); | ||
| window.engagement.rc.open(); | ||
| } | ||
| }); | ||
| } else { | ||
| console.warn('Amplitude engagement is not available.'); | ||
| } | ||
| }); | ||
| }; | ||
|
|
||
| amplitudeScript.onerror = function() { | ||
| console.error('Failed to load Amplitude engagement script'); | ||
| }; | ||
|
|
||
| document.head.appendChild(amplitudeScript); | ||
| </script> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the search input has a focused state by default when you open the amplitude's guides and surveys.