@docx-editor.dev/telemetry 2.29.0 → 2.30.0

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.
Files changed (51) hide show
  1. package/README.md +5 -1
  2. package/dist/{chunk-U6ERFNUM.cjs → chunk-6BTB6Y3H.cjs} +1 -1
  3. package/dist/chunk-7SYLCJFQ.cjs +1 -0
  4. package/dist/chunk-AL2YERWY.cjs +1 -0
  5. package/dist/chunk-E2HR5DHZ.cjs +2 -0
  6. package/dist/{chunk-RRYW7EAV.js → chunk-E3FTXDLH.js} +1 -1
  7. package/dist/{chunk-LFX65QJG.js → chunk-JM4KJB6O.js} +1 -1
  8. package/dist/{chunk-7ZXJ6HP2.cjs → chunk-PZZC5AXX.cjs} +1 -1
  9. package/dist/{chunk-MJX3ECH3.cjs → chunk-QDOUVRQA.cjs} +1 -1
  10. package/dist/chunk-RSWAOCAT.js +1 -0
  11. package/dist/chunk-W5HFB5EV.js +1 -0
  12. package/dist/chunk-WHVIRIUW.js +1 -0
  13. package/dist/chunk-WLWS5CZT.js +2 -0
  14. package/dist/hocuspocus/index.cjs +1 -1
  15. package/dist/hocuspocus/index.d.cts +1 -1
  16. package/dist/hocuspocus/index.d.ts +1 -1
  17. package/dist/hocuspocus/index.js +1 -1
  18. package/dist/index.cjs +1 -1
  19. package/dist/index.d.cts +30 -7
  20. package/dist/index.d.ts +30 -7
  21. package/dist/index.js +1 -1
  22. package/dist/ingest/index.cjs +1 -1
  23. package/dist/ingest/index.d.cts +21 -12
  24. package/dist/ingest/index.d.ts +21 -12
  25. package/dist/ingest/index.js +1 -1
  26. package/dist/otel/index.cjs +1 -1
  27. package/dist/otel/index.d.cts +1 -1
  28. package/dist/otel/index.d.ts +1 -1
  29. package/dist/otel/index.js +1 -1
  30. package/dist/{pipeline-DbVW7S-K.d.cts → pipeline-CCq2Ng0B.d.cts} +6 -0
  31. package/dist/{pipeline-DbVW7S-K.d.ts → pipeline-CCq2Ng0B.d.ts} +6 -0
  32. package/dist/prometheus/index.cjs +1 -1
  33. package/dist/prometheus/index.d.cts +1 -1
  34. package/dist/prometheus/index.d.ts +1 -1
  35. package/dist/prometheus/index.js +1 -1
  36. package/dist/sentry/index.cjs +1 -1
  37. package/dist/sentry/index.d.cts +1 -1
  38. package/dist/sentry/index.d.ts +1 -1
  39. package/dist/sentry/index.js +1 -1
  40. package/dist/server/index.cjs +1 -1
  41. package/dist/server/index.d.cts +2 -2
  42. package/dist/server/index.d.ts +2 -2
  43. package/dist/server/index.js +1 -1
  44. package/package.json +3 -3
  45. package/dist/chunk-73YEPWY5.js +0 -1
  46. package/dist/chunk-DTEVX2XS.js +0 -1
  47. package/dist/chunk-LFQSY2TD.cjs +0 -1
  48. package/dist/chunk-LGNT4I5W.cjs +0 -1
  49. package/dist/chunk-NUN46EXH.js +0 -2
  50. package/dist/chunk-S7KBMROA.js +0 -1
  51. package/dist/chunk-UK2MNJCG.cjs +0 -2
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export{a as callbackExporter,d as consoleExporter,c as isFailure,e as memoryExporter}from'./chunk-NUN46EXH.js';import {c,b as b$1}from'./chunk-S7KBMROA.js';export{b as ENGINE_VERSION,a as MAX_METRIC_LABEL_VALUES}from'./chunk-S7KBMROA.js';import {a as a$1}from'./chunk-73YEPWY5.js';export{a as METRICS,b as prometheusName}from'./chunk-73YEPWY5.js';import {b,a}from'./chunk-DTEVX2XS.js';import'./chunk-DT2KMPUJ.js';import {explainDiagnostic}from'@docx-editor.dev/core';export{explainDiagnostic}from'@docx-editor.dev/core';var W={documentOpen:true,editing:true,trackedChanges:true,fonts:true,history:true,customNodes:true,collaborationClient:true,performance:true},q=new Set(["edit.tracking-required","edit.suggesting-needs-author","edit.tracking-mode-unsupported","edit.tracking-author-required","edit.tracking-unsupported-host"]);function U(e){switch(e.kind){case "document.open":return "documentOpen";case "edit.rejected":return e.tracked||q.has(e.code)?"trackedChanges":"editing";case "review.skipped":return "trackedChanges";case "font.failed":return "fonts";case "history":return "history";case "custom-node":return "customNodes";case "collab.status":case "collab.participants":return "collaborationClient";case "performance":return "performance";default:return null}}function X(e){return e.kind==="edit.rejected"?[e.editorSessionId,e.code,e.cause,e.errorName,e.stage,e.origin,e.tracked,e.command].join("|"):e.kind==="font.failed"?`${e.editorSessionId}|font|${e.code}`:e.kind==="history"||e.kind==="custom-node"?`${e.editorSessionId}|${e.kind}|${e.code}`:e.kind==="collab.participants"?`${e.editorSessionId}|participants`:e.kind==="collab.status"?`${e.editorSessionId}|status|${e.status}|${e.code??""}|${e.recovering}`:null}function Y(e){let t=c(e),m=e.metricLabels??[];function n(r){let o={};try{let a=typeof e.attributes=="function"?e.attributes():e.attributes;o=b(a??{},"attributes");}catch{}return Object.freeze({...o,...r})}function s(r){let o={};for(let a of m)r[a]!==void 0&&(o[a]=r[a]);return o}let f=e.include??W,l=e.dedupeWindowMs??1e4,g=r=>{try{if(e.filter&&!e.filter(r))return}catch{return}t.event(r);},h=e.documentShape==="detailed",y=new Map,T=false,w=()=>{},E=false;function D(r){let o=f[r];return o?o===true?1:Math.min(1,Math.max(0,o.sampleRate??1)):null}let b$2=new Map;function k(r,o,a){if(a>=1)return true;if(o!=="performance")return Math.random()<a;let p=b$2.get(r.editorSessionId);return p===void 0&&(b$2.size>=1e3&&b$2.clear(),p=Math.random()<a,b$2.set(r.editorSessionId,p)),p}function v(){if(T)return;T=true;let r=globalThis;if(typeof r.addEventListener!="function")return;let o=()=>{t.setPageClosing(true),u();},a=()=>{let p=globalThis.document?.visibilityState==="hidden";t.setPageClosing(p),p&&u();};r.addEventListener("pagehide",o),r.addEventListener("visibilitychange",a),w=()=>{r.removeEventListener?.("pagehide",o),r.removeEventListener?.("visibilitychange",a);};}function x(r){let o=y.get(r);if(o)if(y.delete(r),clearTimeout(o.timer),o.latest){let a=o.event;o.latest.count!==a.count&&g(I(F(o.latest,h),t,o.event.attributes));}else o.repeated>0&&g({...o.event,repeated:o.repeated});}function i(r,o={}){if(E||!t.consented())return;let a$2=n(o),p=a(I(r,t,a$2));if("dropped"in p){t.metric(a$1.droppedEvents,1,{...s(a$2),reason:p.dropped,"docx_editor.version":b$1});return}let A=U(r),M=A?D(A):null;if(M===null||A==="performance"&&M===0)return;v(),Z(t,p.event,s(a$2));let S=l>0?X(r):null,O=S?y.get(S):void 0;if(O){r.kind==="collab.participants"?O.latest=r:O.repeated+=1;return}if(!k(r,A,M))return;let N=I(F(r,h),t,a$2);if(g(N),S){let R=setTimeout(()=>x(S),l);R.unref?.(),y.set(S,{event:N,repeated:0,timer:R});}}function c$1(r){return Object.freeze({id:"telemetry",onDiagnostic:o=>i(o,r),wantsDiagnostic:o=>!E&&(o!=="performance"||(D("performance")??0)>0&&t.consented())})}async function u(){for(let r of [...y.keys()])x(r);await t.flush();}return {module:c$1({}),moduleFor(r){return c$1(b(r,"moduleFor"))},record:i,flush:u,async shutdown(){for(let r of [...y.keys()])x(r);E=true,w(),await t.shutdown();}}}function F(e,t){if(t||e.kind!=="document.open"||e.outcome!=="opened"||!("shape"in e))return e;let{shape:m,...n}=e;return n}function I(e,t,m){let n="code"in e?e.code:void 0;return {...e,...n?explainDiagnostic(n):{},engineVersion:b$1,resource:t.resource,attributes:m}}function Z(e,t,m){let n={metric:(s,f,l={})=>e.metric(s,f,{...l,...m,"docx_editor.version":b$1})};switch(t.kind){case "document.open":t.outcome==="opened"?(n.metric(a$1.documentOpens,1,{outcome:"opened",code:"none",cause:"none",part:"none"}),n.metric(a$1.documentOpenDuration,t.durationMs/1e3)):n.metric(a$1.documentOpens,1,{outcome:"rejected",code:t.code,cause:t.cause??"none",part:t.part??"none"});return;case "edit.rejected":n.metric(a$1.editRejections,1,{code:t.code,cause:t.cause??"none",origin:t.origin,tracked:t.tracked});return;case "review.skipped":n.metric(a$1.reviewSkipped,t.count,{code:t.code,cause:t.cause??"none",operation:t.operation??"none",change_kind:t.changeKind??"none"});return;case "font.failed":n.metric(a$1.fontFailures,1,{code:t.code});return;case "history":n.metric(a$1.historyDiagnostics,1,{code:t.code});return;case "custom-node":n.metric(a$1.customNodeDiagnostics,1,{code:t.code});return;case "collab.status":n.metric(a$1.collabClientStatusTransitions,1,{status:t.status,code:t.code??"none"}),t.connectMs!==void 0&&n.metric(a$1.collabClientConnectDuration,t.connectMs/1e3);return;case "collab.participants":n.metric(a$1.collabClientParticipants,t.count);return;case "performance":{let s=t.pagesBucket??"unknown";L(n,a$1.editorInteractionDuration,s,t.interaction),L(n,a$1.editorLayoutDuration,s,t.layout),L(n,a$1.editorPaintDuration,s,t.paint);}}}function L(e,t,m,n){if(!n)return;let s=t.buckets??[];n.bands.forEach((f,l)=>{let g=s[l],h=l===0?0:s[l-1],y=g===void 0?Math.max(n.maxMs/1e3,h+1e-6):(h+g)/2;for(let T=0;T<f;T+=1)e.metric(t,y,{pages:m});});}var J=new TextEncoder,Q=e=>J.encode(e).byteLength;function ee(e){let t=Math.min(50,Math.max(1,Math.floor(e.batchSize??20))),m=e.flushIntervalMs??1e4,n=[],s,f,l=new Set,g=i=>{try{e.onError?.(i);}catch{}},h=(i,c)=>{if(typeof fetch!="function")return;let u=fetch(e.url,{method:"POST",headers:{"Content-Type":"application/json",...e.headers},body:i,keepalive:c}).then(r=>{if(!r.ok)throw new Error(`telemetry endpoint answered ${r.status}`)}).catch(g).finally(()=>l.delete(u));l.add(u);},y=i=>{let c=globalThis.navigator;if(!e.headers&&typeof c?.sendBeacon=="function")try{if(c.sendBeacon(e.url,new Blob([i],{type:"application/json"})))return}catch{}h(i,true);},T=i=>{let c=Math.min(t,n.length);for(;c>0;){let u=JSON.stringify(n.slice(0,c)),r=Q(u);if(r<=i)return {body:u,bytes:r,count:c};if(c===1)return null;c=Math.ceil(c/2);}return null},w=0,E=false,D=i=>{if(s!==void 0&&clearTimeout(s),s=void 0,f&&!f.consented()){n=[];return}(!i||!E)&&(w=0),E=i;let c=0;for(;n.length;){let u=T(61440-(i?w:0));if(!u){c+=i?n.length:1,n=i?[]:n.slice(1);continue}n=n.slice(u.count),i?(w+=u.bytes,y(u.body)):h(u.body,false);}c&&g(new Error(`telemetry dropped ${c} events that did not fit`));},b=()=>{let i=f?.pageClosing()??false;return i||(E=false),i},k=globalThis.document,v=()=>{k?.visibilityState==="visible"&&(E=false);},x=()=>k?.removeEventListener?.("visibilitychange",v);return {name:"http",attach(i){f=i,k?.addEventListener?.("visibilitychange",v);},event(i){n.push(i),n.length>=t?D(b()):s===void 0&&(s=setTimeout(()=>D(b()),m),s.unref?.());},async flush(){D(b()),await Promise.all(l);},async shutdown(){x(),D(b()),await Promise.all(l);}}}function te(e={}){return ()=>{let t=globalThis;if(!t.window||!t.document||!t.navigator||t.navigator.globalPrivacyControl===true||t.navigator.doNotTrack==="1")return false;if(!e.optOutKey)return true;try{return globalThis.localStorage?.getItem(e.optOutKey)!=="off"}catch{return true}}}export{te as browserPrivacySignals,Y as createTelemetry,ee as httpExporter};
1
+ import {c,b as b$1}from'./chunk-WHVIRIUW.js';export{b as ENGINE_VERSION,a as MAX_METRIC_LABEL_VALUES}from'./chunk-WHVIRIUW.js';import {a as a$1}from'./chunk-RSWAOCAT.js';export{a as METRICS,b as prometheusName}from'./chunk-RSWAOCAT.js';export{a as callbackExporter,e as consoleExporter,d as failureCount,c as isFailure,f as memoryExporter}from'./chunk-WLWS5CZT.js';import {c as c$1,a,b}from'./chunk-W5HFB5EV.js';import'./chunk-DT2KMPUJ.js';import {explainDiagnostic}from'@docx-editor.dev/core';export{explainDiagnostic}from'@docx-editor.dev/core';var X={documentOpen:true,documentSave:true,sessions:true,editing:true,trackedChanges:true,fonts:true,history:true,customNodes:true,collaborationClient:true,performance:true},Y=new Set(["edit.tracking-required","edit.suggesting-needs-author","edit.tracking-mode-unsupported","edit.tracking-author-required","edit.tracking-unsupported-host"]);function Z(e){switch(e.kind){case "document.open":return "documentOpen";case "document.save":return "documentSave";case "session":return "sessions";case "edit.rejected":return e.tracked||Y.has(e.code)?"trackedChanges":"editing";case "review.skipped":return "trackedChanges";case "font.failed":return "fonts";case "history":return "history";case "custom-node":return "customNodes";case "collab.status":case "collab.participants":return "collaborationClient";case "performance":return "performance";default:return null}}function J(e){return e.kind==="collab.participants"?`${e.editorSessionId}|participants`:e.kind==="edit.rejected"?[e.editorSessionId,e.code,e.cause,e.errorName,e.stage,e.origin,e.tracked,e.command].join("|"):e.kind==="font.failed"?`${e.editorSessionId}|font|${e.code}`:e.kind==="history"||e.kind==="custom-node"?`${e.editorSessionId}|${e.kind}|${e.code}`:e.kind==="collab.status"?`${e.editorSessionId}|status|${e.status}|${e.code??""}|${e.recovering}`:null}function Q(e){let t=c(e),m=e.metricLabels??[];function n(o){let r={};try{let a=typeof e.attributes=="function"?e.attributes():e.attributes;r=c$1(a??{},"attributes");}catch{}return Object.freeze({...r,...o})}function c$2(o){let r={};for(let a of m)o[a]!==void 0&&(r[a]=o[a]);return r}let f=e.include??X,l=e.dedupeWindowMs??1e4,g=o=>{try{if(e.filter&&!e.filter(o))return}catch{return}t.event(o);},E=e.documentShape==="detailed",y=new Map,S=false,k=()=>{},T=false;function D(o){let r=f[o];return r?r===true?1:Math.min(1,Math.max(0,r.sampleRate??1)):null}let h=new Map;function w(o,r,a){if(a>=1)return true;if(r!=="performance"&&r!=="sessions")return Math.random()<a;let p=`${r}|${o.editorSessionId}`,b=h.get(p);return b===void 0&&(h.size>=1e3&&h.clear(),b=Math.random()<a,h.set(p,b)),b}function M(){if(S)return;S=true;let o=globalThis;if(typeof o.addEventListener!="function")return;let r=()=>{t.setPageClosing(true),u();},a=()=>{let p=globalThis.document?.visibilityState==="hidden";t.setPageClosing(p),p&&u();};o.addEventListener("pagehide",r),o.addEventListener("visibilitychange",a),k=()=>{o.removeEventListener?.("pagehide",r),o.removeEventListener?.("visibilitychange",a);};}function v(o){let r=y.get(o);if(r){if(y.delete(o),clearTimeout(r.timer),r.latest){let a=r.event;r.latest.count!==a.count&&g(I(F(r.latest,E),t,r.event.attributes));}else if(r.repeated>0){let{connectMs:a$1,...p}=r.event;g({...p,repeated:Math.min(r.repeated,a)});}}}function i(o,r={}){if(T||!t.consented())return;let a=n(r),p=b(I(o,t,a));if("dropped"in p){t.metric(a$1.droppedEvents,1,{...c$2(a),reason:p.dropped,"docx_editor.version":b$1});return}let b$2=Z(o),A=b$2?D(b$2):null;if(A===null||b$2==="performance"&&A===0)return;M(),ee(t,p.event,c$2(a));let x=l>0?J(o):null,O=x?y.get(x):void 0;if(O){o.kind==="collab.participants"?O.latest=o:O.repeated+=1;return}let _=o.kind==="session"&&o.phase==="end";if(!w(o,b$2,A)){_&&u();return}let L=I(F(o,E),t,a);if(g(L),_&&u(),x){let R=setTimeout(()=>v(x),l);R.unref?.(),y.set(x,{event:L,repeated:0,timer:R});}}function d(o){return Object.freeze({id:"telemetry",onDiagnostic:r=>i(r,o),wantsDiagnostic:r=>!T&&(r==="session"?D("sessions")!==null:r!=="performance"||(D("performance")??0)>0&&t.consented())})}async function u(){for(let o of [...y.keys()])v(o);await t.flush();}return {module:d({}),moduleFor(o){return d(c$1(o,"moduleFor"))},record:i,flush:u,async shutdown(){for(let o of [...y.keys()])v(o);T=true,k(),await t.shutdown();}}}function F(e,t){if(t||e.kind!=="document.open"||e.outcome!=="opened"||!("shape"in e))return e;let{shape:m,...n}=e;return n}function I(e,t,m){let n="code"in e?e.code:void 0;return {...e,...n?explainDiagnostic(n):{},engineVersion:b$1,resource:t.resource,attributes:m}}function ee(e,t,m){let n={metric:(c,f,l={})=>e.metric(c,f,{...l,...m,"docx_editor.version":b$1})};switch(t.kind){case "document.open":t.outcome==="opened"?(n.metric(a$1.documentOpens,1,{outcome:"opened",code:"none",cause:"none",part:"none"}),n.metric(a$1.documentOpenDuration,t.durationMs/1e3)):n.metric(a$1.documentOpens,1,{outcome:"rejected",code:t.code,cause:t.cause??"none",part:t.part??"none"});return;case "edit.rejected":n.metric(a$1.editRejections,1,{code:t.code,cause:t.cause??"none",origin:t.origin,tracked:t.tracked});return;case "review.skipped":n.metric(a$1.reviewSkipped,t.count,{code:t.code,cause:t.cause??"none",operation:t.operation??"none",change_kind:t.changeKind??"none"});return;case "font.failed":n.metric(a$1.fontFailures,1,{code:t.code});return;case "history":n.metric(a$1.historyDiagnostics,1,{code:t.code});return;case "custom-node":n.metric(a$1.customNodeDiagnostics,1,{code:t.code});return;case "collab.status":n.metric(a$1.collabClientStatusTransitions,1,{status:t.status,code:t.code??"none"}),t.connectMs!==void 0&&n.metric(a$1.collabClientConnectDuration,t.connectMs/1e3);return;case "collab.participants":n.metric(a$1.collabClientParticipants,t.count);return;case "performance":{let c=t.pagesBucket??"unknown";N(n,a$1.editorInteractionDuration,c,t.interaction),N(n,a$1.editorLayoutDuration,c,t.layout),N(n,a$1.editorPaintDuration,c,t.paint);return}case "document.save":n.metric(a$1.documentSaves,1,{outcome:t.outcome,code:t.outcome==="rejected"?t.code:"none"}),t.outcome==="saved"&&n.metric(a$1.documentSaveDuration,t.durationMs/1e3);return;case "session":te(n,t);}}function te(e,t){if(t.phase==="start"){e.metric(a$1.editorSessions,1,{phase:"start"});return}if(t.phase==="end"){e.metric(a$1.editorSessions,1,{phase:"end"}),e.metric(a$1.editorSessionDuration,t.durationMs/1e3);return}t.activeMs>0&&e.metric(a$1.editorActiveTime,t.activeMs/1e3);for(let[m,n]of [["input",t.inputEdits],["command",t.commandEdits],["automation",t.automationEdits]])n>0&&e.metric(a$1.edits,n,{origin:m});}function N(e,t,m,n){if(!n)return;let c=t.buckets??[];n.bands.forEach((f,l)=>{let g=c[l],E=l===0?0:c[l-1],y=g===void 0?Math.max(n.maxMs/1e3,E+1e-6):(E+g)/2;for(let S=0;S<f;S+=1)e.metric(t,y,{pages:m});});}var oe=new TextEncoder,ne=e=>oe.encode(e).byteLength;function re(e){let t=Math.min(50,Math.max(1,Math.floor(e.batchSize??20))),m=e.flushIntervalMs??1e4,n=[],c,f,l=new Set,g=i=>{try{e.onError?.(i);}catch{}},E=(i,d)=>{if(typeof fetch!="function")return;let u=fetch(e.url,{method:"POST",headers:{"Content-Type":"application/json",...e.headers},body:i,keepalive:d}).then(o=>{if(!o.ok)throw new Error(`telemetry endpoint answered ${o.status}`)}).catch(g).finally(()=>l.delete(u));l.add(u);},y=i=>{let d=globalThis.navigator;if(!e.headers&&typeof d?.sendBeacon=="function")try{if(d.sendBeacon(e.url,new Blob([i],{type:"application/json"})))return}catch{}E(i,true);},S=i=>{let d=Math.min(t,n.length);for(;d>0;){let u=JSON.stringify(n.slice(0,d)),o=ne(u);if(o<=i)return {body:u,bytes:o,count:d};if(d===1)return null;d=Math.ceil(d/2);}return null},k=0,T=false,D=i=>{if(c!==void 0&&clearTimeout(c),c=void 0,f&&!f.consented()){n=[];return}(!i||!T)&&(k=0),T=i;let d=0;for(;n.length;){let u=S(61440-(i?k:0));if(!u){d+=i?n.length:1,n=i?[]:n.slice(1);continue}n=n.slice(u.count),i?(k+=u.bytes,y(u.body)):E(u.body,false);}d&&g(new Error(`telemetry dropped ${d} events that did not fit`));},h=()=>{let i=f?.pageClosing()??false;return i||(T=false),i},w=globalThis.document,M=()=>{w?.visibilityState==="visible"&&(T=false);},v=()=>w?.removeEventListener?.("visibilitychange",M);return {name:"http",attach(i){f=i,w?.addEventListener?.("visibilitychange",M);},event(i){n.push(i),n.length>=t?D(h()):c===void 0&&(c=setTimeout(()=>D(h()),m),c.unref?.());},async flush(){D(h()),await Promise.all(l);},async shutdown(){v(),D(h()),await Promise.all(l);}}}function ie(e={}){return ()=>{let t=globalThis;if(!t.window||!t.document||!t.navigator||t.navigator.globalPrivacyControl===true||t.navigator.doNotTrack==="1")return false;if(!e.optOutKey)return true;try{return globalThis.localStorage?.getItem(e.optOutKey)!=="off"}catch{return true}}}export{ie as browserPrivacySignals,Q as createTelemetry,re as httpExporter};
@@ -1 +1 @@
1
- 'use strict';var chunkLFQSY2TD_cjs=require('../chunk-LFQSY2TD.cjs');require('../chunk-WGWKNKUT.cjs');var b=50,i=e=>typeof e=="string",l=e=>typeof e=="number"&&Number.isFinite(e),m=e=>typeof e=="boolean",k={"edit.rejected":[["code",i],["origin",i],["tracked",m]],"review.skipped":[["code",i],["count",l]],"font.failed":[["code",i]],history:[["code",i]],"custom-node":[["code",i]],"collab.status":[["status",i],["previous",i],["recovering",m]],"collab.participants":[["count",l]],performance:[["windowMs",l]]};function h(e){if(!l(e.schemaVersion)||!l(e.time)||!i(e.editorSessionId)||!i(e.engineVersion))return false;if(e.kind==="document.open")return e.outcome==="opened"?i(e.sizeBucket)&&l(e.durationMs):e.outcome==="rejected"&&i(e.code);let r=k[e.kind];return !!r&&r.every(([t,o])=>o(e[t]))}function w(e,r){if(r.size===0)return {};let t=chunkLFQSY2TD_cjs.c(e)??{};return Object.fromEntries(Object.entries(t).filter(([o])=>r.has(o)))}function E(e,r={}){let t=r.maxEvents??b,o=new Set(r.attributeKeys??[]);return !Array.isArray(e)||e.length>t?[]:e.flatMap(n=>{if(!n||typeof n!="object"||Array.isArray(n))return [];let c=n,{resource:d,attributes:u,...s}=c,a=chunkLFQSY2TD_cjs.a(s);if("dropped"in a||!h(a.event))return [];let g=w(c.attributes,o),{attributes:x,...p}=a.event;return [Object.freeze({...p,resource:w(c.resource,o),attributes:g})]})}function O(e){let{hint:r,docs:t,...o}=e,n="code"in e&&e.code?` ${e.code}`:"";return {...o,dt:e.time,message:`${e.kind}${n}`}}var T=64*1024;async function R(e,r){if(Number(e.headers.get("content-length")??0)>r)return null;let t=e.body;if(!t)return "";let o=t.getReader(),n=[],c=0;for(;;){let{done:s,value:a}=await o.read();if(s)break;if(c+=a.byteLength,c>r)return await o.cancel().catch(()=>{}),null;n.push(a);}let d=new Uint8Array(c),u=0;for(let s of n)d.set(s,u),u+=s.byteLength;return new TextDecoder().decode(d)}function v(e){let r=e.maxBodyBytes??T,t=()=>new Response(null,{status:204}),o=n=>{try{e.onError?.(n);}catch{}};return async n=>{if(n.method!=="POST")return t();if(e.allowedOrigins){let s=n.headers.get("origin");if(!s||!e.allowedOrigins.includes(s))return t()}let c;try{c=await R(n,r);}catch{return t()}if(c===null)return t();let d;try{d=JSON.parse(c);}catch{return t()}let u=E(d,e);if(!u.length)return t();try{let a=await e.forward(u);if(a&&a.ok===!1)throw new Error(`the log service answered ${String(a.status)}`)}catch(s){o(s);}return t()}}exports.telemetryRoute=v;exports.toLogRecord=O;exports.validateTelemetryEvents=E;
1
+ 'use strict';var chunkE2HR5DHZ_cjs=require('../chunk-E2HR5DHZ.cjs'),chunk7SYLCJFQ_cjs=require('../chunk-7SYLCJFQ.cjs');require('../chunk-WGWKNKUT.cjs');var b=50,o=e=>typeof e=="string",u=e=>typeof e=="number"&&Number.isFinite(e),p=e=>typeof e=="boolean",h={"edit.rejected":[["code",o],["origin",o],["tracked",p]],"review.skipped":[["code",o],["count",u]],"font.failed":[["code",o]],history:[["code",o]],"custom-node":[["code",o]],"collab.status":[["status",o],["previous",o],["recovering",p]],"collab.participants":[["count",u]],performance:[["windowMs",u]]},E=["durationMs","activeMs","inputEdits","commandEdits","automationEdits"];function T(e){if(!u(e.schemaVersion)||!u(e.time)||!o(e.editorSessionId)||!o(e.engineVersion))return false;if(e.kind==="document.open")return e.outcome==="opened"?o(e.sizeBucket)&&u(e.durationMs):e.outcome==="rejected"&&o(e.code);if(e.kind==="document.save")return u(e.durationMs)&&(e.outcome==="saved"?o(e.sizeBucket):e.outcome==="rejected"&&o(e.code));if(e.kind==="session")return e.phase==="start"||(e.phase==="active"||e.phase==="end")&&E.every(t=>u(e[t]));let n=h[e.kind];return !!n&&n.every(([t,s])=>s(e[t]))}function w(e,n){if(n.size===0)return {};let t=chunk7SYLCJFQ_cjs.d(e)??{};return Object.fromEntries(Object.entries(t).filter(([s])=>n.has(s)))}function R(e,n={}){let t=n.maxEvents??b,s=new Set(n.attributeKeys??[]);return !Array.isArray(e)||e.length>t?[]:e.flatMap(r=>{if(!r||typeof r!="object"||Array.isArray(r))return [];let a=r,{resource:d,attributes:l,...i}=a,c=chunk7SYLCJFQ_cjs.b(i);if("dropped"in c||!T(c.event))return [];let g=w(a.attributes,s),{attributes:O,...k}=c.event;return [Object.freeze({...k,resource:w(a.resource,s),attributes:g})]})}function _(e){let{hint:n,docs:t,...s}=e,r="code"in e&&e.code?` ${e.code}`:"";return {...s,dt:e.time,message:`${e.kind}${r}`,occurrences:e.repeated??1,failures:chunkE2HR5DHZ_cjs.d(e)}}var x=64*1024;async function A(e,n){if(Number(e.headers.get("content-length")??0)>n)return null;let t=e.body;if(!t)return "";let s=t.getReader(),r=[],a=0;for(;;){let{done:i,value:c}=await s.read();if(i)break;if(a+=c.byteLength,a>n)return await s.cancel().catch(()=>{}),null;r.push(c);}let d=new Uint8Array(a),l=0;for(let i of r)d.set(i,l),l+=i.byteLength;return new TextDecoder().decode(d)}function F(e){let n=e.maxBodyBytes??x,t=()=>new Response(null,{status:204}),s=r=>{try{e.onError?.(r);}catch{}};return async r=>{if(r.method!=="POST")return t();if(e.allowedOrigins){let i=r.headers.get("origin");if(!i||!e.allowedOrigins.includes(i))return t()}let a;try{a=await A(r,n);}catch{return t()}if(a===null)return t();let d;try{d=JSON.parse(a);}catch{return t()}let l=R(d,e);if(!l.length)return t();try{let c=await e.forward(l);if(c&&c.ok===!1)throw new Error(`the log service answered ${String(c.status)}`)}catch(i){s(i);}return t()}}exports.telemetryRoute=F;exports.toLogRecord=_;exports.validateTelemetryEvents=R;
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * @packageDocumentation
12
12
  */
