Merge branch 'develop' into chore-replace-window-bus
This commit is contained in:
@@ -166,7 +166,7 @@ gem 'audited', '~> 5.4', '>= 5.4.1'
|
||||
# need for google auth
|
||||
gem 'omniauth', '>= 2.1.2'
|
||||
gem 'omniauth-google-oauth2', '>= 1.1.2'
|
||||
gem 'omniauth-rails_csrf_protection', '~> 1.0'
|
||||
gem 'omniauth-rails_csrf_protection', '~> 1.0', '>= 1.0.2'
|
||||
|
||||
## Gems for reponse bot
|
||||
# adds cosine similarity to postgres using vector extension
|
||||
|
||||
+8
-8
@@ -148,7 +148,7 @@ GEM
|
||||
barnes (0.0.9)
|
||||
multi_json (~> 1)
|
||||
statsd-ruby (~> 1.1)
|
||||
base64 (0.1.1)
|
||||
base64 (0.2.0)
|
||||
bcrypt (3.1.20)
|
||||
bigdecimal (3.1.7)
|
||||
bindex (0.8.1)
|
||||
@@ -369,7 +369,7 @@ GEM
|
||||
mini_mime (>= 1.0.0)
|
||||
multi_xml (>= 0.5.2)
|
||||
httpclient (2.8.3)
|
||||
i18n (1.14.4)
|
||||
i18n (1.14.5)
|
||||
concurrent-ruby (~> 1.0)
|
||||
image_processing (1.12.2)
|
||||
mini_magick (>= 4.9.5, < 5)
|
||||
@@ -490,14 +490,14 @@ GEM
|
||||
newrelic_rpm (9.6.0)
|
||||
base64
|
||||
nio4r (2.7.1)
|
||||
nokogiri (1.16.4)
|
||||
nokogiri (1.16.5)
|
||||
mini_portile2 (~> 2.8.2)
|
||||
racc (~> 1.4)
|
||||
nokogiri (1.16.4-arm64-darwin)
|
||||
nokogiri (1.16.5-arm64-darwin)
|
||||
racc (~> 1.4)
|
||||
nokogiri (1.16.4-x86_64-darwin)
|
||||
nokogiri (1.16.5-x86_64-darwin)
|
||||
racc (~> 1.4)
|
||||
nokogiri (1.16.4-x86_64-linux)
|
||||
nokogiri (1.16.5-x86_64-linux)
|
||||
racc (~> 1.4)
|
||||
oauth (1.1.0)
|
||||
oauth-tty (~> 1.0, >= 1.0.1)
|
||||
@@ -524,7 +524,7 @@ GEM
|
||||
omniauth-oauth2 (1.8.0)
|
||||
oauth2 (>= 1.4, < 3)
|
||||
omniauth (~> 2.0)
|
||||
omniauth-rails_csrf_protection (1.0.1)
|
||||
omniauth-rails_csrf_protection (1.0.2)
|
||||
actionpack (>= 4.2)
|
||||
omniauth (~> 2.0)
|
||||
openssl (3.1.0)
|
||||
@@ -904,7 +904,7 @@ DEPENDENCIES
|
||||
omniauth (>= 2.1.2)
|
||||
omniauth-google-oauth2 (>= 1.1.2)
|
||||
omniauth-oauth2
|
||||
omniauth-rails_csrf_protection (~> 1.0)
|
||||
omniauth-rails_csrf_protection (~> 1.0, >= 1.0.2)
|
||||
pg
|
||||
pg_search
|
||||
pgvector
|
||||
|
||||
@@ -10,14 +10,37 @@ import {
|
||||
getUserCookieName,
|
||||
hasUserKeys,
|
||||
} from '../sdk/cookieHelpers';
|
||||
import { addClasses, removeClasses } from '../sdk/DOMHelpers';
|
||||
import {
|
||||
addClasses,
|
||||
removeClasses,
|
||||
restoreWidgetInDOM,
|
||||
} from '../sdk/DOMHelpers';
|
||||
import { setCookieWithDomain } from '../sdk/cookieHelpers';
|
||||
import { SDK_SET_BUBBLE_VISIBILITY } from 'shared/constants/sharedFrameEvents';
|
||||
|
||||
const runSDK = ({ baseUrl, websiteToken }) => {
|
||||
if (window.$chatwoot) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.Turbo) {
|
||||
// if this is a Rails Turbo app
|
||||
document.addEventListener('turbo:before-render', event =>
|
||||
restoreWidgetInDOM(event.detail.newBody)
|
||||
);
|
||||
}
|
||||
|
||||
if (window.Turbolinks) {
|
||||
document.addEventListener('turbolinks:before-render', event => {
|
||||
restoreWidgetInDOM(event.data.newBody);
|
||||
});
|
||||
}
|
||||
|
||||
// if this is an astro app
|
||||
document.addEventListener('astro:before-swap', event =>
|
||||
restoreWidgetInDOM(event.newDocument.body)
|
||||
);
|
||||
|
||||
const chatwootSettings = window.chatwootSettings || {};
|
||||
let locale = chatwootSettings.locale;
|
||||
let baseDomain = chatwootSettings.baseDomain;
|
||||
|
||||
@@ -4,9 +4,28 @@ import { IFrameHelper } from './IFrameHelper';
|
||||
export const loadCSS = () => {
|
||||
const css = document.createElement('style');
|
||||
css.innerHTML = `${SDK_CSS}`;
|
||||
css.id = 'cw-widget-styles';
|
||||
document.body.appendChild(css);
|
||||
};
|
||||
|
||||
// This is a method specific to Turbo
|
||||
// The body replacing strategy removes Chatwoot styles
|
||||
// as well as the widget, this help us get it back
|
||||
export const restoreElement = (id, newBody) => {
|
||||
const element = document.getElementById(id);
|
||||
const newElement = newBody.querySelector(`#${id}`);
|
||||
|
||||
if (element && !newElement) {
|
||||
newBody.appendChild(element);
|
||||
}
|
||||
};
|
||||
|
||||
export const restoreWidgetInDOM = newBody => {
|
||||
restoreElement('cw-bubble-holder', newBody);
|
||||
restoreElement('cw-widget-holder', newBody);
|
||||
restoreElement('cw-widget-styles', newBody);
|
||||
};
|
||||
|
||||
export const addClasses = (elm, classes) => {
|
||||
elm.classList.add(...classes.split(' '));
|
||||
};
|
||||
|
||||
@@ -78,6 +78,7 @@ export const IFrameHelper = {
|
||||
}
|
||||
|
||||
addClasses(widgetHolder, holderClassName);
|
||||
widgetHolder.id = 'cw-widget-holder';
|
||||
widgetHolder.appendChild(iframe);
|
||||
body.appendChild(widgetHolder);
|
||||
IFrameHelper.initPostMessageCommunication();
|
||||
|
||||
@@ -61,6 +61,7 @@ export const createBubbleHolder = hideMessageBubble => {
|
||||
addClasses(bubbleHolder, 'woot-hidden');
|
||||
}
|
||||
addClasses(bubbleHolder, 'woot--bubble-holder');
|
||||
bubbleHolder.id = 'cw-bubble-holder';
|
||||
body.appendChild(bubbleHolder);
|
||||
};
|
||||
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
v-on-clickaway="closeDropdown"
|
||||
:class="dropdownBackgroundClass"
|
||||
class="country-dropdown h-48 overflow-y-auto z-10 absolute top-12 px-0 pt-0 pl-1 pr-1 pb-1 rounded shadow-lg"
|
||||
@keydown.up="moveSelectionUp"
|
||||
@keydown.down="moveSelectionDown"
|
||||
@keydown.enter="onSelect"
|
||||
>
|
||||
<div class="sticky top-0" :class="dropdownBackgroundClass">
|
||||
<input
|
||||
@@ -85,7 +88,6 @@
|
||||
<script>
|
||||
import countries from 'shared/constants/countries.js';
|
||||
import FluentIcon from 'shared/components/FluentIcon/Index.vue';
|
||||
import mentionSelectionKeyboardMixin from 'dashboard/components/widgets/mentions/mentionSelectionKeyboardMixin.js';
|
||||
import FormulateInputMixin from '@braid/vue-formulate/src/FormulateInputMixin';
|
||||
import darkModeMixin from 'widget/mixins/darkModeMixin';
|
||||
|
||||
@@ -93,7 +95,7 @@ export default {
|
||||
components: {
|
||||
FluentIcon,
|
||||
},
|
||||
mixins: [mentionSelectionKeyboardMixin, FormulateInputMixin, darkModeMixin],
|
||||
mixins: [FormulateInputMixin, darkModeMixin],
|
||||
props: {
|
||||
placeholder: {
|
||||
type: String,
|
||||
@@ -185,6 +187,14 @@ export default {
|
||||
);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
items(newItems) {
|
||||
if (newItems.length < this.selectedIndex + 1) {
|
||||
// Reset the selected index to 0 if the new items length is less than the selected index.
|
||||
this.selectedIndex = 0;
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
setContextValue(code) {
|
||||
// This function is used to set the context value.
|
||||
@@ -235,7 +245,26 @@ export default {
|
||||
this.scrollToFocusedOrActiveItem(this.focusedOrActiveItem('focus'));
|
||||
});
|
||||
},
|
||||
adjustSelection(direction) {
|
||||
if (!this.showDropdown) return;
|
||||
const maxIndex = this.items.length - 1;
|
||||
if (direction === 'up') {
|
||||
this.selectedIndex =
|
||||
this.selectedIndex <= 0 ? maxIndex : this.selectedIndex - 1;
|
||||
} else if (direction === 'down') {
|
||||
this.selectedIndex =
|
||||
this.selectedIndex >= maxIndex ? 0 : this.selectedIndex + 1;
|
||||
}
|
||||
this.adjustScroll();
|
||||
},
|
||||
moveSelectionUp() {
|
||||
this.adjustSelection('up');
|
||||
},
|
||||
moveSelectionDown() {
|
||||
this.adjustSelection('down');
|
||||
},
|
||||
onSelect() {
|
||||
if (!this.showDropdown || this.selectedIndex === -1) return;
|
||||
this.onSelectCountry(this.items[this.selectedIndex]);
|
||||
},
|
||||
scrollToFocusedOrActiveItem(item) {
|
||||
|
||||
@@ -66,7 +66,7 @@ module Enterprise::Concerns::Article
|
||||
{ role: 'user', content: "title: #{title} \n description: #{description} \n content: #{content}" }
|
||||
]
|
||||
headers = { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{ENV.fetch('OPENAI_API_KEY', nil)}" }
|
||||
body = { model: 'gpt-4-turbo', messages: messages, response_format: { type: 'json_object' } }.to_json
|
||||
body = { model: 'gpt-4o', messages: messages, response_format: { type: 'json_object' } }.to_json
|
||||
Rails.logger.info "Requesting Chat GPT with body: #{body}"
|
||||
response = HTTParty.post('https://api.openai.com/v1/chat/completions', headers: headers, body: body)
|
||||
Rails.logger.info "Chat GPT response: #{response.body}"
|
||||
|
||||
@@ -4,7 +4,7 @@ class ChatGpt
|
||||
end
|
||||
|
||||
def initialize(context_sections = '')
|
||||
@model = 'gpt-4-0125-preview'
|
||||
@model = 'gpt-4o'
|
||||
@messages = [system_message(context_sections)]
|
||||
end
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace :ip_lookup do
|
||||
Rails.logger.info '[rake ip_lookup:setup] Fetch GeoLite2-City database'
|
||||
|
||||
begin
|
||||
base_url = 'https://download.maxmind.com/app/geoip_download'
|
||||
base_url = ENV.fetch('IP_LOOKUP_BASE_URL', 'https://download.maxmind.com/app/geoip_download')
|
||||
source_file = Down.download(
|
||||
"#{base_url}?edition_id=GeoLite2-City&suffix=tar.gz&license_key=#{ip_lookup_api_key}"
|
||||
)
|
||||
|
||||
@@ -97,6 +97,8 @@ RSpec.describe 'Contacts API', type: :request do
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
response_body = response.parsed_body
|
||||
# TODO: this spec has been flaky for a while, so adding a debug statement to see the response
|
||||
Rails.logger.info(response_body)
|
||||
expect(response_body['payload'].first['email']).to eq(contact.email)
|
||||
expect(response_body['payload'].first['id']).to eq(contact.id)
|
||||
expect(response_body['payload'].last['email']).to eq(contact_4.email)
|
||||
|
||||
Reference in New Issue
Block a user