fix: umami 스크립트를 날씨각에 복사해 두고 써서 외부 스크립트를 직접 실행하지 않게 — 무결성 확인(SRI) 대신

- analytics.webforai.kr/script.js 를 frontend/public/embed/umami.js 로 복사(2026-11-26), 기록은 data-host-url 로 같은 umami 서버에 보냄
- 날씨각 웹(index.html)과 위젯 카드 모두 복사본을 씀. umami 서버가 다른 사이트의 파일 확인 요청(CORS)을 허락하지 않아 SRI 는 쓸 수 없음
- 복사본은 린트에서 뺌, 운영 문서에 다시 받는 법
This commit is contained in:
skkim committed 2026-11-26 15:32:58 +09:00
1 parent 3257360b5b
commit 11ce52a2d1
6 files changed
+28 -12

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
/* umami 방문 통계 스크립트 — https://analytics.webforai.kr/script.js 를 2026-11-26 그대로 복사한 것.
외부 스크립트를 날씨각 페이지에서 직접 실행하지 않으려고(무결성 확인 대신) 날씨각에서 준다. 기록은 data-host-url 의 umami 서버로 간다.
umami 서버를 업그레이드해 기록이 안 되면 같은 주소에서 다시 받아 덮어쓴다(이 주석은 남긴다). 손으로 고치지 않는다. */
!function(){"use strict";function e(e,t=2e3){return e.slice(0,t).replace(/https?:\/\/[^\s)]+/g,e=>{try{const t=e.match(/:\d+:\d+$/)?.[0]||"",n=new URL(t?e.slice(0,-t.length):e);return`${n.origin}${n.pathname}${t}`}catch{return"[url]"}}).replace(/[\w.+-]+@[\w.-]+\.[a-z]{2,}/gi,"[email]").replace(/\beyJ[\w-]+\.[\w-]+\.[\w-]+\b/g,"[token]").replace(/\b(password|secret|token|authorization|api[_-]?key)\s*[:=]\s*[^\s,;]+/gi,"$1=[redacted]").slice(0,t)}function t(t){try{return e(new URL(t,"https://localhost").pathname,500)}catch{return"/"}}function n(t={}){return Object.fromEntries(Object.entries(t).slice(0,20).filter(([e])=>!/password|secret|token|authorization|cookie|email|api.?key/i.test(e)).map(([t,n])=>[e(t,50),e(String(n),200)]))}function a(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const e=crypto.getRandomValues(new Uint8Array(16));e[6]=15&e[6]|64,e[8]=63&e[8]|128;const t=Array.from(e,e=>e.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function r(r){const i=new WeakMap,o=[];let s=!1,c=!1,l=0,d=0,f=0;async function u(u,m={},p=!0){try{if(!r.enabled||c||r.disabled()||o.length>=20)return;const h=Date.now();if(h<l)return;const y=Math.floor(h/6e4);if(d!==y&&(d=y,f=0),f>=20)return;if(u&&"object"==typeof u){if(h-(i.get(u)||0)<1e3)return;i.set(u,h)}f++;const g=r.context(),b=r.cache(),v=u&&"object"==typeof u?u:null,w="string"==typeof v?.message?v.message:"string"==typeof u?u:"Non-Error exception",T={version:1,website:g.website,eventId:a(),timestamp:h,name:e("string"==typeof v?.name?v.name:"Error",200)||"Error",message:e(w),stack:e("string"==typeof v?.stack?v.stack:"",16e3),handled:p,url:t(g.url),id:g.id,salt:g.salt,screen:g.screen,language:g.language,release:e(m.release||r.release,100),environment:e(m.environment||r.environment,50),tags:n(m.tags),...m.fingerprint?.length?{fingerprint:m.fingerprint.slice(0,5).map(t=>e(t,200))}:{}};let S;c=!0;try{S=r.beforeSend(T)}finally{c=!1}const k=await S;if(!k||r.disabled())return;o.push({payload:{...k,website:T.website,eventId:T.eventId,timestamp:h,version:1},cache:b}),async function(){if(!s){s=!0;try{for(;o.length;){const e=o.shift();if(!e||r.disabled())continue;const t=JSON.stringify({type:"error",payload:e.payload});if(!((new TextEncoder).encode(t).byteLength>48e3))for(let n=0;n<3&&!r.disabled();n++){try{const n=await fetch(r.endpoint,{method:"POST",keepalive:!0,credentials:"omit",body:t,headers:{"Content-Type":"application/json",...e.cache?{"x-umami-cache":e.cache}:{}}});if(n.ok){const t=await n.json();t.cache&&r.cache()===e.cache&&r.context().id===e.payload.id&&r.updateCache(t.cache);break}if(429===n.status){o.length=0;const e=Number(n.headers.get("Retry-After"))||60;l=Date.now()+1e3*Math.max(1,Math.min(e,300));break}if(n.status<500)break}catch{}n<2&&await new Promise(e=>setTimeout(e,1e3*2**n))}}}finally{s=!1}}}().catch(()=>{})}catch{}}return r.enabled&&(window.addEventListener("error",e=>{e.message&&u(e.error||{name:"Error",message:e.message,stack:e.filename?`at ${e.filename}:${e.lineno}:${e.colno}`:""},{},!1)}),window.addEventListener("unhandledrejection",e=>{u(e.reason,{},!1)})),{captureException:(e,t)=>u(e,t)}}(e=>{const{screen:{width:t,height:n},navigator:{language:a,doNotTrack:i,msDoNotTrack:o},location:s,document:c,history:l,top:d,doNotTrack:f}=e,{currentScript:u,referrer:m}=c,p=e.umamiConfig||{};if(!u&&!p.websiteId)return;const{hostname:h,href:y,origin:g}=s;let b;try{b=y.startsWith("data:")?void 0:e.localStorage}catch{}const v="data-",w="false",T="true",S=u?u.getAttribute.bind(u):()=>null,k=e=>{const t=S(`${v}${e}`);if(null!=t)return t;const n=p[(e=>e.replace(/-([a-z])/g,e=>e[1].toUpperCase()))(e)];return null==n||"function"==typeof n?null:Array.isArray(n)?n.join(","):String(n)},$=()=>{const t=k("before-send"),n=t?e[t]:p.beforeSend;return"function"==typeof n?n:void 0},x=k("website-id"),E=k("host-url"),j=k("distinct-id")||void 0,M=k("tag")||void 0,I=k("salt")||void 0,U=k("salt-rotation"),L=k("auto-track")!==w,O=k("do-not-track")===T,A=k("exclude-search")===T,D=k("exclude-hash")===T,C=k("domains")||"",N=k("fetch-credentials")||"omit",R=k("performance")===T,P=k("auto-pageview")!==w,z=C.split(",").map(e=>e.trim()),_=E||""||(u?u.src.split("/").slice(0,-1).join("/"):"");if(!u&&!_)return;const J=`${_.replace(/\/$/,"")}/api/send`,K=`${t}x${n}`,W=/data-umami-event-([\w-_]+)/,B=`${v}umami-event`,V=300,q=e=>{if(!e)return e;try{const t=new URL(e,s.href);return A&&(t.search=""),D&&(t.hash=""),t.toString()}catch{return e}},F=()=>{if(I)return I;const e={hourly:13,daily:10,weekly:10,monthly:7}[U];if(!e)return;const t=new Date;return"weekly"===U&&t.setUTCDate(t.getUTCDate()-t.getUTCDay()),t.toISOString().slice(0,e)},G=()=>{return{website:x,screen:K,language:a,title:c.title,hostname:h,url:re,referrer:(e=ie,e===g||e?.startsWith(`${g}/`)?e.slice(g.length):e),tag:M,id:ce||void 0,salt:F()};var e},H=(e,t,n)=>{n&&("function"==typeof ae&&ae(),ie=re,re=q(n),re!==ie&&P&&setTimeout(Z,VLine truncated