13
- import { a as TelemetryEvent } from '../pipeline-DbVW7S-K.cjs';
13
+ import { a as TelemetryEvent } from '../pipeline-CCq2Ng0B.cjs';
14
14
  import '@docx-editor.dev/core';
15
15
 
16
16
  /** Options for {@link validateTelemetryEvents}. @public */
@@ -26,14 +26,15 @@ interface ValidateTelemetryEventsOptions {
26
26
  }
27
27
  /**
28
28
  * The telemetry events in an untrusted request body, checked again with the package's own
29
- * closed lists. An event with an unknown kind or code, or without the fields its kind needs, is
30
- * dropped. A field outside its list is removed. The client's `resource` and `attributes` keep
31
- * only the keys in `attributeKeys`. Returns an empty list for a body that is not an array or is
32
- * longer than `maxEvents`.
29
+ * closed lists. An event with an unknown kind or code, a code of another kind, a value outside
30
+ * its list or range, or without the fields its kind needs, is dropped. An unknown field, a
31
+ * number or timing summary its kind does not carry, or a wall-clock span above its bound is
32
+ * removed. The client's `resource` and `attributes` keep only the keys in `attributeKeys`.
33
+ * Returns an empty list for a body that is not an array or is longer than `maxEvents`.
33
34
  *
34
- * The check proves that every value comes from the package's lists or is a number. It cannot
35
- * prove that a client told the truth: a script can send a well-formed event that never
36
- * happened. It can never send text.
35
+ * The check proves that every value comes from the package's lists or is a number in the range
36
+ * the engine produces. It cannot prove that a client told the truth: a script can send a
37
+ * well-formed event that never happened. It can never send text.
37
38
  *
38
39
  * @example
39
40
  * ```ts
@@ -43,17 +44,25 @@ interface ValidateTelemetryEventsOptions {
43
44
  * @public
44
45
  */
