@stacksjs/analytics 0.70.86 → 0.70.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/dist/index.js +0 -57
package/package.json
CHANGED
package/dist/index.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
var B=1;function F(m){if(!m.siteId||!m.apiEndpoint)return"";let x=q(m.siteId),W=q(m.apiEndpoint),j=m.honorDnt?'if(n.doNotTrack==="1")return;':"",w=m.trackHashChanges?"w.addEventListener('hashchange',pv);":"",y=m.trackOutboundLinks?`
|
|
3
|
-
d.addEventListener('click',function(e){
|
|
4
|
-
var a=e.target.closest('a');
|
|
5
|
-
if(a&&a.hostname!==location.hostname){
|
|
6
|
-
t('outbound',{url:a.href});
|
|
7
|
-
}
|
|
8
|
-
});`:"";return`<!-- Stacks Self-Hosted Analytics -->
|
|
9
|
-
<script data-site="${x}" data-api="${W}" defer>
|
|
10
|
-
(function(){
|
|
11
|
-
'use strict';
|
|
12
|
-
var d=document,w=window,n=navigator,s=d.currentScript;
|
|
13
|
-
var site=s.dataset.site,api=s.dataset.api;
|
|
14
|
-
${j}
|
|
15
|
-
var q=[],sid=Math.random().toString(36).slice(2);
|
|
16
|
-
function t(e,p){
|
|
17
|
-
var x=new XMLHttpRequest();
|
|
18
|
-
x.open('POST',api+'/collect',true);
|
|
19
|
-
x.setRequestHeader('Content-Type','application/json');
|
|
20
|
-
// Strip the URL's query string before sending. location.href includes
|
|
21
|
-
// tokens / session IDs / search terms that shouldn't reach the
|
|
22
|
-
// analytics backend. Same goes for document.referrer when it points
|
|
23
|
-
// back to our own domain (path is fine, query is not).
|
|
24
|
-
var safeUrl=location.origin+location.pathname+location.hash;
|
|
25
|
-
var safeRef=d.referrer?d.referrer.split('?')[0]:'';
|
|
26
|
-
x.send(JSON.stringify({
|
|
27
|
-
s:site,sid:sid,e:e,p:p||{},
|
|
28
|
-
u:safeUrl,r:safeRef,t:d.title,
|
|
29
|
-
sw:screen.width,sh:screen.height
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
function pv(){t('pageview');}
|
|
33
|
-
${w}
|
|
34
|
-
${y}
|
|
35
|
-
if(d.readyState==='complete')pv();
|
|
36
|
-
else w.addEventListener('load',pv);
|
|
37
|
-
w.stacksAnalytics={track:function(n,v){t('event',{name:n,value:v});}};
|
|
38
|
-
})();
|
|
39
|
-
</script>`}function G(m){if(!m.siteId||!m.apiEndpoint)return[];return[["script",{"data-site":m.siteId,"data-api":m.apiEndpoint,defer:"",innerHTML:z(m)}]]}function z(m){let x=m.honorDnt?'if(n.doNotTrack==="1")return;':"",W=m.trackHashChanges?"w.addEventListener('hashchange',pv);":"",j=m.trackOutboundLinks?"d.addEventListener('click',function(e){var a=e.target.closest('a');if(a&&a.hostname!==location.hostname){t('outbound',{url:a.href});}});":"";return`(function(){
|
|
40
|
-
'use strict';
|
|
41
|
-
var d=document,w=window,n=navigator,s=d.currentScript;
|
|
42
|
-
var site=s.dataset.site,api=s.dataset.api;
|
|
43
|
-
${x}
|
|
44
|
-
var q=[],sid=Math.random().toString(36).slice(2);
|
|
45
|
-
function t(e,p){
|
|
46
|
-
var x=new XMLHttpRequest();
|
|
47
|
-
x.open('POST',api+'/collect',true);
|
|
48
|
-
x.setRequestHeader('Content-Type','application/json');
|
|
49
|
-
var safeUrl=location.origin+location.pathname+location.hash;var safeRef=d.referrer?d.referrer.split('?')[0]:'';x.send(JSON.stringify({s:site,sid:sid,e:e,p:p||{},u:safeUrl,r:safeRef,t:d.title,sw:screen.width,sh:screen.height}));
|
|
50
|
-
}
|
|
51
|
-
function pv(){t('pageview');}
|
|
52
|
-
${W}
|
|
53
|
-
${j}
|
|
54
|
-
if(d.readyState==='complete')pv();
|
|
55
|
-
else w.addEventListener('load',pv);
|
|
56
|
-
w.stacksAnalytics={track:function(n,v){t('event',{name:n,value:v});}};
|
|
57
|
-
})();`}function q(m){return m.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}export{G as getSelfHostedAnalyticsHead,F as generateSelfHostedScript,B as fathomWip};
|