@royaltics/tracker-sails 0.0.24 → 0.0.25
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/dist/index.cjs +1 -1
- package/dist/index.js +10 -10
- package/dist/types/index.d.ts +3 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const a=require("@royaltics/tracker");module.exports=function(t){let e;return{defaults:{__configKey__:{enabled:!0,webhookUrl:"N/A",licenseId:"",licenseDevice:"",licenseName:"",app:"sails-app",version:"",platform:"sails",maxRetries:3,timeout:1e4,debug:!1,flushInterval:1e4,maxQueueSize:100,headers:{}}},initialize:function(n){const u=t.config.tracker||{};if(!u.enabled)return t.log.warn("@royaltics/tracker-sails hook deactivated"),n();if(!u.webhookUrl)return t.log.error("DSN for @royaltics/tracker-sails is required in config/tracker.js"),n();try{if(e=a.Tracker.create(u),!e)return t.log.error("@royaltics/tracker failed to initialize"),n();t.tracker={error:(r,i)=>e.error(r,"ERROR",i),fatal:(r,i)=>e.error(r,"FATAL",i),debug:(r,i)=>e.error(r,"DEBUG",i),capture:(r,i)=>e.error(r,"ERROR",i),info:(r,i)=>e.event(r,"INFO",i),warn:(r,i)=>e.event(r,"WARNING",i),event:(r,i,c)=>e.event(r,i,c),flush:async()=>await e.forceFlush(),pause:()=>e.pause(),resume:()=>e.resume(),shutdown:()=>e.shutdown()},process.on("unhandledRejection",function(r){u.debug&&t.log.info("Unhandled rejection:",r),e==null||e.error(r instanceof Error?r:new Error(String(r)))}),u.captureRoutes&&e&&l(t,e,u),u.debug&&t.log.info("@royaltics/tracker-sails initialized successfully")}catch(r){u.debug&&t.log.error("Failed to initialize @royaltics/tracker-sails:",r)}return n()},shutdown:function(n){e&&a.Tracker.shutdown(),n()}}};function l(o,t,e){o.on&&(o.on("router:request",(n,u)=>{if(d(n.url,["https://sailsjs.com","https://api.royaltics.com"]))return;const r=s(n,e);t.event("Request received","INFO",{request:r})}),o.on("router:request:error",(n,u)=>{if(e.ignoredErrors||f(n,["SailsError","RoyalticsError"]))return;const r=s(u,e);t.error(n,"ERROR",{request:r})}))}function s(o,t){return{method:o.method??"UNKNOWN",url:o.url??"UNKNOWN",ip:o.ip,headers:t.captureHeaders?o.headers:void 0,query:t.captureQueries?o.query:void 0,body:t.captureQueries?o.body:void 0}}function d(o,t){return t?t.some(e=>new RegExp(e).test(o)):!1}function f(o,t){return t?t.some(e=>{const n=new RegExp(e);return n.test(o.name)||n.test(o.message)}):!1}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var d = (o, e) => () => (e || o((e = { exports: {} }).exports, e), e.exports);
|
|
2
|
-
import { Tracker as
|
|
3
|
-
var g = d((y,
|
|
4
|
-
|
|
2
|
+
import { Tracker as a } from "@royaltics/tracker";
|
|
3
|
+
var g = d((y, c) => {
|
|
4
|
+
c.exports = function(e) {
|
|
5
5
|
let r;
|
|
6
6
|
return {
|
|
7
7
|
defaults: {
|
|
@@ -29,16 +29,16 @@ var g = d((y, l) => {
|
|
|
29
29
|
if (!u.webhookUrl)
|
|
30
30
|
return e.log.error("DSN for @royaltics/tracker-sails is required in config/tracker.js"), n();
|
|
31
31
|
try {
|
|
32
|
-
if (r =
|
|
32
|
+
if (r = a.create(u), !r)
|
|
33
33
|
return e.log.error("@royaltics/tracker failed to initialize"), n();
|
|
34
34
|
e.tracker = {
|
|
35
35
|
error: (t, i) => r.error(t, "ERROR", i),
|
|
36
36
|
fatal: (t, i) => r.error(t, "FATAL", i),
|
|
37
37
|
debug: (t, i) => r.error(t, "DEBUG", i),
|
|
38
|
-
capture: (t, i
|
|
38
|
+
capture: (t, i) => r.error(t, "ERROR", i),
|
|
39
39
|
info: (t, i) => r.event(t, "INFO", i),
|
|
40
40
|
warn: (t, i) => r.event(t, "WARNING", i),
|
|
41
|
-
event: (t, i,
|
|
41
|
+
event: (t, i, l) => r.event(t, i, l),
|
|
42
42
|
flush: async () => await r.forceFlush(),
|
|
43
43
|
pause: () => r.pause(),
|
|
44
44
|
resume: () => r.resume(),
|
|
@@ -52,22 +52,22 @@ var g = d((y, l) => {
|
|
|
52
52
|
return n();
|
|
53
53
|
},
|
|
54
54
|
shutdown: function(n) {
|
|
55
|
-
r &&
|
|
55
|
+
r && a.shutdown(), n();
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
59
|
function f(o, e, r) {
|
|
60
60
|
o.on && (o.on("router:request", (n, u) => {
|
|
61
61
|
if (h(n.url, ["https://sailsjs.com", "https://api.royaltics.com"])) return;
|
|
62
|
-
const t =
|
|
62
|
+
const t = s(n, r);
|
|
63
63
|
e.event("Request received", "INFO", { request: t });
|
|
64
64
|
}), o.on("router:request:error", (n, u) => {
|
|
65
65
|
if (r.ignoredErrors || p(n, ["SailsError", "RoyalticsError"])) return;
|
|
66
|
-
const t =
|
|
66
|
+
const t = s(u, r);
|
|
67
67
|
e.error(n, "ERROR", { request: t });
|
|
68
68
|
}));
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function s(o, e) {
|
|
71
71
|
return {
|
|
72
72
|
method: o.method ?? "UNKNOWN",
|
|
73
73
|
url: o.url ?? "UNKNOWN",
|
package/dist/types/index.d.ts
CHANGED
|
@@ -30,7 +30,9 @@ export interface SailsHookContext {
|
|
|
30
30
|
info: (message: string, ...args: unknown[]) => void;
|
|
31
31
|
};
|
|
32
32
|
on?: (event: string, handler: (...args: any[]) => void) => void;
|
|
33
|
-
tracker?: SailsTrackerClient
|
|
33
|
+
tracker?: Omit<SailsTrackerClient, 'capture'> & {
|
|
34
|
+
capture: (error: Error | Record<string, unknown>, metadata?: Record<string, unknown>) => ErrorTrackerClient;
|
|
35
|
+
};
|
|
34
36
|
};
|
|
35
37
|
}
|
|
36
38
|
export interface RequestContext {
|