45
46
  declare function validateTelemetryEvents(body: unknown, options?: ValidateTelemetryEventsOptions): TelemetryEvent[];
46
- /** A log record with the fields log services read for time and summary. @public */
47
+ /** A log record with the fields log services read for time, summary, and counts. @public */
47
48
  type TelemetryLogRecord = Record<string, unknown> & {
48
49
  /** The event time in milliseconds since the epoch, which Better Stack and others read. */
49
50
  readonly dt: number;
50
51
  /** A one-line summary, such as `edit.rejected edit.picture-selected`. */
51
52
  readonly message: string;
53
+ /**
54
+ * How many times the event happened: `1`, or `repeated` for a deduplication summary, whose
55
+ * first event was already sent. Sum it to count events; do not count records.
56
+ */
57
+ readonly occurrences: number;
58
+ /** How many failures the record adds to a failure total. See `failureCount`. */
59
+ readonly failures: number;
52
60
  };
53
61
  /**
54
- * An event as a log record: `dt` for the time, `message` for the live tail, and every field of
55
- * the event except the fixed `hint` and `docs` text, which the code already identifies. Add
56
- * your own fixed fields, such as a service name, to the result.
62
+ * An event as a log record: `dt` for the time, `message` for the live tail, `occurrences` and
63
+ * `failures` to sum, and every field of the event except the fixed `hint` and `docs` text,
64
+ * which the code already identifies. Add your own fixed fields, such as a service name, to the
65
+ * result.
57
66
  *
58
67
  * @example
59
68
  * ```ts
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * @packageDocumentation
12
12
  */
13
- import { a as TelemetryEvent } from '../pipeline-DbVW7S-K.js';
13
+ import { a as TelemetryEvent } from '../pipeline-CCq2Ng0B.js';
14
14
  import '@docx-editor.dev/core';
15
15
 
16
16
  /** Options for {@link validateTelemetryEvents}. @public */
@@ -26,14 +26,15 @@ interface ValidateTelemetryEventsOptions {
26
26
  }
27
27
  /**
28
28
  * The telemetry events in an untrusted request body, checked again with the package's own
29
- * closed lists. An event with an unknown kind or code, or without the fields its kind needs, is
30
- * dropped. A field outside its list is removed. The client's `resource` and `attributes` keep
31
- * only the keys in `attributeKeys`. Returns an empty list for a body that is not an array or is
32
- * longer than `maxEvents`.
29
+ * closed lists. An event with an unknown kind or code, a code of another kind, a value outside
30
+ * its list or range, or without the fields its kind needs, is dropped. An unknown field, a
31
+ * number or timing summary its kind does not carry, or a wall-clock span above its bound is
32
+ * removed. The client's `resource` and `attributes` keep only the keys in `attributeKeys`.
33
+ * Returns an empty list for a body that is not an array or is longer than `maxEvents`.
33
34
  *
34
- * The check proves that every value comes from the package's lists or is a number. It cannot
35
- * prove that a client told the truth: a script can send a well-formed event that never
36
- * happened. It can never send text.
35
+ * The check proves that every value comes from the package's lists or is a number in the range
36
+ * the engine produces. It cannot prove that a client told the truth: a script can send a
37
+ * well-formed event that never happened. It can never send text.
37
38
  *
38
39
  * @example
39
40
  * ```ts
@@ -43,17 +44,25 @@ interface ValidateTelemetryEventsOptions {
43
44
  * @public
44
45
  */
45
46
  declare function validateTelemetryEvents(body: unknown, options?: ValidateTelemetryEventsOptions): TelemetryEvent[];
46
- /** A log record with the fields log services read for time and summary. @public */
47
+ /** A log record with the fields log services read for time, summary, and counts. @public */
47
48
  type TelemetryLogRecord = Record<string, unknown> & {
48
49
  /** The event time in milliseconds since the epoch, which Better Stack and others read. */
49
50
  readonly dt: number;
50
51
  /** A one-line summary, such as `edit.rejected edit.picture-selected`. */
51
52
  readonly message: string;
53
+ /**
54
+ * How many times the event happened: `1`, or `repeated` for a deduplication summary, whose
55
+ * first event was already sent. Sum it to count events; do not count records.
56
+ */
57
+ readonly occurrences: number;
58
+ /** How many failures the record adds to a failure total. See `failureCount`. */
59
+ readonly failures: number;
52
60
  };
