UNPKG

@qwik.dev/core

Version:

An open source framework for building instant loading web apps at any scale, without the extra effort.

2 lines (1 loc) 2.06 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@qwik.dev/core"),L=require("@qwik.dev/core/jsx-runtime"),T=g.sync$(()=>((r,i,w,_,b,l,y)=>{var h=__QI_KEY__,d=__QI_URL__,E=i.querySelector("[q\\:version]")?.getAttribute("q:version")||"unknown",f=i.querySelector("[q\\:manifest-hash]")?.getAttribute("q:manifest-hash")||"dev",s=[],q=new Set,o=0,v=0,a,p=b.now(),m=i.querySelector("[q\\:route]"),I=()=>{if(a=void 0,s.length>o){var t={qVersion:E,publicApiKey:h,manifestHash:f,previousSymbol:o==0?void 0:s[o-1].symbol,symbols:s.slice(o)};_.sendBeacon(d,y(t)),o=s.length}},k=()=>{a!=null&&clearTimeout(a),a=setTimeout(I,1e3)};r.qSymbolTracker={symbols:s,publicApiKey:h},m&&new MutationObserver(t=>{var e=t.find(n=>n.attributeName==="q:route");e&&(p=b.now())}).observe(m,{attributes:!0}),i.addEventListener("visibilitychange",()=>i.visibilityState==="hidden"&&I()),i.addEventListener("qsymbol",t=>{var e=t,n=e.detail,u=n.reqTime,S=e.timeStamp,c=n.symbol;if(!q.has(c)){q.add(c);var R=m?.getAttribute("q:route")||"/";s.push({symbol:c,route:R,delay:l(0-v+u),latency:l(S-u),timeline:l(0-p+u),interaction:!!n.element}),v=S,k()}}),r.addEventListener("error",t=>{var e=t.error;if(e&&typeof e=="object"){var n={url:`${w}`,manifestHash:f,timestamp:new Date().getTime(),source:t.filename,line:t.lineno,column:t.colno,message:t.message,error:"message"in e?e.message:`${e}`,stack:"stack"in e&&e.stack||""};_.sendBeacon(`${d}error/`,y(n))}})})(window,document,location,navigator,performance,Math.round,JSON.stringify)),$=g.component$(()=>{if(!__EXPERIMENTAL__.insights)throw new Error('Insights is experimental and must be enabled with `experimental: ["insights"]` in the `qwikVite` plugin.');const r=globalThis.__QI_KEY__,i=globalThis.__QI_URL__;return!r||!i?(g.isDev||console.warn("<Insights />: no config from qwikInsights plugin, skipping..."),null):L.jsx("script",{"document:onQInit$":T,dangerouslySetInnerHTML:`__QI_KEY__=${JSON.stringify(r)};__QI_URL__=${JSON.stringify(i)}`})});exports.Insights=$;exports.insightsPing=T;