<script setup>
import { onMounted, watch } from 'vue'
import { useRoute } from 'vue-router'
import { createSignal } from '@signal-js/browser'
const route = useRoute()
let signal = null
onMounted(async () => {
signal = createSignal({
endpoint: '...',
apiKey: '...',
projectId: '...',
enableSessionTracking: true,
})
await signal.start()
signal.capture('$pageview', {
$pathname: route.path,
$title: document.title,
$current_url: window.location.href,
})
})
watch(() => route.path, () => {
signal?.capture('$pageview', {
$pathname: route.path,
$title: document.title,
$current_url: window.location.href,
})
})
</script>