53
61
  /**
54
- * An event as a log record: `dt` for the time, `message` for the live tail, and every field of
55
- * the event except the fixed `hint` and `docs` text, which the code already identifies. Add
56
- * your own fixed fields, such as a service name, to the result.
62
+ * An event as a log record: `dt` for the time, `message` for the live tail, `occurrences` and
63
+ * `failures` to sum, and every field of the event except the fixed `hint` and `docs` text,
64
+ * which the code already identifies. Add your own fixed fields, such as a service name, to the
65
+ * result.
57
66
  *
58
67
  * @example
59
68
  * ```ts
@@ -1 +1 @@
1
- import {a,c}from'../chunk-DTEVX2XS.js';import'../chunk-DT2KMPUJ.js';var b=50,i=e=>typeof e=="string",l=e=>typeof e=="number"&&Number.isFinite(e),m=e=>typeof e=="boolean",k={"edit.rejected":[["code",i],["origin",i],["tracked",m]],"review.skipped":[["code",i],["count",l]],"font.failed":[["code",i]],history:[["code",i]],"custom-node":[["code",i]],"collab.status":[["status",i],["previous",i],["recovering",m]],"collab.participants":[["count",l]],performance:[["windowMs",l]]};function h(e){if(!l(e.schemaVersion)||!l(e.time)||!i(e.editorSessionId)||!i(e.engineVersion))return false;if(e.kind==="document.open")return e.outcome==="opened"?i(e.sizeBucket)&&l(e.durationMs):e.outcome==="rejected"&&i(e.code);let r=k[e.kind];return !!r&&r.every(([t,o])=>o(e[t]))}function w(e,r){if(r.size===0)return {};let t=c(e)??{};return Object.fromEntries(Object.entries(t).filter(([o])=>r.has(o)))}function E(e,r={}){let t=r.maxEvents??b,o=new Set(r.attributeKeys??[]);return !Array.isArray(e)||e.length>t?[]:e.flatMap(n=>{if(!n||typeof n!="object"||Array.isArray(n))return [];let c=n,{resource:d,attributes:u,...s}=c,a$1=a(s);if("dropped"in a$1||!h(a$1.event))return [];let g=w(c.attributes,o),{attributes:x,...p}=a$1.event;return [Object.freeze({...p,resource:w(c.resource,o),attributes:g})]})}function O(e){let{hint:r,docs:t,...o}=e,n="code"in e&&e.code?` ${e.code}`:"";return {...o,dt:e.time,message:`${e.kind}${n}`}}var T=64*1024;async function R(e,r){if(Number(e.headers.get("content-length")??0)>r)return null;let t=e.body;if(!t)return "";let o=t.getReader(),n=[],c=0;for(;;){let{done:s,value:a}=await o.read();if(s)break;if(c+=a.byteLength,c>r)return await o.cancel().catch(()=>{}),null;n.push(a);}let d=new Uint8Array(c),u=0;for(let s of n)d.set(s,u),u+=s.byteLength;return new TextDecoder().decode(d)}function v(e){let r=e.maxBodyBytes??T,t=()=>new Response(null,{status:204}),o=n=>{try{e.onError?.(n);}catch{}};return async n=>{if(n.method!=="POST")return t();if(e.allowedOrigins){let s=n.headers.get("origin");if(!s||!e.allowedOrigins.includes(s))return t()}let c;try{c=await R(n,r);}catch{return t()}if(c===null)return t();let d;try{d=JSON.parse(c);}catch{return t()}let u=E(d,e);if(!u.length)return t();try{let a=await e.forward(u);if(a&&a.ok===!1)throw new Error(`the log service answered ${String(a.status)}`)}catch(s){o(s);}return t()}}export{v as telemetryRoute,O as toLogRecord,E as validateTelemetryEvents};
1
+ import {d}from'../chunk-WLWS5CZT.js';import {b as b$1,d as d$1}from'../chunk-W5HFB5EV.js';import'../chunk-DT2KMPUJ.js';var b=50,o=e=>typeof e=="string",u=e=>typeof e=="number"&&Number.isFinite(e),p=e=>typeof e=="boolean",h={"edit.rejected":[["code",o],["origin",o],["tracked",p]],"review.skipped":[["code",o],["count",u]],"font.failed":[["code",o]],history:[["code",o]],"custom-node":[["code",o]],"collab.status":[["status",o],["previous",o],["recovering",p]],"collab.participants":[["count",u]],performance:[["windowMs",u]]},E=["durationMs","activeMs","inputEdits","commandEdits","automationEdits"];function T(e){if(!u(e.schemaVersion)||!u(e.time)||!o(e.editorSessionId)||!o(e.engineVersion))return false;if(e.kind==="document.open")return e.outcome==="opened"?o(e.sizeBucket)&&u(e.durationMs):e.outcome==="rejected"&&o(e.code);if(e.kind==="document.save")return u(e.durationMs)&&(e.outcome==="saved"?o(e.sizeBucket):e.outcome==="rejected"&&o(e.code));if(e.kind==="session")return e.phase==="start"||(e.phase==="active"||e.phase==="end")&&E.every(t=>u(e[t]));let n=h[e.kind];return !!n&&n.every(([t,s])=>s(e[t]))}function w(e,n){if(n.size===0)return {};let t=d$1(e)??{};return Object.fromEntries(Object.entries(t).filter(([s])=>n.has(s)))}function R(e,n={}){let t=n.maxEvents??b,s=new Set(n.attributeKeys??[]);return !Array.isArray(e)||e.length>t?[]:e.flatMap(r=>{if(!r||typeof r!="object"||Array.isArray(r))return [];let a=r,{resource:d,attributes:l,...i}=a,c=b$1(i);if("dropped"in c||!T(c.event))return [];let g=w(a.attributes,s),{attributes:O,...k}=c.event;return [Object.freeze({...k,resource:w(a.resource,s),attributes:g})]})}function _(e){let{hint:n,docs:t,...s}=e,r="code"in e&&e.code?` ${e.code}`:"";return {...s,dt:e.time,message:`${e.kind}${r}`,occurrences:e.repeated??1,failures:d(e)}}var x=64*1024;async function A(e,n){if(Number(e.headers.get("content-length")??0)>n)return null;let t=e.body;if(!t)return "";let s=t.getReader(),r=[],a=0;for(;;){let{done:i,value:c}=await s.read();if(i)break;if(a+=c.byteLength,a>n)return await s.cancel().catch(()=>{}),null;r.push(c);}let d=new Uint8Array(a),l=0;for(let i of r)d.set(i,l),l+=i.byteLength;return new TextDecoder().decode(d)}function F(e){let n=e.maxBodyBytes??x,t=()=>new Response(null,{status:204}),s=r=>{try{e.onError?.(r);}catch{}};return async r=>{if(r.method!=="POST")return t();if(e.allowedOrigins){let i=r.headers.get("origin");if(!i||!e.allowedOrigins.includes(i))return t()}let a;try{a=await A(r,n);}catch{return t()}if(a===null)return t();let d;try{d=JSON.parse(a);}catch{return t()}let l=R(d,e);if(!l.length)return t();try{let c=await e.forward(l);if(c&&c.ok===!1)throw new Error(`the log service answered ${String(c.status)}`)}catch(i){s(i);}return t()}}export{F as telemetryRoute,_ as toLogRecord,R as validateTelemetryEvents};
@@ -1 +1 @@
1
- 'use strict';var chunkUK2MNJCG_cjs=require('../chunk-UK2MNJCG.cjs'),chunkWGWKNKUT_cjs=require('../chunk-WGWKNKUT.cjs'),api=require('@opentelemetry/api');var w="@docx-editor.dev/telemetry";function O(o){let n=o.getDelegate?.()??o;return /^Noop/.test(n?.constructor?.name??"")}var M=false;function E(o,n){let s=chunkWGWKNKUT_cjs.a();M||s==="production"||!O(o)||!O(n)||(M=true,console.warn("[docx-editor telemetry] otelExporter found no OpenTelemetry SDK. Register a MeterProvider and a TracerProvider before creating the exporter, or pass them as options. Until then every measurement is dropped."));}function h(o,n,s){return o.createObservableGauge(n.name,{unit:n.unit,description:n.description}).addCallback(t=>{for(let{value:i,attributes:a}of s.values())t.observe(i,a);}),{record(t,i={}){s.set(f(i),{value:t,attributes:i});},forget(t){s.delete(f(t));}}}function f(o){return JSON.stringify(Object.keys(o).sort().map(n=>[n,o[n]]))}function m(o){let n={...o.resource,...o.attributes};for(let[s,t]of Object.entries(o))if(!(s==="resource"||s==="attributes"||s==="hint"||s==="docs")){if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")n[`docx_editor.${s}`]=t;else if(s==="shape"&&t&&typeof t=="object")for(let[i,a]of Object.entries(t))typeof a=="string"&&(n[`docx_editor.shape.${i}`]=a);else if(t&&typeof t=="object"&&!Array.isArray(t))for(let[i,a]of Object.entries(t))typeof a=="number"&&(n[`docx_editor.${s}.${i}`]=a);}return n}function j(o={}){let n=o.scope??w,s=()=>o.meterProvider??api.metrics.getMeterProvider(),t=()=>o.tracerProvider??api.trace.getTracerProvider(),i,a,l=new Map,p=new Map,g=false;function P(e){let r=p.get(e);return r||(r=new Map,p.set(e,r)),r}function k(){let e=s();return (e!==i||!a)&&(i=e,a=e.getMeter(n),l.clear()),a}function T(e){let r=k();g||(g=true,setTimeout(()=>E(s(),t()),5e3).unref?.());let c=l.get(e.name);if(c)return c;let d={unit:e.unit,description:e.description},u=e.kind==="counter"?r.createCounter(e.name,d):e.kind==="histogram"?r.createHistogram(e.name,{...d,...e.buckets?{advice:{explicitBucketBoundaries:[...e.buckets]}}:{}}):h(r,e,P(e.name));return l.set(e.name,u),u}return {name:"otel",metric(e){let r=T(e.definition),c=e.attributes;"add"in r?r.add(e.value,c):r.record(e.value,c);},event(e){if(e.kind==="document.open"){let d=e.time-(e.outcome==="opened"?e.durationMs:0),u=t().getTracer(n).startSpan("docx_editor.document.open",{startTime:d,attributes:m(e)},o.parentContext?.());e.outcome==="rejected"&&u.setStatus({code:api.SpanStatusCode.ERROR,message:e.code}),u.end(e.time);return}let r=api.trace.getActiveSpan();if(r){r.addEvent(`docx_editor.${e.kind}`,m(e));return}if(!chunkUK2MNJCG_cjs.c(e))return;let c=t().getTracer(n).startSpan(`docx_editor.${e.kind}`,{startTime:e.time,attributes:m(e)},o.parentContext?.());c.setStatus({code:api.SpanStatusCode.ERROR,message:"code"in e?e.code:e.kind}),c.end(e.time);},forget(e,r){p.get(e.name)?.delete(f(r));},async flush(){let e=r=>(r.getDelegate?.()??r).forceFlush?.();await Promise.all([e(s()),e(t())]);}}}exports.otelExporter=j;
1
+ 'use strict';var chunkE2HR5DHZ_cjs=require('../chunk-E2HR5DHZ.cjs'),chunkWGWKNKUT_cjs=require('../chunk-WGWKNKUT.cjs'),api=require('@opentelemetry/api');var E="@docx-editor.dev/telemetry";function M(o){let n=o.getDelegate?.()??o;return /^Noop/.test(n?.constructor?.name??"")}var k=false;function h(o,n){let s=chunkWGWKNKUT_cjs.a();k||s==="production"||!M(o)||!M(n)||(k=true,console.warn("[docx-editor telemetry] otelExporter found no OpenTelemetry SDK. Register a MeterProvider and a TracerProvider before creating the exporter, or pass them as options. Until then every measurement is dropped."));}function C(o,n,s){return o.createObservableGauge(n.name,{unit:n.unit,description:n.description}).addCallback(t=>{for(let{value:i,attributes:a}of s.values())t.observe(i,a);}),{record(t,i={}){s.set(g(i),{value:t,attributes:i});},forget(t){s.delete(g(t));}}}function g(o){return JSON.stringify(Object.keys(o).sort().map(n=>[n,o[n]]))}function f(o){let n={...o.resource,...o.attributes};for(let[s,t]of Object.entries(o))if(!(s==="resource"||s==="attributes"||s==="hint"||s==="docs")){if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")n[`docx_editor.${s}`]=t;else if(s==="shape"&&t&&typeof t=="object")for(let[i,a]of Object.entries(t))typeof a=="string"&&(n[`docx_editor.shape.${i}`]=a);else if(t&&typeof t=="object"&&!Array.isArray(t))for(let[i,a]of Object.entries(t))typeof a=="number"&&(n[`docx_editor.${s}.${i}`]=a);}return n}function j(o={}){let n=o.scope??E,s=()=>o.meterProvider??api.metrics.getMeterProvider(),t=()=>o.tracerProvider??api.trace.getTracerProvider(),i,a,l=new Map,m=new Map,b=false;function P(e){let r=m.get(e);return r||(r=new Map,m.set(e,r)),r}function T(){let e=s();return (e!==i||!a)&&(i=e,a=e.getMeter(n),l.clear()),a}function A(e){let r=T();b||(b=true,setTimeout(()=>h(s(),t()),5e3).unref?.());let c=l.get(e.name);if(c)return c;let u={unit:e.unit,description:e.description},d=e.kind==="counter"?r.createCounter(e.name,u):e.kind==="histogram"?r.createHistogram(e.name,{...u,...e.buckets?{advice:{explicitBucketBoundaries:[...e.buckets]}}:{}}):C(r,e,P(e.name));return l.set(e.name,d),d}return {name:"otel",metric(e){let r=A(e.definition),c=e.attributes;"add"in r?r.add(e.value,c):r.record(e.value,c);},event(e){if(e.kind==="document.open"||e.kind==="document.save"){let u=e.kind==="document.save"||e.outcome==="opened"?e.durationMs:0,d=e.time-u,p=t().getTracer(n).startSpan(`docx_editor.${e.kind}`,{startTime:d,attributes:f(e)},o.parentContext?.());e.outcome==="rejected"&&p.setStatus({code:api.SpanStatusCode.ERROR,message:e.code}),p.end(e.time);return}let r=api.trace.getActiveSpan();if(r){r.addEvent(`docx_editor.${e.kind}`,f(e));return}if(!chunkE2HR5DHZ_cjs.c(e))return;let c=t().getTracer(n).startSpan(`docx_editor.${e.kind}`,{startTime:e.time,attributes:f(e)},o.parentContext?.());c.setStatus({code:api.SpanStatusCode.ERROR,message:"code"in e?e.code:e.kind}),c.end(e.time);},forget(e,r){m.get(e.name)?.delete(g(r));},async flush(){let e=r=>(r.getDelegate?.()??r).forceFlush?.();await Promise.all([e(s()),e(t())]);}}}exports.otelExporter=j;
@@ -6,7 +6,7 @@
6
6
  * @packageDocumentation
7
7
  */
8
8
  import { MeterProvider, TracerProvider, Context } from '@opentelemetry/api';
9
- import { b as TelemetryExporter } from '../pipeline-DbVW7S-K.cjs';
9
+ import { b as TelemetryExporter } from '../pipeline-CCq2Ng0B.cjs';
10
10
  import '@docx-editor.dev/core';
11
11
 
12
12
  /**
@@ -6,7 +6,7 @@
6
6
  * @packageDocumentation
7
7
  */
8
8
  import { MeterProvider, TracerProvider, Context } from '@opentelemetry/api';
9
- import { b as TelemetryExporter } from '../pipeline-DbVW7S-K.js';
9
+ import { b as TelemetryExporter } from '../pipeline-CCq2Ng0B.js';
10
10
  import '@docx-editor.dev/core';
11
11
 
