Initial commit
This commit is contained in:
97
resources/js/components/service/Amplitude.vue
Normal file
97
resources/js/components/service/Amplitude.vue
Normal file
@@ -0,0 +1,97 @@
|
||||
<template />
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
export default {
|
||||
|
||||
name: 'Amplitude',
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
loaded: false,
|
||||
amplitudeInstance: null
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapGetters({
|
||||
authenticated: 'auth/check',
|
||||
user: 'auth/user'
|
||||
})
|
||||
},
|
||||
|
||||
watch: {
|
||||
$route () {
|
||||
this.loadAmplitude()
|
||||
},
|
||||
authenticated () {
|
||||
this.authenticateUser()
|
||||
}
|
||||
},
|
||||
|
||||
mounted () {},
|
||||
|
||||
methods: {
|
||||
authenticateUser () {
|
||||
if (this.loaded && this.authenticated) {
|
||||
this.amplitudeInstance.setUserId(this.user.id)
|
||||
this.amplitudeInstance.setUserProperties({
|
||||
email: this.user.email,
|
||||
subscribed: this.user.is_subscribed,
|
||||
enterprise_subscription: this.user.has_enterprise_subscription
|
||||
})
|
||||
}
|
||||
},
|
||||
loadAmplitude () {
|
||||
if (this.loaded || !typeof window.amplitude === 'undefined') return
|
||||
|
||||
(function (e, t) {
|
||||
const n = e.amplitude || { _q: [], _iq: {} }; const r = t.createElement('script')
|
||||
r.type = 'text/javascript'
|
||||
r.integrity = 'sha384-+EO59vL/X7v6VE2s6/F4HxfHlK0nDUVWKVg8K9oUlvffAeeaShVBmbORTC2D3UF+'
|
||||
r.crossOrigin = 'anonymous'; r.async = true
|
||||
r.src = 'https://cdn.amplitude.com/libs/amplitude-8.17.0-min.gz.js'
|
||||
r.onload = function () {
|
||||
if (!e.amplitude.runQueuedFunctions) {
|
||||
console.log('[Amplitude] Error: could not load SDK')
|
||||
}
|
||||
}
|
||||
const i = t.getElementsByTagName('script')[0]; i.parentNode.insertBefore(r, i)
|
||||
function s (e, t) {
|
||||
e.prototype[t] = function () {
|
||||
this._q.push([t].concat(Array.prototype.slice.call(arguments, 0))); return this
|
||||
}
|
||||
}
|
||||
const o = function () { this._q = []; return this }
|
||||
const a = ['add', 'append', 'clearAll', 'prepend', 'set', 'setOnce', 'unset', 'preInsert', 'postInsert', 'remove']
|
||||
for (let c = 0; c < a.length; c++) { s(o, a[c]) }n.Identify = o; const u = function () {
|
||||
this._q = []
|
||||
return this
|
||||
}
|
||||
const l = ['setProductId', 'setQuantity', 'setPrice', 'setRevenueType', 'setEventProperties']
|
||||
for (let p = 0; p < l.length; p++) { s(u, l[p]) }n.Revenue = u
|
||||
const d = ['init', 'logEvent', 'logRevenue', 'setUserId', 'setUserProperties', 'setOptOut', 'setVersionName', 'setDomain', 'setDeviceId', 'enableTracking', 'setGlobalUserProperties', 'identify', 'clearUserProperties', 'setGroup', 'logRevenueV2', 'regenerateDeviceId', 'groupIdentify', 'onInit', 'logEventWithTimestamp', 'logEventWithGroups', 'setSessionId', 'resetSessionId']
|
||||
function v (e) {
|
||||
function t (t) {
|
||||
e[t] = function () {
|
||||
e._q.push([t].concat(Array.prototype.slice.call(arguments, 0)))
|
||||
}
|
||||
}
|
||||
for (let n = 0; n < d.length; n++) { t(d[n]) }
|
||||
}v(n); n.getInstance = function (e) {
|
||||
e = (!e || e.length === 0 ? '$default_instance' : e).toLowerCase()
|
||||
if (!Object.prototype.hasOwnProperty.call(n._iq, e)) {
|
||||
n._iq[e] = { _q: [] }; v(n._iq[e])
|
||||
} return n._iq[e]
|
||||
}; e.amplitude = n
|
||||
})(window, document)
|
||||
|
||||
this.amplitudeInstance = window.amplitude.getInstance()
|
||||
this.amplitudeInstance.init('9952c8b914ce3f2bd494fce2dba18243')
|
||||
this.loaded = true
|
||||
this.authenticateUser()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
34
resources/js/components/service/Crisp.vue
Normal file
34
resources/js/components/service/Crisp.vue
Normal file
@@ -0,0 +1,34 @@
|
||||
<template />
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Crisp',
|
||||
|
||||
computed: {
|
||||
isIframe () {
|
||||
return window.location !== window.parent.location || window.frameElement
|
||||
}
|
||||
},
|
||||
|
||||
watch: {},
|
||||
|
||||
mounted () {
|
||||
this.loadCrisp()
|
||||
},
|
||||
|
||||
methods: {
|
||||
loadCrisp () {
|
||||
if (this.isIframe) return
|
||||
|
||||
window.$crisp = []
|
||||
window.CRISP_WEBSITE_ID = '94219d77-06ff-4aec-b07a-5bf26ec8fde1'
|
||||
|
||||
const script = document.createElement('script')
|
||||
script.setAttribute('src', 'https://client.crisp.chat/l.js')
|
||||
script.setAttribute('id', 'crisp-widget')
|
||||
script.setAttribute('async', 1)
|
||||
document.head.appendChild(script)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
49
resources/js/components/service/Hotjar.vue
Normal file
49
resources/js/components/service/Hotjar.vue
Normal file
@@ -0,0 +1,49 @@
|
||||
<template />
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
export default {
|
||||
|
||||
name: 'Hotjar',
|
||||
|
||||
watch: {
|
||||
authenticated () {
|
||||
if (this.authenticated) {
|
||||
this.loadHotjar()
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
mounted () {
|
||||
this.loadHotjar()
|
||||
},
|
||||
|
||||
methods: {
|
||||
loadHotjar () {
|
||||
if (!this.authenticated || this.isIframe) return
|
||||
|
||||
(function (h, o, t, j, a, r) {
|
||||
h.hj = h.hj || function () {
|
||||
(h.hj.q = h.hj.q || []).push(arguments)
|
||||
}
|
||||
h._hjSettings = { hjid: 2449591, hjsv: 6 }
|
||||
a = o.getElementsByTagName('head')[0]
|
||||
r = o.createElement('script')
|
||||
r.async = 1
|
||||
r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv
|
||||
a.appendChild(r)
|
||||
})(window, document, 'https://static.hotjar.com/c/hotjar-', '.js?sv=')
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapGetters({
|
||||
authenticated: 'auth/check'
|
||||
}),
|
||||
isIframe () {
|
||||
return window.location !== window.parent.location || window.frameElement
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user