Work in progress

This commit is contained in:
Julien Nahum
2023-12-09 15:47:03 +01:00
parent f970557b76
commit 1f853e8178
315 changed files with 34058 additions and 25 deletions

34
client/composables/useAmplitude.js vendored Normal file
View File

@@ -0,0 +1,34 @@
import amplitude from 'amplitude-js'
import config from '~/opnform.config.js'
export default () => {
const amplitudeClient = config.amplitude_code ? amplitude.getInstance().init(config.amplitude_code) : null;
const logEvent = function (eventName, eventData) {
if (!config.production || !amplitudeClient) {
console.log('[DEBUG] Amplitude logged event:', eventName, eventData)
}
if (eventData && typeof eventData !== 'object') {
throw new Error('Amplitude event value must be an object.')
}
amplitudeClient.logEvent(eventName, eventData)
}
const setUser = function (user) {
amplitudeClient.setUserId(user.id)
amplitudeClient.setUserProperties({
email: this.user.email,
subscribed: this.user.is_subscribed,
enterprise_subscription: this.user.has_enterprise_subscription
})
}
return {
logEvent,
setUser,
amplitude: amplitudeClient
}
}

2
client/composables/useConfig.js vendored Normal file
View File

@@ -0,0 +1,2 @@
import opnformConfig from "~/opnform.config.js";
export const useConfig = () => opnformConfig

53
client/composables/useCrisp.js vendored Normal file
View File

@@ -0,0 +1,53 @@
export const useCrisp = () => {
function push(args) {
if (process.client) {
window.$crisp.push(args)
}
}
function openChat() {
push(['do', 'chat:open'])
}
function showChat() {
push(['do', 'chat:show'])
}
function hideChat() {
push(['do', 'chat:hide'])
}
function closeChat() {
push(['do', 'chat:close'])
}
function openAndShowChat(message = null) {
showChat()
openChat()
if (message) sendTextMessage(message)
}
function openHelpdesk(){
push(['do', 'helpdesk:search'])
}
function openHelpdeskArticle(articleSlug, lang = 'en') {
push(['do', 'helpdesk:article:open', [lang, articleSlug]])
}
function sendTextMessage(message) {
push(['do', 'message:send', ['text',message]])
}
return {
push,
openChat,
showChat,
hideChat,
closeChat,
openAndShowChat,
openHelpdesk,
openHelpdeskArticle,
sendTextMessage
}
}

6
client/composables/useIsIframe.js vendored Normal file
View File

@@ -0,0 +1,6 @@
export const useIsIframe = () => {
if (process.client) {
return window.location !== window.parent.location || window.frameElement
}
return false
}