12
12
  /**
@@ -1 +1 @@
1
- import {c}from'../chunk-NUN46EXH.js';import {a}from'../chunk-DT2KMPUJ.js';import {SpanStatusCode,trace,metrics}from'@opentelemetry/api';var w="@docx-editor.dev/telemetry";function O(o){let n=o.getDelegate?.()??o;return /^Noop/.test(n?.constructor?.name??"")}var M=false;function E(o,n){let s=a();M||s==="production"||!O(o)||!O(n)||(M=true,console.warn("[docx-editor telemetry] otelExporter found no OpenTelemetry SDK. Register a MeterProvider and a TracerProvider before creating the exporter, or pass them as options. Until then every measurement is dropped."));}function h(o,n,s){return o.createObservableGauge(n.name,{unit:n.unit,description:n.description}).addCallback(t=>{for(let{value:i,attributes:a}of s.values())t.observe(i,a);}),{record(t,i={}){s.set(f(i),{value:t,attributes:i});},forget(t){s.delete(f(t));}}}function f(o){return JSON.stringify(Object.keys(o).sort().map(n=>[n,o[n]]))}function m(o){let n={...o.resource,...o.attributes};for(let[s,t]of Object.entries(o))if(!(s==="resource"||s==="attributes"||s==="hint"||s==="docs")){if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")n[`docx_editor.${s}`]=t;else if(s==="shape"&&t&&typeof t=="object")for(let[i,a]of Object.entries(t))typeof a=="string"&&(n[`docx_editor.shape.${i}`]=a);else if(t&&typeof t=="object"&&!Array.isArray(t))for(let[i,a]of Object.entries(t))typeof a=="number"&&(n[`docx_editor.${s}.${i}`]=a);}return n}function j(o={}){let n=o.scope??w,s=()=>o.meterProvider??metrics.getMeterProvider(),t=()=>o.tracerProvider??trace.getTracerProvider(),i,a,l=new Map,p=new Map,g=false;function P(e){let r=p.get(e);return r||(r=new Map,p.set(e,r)),r}function k(){let e=s();return (e!==i||!a)&&(i=e,a=e.getMeter(n),l.clear()),a}function T(e){let r=k();g||(g=true,setTimeout(()=>E(s(),t()),5e3).unref?.());let c=l.get(e.name);if(c)return c;let d={unit:e.unit,description:e.description},u=e.kind==="counter"?r.createCounter(e.name,d):e.kind==="histogram"?r.createHistogram(e.name,{...d,...e.buckets?{advice:{explicitBucketBoundaries:[...e.buckets]}}:{}}):h(r,e,P(e.name));return l.set(e.name,u),u}return {name:"otel",metric(e){let r=T(e.definition),c=e.attributes;"add"in r?r.add(e.value,c):r.record(e.value,c);},event(e){if(e.kind==="document.open"){let d=e.time-(e.outcome==="opened"?e.durationMs:0),u=t().getTracer(n).startSpan("docx_editor.document.open",{startTime:d,attributes:m(e)},o.parentContext?.());e.outcome==="rejected"&&u.setStatus({code:SpanStatusCode.ERROR,message:e.code}),u.end(e.time);return}let r=trace.getActiveSpan();if(r){r.addEvent(`docx_editor.${e.kind}`,m(e));return}if(!c(e))return;let c$1=t().getTracer(n).startSpan(`docx_editor.${e.kind}`,{startTime:e.time,attributes:m(e)},o.parentContext?.());c$1.setStatus({code:SpanStatusCode.ERROR,message:"code"in e?e.code:e.kind}),c$1.end(e.time);},forget(e,r){p.get(e.name)?.delete(f(r));},async flush(){let e=r=>(r.getDelegate?.()??r).forceFlush?.();await Promise.all([e(s()),e(t())]);}}}export{j as otelExporter};
1
+ import {c}from'../chunk-WLWS5CZT.js';import {a}from'../chunk-DT2KMPUJ.js';import {SpanStatusCode,trace,metrics}from'@opentelemetry/api';var E="@docx-editor.dev/telemetry";function M(o){let n=o.getDelegate?.()??o;return /^Noop/.test(n?.constructor?.name??"")}var k=false;function h(o,n){let s=a();k||s==="production"||!M(o)||!M(n)||(k=true,console.warn("[docx-editor telemetry] otelExporter found no OpenTelemetry SDK. Register a MeterProvider and a TracerProvider before creating the exporter, or pass them as options. Until then every measurement is dropped."));}function C(o,n,s){return o.createObservableGauge(n.name,{unit:n.unit,description:n.description}).addCallback(t=>{for(let{value:i,attributes:a}of s.values())t.observe(i,a);}),{record(t,i={}){s.set(g(i),{value:t,attributes:i});},forget(t){s.delete(g(t));}}}function g(o){return JSON.stringify(Object.keys(o).sort().map(n=>[n,o[n]]))}function f(o){let n={...o.resource,...o.attributes};for(let[s,t]of Object.entries(o))if(!(s==="resource"||s==="attributes"||s==="hint"||s==="docs")){if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")n[`docx_editor.${s}`]=t;else if(s==="shape"&&t&&typeof t=="object")for(let[i,a]of Object.entries(t))typeof a=="string"&&(n[`docx_editor.shape.${i}`]=a);else if(t&&typeof t=="object"&&!Array.isArray(t))for(let[i,a]of Object.entries(t))typeof a=="number"&&(n[`docx_editor.${s}.${i}`]=a);}return n}function j(o={}){let n=o.scope??E,s=()=>o.meterProvider??metrics.getMeterProvider(),t=()=>o.tracerProvider??trace.getTracerProvider(),i,a,l=new Map,m=new Map,b=false;function P(e){let r=m.get(e);return r||(r=new Map,m.set(e,r)),r}function T(){let e=s();return (e!==i||!a)&&(i=e,a=e.getMeter(n),l.clear()),a}function A(e){let r=T();b||(b=true,setTimeout(()=>h(s(),t()),5e3).unref?.());let c=l.get(e.name);if(c)return c;let u={unit:e.unit,description:e.description},d=e.kind==="counter"?r.createCounter(e.name,u):e.kind==="histogram"?r.createHistogram(e.name,{...u,...e.buckets?{advice:{explicitBucketBoundaries:[...e.buckets]}}:{}}):C(r,e,P(e.name));return l.set(e.name,d),d}return {name:"otel",metric(e){let r=A(e.definition),c=e.attributes;"add"in r?r.add(e.value,c):r.record(e.value,c);},event(e){if(e.kind==="document.open"||e.kind==="document.save"){let u=e.kind==="document.save"||e.outcome==="opened"?e.durationMs:0,d=e.time-u,p=t().getTracer(n).startSpan(`docx_editor.${e.kind}`,{startTime:d,attributes:f(e)},o.parentContext?.());e.outcome==="rejected"&&p.setStatus({code:SpanStatusCode.ERROR,message:e.code}),p.end(e.time);return}let r=trace.getActiveSpan();if(r){r.addEvent(`docx_editor.${e.kind}`,f(e));return}if(!c(e))return;let c$1=t().getTracer(n).startSpan(`docx_editor.${e.kind}`,{startTime:e.time,attributes:f(e)},o.parentContext?.());c$1.setStatus({code:SpanStatusCode.ERROR,message:"code"in e?e.code:e.kind}),c$1.end(e.time);},forget(e,r){m.get(e.name)?.delete(g(r));},async flush(){let e=r=>(r.getDelegate?.()??r).forceFlush?.();await Promise.all([e(s()),e(t())]);}}}export{j as otelExporter};
@@ -35,6 +35,9 @@ interface MetricDefinition {
35
35
  declare const METRICS: Readonly<{
36
36
  documentOpens: MetricDefinition;
37
37
  documentOpenDuration: MetricDefinition;
38
+ documentSaves: MetricDefinition;
39
+ documentSaveDuration: MetricDefinition;
40
+ edits: MetricDefinition;
38
41
  editRejections: MetricDefinition;
39
42
  reviewSkipped: MetricDefinition;
40
43
  fontFailures: MetricDefinition;
@@ -43,6 +46,9 @@ declare const METRICS: Readonly<{
43
46
  collabClientStatusTransitions: MetricDefinition;
44
47
  collabClientConnectDuration: MetricDefinition;
45
48
  collabClientParticipants: MetricDefinition;
49
+ editorSessions: MetricDefinition;
50
+ editorSessionDuration: MetricDefinition;
51
+ editorActiveTime: MetricDefinition;
46
52
  editorInteractionDuration: MetricDefinition;
47
53
  editorLayoutDuration: MetricDefinition;
48
54
  editorPaintDuration: MetricDefinition;
@@ -35,6 +35,9 @@ interface MetricDefinition {
35
35
  declare const METRICS: Readonly<{
36
36
  documentOpens: MetricDefinition;
37
37
  documentOpenDuration: MetricDefinition;
38
+ documentSaves: MetricDefinition;
39
+ documentSaveDuration: MetricDefinition;
40
+ edits: MetricDefinition;
38
41
  editRejections: MetricDefinition;
39
42
  reviewSkipped: MetricDefinition;
40
43
  fontFailures: MetricDefinition;
@@ -43,6 +46,9 @@ declare const METRICS: Readonly<{
43
46
  collabClientStatusTransitions: MetricDefinition;
44
47
  collabClientConnectDuration: MetricDefinition;
45
48
  collabClientParticipants: MetricDefinition;
49
+ editorSessions: MetricDefinition;
50
+ editorSessionDuration: MetricDefinition;
51
+ editorActiveTime: MetricDefinition;
46
52
  editorInteractionDuration: MetricDefinition;
47
53
  editorLayoutDuration: MetricDefinition;
48
54
  editorPaintDuration: MetricDefinition;
@@ -1 +1 @@
1
- 'use strict';var chunkMJX3ECH3_cjs=require('../chunk-MJX3ECH3.cjs');require('../chunk-LGNT4I5W.cjs');Object.defineProperty(exports,"PROMETHEUS_CONTENT_TYPE",{enumerable:true,get:function(){return chunkMJX3ECH3_cjs.a}});Object.defineProperty(exports,"fetchMetricsHandler",{enumerable:true,get:function(){return chunkMJX3ECH3_cjs.d}});Object.defineProperty(exports,"metricsHandler",{enumerable:true,get:function(){return chunkMJX3ECH3_cjs.c}});Object.defineProperty(exports,"prometheusRegistry",{enumerable:true,get:function(){return chunkMJX3ECH3_cjs.b}});
1
+ 'use strict';var chunkQDOUVRQA_cjs=require('../chunk-QDOUVRQA.cjs');require('../chunk-AL2YERWY.cjs');Object.defineProperty(exports,"PROMETHEUS_CONTENT_TYPE",{enumerable:true,get:function(){return chunkQDOUVRQA_cjs.a}});Object.defineProperty(exports,"fetchMetricsHandler",{enumerable:true,get:function(){return chunkQDOUVRQA_cjs.d}});Object.defineProperty(exports,"metricsHandler",{enumerable:true,get:function(){return chunkQDOUVRQA_cjs.c}});Object.defineProperty(exports,"prometheusRegistry",{enumerable:true,get:function(){return chunkQDOUVRQA_cjs.b}});
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @packageDocumentation
8
8
  */
9
- import { b as TelemetryExporter } from '../pipeline-DbVW7S-K.cjs';
9
+ import { b as TelemetryExporter } from '../pipeline-CCq2Ng0B.cjs';
10
10
  import '@docx-editor.dev/core';
11
11
 
12
12
  /** The Prometheus text exposition content type. @public */
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @packageDocumentation
8
8
  */
9
- import { b as TelemetryExporter } from '../pipeline-DbVW7S-K.js';
9
+ import { b as TelemetryExporter } from '../pipeline-CCq2Ng0B.js';
10
10
  import '@docx-editor.dev/core';
11
11
 
12
12
  /** The Prometheus text exposition content type. @public */
@@ -1 +1 @@
1
- export{a as PROMETHEUS_CONTENT_TYPE,d as fetchMetricsHandler,c as metricsHandler,b as prometheusRegistry}from'../chunk-LFX65QJG.js';import'../chunk-73YEPWY5.js';
1
+ export{a as PROMETHEUS_CONTENT_TYPE,d as fetchMetricsHandler,c as metricsHandler,b as prometheusRegistry}from'../chunk-JM4KJB6O.js';import'../chunk-RSWAOCAT.js';
@@ -1 +1 @@
1
- 'use strict';var chunkUK2MNJCG_cjs=require('../chunk-UK2MNJCG.cjs');var i=class extends Error{name="DocxEditorDiagnosticError";code;constructor(r,t){super(t?`${r}: ${t}`:r),this.code=r;}},u=new Set(["collab.authentication-failed","collab.room-generation-changed"]),l=new Set(["open.failed","open.unsupported-source","open.invalid-limits"]),f=Object.freeze([".docx-editor",".docx-pages"]);function x(e,r){return e.category?.startsWith("ui.")&&g(r?.event?.target)?null:e}function g(e){try{let r=e;return r&&typeof r.closest!="function"&&(r=r.parentElement),!r||typeof r.closest!="function"?!0:r.closest(f.join(", "))!=null}catch{return true}}function p(e){switch(e.kind){case "document.open":return e.outcome==="rejected"&&l.has(e.code);case "edit.rejected":return e.code==="edit.internal-invariant";case "review.skipped":return e.code==="review.revision-unsupported"||e.code==="review.retained-structure";case "font.failed":return e.code==="font.shaper-unavailable";case "collab.status":return e.status==="error"&&!e.recovering&&!u.has(e.code??"");default:return false}}function m(e){return e.kind==="document.open"?e.outcome==="opened":e.kind==="performance"&&e.code===void 0}function c(e){return "code"in e&&e.code?e.code:e.kind}function y(e){let r=e,t={"docx_editor.kind":e.kind,"docx_editor.code":c(e),"docx_editor.version":e.engineVersion,"docx_editor.editor_session":e.editorSessionId};for(let[o,n]of [["origin","origin"],["tracked","tracked"],["status","status"],["outcome","outcome"],["command","command"],["cause","cause"],["part","part"],["errorName","error_name"],["stage","stage"],["operation","operation"],["changeKind","change_kind"],["formattingKind","formatting_kind"]])r[o]!==void 0&&(t[`docx_editor.${n}`]=String(r[o]));for(let[o,n]of Object.entries(e.attributes??{}))t[o]=String(n);return t}function k(e,r){let t=e,o=["cause","errorName","stage","changeKind","formattingKind"].map(n=>t[n]).filter(n=>typeof n=="string");return ["docx-editor",e.kind,r,...o]}function d(e){let{resource:r,...t}=e;return {...t,...Object.keys(r).length?{resource:r}:{}}}function b(e,r={}){let t=r.issue??p,o=r.breadcrumbs??true;return {name:"sentry",event(n){let s=c(n);if(n.repeated===void 0&&t(n)){e.captureException(new i(s,n.hint),{fingerprint:k(n,s),level:n.kind==="font.failed"||n.kind==="review.skipped"?"warning":"error",tags:y(n),contexts:{docx_editor:d(n)}});return}o&&e.addBreadcrumb({category:"docx-editor",message:chunkUK2MNJCG_cjs.b(n),level:m(n)?"info":"warning",data:d(n)});},async flush(){await e.flush?.(2e3);}}}exports.DocxEditorDiagnosticError=i;exports.EDITOR_SELECTORS=f;exports.dropEditorBreadcrumbs=x;exports.isSentryIssue=p;exports.sentryExporter=b;
1
+ 'use strict';var chunkE2HR5DHZ_cjs=require('../chunk-E2HR5DHZ.cjs');var i=class extends Error{name="DocxEditorDiagnosticError";code;constructor(r,t){super(t?`${r}: ${t}`:r),this.code=r;}},u=new Set(["collab.authentication-failed","collab.room-generation-changed"]),l=new Set(["open.failed","open.unsupported-source","open.invalid-limits"]),f=Object.freeze([".docx-editor",".docx-pages"]);function x(e,r){return e.category?.startsWith("ui.")&&g(r?.event?.target)?null:e}function g(e){try{let r=e;return r&&typeof r.closest!="function"&&(r=r.parentElement),!r||typeof r.closest!="function"?!0:r.closest(f.join(", "))!=null}catch{return true}}function p(e){switch(e.kind){case "document.open":return e.outcome==="rejected"&&l.has(e.code);case "document.save":return e.outcome==="rejected"&&e.code==="save.failed";case "edit.rejected":return e.code==="edit.internal-invariant";case "review.skipped":return e.code==="review.revision-unsupported"||e.code==="review.retained-structure";case "font.failed":return e.code==="font.shaper-unavailable";case "collab.status":return e.status==="error"&&!e.recovering&&!u.has(e.code??"");default:return false}}function m(e){return e.kind==="document.open"?e.outcome==="opened":e.kind==="document.save"?e.outcome==="saved":e.kind==="session"?true:e.kind==="performance"&&e.code===void 0}function c(e){return "code"in e&&e.code?e.code:e.kind}function y(e){let r=e,t={"docx_editor.kind":e.kind,"docx_editor.code":c(e),"docx_editor.version":e.engineVersion,"docx_editor.editor_session":e.editorSessionId};for(let[o,n]of [["origin","origin"],["tracked","tracked"],["status","status"],["outcome","outcome"],["command","command"],["cause","cause"],["part","part"],["errorName","error_name"],["stage","stage"],["operation","operation"],["changeKind","change_kind"],["formattingKind","formatting_kind"]])r[o]!==void 0&&(t[`docx_editor.${n}`]=String(r[o]));for(let[o,n]of Object.entries(e.attributes??{}))t[o]=String(n);return t}function k(e,r){let t=e,o=["cause","errorName","stage","changeKind","formattingKind"].map(n=>t[n]).filter(n=>typeof n=="string");return ["docx-editor",e.kind,r,...o]}function d(e){let{resource:r,...t}=e;return {...t,...Object.keys(r).length?{resource:r}:{}}}function b(e,r={}){let t=r.issue??p,o=r.breadcrumbs??true;return {name:"sentry",event(n){let s=c(n);if(n.repeated===void 0&&t(n)){e.captureException(new i(s,n.hint),{fingerprint:k(n,s),level:n.kind==="font.failed"||n.kind==="review.skipped"?"warning":"error",tags:y(n),contexts:{docx_editor:d(n)}});return}o&&e.addBreadcrumb({category:"docx-editor",message:chunkE2HR5DHZ_cjs.b(n),level:m(n)?"info":"warning",data:d(n)});},async flush(){await e.flush?.(2e3);}}}exports.DocxEditorDiagnosticError=i;exports.EDITOR_SELECTORS=f;exports.dropEditorBreadcrumbs=x;exports.isSentryIssue=p;exports.sentryExporter=b;
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @packageDocumentation
6
6
  */
7
- import { a as TelemetryEvent, b as TelemetryExporter } from '../pipeline-DbVW7S-K.cjs';
7
+ import { a as TelemetryEvent, b as TelemetryExporter } from '../pipeline-CCq2Ng0B.cjs';
8
8
  import '@docx-editor.dev/core';
9
9
 
10
10
  /** Sentry severity, as the Sentry SDKs spell it. @public */
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @packageDocumentation
6
6
  */
7
- import { a as TelemetryEvent, b as TelemetryExporter } from '../pipeline-DbVW7S-K.js';
7
+ import { a as TelemetryEvent, b as TelemetryExporter } from '../pipeline-CCq2Ng0B.js';
8
8
  import '@docx-editor.dev/core';
9
9
 
10
10
  /** Sentry severity, as the Sentry SDKs spell it. @public */
