mirror of
https://github.com/plausible/analytics.git
synced 2024-12-25 10:33:01 +03:00
97b24c0492
* Add SSO link with signed JWT token * Falls back to Nolt URL without SSO if token cannot be generated * Add profile image (gravatar) to Nolt SSO link * Improve navbar dropdown * Add 'contact support' link to nav dropdown * Add CSS rule to prevent horizontal jumps * Dark mode styling * Close dropdown when link is clicked * Clarify links in dropdown * Clarify CSS comment * Use Alpine.data() over window * Rename suggestions_dropdown -> combo-box * Mix format * Make logout link look good on dark mode * Use proxy for gravatar * Do not use Gravatar proxy in self-hosted * Changelog * Add Github Repo link to nav dropdown * Make dialyzer happy * Add proxy for Gravatar * Update assets/css/app.css Co-authored-by: hq1 <hq@mtod.org> * Update lib/plausible_web/controllers/avatar_controller.ex Co-authored-by: hq1 <hq@mtod.org> * Fix alpine <> Liveview integration --------- Co-authored-by: hq1 <hq@mtod.org>
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
import "phoenix_html"
|
|
import Alpine from 'alpinejs'
|
|
import { Socket } from "phoenix"
|
|
import { LiveSocket } from "phoenix_live_view"
|
|
|
|
let csrfToken = document.querySelector("meta[name='csrf-token']")
|
|
let websocketUrl = document.querySelector("meta[name='websocket-url']")
|
|
if (csrfToken && websocketUrl) {
|
|
let Hooks = {}
|
|
Hooks.Metrics = {
|
|
mounted() {
|
|
this.handleEvent("send-metrics", ({ event_name, params }) => {
|
|
const afterMetrics = () => {
|
|
this.pushEvent("send-metrics-after", {event_name, params})
|
|
}
|
|
setTimeout(afterMetrics, 5000)
|
|
params.callback = afterMetrics
|
|
window.plausible(event_name, params)
|
|
})
|
|
}
|
|
}
|
|
let token = csrfToken.getAttribute("content")
|
|
let url = websocketUrl.getAttribute("content")
|
|
let liveUrl = (url === "") ? "/live" : new URL("/live", url).href;
|
|
let liveSocket = new LiveSocket(liveUrl, Socket, {
|
|
heartbeatIntervalMs: 10000,
|
|
params: { _csrf_token: token }, hooks: Hooks, dom: {
|
|
// for alpinejs integration
|
|
onBeforeElUpdated(from, to) {
|
|
if (from._x_dataStack) {
|
|
Alpine.clone(from, to);
|
|
}
|
|
},
|
|
}
|
|
})
|
|
|
|
liveSocket.connect()
|
|
window.liveSocket = liveSocket
|
|
}
|