runlight 0.4.1 → 0.4.2

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.
data/assets/tracker.js CHANGED
@@ -1 +1 @@
1
- (function(){var a=window,n=document,u=navigator,p=n.currentScript;if(p){var o=function(e){return p.getAttribute("data-"+e)},R=p.src.replace(/s\.js(\?.*)?$/,"e"),k=o("site"),U=o("hash")!==null,I=o("manual")!==null,T=o("before-send"),$=function(e){return new RegExp("^"+e.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*")+"$")},J=(o("exclude")||"").split(",").filter(Boolean).map(function(e){return $(e.trim())}),A=!1,H=a.runlight&&a.runlight.q||[],m="__RUNLIGHT_RULES__",O=typeof m=="object"&&(m[k]||m[location.hostname.replace(/^www\./,"")]||m["*"])||[],M=/[?&]runlight=pick\b/.test(location.search)&&/[?&]runlight_ticket=/.test(location.search);if(M){var N=n.createElement("script");N.src=p.src.replace(/s\.js(\?.*)?$/,"pick.js")+location.search,n.head.appendChild(N)}var z=!1;try{var B=/[?&]runlight=(ignore|track)\b/.exec(location.search);B&&(B[1]==="ignore"?localStorage.setItem("runlight_ignore","1"):localStorage.removeItem("runlight_ignore")),z=localStorage.getItem("runlight_ignore")==="1"}catch(e){}var P=M||u.webdriver||z||o("dnt")!==null&&(u.doNotTrack==="1"||a.doNotTrack==="1"),E=function(e,t){if(!(A||P)){var r={k:e,u:b};k&&(r.s=k);for(var i in t)r[i]=t[i];if(T!==null)try{if(r=a[T](r),!r||r.constructor!==Object)return}catch(y){return}var s=JSON.stringify(r);u.sendBeacon&&u.sendBeacon(R,s)||a.fetch&&fetch(R,{method:"POST",body:s,keepalive:!0}).catch(function(){})}},Y=function(){var e=new Uint8Array(6);return(a.crypto||{}).getRandomValues?crypto.getRandomValues(e):e.forEach(function(t,r){e[r]=Math.random()*256}),Array.from(e,function(t){return(t+256).toString(36).slice(-2)}).join("")},F=o("404")!==null,b="",v="",f=0,d=0,w=0,q=function(){return n.visibilityState==="visible"&&n.hasFocus()},D=function(){d&&(f+=Date.now()-d),d=0},c=function(){!d&&q()&&(d=Date.now())},S=function(){D(),v&&f>=1e3&&(E("engagement",{i:v,e:f,d:w}),f=0)},V=function(){var e=n.documentElement,t=Math.max(e.scrollHeight,n.body?n.body.scrollHeight:0),r=(a.scrollY||e.scrollTop)+a.innerHeight,i=t>0?Math.min(100,Math.round(r/t*100)):100;i>w&&(w=i)},K=function(){var e=location;return e.protocol+"//"+e.host+e.pathname+e.search+(U?e.hash:"")},h=function(e){var t=typeof e=="string"?new URL(e,location.href).href:K();if(t!==b){var r=b||n.referrer;S(),b=t;var i=new URL(t).pathname;A=J.some(function(s){return s.test(i)}),v=Y(),f=0,w=0,V(),c(),E("pageview",{i:v,r,t:n.title,w:screen.width,h:screen.height,l:u.language}),F&&l("404",{path:location.pathname}),F=!1}},l=function(e,t){typeof e!="string"||!e||E("event",{i:v,n:e,p:t&&typeof t=="object"?t:void 0})},C=function(e){var t=history[e];history[e]=function(){var r=t.apply(this,arguments);return setTimeout(h),r}};I||(C("pushState"),C("replaceState"),a.addEventListener("popstate",h),U&&a.addEventListener("hashchange",h)),n.addEventListener("visibilitychange",function(){n.visibilityState==="hidden"?S():c()}),a.addEventListener("pagehide",S),a.addEventListener("blur",D),a.addEventListener("focus",c),a.addEventListener("scroll",function(){V(),c()},{passive:!0}),n.addEventListener("pointerdown",c,!0),n.addEventListener("keydown",c,!0);var Q=/\.(pdf|zip|gz|tgz|dmg|pkg|exe|msi|apk|docx?|xlsx?|pptx?|csv|txt|rtf|epub|mp3|wav|mp4|mov|avi|mkv|psd|ai|svg|key|numbers|pages)$/i;n.addEventListener("click",function(e){var t=e.target;if(!(!t||!t.closest)){for(var r=t.closest("a[href]"),i=0;i<O.length;i++)try{var s=O[i],y=s[1];(s[0]==="s"?t.closest(y):r&&$(y).test(y.charAt(0)==="/"?r.pathname:r.href))&&l(s[2])}catch(W){}var g=t.closest("[data-runlight]");if(g){for(var G={},x=0;x<g.attributes.length;x++){var _=g.attributes[x];_.name.indexOf("data-runlight-")===0&&(G[_.name.slice(14)]=_.value)}l(g.getAttribute("data-runlight"),G)}if(!(!r||g)){var j=r.href;/^https?:/.test(j)&&(o("downloads")!=="false"&&Q.test(r.pathname)?l("File download",{url:j}):o("outbound")!=="false"&&r.host!==location.host&&l("Outbound link",{url:j}))}}},!0),a.runlight=l,l.pageview=h,I||h();for(var L=0;L<H.length;L++)l.apply(null,H[L])}})();
1
+ (function(){var n=window,a=document,m=navigator,i=location,k=a.currentScript;if(k){var s=function(e){return k.getAttribute("data-"+e)},R=k.src.replace(/s\.js(\?.*)?$/,""),E=R+"e",q=E.indexOf(i.origin+"/")?"text/plain":"application/json",L=s("site"),A=s("hash")!==null,H=s("manual")!==null,T=s("before-send"),$=function(e){return new RegExp("^"+e.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*")+"$")},K=(s("exclude")||"").split(",").filter(Boolean).map(function(e){return $(e.trim())}),N=!1,z=n.runlight&&n.runlight.q||[],b="__RUNLIGHT_RULES__",B=typeof b=="object"&&(b[L]||b[i.hostname.replace(/^www\./,"")]||b["*"])||[],F=/[?&]runlight=pick\b/.test(i.search)&&/[?&]runlight_ticket=/.test(i.search);if(F){var M=a.createElement("script");M.src=R+"pick.js"+i.search,a.head.appendChild(M)}var D=!1;try{var C=/[?&]runlight=(ignore|track)\b/.exec(i.search),x=localStorage;C&&(C[1]==="ignore"?x.setItem("runlight_ignore","1"):x.removeItem("runlight_ignore")),D=x.getItem("runlight_ignore")==="1"}catch(e){}var Q=F||m.webdriver||D||s("dnt")!==null&&(m.doNotTrack==="1"||n.doNotTrack==="1"),S=function(e,t){if(!(N||Q)){var r={k:e,u:w};L&&(r.s=L);for(var o in t)r[o]=t[o];if(T!==null)try{if(r=n[T](r),!r||r.constructor!==Object)return}catch(g){return}var l=new Blob([JSON.stringify(r)],{type:q});try{if(m.sendBeacon(E,l))return}catch(g){}n.fetch&&fetch(E,{method:"POST",body:l,keepalive:!0}).catch(function(){})}},W=function(){var e=new Uint8Array(6);return crypto.getRandomValues(e),Array.from(e,function(t){return(t+256).toString(36).slice(-2)}).join("")},G=s("404")!==null,w="",c="",f=0,d=0,y=0,X=function(){return a.visibilityState==="visible"&&a.hasFocus()},J=function(){d&&(f+=Date.now()-d),d=0},v=function(){!d&&X()&&(d=Date.now())},_=function(){J(),c&&f>=1e3&&(S("engagement",{i:c,e:f,d:y}),f=0)},P=function(){var e=a.documentElement,t=Math.max(e.scrollHeight,a.body?a.body.scrollHeight:0),r=n.scrollY+n.innerHeight,o=t>0?Math.min(100,Math.round(r/t*100)):100;o>y&&(y=o)},Z=function(){return i.origin+i.pathname+i.search+(A?i.hash:"")},h=function(e){var t=typeof e=="string"?new URL(e,i.href).href:Z();if(t!==w){var r=w||a.referrer;_(),w=t;var o=new URL(t).pathname;N=K.some(function(l){return l.test(o)}),c=W(),f=0,y=0,P(),v(),S("pageview",{i:c,r,t:a.title,w:screen.width,h:screen.height,l:m.language}),G&&u("404",{path:i.pathname}),G=!1}},u=function(e,t){typeof e!="string"||!e||S("event",{i:c,n:e,p:t&&typeof t=="object"?t:void 0})},V=function(e){var t=history[e];history[e]=function(){var r=t.apply(this,arguments);return setTimeout(h),r}};H||(V("pushState"),V("replaceState"),n.addEventListener("popstate",h),A&&n.addEventListener("hashchange",h)),a.addEventListener("visibilitychange",function(){a.visibilityState==="hidden"?_():v()}),n.addEventListener("pagehide",_),n.addEventListener("blur",J),n.addEventListener("focus",v),n.addEventListener("scroll",function(){P(),v()},{passive:!0}),a.addEventListener("pointerdown",v,!0),a.addEventListener("keydown",v,!0);var ee=/\.(pdf|zip|gz|tgz|dmg|pkg|exe|msi|apk|docx?|xlsx?|pptx?|csv|txt|rtf|epub|mp3|wav|mp4|mov|avi|mkv|psd|ai|svg|key|numbers|pages)$/i;a.addEventListener("click",function(e){var t=e.target;if(!(!t||!t.closest)){for(var r=t.closest("a[href]"),o=0;o<B.length;o++)try{var l=B[o],g=l[1];(l[0]==="s"?t.closest(g):r&&$(g).test(g.charAt(0)==="/"?r.pathname:r.href))&&u(l[2])}catch(te){}var p=t.closest("[data-runlight]");if(p){for(var Y={},U=0;U<p.attributes.length;U++){var I=p.attributes[U];I.name.indexOf("data-runlight-")===0&&(Y[I.name.slice(14)]=I.value)}u(p.getAttribute("data-runlight"),Y)}if(!(!r||p)){var O=r.href;/^https?:/.test(O)&&(s("downloads")!=="false"&&ee.test(r.pathname)?u("File download",{url:O}):s("outbound")!=="false"&&r.host!==i.host&&u("Outbound link",{url:O}))}}},!0),n.runlight=u,u.pageview=h,H||h();for(var j=0;j<z.length;j++)u.apply(null,z[j])}})();
@@ -2647,7 +2647,7 @@ module Runlight
2647
2647
  if method == "OPTIONS"
2648
2648
  return Http::Response.new("", status: 204, headers: { "access-control-allow-origin" => "*", "access-control-allow-methods" => "POST", "access-control-max-age" => "86400" })
2649
2649
  end
2650
- return coded("Method not allowed", "method_not_allowed", 405) if method != "POST"
2650
+ return coded("Method not allowed. The tracker sends visits here with POST; a GET usually means a firewall or proxy replaced the request with its own error page.", "method_not_allowed", 405) if method != "POST"
2651
2651
 
2652
2652
  begin
2653
2653
  rl.collect(request, context)
@@ -4,7 +4,7 @@ require "json"
4
4
 
5
5
  module Runlight
6
6
  # The gem's own version, which the release keeps equal to the npm package's.
7
- GEM_VERSION = "0.4.1"
7
+ GEM_VERSION = "0.4.2"
8
8
 
9
9
  # The SDK's version and the HTTP API's, read from assets/build.json, which
10
10
  # scripts/ruby-assets.mts writes from the TypeScript SDK, so the two always
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runlight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon C. Phillips