@@ -1 +1 @@
1
- import {b as b$1}from'../chunk-NUN46EXH.js';var i=class extends Error{name="DocxEditorDiagnosticError";code;constructor(r,t){super(t?`${r}: ${t}`:r),this.code=r;}},u=new Set(["collab.authentication-failed","collab.room-generation-changed"]),l=new Set(["open.failed","open.unsupported-source","open.invalid-limits"]),f=Object.freeze([".docx-editor",".docx-pages"]);function x(e,r){return e.category?.startsWith("ui.")&&g(r?.event?.target)?null:e}function g(e){try{let r=e;return r&&typeof r.closest!="function"&&(r=r.parentElement),!r||typeof r.closest!="function"?!0:r.closest(f.join(", "))!=null}catch{return true}}function p(e){switch(e.kind){case "document.open":return e.outcome==="rejected"&&l.has(e.code);case "edit.rejected":return e.code==="edit.internal-invariant";case "review.skipped":return e.code==="review.revision-unsupported"||e.code==="review.retained-structure";case "font.failed":return e.code==="font.shaper-unavailable";case "collab.status":return e.status==="error"&&!e.recovering&&!u.has(e.code??"");default:return false}}function m(e){return e.kind==="document.open"?e.outcome==="opened":e.kind==="performance"&&e.code===void 0}function c(e){return "code"in e&&e.code?e.code:e.kind}function y(e){let r=e,t={"docx_editor.kind":e.kind,"docx_editor.code":c(e),"docx_editor.version":e.engineVersion,"docx_editor.editor_session":e.editorSessionId};for(let[o,n]of [["origin","origin"],["tracked","tracked"],["status","status"],["outcome","outcome"],["command","command"],["cause","cause"],["part","part"],["errorName","error_name"],["stage","stage"],["operation","operation"],["changeKind","change_kind"],["formattingKind","formatting_kind"]])r[o]!==void 0&&(t[`docx_editor.${n}`]=String(r[o]));for(let[o,n]of Object.entries(e.attributes??{}))t[o]=String(n);return t}function k(e,r){let t=e,o=["cause","errorName","stage","changeKind","formattingKind"].map(n=>t[n]).filter(n=>typeof n=="string");return ["docx-editor",e.kind,r,...o]}function d(e){let{resource:r,...t}=e;return {...t,...Object.keys(r).length?{resource:r}:{}}}function b(e,r={}){let t=r.issue??p,o=r.breadcrumbs??true;return {name:"sentry",event(n){let s=c(n);if(n.repeated===void 0&&t(n)){e.captureException(new i(s,n.hint),{fingerprint:k(n,s),level:n.kind==="font.failed"||n.kind==="review.skipped"?"warning":"error",tags:y(n),contexts:{docx_editor:d(n)}});return}o&&e.addBreadcrumb({category:"docx-editor",message:b$1(n),level:m(n)?"info":"warning",data:d(n)});},async flush(){await e.flush?.(2e3);}}}export{i as DocxEditorDiagnosticError,f as EDITOR_SELECTORS,x as dropEditorBreadcrumbs,p as isSentryIssue,b as sentryExporter};
1
+ import {b as b$1}from'../chunk-WLWS5CZT.js';var i=class extends Error{name="DocxEditorDiagnosticError";code;constructor(r,t){super(t?`${r}: ${t}`:r),this.code=r;}},u=new Set(["collab.authentication-failed","collab.room-generation-changed"]),l=new Set(["open.failed","open.unsupported-source","open.invalid-limits"]),f=Object.freeze([".docx-editor",".docx-pages"]);function x(e,r){return e.category?.startsWith("ui.")&&g(r?.event?.target)?null:e}function g(e){try{let r=e;return r&&typeof r.closest!="function"&&(r=r.parentElement),!r||typeof r.closest!="function"?!0:r.closest(f.join(", "))!=null}catch{return true}}function p(e){switch(e.kind){case "document.open":return e.outcome==="rejected"&&l.has(e.code);case "document.save":return e.outcome==="rejected"&&e.code==="save.failed";case "edit.rejected":return e.code==="edit.internal-invariant";case "review.skipped":return e.code==="review.revision-unsupported"||e.code==="review.retained-structure";case "font.failed":return e.code==="font.shaper-unavailable";case "collab.status":return e.status==="error"&&!e.recovering&&!u.has(e.code??"");default:return false}}function m(e){return e.kind==="document.open"?e.outcome==="opened":e.kind==="document.save"?e.outcome==="saved":e.kind==="session"?true:e.kind==="performance"&&e.code===void 0}function c(e){return "code"in e&&e.code?e.code:e.kind}function y(e){let r=e,t={"docx_editor.kind":e.kind,"docx_editor.code":c(e),"docx_editor.version":e.engineVersion,"docx_editor.editor_session":e.editorSessionId};for(let[o,n]of [["origin","origin"],["tracked","tracked"],["status","status"],["outcome","outcome"],["command","command"],["cause","cause"],["part","part"],["errorName","error_name"],["stage","stage"],["operation","operation"],["changeKind","change_kind"],["formattingKind","formatting_kind"]])r[o]!==void 0&&(t[`docx_editor.${n}`]=String(r[o]));for(let[o,n]of Object.entries(e.attributes??{}))t[o]=String(n);return t}function k(e,r){let t=e,o=["cause","errorName","stage","changeKind","formattingKind"].map(n=>t[n]).filter(n=>typeof n=="string");return ["docx-editor",e.kind,r,...o]}function d(e){let{resource:r,...t}=e;return {...t,...Object.keys(r).length?{resource:r}:{}}}function b(e,r={}){let t=r.issue??p,o=r.breadcrumbs??true;return {name:"sentry",event(n){let s=c(n);if(n.repeated===void 0&&t(n)){e.captureException(new i(s,n.hint),{fingerprint:k(n,s),level:n.kind==="font.failed"||n.kind==="review.skipped"?"warning":"error",tags:y(n),contexts:{docx_editor:d(n)}});return}o&&e.addBreadcrumb({category:"docx-editor",message:b$1(n),level:m(n)?"info":"warning",data:d(n)});},async flush(){await e.flush?.(2e3);}}}export{i as DocxEditorDiagnosticError,f as EDITOR_SELECTORS,x as dropEditorBreadcrumbs,p as isSentryIssue,b as sentryExporter};
@@ -1 +1 @@
1
- 'use strict';var chunk7ZXJ6HP2_cjs=require('../chunk-7ZXJ6HP2.cjs');require('../chunk-U6ERFNUM.cjs'),require('../chunk-LGNT4I5W.cjs'),require('../chunk-LFQSY2TD.cjs'),require('../chunk-WGWKNKUT.cjs');Object.defineProperty(exports,"hmacRoomLabel",{enumerable:true,get:function(){return chunk7ZXJ6HP2_cjs.a}});Object.defineProperty(exports,"roomTelemetry",{enumerable:true,get:function(){return chunk7ZXJ6HP2_cjs.b}});
1
+ 'use strict';var chunkPZZC5AXX_cjs=require('../chunk-PZZC5AXX.cjs');require('../chunk-6BTB6Y3H.cjs'),require('../chunk-AL2YERWY.cjs'),require('../chunk-7SYLCJFQ.cjs'),require('../chunk-WGWKNKUT.cjs');Object.defineProperty(exports,"hmacRoomLabel",{enumerable:true,get:function(){return chunkPZZC5AXX_cjs.a}});Object.defineProperty(exports,"roomTelemetry",{enumerable:true,get:function(){return chunkPZZC5AXX_cjs.b}});
@@ -8,8 +8,8 @@
8
8
  * @packageDocumentation
9
9
  */
10
10
  import * as Y from 'yjs';
11
- import { T as TelemetryPipelineOptions } from '../pipeline-DbVW7S-K.cjs';
12
- export { b as TelemetryExporter } from '../pipeline-DbVW7S-K.cjs';
11
+ import { T as TelemetryPipelineOptions } from '../pipeline-CCq2Ng0B.cjs';
12
+ export { b as TelemetryExporter } from '../pipeline-CCq2Ng0B.cjs';
13
13
  import '@docx-editor.dev/core';
14
14
 
15
15
  /** The part of a `y-protocols` `Awareness` the telemetry reads. @public */
@@ -8,8 +8,8 @@
8
8
  * @packageDocumentation
9
9
  */
10
10
  import * as Y from 'yjs';
11
- import { T as TelemetryPipelineOptions } from '../pipeline-DbVW7S-K.js';
12
- export { b as TelemetryExporter } from '../pipeline-DbVW7S-K.js';
11
+ import { T as TelemetryPipelineOptions } from '../pipeline-CCq2Ng0B.js';
12
+ export { b as TelemetryExporter } from '../pipeline-CCq2Ng0B.js';
13
13
  import '@docx-editor.dev/core';
14
14
 
15
15
  /** The part of a `y-protocols` `Awareness` the telemetry reads. @public */
@@ -1 +1 @@
1
- export{a as hmacRoomLabel,b as roomTelemetry}from'../chunk-RRYW7EAV.js';import'../chunk-S7KBMROA.js';import'../chunk-73YEPWY5.js';import'../chunk-DTEVX2XS.js';import'../chunk-DT2KMPUJ.js';
1
+ export{a as hmacRoomLabel,b as roomTelemetry}from'../chunk-E3FTXDLH.js';import'../chunk-WHVIRIUW.js';import'../chunk-RSWAOCAT.js';import'../chunk-W5HFB5EV.js';import'../chunk-DT2KMPUJ.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docx-editor.dev/telemetry",
3
- "version": "2.29.0",
3
+ "version": "2.30.0",
4
4
  "description": "Anonymous diagnostics, metrics, and error reporting for @docx-editor.dev editors and collaboration servers, with OpenTelemetry, Prometheus, and Sentry exporters.",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -56,8 +56,8 @@
56
56
  "license:add": "license-check-and-add add -f license-check.json"
57
57
  },
