@drenso/homey-log 10.39.0 → 10.3900.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.
- package/README.md +2 -0
- package/build/index.js +1 -1
- package/build/index.mjs +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -71,3 +71,5 @@ This version has replaced the raven SDK with [@sentry/node](https://docs.sentry.
|
|
|
71
71
|
This package will now follow the Sentry version included.
|
|
72
72
|
|
|
73
73
|
With 10.39 and onwards, we're using `@sentry/node-core/light` for this library.
|
|
74
|
+
|
|
75
|
+
From 10.3900 and onwards, the sentry minor and patch versions are combined into the minor version (minor * 100 + patch), so we can release patches when necessary.
|
package/build/index.js
CHANGED
|
@@ -19,4 +19,4 @@ Url: ${Ut(e)}`),!0}return!1}function Fa(e,t){return t?.length?Mt(e).some(n=>Ie(n
|
|
|
19
19
|
`),h=m.shift();if(!h)return e.destroy(),n(new Error("No header received from proxy CONNECT response"));let S=h.split(" "),E=+(S[1]||0),x=S.slice(2).join(" "),C={};for(let W of m){if(!W)continue;let ue=W.indexOf(":");if(ue===-1)return e.destroy(),n(new Error(`Invalid header from proxy CONNECT response: "${W}"`));let pe=W.slice(0,ue).toLowerCase(),re=W.slice(ue+1).trimStart(),L=C[pe];typeof L=="string"?C[pe]=[L,re]:Array.isArray(L)?L.push(re):C[pe]=re}jt("got proxy server response: %o %o",h,C),i(),t({connect:{statusCode:E,statusText:x,headers:C},buffered:l})}e.on("error",c),e.on("end",a),s()})}function ot(...e){p.log("[https-proxy-agent]",...e)}var st=class extends Vt{static __initStatic(){this.protocols=["http","https"]}constructor(t,n){super(n),this.options={},this.proxy=typeof t=="string"?new URL(t):t,this.proxyHeaders=n?.headers??{},ot("Creating new HttpsProxyAgent instance: %o",this.proxy.href);let r=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),o=this.proxy.port?parseInt(this.proxy.port,10):this.proxy.protocol==="https:"?443:80;this.connectOpts={ALPNProtocols:["http/1.1"],...n?Ls(n,"headers"):null,host:r,port:o}}async connect(t,n){let{proxy:r}=this;if(!n.host)throw new TypeError('No "host" provided');let o;if(r.protocol==="https:"){ot("Creating `tls.Socket`: %o",this.connectOpts);let d=this.connectOpts.servername||this.connectOpts.host;o=Xn.connect({...this.connectOpts,servername:d&&z.isIP(d)?void 0:d})}else ot("Creating `net.Socket`: %o",this.connectOpts),o=z.connect(this.connectOpts);let s=typeof this.proxyHeaders=="function"?this.proxyHeaders():{...this.proxyHeaders},i=z.isIPv6(n.host)?`[${n.host}]`:n.host,a=`CONNECT ${i}:${n.port} HTTP/1.1\r
|
|
20
20
|
`;if(r.username||r.password){let d=`${decodeURIComponent(r.username)}:${decodeURIComponent(r.password)}`;s["Proxy-Authorization"]=`Basic ${Buffer.from(d).toString("base64")}`}s.Host=`${i}:${n.port}`,s["Proxy-Connection"]||(s["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close");for(let d of Object.keys(s))a+=`${d}: ${s[d]}\r
|
|
21
21
|
`;let c=Os(o);o.write(`${a}\r
|
|
22
|
-
`);let{connect:u,buffered:f}=await c;if(t.emit("proxyConnect",u),this.emit("proxyConnect",u,t),u.statusCode===200){if(t.once("socket",Iu),n.secureEndpoint){ot("Upgrading socket connection to TLS");let d=n.servername||n.host;return Xn.connect({...Ls(n,"host","path","port"),socket:o,servername:z.isIP(d)?void 0:d})}return o}o.destroy();let l=new z.Socket({writable:!1});return l.readable=!0,t.once("socket",d=>{ot("Replaying proxy buffer for failed request"),d.push(f),d.push(null)}),l}};st.__initStatic();function Iu(e){e.resume()}function Ls(e,...t){let n={},r;for(r in e)t.includes(r)||(n[r]=e[r]);return n}var bu=1024*32;function xu(e){return new Ms.Readable({read(){this.push(e),this.push(null)}})}function Ds(e){let t;try{t=new URL(e.url)}catch{return b(()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")}),Je(e,()=>Promise.resolve({}))}let n=t.protocol==="https:",r=Nu(t,e.proxy||(n?process.env.https_proxy:void 0)||process.env.http_proxy),o=n?yu:Tu,s=e.keepAlive===void 0?!1:e.keepAlive,i=r?new st(r):new o.Agent({keepAlive:s,maxSockets:30,timeout:2e3}),a=Cu(e,e.httpModule??o,i);return Je(e,a)}function Nu(e,t){let{no_proxy:n}=process.env;if(!n?.split(",").some(o=>e.host.endsWith(o)||e.hostname.endsWith(o)))return t}function Cu(e,t,n){let{hostname:r,pathname:o,port:s,protocol:i,search:a}=new URL(e.url);return function(u){return new Promise((f,l)=>{Ce(()=>{let d=xu(u.body),m={...e.headers};u.body.length>bu&&(m["content-encoding"]="gzip",d=d.pipe((0,Ps.createGzip)()));let h=r.startsWith("["),S=t.request({method:"POST",agent:n,headers:m,hostname:h?r.slice(1,-1):r,path:`${o}${a}`,port:s,protocol:i,ca:e.caCerts},E=>{E.on("data",()=>{}),E.on("end",()=>{}),E.setEncoding("utf8");let x=E.headers["retry-after"]??null,C=E.headers["x-sentry-rate-limits"]??null;f({statusCode:E.statusCode,headers:{"retry-after":x,"x-sentry-rate-limits":Array.isArray(C)?C[0]||null:C}})});S.on("error",l),d.pipe(S)})})}}function Us(e){if(e===!1)return!1;if(typeof e=="string")return e;let t=ce(process.env.SENTRY_SPOTLIGHT,{strict:!0}),n=t===null&&process.env.SENTRY_SPOTLIGHT?process.env.SENTRY_SPOTLIGHT:void 0;return e===!0?n??!0:t??n}var Fs=require("node:async_hooks");function ks(){let e=new Fs.AsyncLocalStorage;function t(){let a=e.getStore();return a||{scope:Be(),isolationScope:Ge()}}function n(a){let c=t().scope.clone(),u=t().isolationScope;return e.run({scope:c,isolationScope:u},()=>a(c))}function r(a,c){let u=t().isolationScope.clone();return e.run({scope:a,isolationScope:u},()=>c(a))}function o(a){let c=t().scope.clone(),u=t().isolationScope.clone();return e.run({scope:c,isolationScope:u},()=>a(u))}function s(a,c){let u=t().scope.clone();return e.run({scope:u,isolationScope:a},()=>c(a))}function i(a){return n(c=>(c.setSDKProcessingMetadata({__SENTRY_SUPPRESS_TRACING__:!0}),a()))}un({suppressTracing:i,withScope:n,withSetScope:r,withIsolationScope:o,withSetIsolationScope:s,getCurrentScope:()=>t().scope,getIsolationScope:()=>t().isolationScope})}function Kn(e={}){return Ru(e,()=>[])}function Ru(e={},t){let n=Au(e,t);n.debug===!0&&(N?p.enable():b(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),ks(),R().update(n.initialScope),n.spotlight&&!n.integrations.some(({name:s})=>s===zn)&&n.integrations.push(Ns({sidecarUrl:typeof n.spotlight=="string"?n.spotlight:void 0})),Ke(n,"node-light",["node-core"]);let o=new Ft(n);return R().setClient(o),o.init(),_._sentryInjectLoaderHookRegister?.(),p.log(`SDK initialized from ${ys()?"CommonJS":"ESM"} (light mode)`),o.startClientReportTracking(),Lu(),process.env.VERCEL&&process.on("SIGTERM",async()=>{await o.flush(200)}),o}function Au(e,t){let n=vu(e.release),r=Us(e.spotlight),o=Ou(e.tracesSampleRate),s={...e,dsn:e.dsn??process.env.SENTRY_DSN,environment:e.environment??process.env.SENTRY_ENVIRONMENT,sendClientReports:e.sendClientReports??!0,transport:e.transport??Ds,stackParser:Xt(e.stackParser||vs),release:n,tracesSampleRate:o,spotlight:r,debug:ce(e.debug??process.env.SENTRY_DEBUG)},i=e.integrations,a=e.defaultIntegrations??t(s);return{...s,integrations:An({defaultIntegrations:a,integrations:i})}}function vu(e){if(e!==void 0)return e;let t=As();if(t!==void 0)return t}function Ou(e){if(e!==void 0)return e;let t=process.env.SENTRY_TRACES_SAMPLE_RATE;if(!t)return;let n=parseFloat(t);return isFinite(n)?n:void 0}function Lu(){if(ce(process.env.SENTRY_USE_ENVIRONMENT)!==!1){let e=process.env.SENTRY_TRACE,t=process.env.SENTRY_BAGGAGE,n=gn(e,t);R().setPropagationContext(n)}}var H=O(require("homey"),1);process.env.HOME||(process.env.HOME=ws.default.tmpdir());var Qn=class e{_capturedMessages=[];_capturedExceptions=[];constructor({homey:t,options:n}){if(typeof t>"u")return e._error("Error: missing `homey` constructor parameter");if(!H.default.env)return e._error("Error: could not access `Homey.env`");if(typeof H.default.env.HOMEY_LOG_URL!="string")return e._error("Error: expected `HOMEY_LOG_URL` env variable, homey-log is disabled");let r=process.env.DEBUG==="1"&&!e._isLogForced();r&&e._log("App is running in debug mode, not enabling Sentry logging");let o;typeof H.default.env.HOMEY_LOG_SENTRY_PROJECT=="string"&&H.default.env.HOMEY_LOG_SENTRY_PROJECT.length>0&&(o=`${H.default.env.HOMEY_LOG_SENTRY_PROJECT}@${H.default.manifest.version}`),this._manifest=H.default.manifest,this._homeyVersion=t.version,this._managerCloud=t.cloud,this._homeyPlatform=t.platform,this._homeyPlatformVersion=t.platformVersion,this.init(H.default.env.HOMEY_LOG_URL,{enabled:!r,release:o,...n})}init(t,n){return Kn({dsn:t,integrations:[Ae(),Qe(),qe(),et(),tt(),$n(),Zn(),Yn(),jn(),Hn()],maxBreadcrumbs:5,enableMetrics:!1,...n}),this.setTags({appId:this._manifest.id,appVersion:this._manifest.version,homeyVersion:this._homeyVersion,homeyPlatform:this._homeyPlatform,homeyPlatformVersion:this._homeyPlatformVersion}),this._managerCloud.getHomeyId().then(r=>this.setTags({homeyId:r})).catch(r=>e._error("Error: could not get `homeyId`",r)),e._log(`App ${this._manifest.id} v${this._manifest.version} logging on Homey v${this._homeyVersion}...`),this}setTags(t){return At(t),this}setUser(t){return vt(t),this}async captureMessage(t){if(e._log("captureMessage:",t),this._capturedMessages.indexOf(t)>-1){e._log("Prevented sending a duplicate message");return}return this._capturedMessages.push(t),new Promise((n,r)=>{try{n(Rt(t))}catch(o){r(o)}})}async captureException(t){if(e._log("captureException:",t),this._capturedExceptions.indexOf(t)>-1){e._log("Prevented sending a duplicate log");return}return this._capturedExceptions.push(t),new Promise((n,r)=>{try{n(te(t))}catch(o){r(o)}})}static _log(){console.log.bind(null,e._logTime(),"[homey-log]").apply(null,arguments)}static _error(){console.error.bind(null,e._logTime(),"[homey-log]").apply(null,arguments)}static _logTime(){return`\x1B[35m${new Date().toISOString()}\x1B[0m`}static _isLogForced(){switch(H.default.env.HOMEY_LOG_FORCE){case"1":case"true":return!0;default:return!1}}};0&&(module.exports={Log});
|
|
22
|
+
`);let{connect:u,buffered:f}=await c;if(t.emit("proxyConnect",u),this.emit("proxyConnect",u,t),u.statusCode===200){if(t.once("socket",Iu),n.secureEndpoint){ot("Upgrading socket connection to TLS");let d=n.servername||n.host;return Xn.connect({...Ls(n,"host","path","port"),socket:o,servername:z.isIP(d)?void 0:d})}return o}o.destroy();let l=new z.Socket({writable:!1});return l.readable=!0,t.once("socket",d=>{ot("Replaying proxy buffer for failed request"),d.push(f),d.push(null)}),l}};st.__initStatic();function Iu(e){e.resume()}function Ls(e,...t){let n={},r;for(r in e)t.includes(r)||(n[r]=e[r]);return n}var bu=1024*32;function xu(e){return new Ms.Readable({read(){this.push(e),this.push(null)}})}function Ds(e){let t;try{t=new URL(e.url)}catch{return b(()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")}),Je(e,()=>Promise.resolve({}))}let n=t.protocol==="https:",r=Nu(t,e.proxy||(n?process.env.https_proxy:void 0)||process.env.http_proxy),o=n?yu:Tu,s=e.keepAlive===void 0?!1:e.keepAlive,i=r?new st(r):new o.Agent({keepAlive:s,maxSockets:30,timeout:2e3}),a=Cu(e,e.httpModule??o,i);return Je(e,a)}function Nu(e,t){let{no_proxy:n}=process.env;if(!n?.split(",").some(o=>e.host.endsWith(o)||e.hostname.endsWith(o)))return t}function Cu(e,t,n){let{hostname:r,pathname:o,port:s,protocol:i,search:a}=new URL(e.url);return function(u){return new Promise((f,l)=>{Ce(()=>{let d=xu(u.body),m={...e.headers};u.body.length>bu&&(m["content-encoding"]="gzip",d=d.pipe((0,Ps.createGzip)()));let h=r.startsWith("["),S=t.request({method:"POST",agent:n,headers:m,hostname:h?r.slice(1,-1):r,path:`${o}${a}`,port:s,protocol:i,ca:e.caCerts},E=>{E.on("data",()=>{}),E.on("end",()=>{}),E.setEncoding("utf8");let x=E.headers["retry-after"]??null,C=E.headers["x-sentry-rate-limits"]??null;f({statusCode:E.statusCode,headers:{"retry-after":x,"x-sentry-rate-limits":Array.isArray(C)?C[0]||null:C}})});S.on("error",l),d.pipe(S)})})}}function Us(e){if(e===!1)return!1;if(typeof e=="string")return e;let t=ce(process.env.SENTRY_SPOTLIGHT,{strict:!0}),n=t===null&&process.env.SENTRY_SPOTLIGHT?process.env.SENTRY_SPOTLIGHT:void 0;return e===!0?n??!0:t??n}var Fs=require("node:async_hooks");function ks(){let e=new Fs.AsyncLocalStorage;function t(){let a=e.getStore();return a||{scope:Be(),isolationScope:Ge()}}function n(a){let c=t().scope.clone(),u=t().isolationScope;return e.run({scope:c,isolationScope:u},()=>a(c))}function r(a,c){let u=t().isolationScope.clone();return e.run({scope:a,isolationScope:u},()=>c(a))}function o(a){let c=t().scope.clone(),u=t().isolationScope.clone();return e.run({scope:c,isolationScope:u},()=>a(u))}function s(a,c){let u=t().scope.clone();return e.run({scope:u,isolationScope:a},()=>c(a))}function i(a){return n(c=>(c.setSDKProcessingMetadata({__SENTRY_SUPPRESS_TRACING__:!0}),a()))}un({suppressTracing:i,withScope:n,withSetScope:r,withIsolationScope:o,withSetIsolationScope:s,getCurrentScope:()=>t().scope,getIsolationScope:()=>t().isolationScope})}function Kn(e={}){return Ru(e,()=>[])}function Ru(e={},t){let n=Au(e,t);n.debug===!0&&(N?p.enable():b(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),ks(),R().update(n.initialScope),n.spotlight&&!n.integrations.some(({name:s})=>s===zn)&&n.integrations.push(Ns({sidecarUrl:typeof n.spotlight=="string"?n.spotlight:void 0})),Ke(n,"node-light",["node-core"]);let o=new Ft(n);return R().setClient(o),o.init(),_._sentryInjectLoaderHookRegister?.(),p.log(`SDK initialized from ${ys()?"CommonJS":"ESM"} (light mode)`),o.startClientReportTracking(),Lu(),process.env.VERCEL&&process.on("SIGTERM",async()=>{await o.flush(200)}),o}function Au(e,t){let n=vu(e.release),r=Us(e.spotlight),o=Ou(e.tracesSampleRate),s={...e,dsn:e.dsn??process.env.SENTRY_DSN,environment:e.environment??process.env.SENTRY_ENVIRONMENT,sendClientReports:e.sendClientReports??!0,transport:e.transport??Ds,stackParser:Xt(e.stackParser||vs),release:n,tracesSampleRate:o,spotlight:r,debug:ce(e.debug??process.env.SENTRY_DEBUG)},i=e.integrations,a=e.defaultIntegrations??t(s);return{...s,integrations:An({defaultIntegrations:a,integrations:i})}}function vu(e){if(e!==void 0)return e;let t=As();if(t!==void 0)return t}function Ou(e){if(e!==void 0)return e;let t=process.env.SENTRY_TRACES_SAMPLE_RATE;if(!t)return;let n=parseFloat(t);return isFinite(n)?n:void 0}function Lu(){if(ce(process.env.SENTRY_USE_ENVIRONMENT)!==!1){let e=process.env.SENTRY_TRACE,t=process.env.SENTRY_BAGGAGE,n=gn(e,t);R().setPropagationContext(n)}}var H=O(require("homey"),1);process.env.HOME||(process.env.HOME=ws.default.tmpdir());var Qn=class e{_capturedMessages=[];_capturedExceptions=[];constructor({homey:t,options:n}){if(typeof t>"u")return e._error("Error: missing `homey` constructor parameter");if(!H.default.env)return e._error("Error: could not access `Homey.env`");if(typeof H.default.env.HOMEY_LOG_URL!="string")return e._error("Error: expected `HOMEY_LOG_URL` env variable, homey-log is disabled");let r=process.env.DEBUG==="1"&&!e._isLogForced();r&&e._log("App is running in debug mode, not enabling Sentry logging");let o;typeof H.default.env.HOMEY_LOG_SENTRY_PROJECT=="string"&&H.default.env.HOMEY_LOG_SENTRY_PROJECT.length>0&&(o=`${H.default.env.HOMEY_LOG_SENTRY_PROJECT}@${H.default.manifest.version}`),this._manifest=H.default.manifest,this._homeyVersion=t.version,this._managerCloud=t.cloud,this._homeyPlatform=t.platform,this._homeyPlatformVersion=t.platformVersion,this.init(H.default.env.HOMEY_LOG_URL,{enabled:!r,release:o,...n})}init(t,n){return Kn({dsn:t,integrations:[Ae(),Qe(),qe(),et(),tt(),$n(),Zn(),Yn(),jn(),Hn({app:!1,cloudResource:!1})],maxBreadcrumbs:5,enableMetrics:!1,...n}),this.setTags({appId:this._manifest.id,appVersion:this._manifest.version,homeyVersion:this._homeyVersion,homeyPlatform:this._homeyPlatform,homeyPlatformVersion:this._homeyPlatformVersion}),this._managerCloud.getHomeyId().then(r=>this.setTags({homeyId:r})).catch(r=>e._error("Error: could not get `homeyId`",r)),e._log(`App ${this._manifest.id} v${this._manifest.version} logging on Homey v${this._homeyVersion}...`),this}setTags(t){return At(t),this}setUser(t){return vt(t),this}async captureMessage(t){if(e._log("captureMessage:",t),this._capturedMessages.indexOf(t)>-1){e._log("Prevented sending a duplicate message");return}return this._capturedMessages.push(t),new Promise((n,r)=>{try{n(Rt(t))}catch(o){r(o)}})}async captureException(t){if(e._log("captureException:",t),this._capturedExceptions.indexOf(t)>-1){e._log("Prevented sending a duplicate log");return}return this._capturedExceptions.push(t),new Promise((n,r)=>{try{n(te(t))}catch(o){r(o)}})}static _log(){console.log.bind(null,e._logTime(),"[homey-log]").apply(null,arguments)}static _error(){console.error.bind(null,e._logTime(),"[homey-log]").apply(null,arguments)}static _logTime(){return`\x1B[35m${new Date().toISOString()}\x1B[0m`}static _isLogForced(){switch(H.default.env.HOMEY_LOG_FORCE){case"1":case"true":return!0;default:return!1}}};0&&(module.exports={Log});
|
package/build/index.mjs
CHANGED
|
@@ -19,4 +19,4 @@ Url: ${Pt(e)}`),!0}return!1}function da(e,t){return t?.length?Ot(e).some(n=>Ee(n
|
|
|
19
19
|
`),h=m.shift();if(!h)return e.destroy(),n(new Error("No header received from proxy CONNECT response"));let S=h.split(" "),E=+(S[1]||0),x=S.slice(2).join(" "),C={};for(let G of m){if(!G)continue;let ce=G.indexOf(":");if(ce===-1)return e.destroy(),n(new Error(`Invalid header from proxy CONNECT response: "${G}"`));let ue=G.slice(0,ce).toLowerCase(),ne=G.slice(ce+1).trimStart(),O=C[ue];typeof O=="string"?C[ue]=[O,ne]:Array.isArray(O)?O.push(ne):C[ue]=ne}Gt("got proxy server response: %o %o",h,C),i(),t({connect:{statusCode:E,statusText:x,headers:C},buffered:l})}e.on("error",c),e.on("end",a),s()})}function rt(...e){p.log("[https-proxy-agent]",...e)}var ot=class extends Bt{static __initStatic(){this.protocols=["http","https"]}constructor(t,n){super(n),this.options={},this.proxy=typeof t=="string"?new URL(t):t,this.proxyHeaders=n?.headers??{},rt("Creating new HttpsProxyAgent instance: %o",this.proxy.href);let r=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),o=this.proxy.port?parseInt(this.proxy.port,10):this.proxy.protocol==="https:"?443:80;this.connectOpts={ALPNProtocols:["http/1.1"],...n?Ss(n,"headers"):null,host:r,port:o}}async connect(t,n){let{proxy:r}=this;if(!n.host)throw new TypeError('No "host" provided');let o;if(r.protocol==="https:"){rt("Creating `tls.Socket`: %o",this.connectOpts);let d=this.connectOpts.servername||this.connectOpts.host;o=Vn.connect({...this.connectOpts,servername:d&&$.isIP(d)?void 0:d})}else rt("Creating `net.Socket`: %o",this.connectOpts),o=$.connect(this.connectOpts);let s=typeof this.proxyHeaders=="function"?this.proxyHeaders():{...this.proxyHeaders},i=$.isIPv6(n.host)?`[${n.host}]`:n.host,a=`CONNECT ${i}:${n.port} HTTP/1.1\r
|
|
20
20
|
`;if(r.username||r.password){let d=`${decodeURIComponent(r.username)}:${decodeURIComponent(r.password)}`;s["Proxy-Authorization"]=`Basic ${Buffer.from(d).toString("base64")}`}s.Host=`${i}:${n.port}`,s["Proxy-Connection"]||(s["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close");for(let d of Object.keys(s))a+=`${d}: ${s[d]}\r
|
|
21
21
|
`;let c=hs(o);o.write(`${a}\r
|
|
22
|
-
`);let{connect:u,buffered:f}=await c;if(t.emit("proxyConnect",u),this.emit("proxyConnect",u,t),u.statusCode===200){if(t.once("socket",uu),n.secureEndpoint){rt("Upgrading socket connection to TLS");let d=n.servername||n.host;return Vn.connect({...Ss(n,"host","path","port"),socket:o,servername:$.isIP(d)?void 0:d})}return o}o.destroy();let l=new $.Socket({writable:!1});return l.readable=!0,t.once("socket",d=>{rt("Replaying proxy buffer for failed request"),d.push(f),d.push(null)}),l}};ot.__initStatic();function uu(e){e.resume()}function Ss(e,...t){let n={},r;for(r in e)t.includes(r)||(n[r]=e[r]);return n}var mu=1024*32;function gu(e){return new fu({read(){this.push(e),this.push(null)}})}function Es(e){let t;try{t=new URL(e.url)}catch{return b(()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")}),ze(e,()=>Promise.resolve({}))}let n=t.protocol==="https:",r=_u(t,e.proxy||(n?process.env.https_proxy:void 0)||process.env.http_proxy),o=n?lu:pu,s=e.keepAlive===void 0?!1:e.keepAlive,i=r?new ot(r):new o.Agent({keepAlive:s,maxSockets:30,timeout:2e3}),a=hu(e,e.httpModule??o,i);return ze(e,a)}function _u(e,t){let{no_proxy:n}=process.env;if(!n?.split(",").some(o=>e.host.endsWith(o)||e.hostname.endsWith(o)))return t}function hu(e,t,n){let{hostname:r,pathname:o,port:s,protocol:i,search:a}=new URL(e.url);return function(u){return new Promise((f,l)=>{Ne(()=>{let d=gu(u.body),m={...e.headers};u.body.length>mu&&(m["content-encoding"]="gzip",d=d.pipe(du()));let h=r.startsWith("["),S=t.request({method:"POST",agent:n,headers:m,hostname:h?r.slice(1,-1):r,path:`${o}${a}`,port:s,protocol:i,ca:e.caCerts},E=>{E.on("data",()=>{}),E.on("end",()=>{}),E.setEncoding("utf8");let x=E.headers["retry-after"]??null,C=E.headers["x-sentry-rate-limits"]??null;f({statusCode:E.statusCode,headers:{"retry-after":x,"x-sentry-rate-limits":Array.isArray(C)?C[0]||null:C}})});S.on("error",l),d.pipe(S)})})}}function Is(e){if(e===!1)return!1;if(typeof e=="string")return e;let t=ae(process.env.SENTRY_SPOTLIGHT,{strict:!0}),n=t===null&&process.env.SENTRY_SPOTLIGHT?process.env.SENTRY_SPOTLIGHT:void 0;return e===!0?n??!0:t??n}import{AsyncLocalStorage as Su}from"node:async_hooks";function Ts(){let e=new Su;function t(){let a=e.getStore();return a||{scope:we(),isolationScope:Be()}}function n(a){let c=t().scope.clone(),u=t().isolationScope;return e.run({scope:c,isolationScope:u},()=>a(c))}function r(a,c){let u=t().isolationScope.clone();return e.run({scope:a,isolationScope:u},()=>c(a))}function o(a){let c=t().scope.clone(),u=t().isolationScope.clone();return e.run({scope:c,isolationScope:u},()=>a(u))}function s(a,c){let u=t().scope.clone();return e.run({scope:u,isolationScope:a},()=>c(a))}function i(a){return n(c=>(c.setSDKProcessingMetadata({__SENTRY_SUPPRESS_TRACING__:!0}),a()))}rn({suppressTracing:i,withScope:n,withSetScope:r,withIsolationScope:o,withSetIsolationScope:s,getCurrentScope:()=>t().scope,getIsolationScope:()=>t().isolationScope})}function jn(e={}){return Eu(e,()=>[])}function Eu(e={},t){let n=Iu(e,t);n.debug===!0&&(N?p.enable():b(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),Ts(),R().update(n.initialScope),n.spotlight&&!n.integrations.some(({name:s})=>s===Wn)&&n.integrations.push(fs({sidecarUrl:typeof n.spotlight=="string"?n.spotlight:void 0})),Xe(n,"node-light",["node-core"]);let o=new Dt(n);return R().setClient(o),o.init(),_._sentryInjectLoaderHookRegister?.(),p.log(`SDK initialized from ${ps()?"CommonJS":"ESM"} (light mode)`),o.startClientReportTracking(),bu(),process.env.VERCEL&&process.on("SIGTERM",async()=>{await o.flush(200)}),o}function Iu(e,t){let n=Tu(e.release),r=Is(e.spotlight),o=yu(e.tracesSampleRate),s={...e,dsn:e.dsn??process.env.SENTRY_DSN,environment:e.environment??process.env.SENTRY_ENVIRONMENT,sendClientReports:e.sendClientReports??!0,transport:e.transport??Es,stackParser:jt(e.stackParser||_s),release:n,tracesSampleRate:o,spotlight:r,debug:ae(e.debug??process.env.SENTRY_DEBUG)},i=e.integrations,a=e.defaultIntegrations??t(s);return{...s,integrations:bn({defaultIntegrations:a,integrations:i})}}function Tu(e){if(e!==void 0)return e;let t=gs();if(t!==void 0)return t}function yu(e){if(e!==void 0)return e;let t=process.env.SENTRY_TRACES_SAMPLE_RATE;if(!t)return;let n=parseFloat(t);return isFinite(n)?n:void 0}function bu(){if(ae(process.env.SENTRY_USE_ENVIRONMENT)!==!1){let e=process.env.SENTRY_TRACE,t=process.env.SENTRY_BAGGAGE,n=pn(e,t);R().setPropagationContext(n)}}import Z from"homey";process.env.HOME||(process.env.HOME=Nu.tmpdir());var ys=class e{_capturedMessages=[];_capturedExceptions=[];constructor({homey:t,options:n}){if(typeof t>"u")return e._error("Error: missing `homey` constructor parameter");if(!Z.env)return e._error("Error: could not access `Homey.env`");if(typeof Z.env.HOMEY_LOG_URL!="string")return e._error("Error: expected `HOMEY_LOG_URL` env variable, homey-log is disabled");let r=process.env.DEBUG==="1"&&!e._isLogForced();r&&e._log("App is running in debug mode, not enabling Sentry logging");let o;typeof Z.env.HOMEY_LOG_SENTRY_PROJECT=="string"&&Z.env.HOMEY_LOG_SENTRY_PROJECT.length>0&&(o=`${Z.env.HOMEY_LOG_SENTRY_PROJECT}@${Z.manifest.version}`),this._manifest=Z.manifest,this._homeyVersion=t.version,this._managerCloud=t.cloud,this._homeyPlatform=t.platform,this._homeyPlatformVersion=t.platformVersion,this.init(Z.env.HOMEY_LOG_URL,{enabled:!r,release:o,...n})}init(t,n){return jn({dsn:t,integrations:[Re(),Ke(),Qe(),qe(),et(),Gn(),Hn(),kn(),Bn(),Un()],maxBreadcrumbs:5,enableMetrics:!1,...n}),this.setTags({appId:this._manifest.id,appVersion:this._manifest.version,homeyVersion:this._homeyVersion,homeyPlatform:this._homeyPlatform,homeyPlatformVersion:this._homeyPlatformVersion}),this._managerCloud.getHomeyId().then(r=>this.setTags({homeyId:r})).catch(r=>e._error("Error: could not get `homeyId`",r)),e._log(`App ${this._manifest.id} v${this._manifest.version} logging on Homey v${this._homeyVersion}...`),this}setTags(t){return Ct(t),this}setUser(t){return Rt(t),this}async captureMessage(t){if(e._log("captureMessage:",t),this._capturedMessages.indexOf(t)>-1){e._log("Prevented sending a duplicate message");return}return this._capturedMessages.push(t),new Promise((n,r)=>{try{n(Nt(t))}catch(o){r(o)}})}async captureException(t){if(e._log("captureException:",t),this._capturedExceptions.indexOf(t)>-1){e._log("Prevented sending a duplicate log");return}return this._capturedExceptions.push(t),new Promise((n,r)=>{try{n(ee(t))}catch(o){r(o)}})}static _log(){console.log.bind(null,e._logTime(),"[homey-log]").apply(null,arguments)}static _error(){console.error.bind(null,e._logTime(),"[homey-log]").apply(null,arguments)}static _logTime(){return`\x1B[35m${new Date().toISOString()}\x1B[0m`}static _isLogForced(){switch(Z.env.HOMEY_LOG_FORCE){case"1":case"true":return!0;default:return!1}}};export{ys as Log};
|
|
22
|
+
`);let{connect:u,buffered:f}=await c;if(t.emit("proxyConnect",u),this.emit("proxyConnect",u,t),u.statusCode===200){if(t.once("socket",uu),n.secureEndpoint){rt("Upgrading socket connection to TLS");let d=n.servername||n.host;return Vn.connect({...Ss(n,"host","path","port"),socket:o,servername:$.isIP(d)?void 0:d})}return o}o.destroy();let l=new $.Socket({writable:!1});return l.readable=!0,t.once("socket",d=>{rt("Replaying proxy buffer for failed request"),d.push(f),d.push(null)}),l}};ot.__initStatic();function uu(e){e.resume()}function Ss(e,...t){let n={},r;for(r in e)t.includes(r)||(n[r]=e[r]);return n}var mu=1024*32;function gu(e){return new fu({read(){this.push(e),this.push(null)}})}function Es(e){let t;try{t=new URL(e.url)}catch{return b(()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")}),ze(e,()=>Promise.resolve({}))}let n=t.protocol==="https:",r=_u(t,e.proxy||(n?process.env.https_proxy:void 0)||process.env.http_proxy),o=n?lu:pu,s=e.keepAlive===void 0?!1:e.keepAlive,i=r?new ot(r):new o.Agent({keepAlive:s,maxSockets:30,timeout:2e3}),a=hu(e,e.httpModule??o,i);return ze(e,a)}function _u(e,t){let{no_proxy:n}=process.env;if(!n?.split(",").some(o=>e.host.endsWith(o)||e.hostname.endsWith(o)))return t}function hu(e,t,n){let{hostname:r,pathname:o,port:s,protocol:i,search:a}=new URL(e.url);return function(u){return new Promise((f,l)=>{Ne(()=>{let d=gu(u.body),m={...e.headers};u.body.length>mu&&(m["content-encoding"]="gzip",d=d.pipe(du()));let h=r.startsWith("["),S=t.request({method:"POST",agent:n,headers:m,hostname:h?r.slice(1,-1):r,path:`${o}${a}`,port:s,protocol:i,ca:e.caCerts},E=>{E.on("data",()=>{}),E.on("end",()=>{}),E.setEncoding("utf8");let x=E.headers["retry-after"]??null,C=E.headers["x-sentry-rate-limits"]??null;f({statusCode:E.statusCode,headers:{"retry-after":x,"x-sentry-rate-limits":Array.isArray(C)?C[0]||null:C}})});S.on("error",l),d.pipe(S)})})}}function Is(e){if(e===!1)return!1;if(typeof e=="string")return e;let t=ae(process.env.SENTRY_SPOTLIGHT,{strict:!0}),n=t===null&&process.env.SENTRY_SPOTLIGHT?process.env.SENTRY_SPOTLIGHT:void 0;return e===!0?n??!0:t??n}import{AsyncLocalStorage as Su}from"node:async_hooks";function Ts(){let e=new Su;function t(){let a=e.getStore();return a||{scope:we(),isolationScope:Be()}}function n(a){let c=t().scope.clone(),u=t().isolationScope;return e.run({scope:c,isolationScope:u},()=>a(c))}function r(a,c){let u=t().isolationScope.clone();return e.run({scope:a,isolationScope:u},()=>c(a))}function o(a){let c=t().scope.clone(),u=t().isolationScope.clone();return e.run({scope:c,isolationScope:u},()=>a(u))}function s(a,c){let u=t().scope.clone();return e.run({scope:u,isolationScope:a},()=>c(a))}function i(a){return n(c=>(c.setSDKProcessingMetadata({__SENTRY_SUPPRESS_TRACING__:!0}),a()))}rn({suppressTracing:i,withScope:n,withSetScope:r,withIsolationScope:o,withSetIsolationScope:s,getCurrentScope:()=>t().scope,getIsolationScope:()=>t().isolationScope})}function jn(e={}){return Eu(e,()=>[])}function Eu(e={},t){let n=Iu(e,t);n.debug===!0&&(N?p.enable():b(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),Ts(),R().update(n.initialScope),n.spotlight&&!n.integrations.some(({name:s})=>s===Wn)&&n.integrations.push(fs({sidecarUrl:typeof n.spotlight=="string"?n.spotlight:void 0})),Xe(n,"node-light",["node-core"]);let o=new Dt(n);return R().setClient(o),o.init(),_._sentryInjectLoaderHookRegister?.(),p.log(`SDK initialized from ${ps()?"CommonJS":"ESM"} (light mode)`),o.startClientReportTracking(),bu(),process.env.VERCEL&&process.on("SIGTERM",async()=>{await o.flush(200)}),o}function Iu(e,t){let n=Tu(e.release),r=Is(e.spotlight),o=yu(e.tracesSampleRate),s={...e,dsn:e.dsn??process.env.SENTRY_DSN,environment:e.environment??process.env.SENTRY_ENVIRONMENT,sendClientReports:e.sendClientReports??!0,transport:e.transport??Es,stackParser:jt(e.stackParser||_s),release:n,tracesSampleRate:o,spotlight:r,debug:ae(e.debug??process.env.SENTRY_DEBUG)},i=e.integrations,a=e.defaultIntegrations??t(s);return{...s,integrations:bn({defaultIntegrations:a,integrations:i})}}function Tu(e){if(e!==void 0)return e;let t=gs();if(t!==void 0)return t}function yu(e){if(e!==void 0)return e;let t=process.env.SENTRY_TRACES_SAMPLE_RATE;if(!t)return;let n=parseFloat(t);return isFinite(n)?n:void 0}function bu(){if(ae(process.env.SENTRY_USE_ENVIRONMENT)!==!1){let e=process.env.SENTRY_TRACE,t=process.env.SENTRY_BAGGAGE,n=pn(e,t);R().setPropagationContext(n)}}import Z from"homey";process.env.HOME||(process.env.HOME=Nu.tmpdir());var ys=class e{_capturedMessages=[];_capturedExceptions=[];constructor({homey:t,options:n}){if(typeof t>"u")return e._error("Error: missing `homey` constructor parameter");if(!Z.env)return e._error("Error: could not access `Homey.env`");if(typeof Z.env.HOMEY_LOG_URL!="string")return e._error("Error: expected `HOMEY_LOG_URL` env variable, homey-log is disabled");let r=process.env.DEBUG==="1"&&!e._isLogForced();r&&e._log("App is running in debug mode, not enabling Sentry logging");let o;typeof Z.env.HOMEY_LOG_SENTRY_PROJECT=="string"&&Z.env.HOMEY_LOG_SENTRY_PROJECT.length>0&&(o=`${Z.env.HOMEY_LOG_SENTRY_PROJECT}@${Z.manifest.version}`),this._manifest=Z.manifest,this._homeyVersion=t.version,this._managerCloud=t.cloud,this._homeyPlatform=t.platform,this._homeyPlatformVersion=t.platformVersion,this.init(Z.env.HOMEY_LOG_URL,{enabled:!r,release:o,...n})}init(t,n){return jn({dsn:t,integrations:[Re(),Ke(),Qe(),qe(),et(),Gn(),Hn(),kn(),Bn(),Un({app:!1,cloudResource:!1})],maxBreadcrumbs:5,enableMetrics:!1,...n}),this.setTags({appId:this._manifest.id,appVersion:this._manifest.version,homeyVersion:this._homeyVersion,homeyPlatform:this._homeyPlatform,homeyPlatformVersion:this._homeyPlatformVersion}),this._managerCloud.getHomeyId().then(r=>this.setTags({homeyId:r})).catch(r=>e._error("Error: could not get `homeyId`",r)),e._log(`App ${this._manifest.id} v${this._manifest.version} logging on Homey v${this._homeyVersion}...`),this}setTags(t){return Ct(t),this}setUser(t){return Rt(t),this}async captureMessage(t){if(e._log("captureMessage:",t),this._capturedMessages.indexOf(t)>-1){e._log("Prevented sending a duplicate message");return}return this._capturedMessages.push(t),new Promise((n,r)=>{try{n(Nt(t))}catch(o){r(o)}})}async captureException(t){if(e._log("captureException:",t),this._capturedExceptions.indexOf(t)>-1){e._log("Prevented sending a duplicate log");return}return this._capturedExceptions.push(t),new Promise((n,r)=>{try{n(ee(t))}catch(o){r(o)}})}static _log(){console.log.bind(null,e._logTime(),"[homey-log]").apply(null,arguments)}static _error(){console.error.bind(null,e._logTime(),"[homey-log]").apply(null,arguments)}static _logTime(){return`\x1B[35m${new Date().toISOString()}\x1B[0m`}static _isLogForced(){switch(Z.env.HOMEY_LOG_FORCE){case"1":case"true":return!0;default:return!1}}};export{ys as Log};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drenso/homey-log",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.3900.0",
|
|
4
4
|
"description": "Interface with Sentry for Homey",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"module": "./build/index.mjs",
|
|
@@ -31,21 +31,21 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/Drenso/homey-log#readme",
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@eslint/js": "
|
|
34
|
+
"@eslint/js": "10.0.1",
|
|
35
35
|
"@sentry/node-core": "10.39.0",
|
|
36
36
|
"@types/homey": "npm:homey-apps-sdk-v3-types@0.3.12",
|
|
37
37
|
"@types/node": "24.10.13",
|
|
38
38
|
"esbuild": "0.27.3",
|
|
39
|
-
"eslint": "
|
|
39
|
+
"eslint": "10.0.0",
|
|
40
40
|
"eslint-config-prettier": "10.1.8",
|
|
41
|
-
"globals": "
|
|
41
|
+
"globals": "17.3.0",
|
|
42
42
|
"homey": "3.12.2",
|
|
43
43
|
"jsdoc": "4.0.5",
|
|
44
44
|
"jsdoc-ts-utils": "6.0.0",
|
|
45
45
|
"npm-watch": "0.13.0",
|
|
46
46
|
"prettier": "3.8.1",
|
|
47
47
|
"serve": "14.2.5",
|
|
48
|
-
"typescript": "
|
|
48
|
+
"typescript": "5.9.3",
|
|
49
49
|
"watch": "1.0.2",
|
|
50
50
|
"ws": "8.19.0"
|
|
51
51
|
},
|