58
58
  "peerDependencies": {
59
- "@docx-editor.dev/core": "~2.29.0",
60
- "@docx-editor.dev/pro": "~2.29.0",
59
+ "@docx-editor.dev/core": "~2.30.0",
60
+ "@docx-editor.dev/pro": "~2.30.0",
61
61
  "@opentelemetry/api": "^1.9.0",
62
62
  "yjs": "^13.6.32",
63
63
  "@hocuspocus/server": "^4.6.0"
@@ -1 +0,0 @@
1
- var e="docx_editor.version",n=[.005,.01,.025,.05,.1,.25,.5,1,2.5,5,10,30,60],l=[1024,16*1024,64*1024,256*1024,1024*1024,4*1024*1024,16*1024*1024,64*1024*1024,256*1024*1024,1024*1024*1024],i=[.016,.033,.05,.1,.2,.5,1],c=[1,2,3,5,10,20,50,100,250],p=[1e3,1e4,5e4,1e5,25e4,5e5,1e6],g=[.1,.25,.5,.75,.9,.95,1],d=[60,300,900,3600,4*3600,24*3600,168*3600];function o(t,r,a,m,u=[],s){return Object.freeze({name:t,kind:r,unit:a,description:m,labels:u,...s?{buckets:s}:{}})}var b=Object.freeze({documentOpens:o("docx_editor.document.opens","counter","{open}","Documents opened or refused, by outcome, refusal code, engine reason, and part role.",["outcome","code","cause","part",e]),documentOpenDuration:o("docx_editor.document.open.duration","histogram","s","Time from the start of an open to the laid-out document.",[e],n),editRejections:o("docx_editor.edit.rejections","counter","{edit}","Edits, commands, and tracked changes refused, by public code and engine reason.",["code","cause","origin","tracked",e]),reviewSkipped:o("docx_editor.review.skipped","counter","{change}","Tracked changes skipped by accept, reject, or reassign requests, by engine reason, operation, and change kind.",["code","cause","operation","change_kind",e]),fontFailures:o("docx_editor.font.failures","counter","{failure}","Font faces that failed to load and were substituted.",["code",e]),historyDiagnostics:o("docx_editor.history.diagnostics","counter","{event}","Undo steps that did not group as the gesture intended, by code.",["code",e]),customNodeDiagnostics:o("docx_editor.custom_node.diagnostics","counter","{node}","Custom node payloads that could not be read, by code.",["code",e]),collabClientStatusTransitions:o("docx_editor.collab.client.status_transitions","counter","{transition}","Collaboration status changes on clients, by new status and failure code.",["status","code",e]),collabClientConnectDuration:o("docx_editor.collab.client.connect.duration","histogram","s","Time from an editor attaching a room to its first ready status, when the editor attached before the room was ready.",[e],n),collabClientParticipants:o("docx_editor.collab.client.participants","histogram","{participant}","People in the room, as each client sees it when the count changes.",[e],c),editorInteractionDuration:o("docx_editor.editor.interaction.duration","histogram","s","Key presses and pointer presses on the pages, to the next frame on screen, by page count bucket. Bucket counts are exact; the sum is estimated from the bands.",["pages",e],i),editorLayoutDuration:o("docx_editor.editor.layout.duration","histogram","s","Engine layout passes after edits and view changes, background work included, by page count bucket. Bucket counts are exact; the sum is estimated from the bands.",["pages",e],i),editorPaintDuration:o("docx_editor.editor.paint.duration","histogram","s","Engine paints of the pages, by page count bucket. Bucket counts are exact; the sum is estimated from the bands.",["pages",e],i),droppedEvents:o("docx_editor.telemetry.dropped_events","counter","{event}","Events the anonymity guard dropped, by reason. Usually a version mismatch.",["reason",e]),roomsActive:o("docx_editor.collab.rooms.active","gauge","{room}","Rooms loaded."),connectionsActive:o("docx_editor.collab.connections.active","gauge","{connection}","Open client connections. One person with two tabs is two connections."),participantsActive:o("docx_editor.collab.participants.active","gauge","{participant}","People present in all rooms, from awareness states."),roomParticipants:o("docx_editor.collab.room.participants","histogram","{participant}","People present in each room, sampled once per room per interval.",[],c),roomParticipantsMax:o("docx_editor.collab.room.participants.max","gauge","{participant}","People in the fullest room now."),roomMemory:o("docx_editor.collab.room.memory","histogram","By","Bytes each room holds, sampled per room: encoded state, blobs, and updates not yet stored.",["kind"],l),roomsMemory:o("docx_editor.collab.rooms.memory","gauge","By","Bytes all rooms hold together at the last sample.",["kind"]),roomNodes:o("docx_editor.collab.room.nodes","histogram","{node}","Shared document nodes per room, live and tombstoned.",["state"],p),roomResourceUsage:o("docx_editor.collab.room.resource_usage","histogram","1","Share of each room resource limit in use, from 0 to 1.",["resource"],g),roomAge:o("docx_editor.collab.room.age","histogram","s","How long each room has been loaded.",[],d),roomIdle:o("docx_editor.collab.room.idle","histogram","s","Time since each room last changed.",[],d),roomLoadDuration:o("docx_editor.collab.room.load.duration","histogram","s","Time to load a room, by outcome.",["outcome"],n),roomStoreDuration:o("docx_editor.collab.room.store.duration","histogram","s","Time to store a room, by outcome.",["outcome"],n),admissionRejections:o("docx_editor.collab.admission.rejections","counter","{connection}","Connections refused at admission, by reason.",["reason"]),messageRefusals:o("docx_editor.collab.message.refusals","counter","{message}","Messages refused before they applied, by reason, such as room-generation-changed.",["reason"]),updates:o("docx_editor.collab.updates","counter","{update}","Document updates applied to rooms."),updateBytes:o("docx_editor.collab.update.bytes","counter","By","Bytes of document updates applied to rooms."),roomParticipantsByRoom:o("docx_editor.collab.room.participants.current","gauge","{participant}","People in each room, labeled by room. Recorded only with perRoomSeries.",["room"]),roomMemoryByRoom:o("docx_editor.collab.room.memory.current","gauge","By","Bytes each room holds, labeled by room and kind. Recorded only with perRoomSeries.",["room","kind"]),migrations:o("docx_editor.collab.migrations","counter","{room}","Room migrations, by outcome.",["outcome"])}),h={s:"seconds",By:"bytes"};function y(t){let r=t.name.replace(/[^a-zA-Z0-9_]/g,"_"),a=t.unit==="1"?t.kind==="gauge"?"ratio":void 0:h[t.unit];return a&&!r.endsWith(`_${a}`)&&(r+=`_${a}`),t.kind==="counter"&&(r+="_total"),r}export{b as a,y as b};
@@ -1 +0,0 @@
1
- import {a as a$1}from'./chunk-DT2KMPUJ.js';import {diagnosticCodes,diagnosticCauses,diagnosticCommands,explainDiagnostic}from'@docx-editor.dev/core';var w=new Set(diagnosticCodes());function u(t){return new Set(Object.keys(t))}var N=u({package:true,"content-types":true,relationships:true,"main-document":true,glossary:true,styles:true,numbering:true,settings:true,"web-settings":true,"font-table":true,theme:true,header:true,footer:true,footnotes:true,endnotes:true,comments:true,people:true,"custom-xml":true,"document-properties":true,media:true,embedding:true,other:true}),C=u({Error:true,TypeError:true,RangeError:true,ReferenceError:true,SyntaxError:true,other:true}),j=u({accept:true,reject:true,reassign:true}),M=u({"open-mount":true,"open-layout":true,command:true,"review-item":true,automation:true}),T=u({insert:true,delete:true,replace:true,moveFrom:true,moveTo:true,format:true,paragraphMark:true,structural:true}),D=u({rPrChange:true,pPrChange:true,sectPrChange:true,tblPrChange:true,tblPrExChange:true,tblGridChange:true,trPrChange:true,tcPrChange:true,numberingChange:true,other:true}),c={kind:new Set(["document.open","edit.rejected","review.skipped","font.failed","history","custom-node","collab.status","collab.participants","performance"]),code:w,outcome:new Set(["opened","rejected"]),origin:new Set(["command","input","automation"]),command:new Set(diagnosticCommands()),sizeBucket:/^(?:\d+(?:KiB|MiB)?-\d+(?:KiB|MiB)|512MiB\+)$/,pagesBucket:new Set(["0","1","2-9","10-99","100-999","1000+"]),editorSessionId:/^e_(?:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[0-9a-f]{16,64}|[0-9a-z]{6,12}_[0-9a-z]{1,8})$/,engineVersion:/^(?:development|\d{1,4}\.\d{1,4}\.\d{1,4}(?:-[0-9A-Za-z.]{1,20})?)$/,status:new Set(["initializing","ready","disconnected","error","destroyed"]),previous:new Set(["none","initializing","ready","disconnected","error","destroyed"]),cause:new Set(diagnosticCauses()),part:N,errorName:C,stage:M,operation:j,changeKind:T,formattingKind:D},l=new Set(["schemaVersion","time","durationMs","count","repeated","connectMs","participants","windowMs"]),g=new Set(["tracked","recovering"]),m=new Set;function a(t,n=t){m.has(n)||a$1()==="production"||(m.add(n),console.warn(`[docx-editor telemetry] ${t}`));}function f(t,n){let i=Object.hasOwn(c,t)?c[t]:void 0;return i?i instanceof RegExp?i.test(n):i.has(n):false}function B(t){let n=t;if(typeof n.kind!="string"||!f("kind",n.kind))return a("dropped an event of an unknown kind; core and telemetry versions may differ","kind"),{dropped:"unknown-kind"};let i=typeof n.code=="string"?n.code:void 0;if(i!==void 0&&!w.has(i))return a("dropped an event with an unknown code; core and telemetry versions may differ","code"),{dropped:"unknown-code"};let o=i?explainDiagnostic(i):void 0,r={};for(let[e,s]of Object.entries(n)){if(e==="resource"||e==="attributes")continue;if(e==="shape"){let d=K(s);if(!d)return a('dropped an event whose "shape" is not a valid document shape',"shape"),{dropped:"invalid-field"};r.shape=d;continue}if(I.has(e)){let d=x(s);if(!d)return a(`dropped an event whose "${e}" is not a valid timing summary`,`timing:${e}`),{dropped:"invalid-field"};r[e]=d;continue}if(e==="hint"||e==="docs"){o&&s===o[e]&&(r[e]=s);continue}let R=Object.hasOwn(c,e)||l.has(e)||g.has(e);if(typeof s=="number"&&l.has(e)&&Number.isFinite(s))r[e]=s;else if(typeof s=="boolean"&&g.has(e))r[e]=s;else if(typeof s=="string"&&f(e,s))r[e]=s;else {if(R)return a(`dropped an event whose "${e}" is not a valid value`,`field:${e}`),{dropped:"invalid-field"};a(`dropped the field "${e}", which is not an anonymous diagnostic field`,`extra:${e}`);}}return r.resource=t.resource,r.attributes=t.attributes??{},{event:Object.freeze(r)}}var I=new Set(["interaction","layout","paint"]),y=["count","p50Ms","p95Ms","maxMs"],$=8,h=t=>typeof t=="number"&&Number.isFinite(t)&&t>=0;function x(t){if(!t||typeof t!="object")return null;let n=t,i=[...y,"bands"];if(Object.keys(n).some(e=>!i.includes(e)))return null;let o={};for(let e of y){if(!h(n[e]))return null;o[e]=n[e];}let r=n.bands;return !Array.isArray(r)||r.length!==$||!r.every(h)?null:(o.bands=Object.freeze([...r]),Object.freeze(o))}var b=["parts","paragraphs","reviewItems","embeddedFonts"];function K(t){if(!t||typeof t!="object")return null;let n=t;if(Object.keys(n).some(o=>!b.includes(o)))return null;let i={};for(let o of b){let r=n[o];if(typeof r!="string"||!f("pagesBucket",r))return null;i[o]=r;}return Object.freeze(i)}var k=/^[A-Za-z_][A-Za-z0-9_.-]{0,63}$/,S=/^[A-Za-z0-9_.:+-]{0,64}$/;function F(t,n,i){let o={};for(let[r,e]of Object.entries(t)){if(!k.test(r)||i&&!i.includes(r)){a(`dropped the attribute "${r.slice(0,40)}" on ${n}`,`attribute:${n}:${r}`);continue}typeof e=="number"||typeof e=="boolean"?o[r]=e:typeof e=="string"&&(o[r]=i&&!S.test(e)?"other":e.slice(0,256));}return o}function P(t){if(!t||typeof t!="object"||Array.isArray(t))return;let n={};for(let[i,o]of Object.entries(t))k.test(i)&&(typeof o=="boolean"||typeof o=="number"&&Number.isFinite(o)||typeof o=="string"&&o&&S.test(o))&&(n[i]=o);return Object.keys(n).length?n:void 0}export{B as a,F as b,P as c};
@@ -1 +0,0 @@
1
- 'use strict';var chunkWGWKNKUT_cjs=require('./chunk-WGWKNKUT.cjs'),core=require('@docx-editor.dev/core');var w=new Set(core.diagnosticCodes());function u(t){return new Set(Object.keys(t))}var N=u({package:true,"content-types":true,relationships:true,"main-document":true,glossary:true,styles:true,numbering:true,settings:true,"web-settings":true,"font-table":true,theme:true,header:true,footer:true,footnotes:true,endnotes:true,comments:true,people:true,"custom-xml":true,"document-properties":true,media:true,embedding:true,other:true}),C=u({Error:true,TypeError:true,RangeError:true,ReferenceError:true,SyntaxError:true,other:true}),j=u({accept:true,reject:true,reassign:true}),M=u({"open-mount":true,"open-layout":true,command:true,"review-item":true,automation:true}),T=u({insert:true,delete:true,replace:true,moveFrom:true,moveTo:true,format:true,paragraphMark:true,structural:true}),D=u({rPrChange:true,pPrChange:true,sectPrChange:true,tblPrChange:true,tblPrExChange:true,tblGridChange:true,trPrChange:true,tcPrChange:true,numberingChange:true,other:true}),c={kind:new Set(["document.open","edit.rejected","review.skipped","font.failed","history","custom-node","collab.status","collab.participants","performance"]),code:w,outcome:new Set(["opened","rejected"]),origin:new Set(["command","input","automation"]),command:new Set(core.diagnosticCommands()),sizeBucket:/^(?:\d+(?:KiB|MiB)?-\d+(?:KiB|MiB)|512MiB\+)$/,pagesBucket:new Set(["0","1","2-9","10-99","100-999","1000+"]),editorSessionId:/^e_(?:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[0-9a-f]{16,64}|[0-9a-z]{6,12}_[0-9a-z]{1,8})$/,engineVersion:/^(?:development|\d{1,4}\.\d{1,4}\.\d{1,4}(?:-[0-9A-Za-z.]{1,20})?)$/,status:new Set(["initializing","ready","disconnected","error","destroyed"]),previous:new Set(["none","initializing","ready","disconnected","error","destroyed"]),cause:new Set(core.diagnosticCauses()),part:N,errorName:C,stage:M,operation:j,changeKind:T,formattingKind:D},l=new Set(["schemaVersion","time","durationMs","count","repeated","connectMs","participants","windowMs"]),g=new Set(["tracked","recovering"]),m=new Set;function a(t,n=t){m.has(n)||chunkWGWKNKUT_cjs.a()==="production"||(m.add(n),console.warn(`[docx-editor telemetry] ${t}`));}function f(t,n){let i=Object.hasOwn(c,t)?c[t]:void 0;return i?i instanceof RegExp?i.test(n):i.has(n):false}function B(t){let n=t;if(typeof n.kind!="string"||!f("kind",n.kind))return a("dropped an event of an unknown kind; core and telemetry versions may differ","kind"),{dropped:"unknown-kind"};let i=typeof n.code=="string"?n.code:void 0;if(i!==void 0&&!w.has(i))return a("dropped an event with an unknown code; core and telemetry versions may differ","code"),{dropped:"unknown-code"};let o=i?core.explainDiagnostic(i):void 0,r={};for(let[e,s]of Object.entries(n)){if(e==="resource"||e==="attributes")continue;if(e==="shape"){let d=K(s);if(!d)return a('dropped an event whose "shape" is not a valid document shape',"shape"),{dropped:"invalid-field"};r.shape=d;continue}if(I.has(e)){let d=x(s);if(!d)return a(`dropped an event whose "${e}" is not a valid timing summary`,`timing:${e}`),{dropped:"invalid-field"};r[e]=d;continue}if(e==="hint"||e==="docs"){o&&s===o[e]&&(r[e]=s);continue}let R=Object.hasOwn(c,e)||l.has(e)||g.has(e);if(typeof s=="number"&&l.has(e)&&Number.isFinite(s))r[e]=s;else if(typeof s=="boolean"&&g.has(e))r[e]=s;else if(typeof s=="string"&&f(e,s))r[e]=s;else {if(R)return a(`dropped an event whose "${e}" is not a valid value`,`field:${e}`),{dropped:"invalid-field"};a(`dropped the field "${e}", which is not an anonymous diagnostic field`,`extra:${e}`);}}return r.resource=t.resource,r.attributes=t.attributes??{},{event:Object.freeze(r)}}var I=new Set(["interaction","layout","paint"]),y=["count","p50Ms","p95Ms","maxMs"],$=8,h=t=>typeof t=="number"&&Number.isFinite(t)&&t>=0;function x(t){if(!t||typeof t!="object")return null;let n=t,i=[...y,"bands"];if(Object.keys(n).some(e=>!i.includes(e)))return null;let o={};for(let e of y){if(!h(n[e]))return null;o[e]=n[e];}let r=n.bands;return !Array.isArray(r)||r.length!==$||!r.every(h)?null:(o.bands=Object.freeze([...r]),Object.freeze(o))}var b=["parts","paragraphs","reviewItems","embeddedFonts"];function K(t){if(!t||typeof t!="object")return null;let n=t;if(Object.keys(n).some(o=>!b.includes(o)))return null;let i={};for(let o of b){let r=n[o];if(typeof r!="string"||!f("pagesBucket",r))return null;i[o]=r;}return Object.freeze(i)}var k=/^[A-Za-z_][A-Za-z0-9_.-]{0,63}$/,S=/^[A-Za-z0-9_.:+-]{0,64}$/;function F(t,n,i){let o={};for(let[r,e]of Object.entries(t)){if(!k.test(r)||i&&!i.includes(r)){a(`dropped the attribute "${r.slice(0,40)}" on ${n}`,`attribute:${n}:${r}`);continue}typeof e=="number"||typeof e=="boolean"?o[r]=e:typeof e=="string"&&(o[r]=i&&!S.test(e)?"other":e.slice(0,256));}return o}function P(t){if(!t||typeof t!="object"||Array.isArray(t))return;let n={};for(let[i,o]of Object.entries(t))k.test(i)&&(typeof o=="boolean"||typeof o=="number"&&Number.isFinite(o)||typeof o=="string"&&o&&S.test(o))&&(n[i]=o);return Object.keys(n).length?n:void 0}exports.a=B;exports.b=F;exports.c=P;
@@ -1 +0,0 @@
1
- 'use strict';var e="docx_editor.version",n=[.005,.01,.025,.05,.1,.25,.5,1,2.5,5,10,30,60],l=[1024,16*1024,64*1024,256*1024,1024*1024,4*1024*1024,16*1024*1024,64*1024*1024,256*1024*1024,1024*1024*1024],i=[.016,.033,.05,.1,.2,.5,1],c=[1,2,3,5,10,20,50,100,250],p=[1e3,1e4,5e4,1e5,25e4,5e5,1e6],g=[.1,.25,.5,.75,.9,.95,1],d=[60,300,900,3600,4*3600,24*3600,168*3600];function o(t,r,a,m,u=[],s){return Object.freeze({name:t,kind:r,unit:a,description:m,labels:u,...s?{buckets:s}:{}})}var b=Object.freeze({documentOpens:o("docx_editor.document.opens","counter","{open}","Documents opened or refused, by outcome, refusal code, engine reason, and part role.",["outcome","code","cause","part",e]),documentOpenDuration:o("docx_editor.document.open.duration","histogram","s","Time from the start of an open to the laid-out document.",[e],n),editRejections:o("docx_editor.edit.rejections","counter","{edit}","Edits, commands, and tracked changes refused, by public code and engine reason.",["code","cause","origin","tracked",e]),reviewSkipped:o("docx_editor.review.skipped","counter","{change}","Tracked changes skipped by accept, reject, or reassign requests, by engine reason, operation, and change kind.",["code","cause","operation","change_kind",e]),fontFailures:o("docx_editor.font.failures","counter","{failure}","Font faces that failed to load and were substituted.",["code",e]),historyDiagnostics:o("docx_editor.history.diagnostics","counter","{event}","Undo steps that did not group as the gesture intended, by code.",["code",e]),customNodeDiagnostics:o("docx_editor.custom_node.diagnostics","counter","{node}","Custom node payloads that could not be read, by code.",["code",e]),collabClientStatusTransitions:o("docx_editor.collab.client.status_transitions","counter","{transition}","Collaboration status changes on clients, by new status and failure code.",["status","code",e]),collabClientConnectDuration:o("docx_editor.collab.client.connect.duration","histogram","s","Time from an editor attaching a room to its first ready status, when the editor attached before the room was ready.",[e],n),collabClientParticipants:o("docx_editor.collab.client.participants","histogram","{participant}","People in the room, as each client sees it when the count changes.",[e],c),editorInteractionDuration:o("docx_editor.editor.interaction.duration","histogram","s","Key presses and pointer presses on the pages, to the next frame on screen, by page count bucket. Bucket counts are exact; the sum is estimated from the bands.",["pages",e],i),editorLayoutDuration:o("docx_editor.editor.layout.duration","histogram","s","Engine layout passes after edits and view changes, background work included, by page count bucket. Bucket counts are exact; the sum is estimated from the bands.",["pages",e],i),editorPaintDuration:o("docx_editor.editor.paint.duration","histogram","s","Engine paints of the pages, by page count bucket. Bucket counts are exact; the sum is estimated from the bands.",["pages",e],i),droppedEvents:o("docx_editor.telemetry.dropped_events","counter","{event}","Events the anonymity guard dropped, by reason. Usually a version mismatch.",["reason",e]),roomsActive:o("docx_editor.collab.rooms.active","gauge","{room}","Rooms loaded."),connectionsActive:o("docx_editor.collab.connections.active","gauge","{connection}","Open client connections. One person with two tabs is two connections."),participantsActive:o("docx_editor.collab.participants.active","gauge","{participant}","People present in all rooms, from awareness states."),roomParticipants:o("docx_editor.collab.room.participants","histogram","{participant}","People present in each room, sampled once per room per interval.",[],c),roomParticipantsMax:o("docx_editor.collab.room.participants.max","gauge","{participant}","People in the fullest room now."),roomMemory:o("docx_editor.collab.room.memory","histogram","By","Bytes each room holds, sampled per room: encoded state, blobs, and updates not yet stored.",["kind"],l),roomsMemory:o("docx_editor.collab.rooms.memory","gauge","By","Bytes all rooms hold together at the last sample.",["kind"]),roomNodes:o("docx_editor.collab.room.nodes","histogram","{node}","Shared document nodes per room, live and tombstoned.",["state"],p),roomResourceUsage:o("docx_editor.collab.room.resource_usage","histogram","1","Share of each room resource limit in use, from 0 to 1.",["resource"],g),roomAge:o("docx_editor.collab.room.age","histogram","s","How long each room has been loaded.",[],d),roomIdle:o("docx_editor.collab.room.idle","histogram","s","Time since each room last changed.",[],d),roomLoadDuration:o("docx_editor.collab.room.load.duration","histogram","s","Time to load a room, by outcome.",["outcome"],n),roomStoreDuration:o("docx_editor.collab.room.store.duration","histogram","s","Time to store a room, by outcome.",["outcome"],n),admissionRejections:o("docx_editor.collab.admission.rejections","counter","{connection}","Connections refused at admission, by reason.",["reason"]),messageRefusals:o("docx_editor.collab.message.refusals","counter","{message}","Messages refused before they applied, by reason, such as room-generation-changed.",["reason"]),updates:o("docx_editor.collab.updates","counter","{update}","Document updates applied to rooms."),updateBytes:o("docx_editor.collab.update.bytes","counter","By","Bytes of document updates applied to rooms."),roomParticipantsByRoom:o("docx_editor.collab.room.participants.current","gauge","{participant}","People in each room, labeled by room. Recorded only with perRoomSeries.",["room"]),roomMemoryByRoom:o("docx_editor.collab.room.memory.current","gauge","By","Bytes each room holds, labeled by room and kind. Recorded only with perRoomSeries.",["room","kind"]),migrations:o("docx_editor.collab.migrations","counter","{room}","Room migrations, by outcome.",["outcome"])}),h={s:"seconds",By:"bytes"};function y(t){let r=t.name.replace(/[^a-zA-Z0-9_]/g,"_"),a=t.unit==="1"?t.kind==="gauge"?"ratio":void 0:h[t.unit];return a&&!r.endsWith(`_${a}`)&&(r+=`_${a}`),t.kind==="counter"&&(r+="_total"),r}exports.a=b;exports.b=y;
@@ -1,2 +0,0 @@
1
- function u(e,o){return {name:"callback",event:e,...o?{metric:o}:{}}}function n(e){let o=e,r=["operation","changeKind","formattingKind","cause","errorName","stage","part"].map(t=>o[t]).filter(t=>typeof t=="string");return r.length?` [${r.join(", ")}]`:""}function i(e){let o=e.repeated?` (and ${e.repeated} more)`:"";switch(e.kind){case "document.open":return e.outcome==="rejected"?`document refused: ${e.code}${n(e)}`:e.pagesBucket===void 0?`document opened: ${e.sizeBucket}, ${e.durationMs} ms`:`document opened: ${e.pagesBucket} pages, ${e.sizeBucket}, ${e.durationMs} ms`;case "edit.rejected":{let r=e.command?`${e.origin} ${e.command}`:e.origin;return `edit refused: ${e.code}${n(e)} (${r}, ${e.tracked?"tracked":"untracked"})${o}`}case "review.skipped":return `tracked changes skipped: ${e.code}${n(e)} x${e.count}`;case "font.failed":return `font substituted: ${e.code}${o}`;case "history":return `undo history: ${e.code}${o}`;case "custom-node":return `custom node payload unreadable: ${e.code}${o}`;case "collab.participants":return `collaboration: ${e.count} ${e.count===1?"person":"people"} in the room`;case "collab.status":{let r=e.code?`: ${e.code}`:"",t=e.connectMs!==void 0?` after ${e.connectMs} ms`:"";return `collaboration ${e.status}${r}${e.recovering?" (recovering)":""}${t}`}case "performance":{let r=[c("key presses and clicks",e.interaction),c("layout",e.layout),c("paint",e.paint)].filter(Boolean),t=e.pagesBucket===void 0?"":`, ${e.pagesBucket} pages`;return `performance over ${Math.round(e.windowMs/1e3)} s${t}: ${r.join("; ")}`}}}function c(e,o){return o?`${e} p50 ${o.p50Ms} ms, p95 ${o.p95Ms} ms, max ${o.maxMs} ms (x${o.count})`:""}function a(e){if(e.repeated!==void 0)return false;switch(e.kind){case "document.open":return e.outcome==="rejected";case "collab.participants":case "history":case "performance":return false;case "collab.status":return e.status==="error"&&e.code!=="collab.authentication-failed"&&e.code!=="collab.room-generation-changed";case "edit.rejected":return !s.has(e.code);case "font.failed":return e.code!=="font.missing";case "review.skipped":return e.code!=="review.stale-revision";default:return true}}var s=new Set(["edit.stale-target","edit.read-only","edit.protected-content","edit.refresh-in-progress","edit.collaboration-not-ready"]);function l(e={}){let o=e.console??console;return {name:"console",event(r){let t=[`[docx-editor] ${i(r)}`];r.hint&&t.push(` ${r.hint}`),r.docs&&t.push(` ${r.docs}`),(a(r)||r.kind==="performance"&&r.code!==void 0?o.warn:o.info).call(o,t.join(`
2
- `));},...e.metrics?{metric(r){o.info(`[docx-editor] ${r.definition.name} ${r.value}`,r.attributes);}}:{}}}function p(){let e=[],o=[];return {name:"memory",events:e,metrics:o,event:r=>{e.push(r);},metric:r=>{o.push(r);},clear(){e.length=0,o.length=0;}}}export{u as a,i as b,a as c,l as d,p as e};
@@ -1 +0,0 @@
1
- import {a as a$1}from'./chunk-73YEPWY5.js';import {b,a}from'./chunk-DTEVX2XS.js';var A=50,R="2.29.0";function M(o){let i=[...o.exporters],T=Object.freeze({...b(o.resource??{},"resource")}),d=[...o.metricLabels??[]],m=new Map,b$1=new Set;function y(e){if(d.length===0)return e;let r={...e};for(let t of d){let n=r[t];if(n===void 0)continue;let s=String(n),a=m.get(t);if(a||m.set(t,a=new Set),!a.has(s)){if(a.size>=A){r[t]="other";continue}a.add(s);}}return r}let f=false;function p(e,r){if(!b$1.has(r)){b$1.add(r);try{if(o.onExporterError){let t=o.onExporterError(e,r);t&&typeof t.then=="function"&&Promise.resolve(t).catch(()=>{});}else console.warn(`[docx-editor telemetry] exporter "${r}" failed`,e);}catch{}}}function c(e,r){try{let t=r();if(!t||typeof t.then!="function")return;Promise.resolve(t).then(void 0,n=>p(n,e.name));}catch(t){p(t,e.name);}}function v(){let e=o.consent??true;if(typeof e=="boolean")return e;try{return e()===!0}catch{return false}}function u(){return !f&&v()}let E=false,_=()=>E||globalThis.document?.visibilityState==="hidden";for(let e of i)c(e,()=>e.attach?.({consented:v,pageClosing:_}));async function g(e){await Promise.all(i.map(async r=>{try{await e(r);}catch(t){p(t,r.name);}}));}return {resource:T,consented:u,event(e){if(!u())return;let r=a(e);if("dropped"in r){this.metric(a$1.droppedEvents,1,{reason:r.dropped});return}for(let t of i)t.event&&c(t,()=>t.event(r.event));},metric(e,r,t={}){if(!u()||!Number.isFinite(r))return;let n={definition:e,value:r,attributes:y(b(t,e.name,[...e.labels,...d]))};for(let s of i)s.metric&&c(s,()=>s.metric(n));},forget(e,r){let t=b(r,e.name,e.labels);for(let n of i)n.forget&&c(n,()=>n.forget(e,t));},declare(e,r={}){if(!u())return;let t=y(b(r,e.name,[...e.labels,...d]));for(let n of i)n.declare&&c(n,()=>n.declare(e,t));},flush:()=>g(e=>e.flush?.()),setPageClosing(e){E=e;},async shutdown(){f||(f=true,await g(e=>e.shutdown?e.shutdown():e.flush?.()));}}}export{A as a,R as b,M as c};
@@ -1,2 +0,0 @@
1
- 'use strict';function u(e,o){return {name:"callback",event:e,...o?{metric:o}:{}}}function n(e){let o=e,r=["operation","changeKind","formattingKind","cause","errorName","stage","part"].map(t=>o[t]).filter(t=>typeof t=="string");return r.length?` [${r.join(", ")}]`:""}function i(e){let o=e.repeated?` (and ${e.repeated} more)`:"";switch(e.kind){case "document.open":return e.outcome==="rejected"?`document refused: ${e.code}${n(e)}`:e.pagesBucket===void 0?`document opened: ${e.sizeBucket}, ${e.durationMs} ms`:`document opened: ${e.pagesBucket} pages, ${e.sizeBucket}, ${e.durationMs} ms`;case "edit.rejected":{let r=e.command?`${e.origin} ${e.command}`:e.origin;return `edit refused: ${e.code}${n(e)} (${r}, ${e.tracked?"tracked":"untracked"})${o}`}case "review.skipped":return `tracked changes skipped: ${e.code}${n(e)} x${e.count}`;case "font.failed":return `font substituted: ${e.code}${o}`;case "history":return `undo history: ${e.code}${o}`;case "custom-node":return `custom node payload unreadable: ${e.code}${o}`;case "collab.participants":return `collaboration: ${e.count} ${e.count===1?"person":"people"} in the room`;case "collab.status":{let r=e.code?`: ${e.code}`:"",t=e.connectMs!==void 0?` after ${e.connectMs} ms`:"";return `collaboration ${e.status}${r}${e.recovering?" (recovering)":""}${t}`}case "performance":{let r=[c("key presses and clicks",e.interaction),c("layout",e.layout),c("paint",e.paint)].filter(Boolean),t=e.pagesBucket===void 0?"":`, ${e.pagesBucket} pages`;return `performance over ${Math.round(e.windowMs/1e3)} s${t}: ${r.join("; ")}`}}}function c(e,o){return o?`${e} p50 ${o.p50Ms} ms, p95 ${o.p95Ms} ms, max ${o.maxMs} ms (x${o.count})`:""}function a(e){if(e.repeated!==void 0)return false;switch(e.kind){case "document.open":return e.outcome==="rejected";case "collab.participants":case "history":case "performance":return false;case "collab.status":return e.status==="error"&&e.code!=="collab.authentication-failed"&&e.code!=="collab.room-generation-changed";case "edit.rejected":return !s.has(e.code);case "font.failed":return e.code!=="font.missing";case "review.skipped":return e.code!=="review.stale-revision";default:return true}}var s=new Set(["edit.stale-target","edit.read-only","edit.protected-content","edit.refresh-in-progress","edit.collaboration-not-ready"]);function l(e={}){let o=e.console??console;return {name:"console",event(r){let t=[`[docx-editor] ${i(r)}`];r.hint&&t.push(` ${r.hint}`),r.docs&&t.push(` ${r.docs}`),(a(r)||r.kind==="performance"&&r.code!==void 0?o.warn:o.info).call(o,t.join(`
2
- `));},...e.metrics?{metric(r){o.info(`[docx-editor] ${r.definition.name} ${r.value}`,r.attributes);}}:{}}}function p(){let e=[],o=[];return {name:"memory",events:e,metrics:o,event:r=>{e.push(r);},metric:r=>{o.push(r);},clear(){e.length=0,o.length=0;}}}exports.a=u;exports.b=i;exports.c=a;exports.d=l;exports.e=p;