@royaltics/tracker-sails 0.0.23 → 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 CHANGED
@@ -1 +1 @@
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,flushInterval:1e4,maxQueueSize:100,headers:{}}},initialize:function(i){const n=t.config.tracker||{};if(!n.enabled)return t.log.warn("@royaltics/tracker-sails hook deactivated"),i();if(!n.webhookUrl)return t.log.error("DSN for @royaltics/tracker-sails is required in config/tracker.js"),i();try{n.debug&&t.log.info("Initializing @royaltics/tracker-sails..."),console.log(a.Tracker),e=a.Tracker.create(n),t.tracker={error:(r,u)=>e.error(r,"ERROR",u),fatal:(r,u)=>e.error(r,"FATAL",u),debug:(r,u)=>e.error(r,"DEBUG",u),capture:(r,u,s)=>e.error(r,u,s),info:(r,u)=>e.event(r,"INFO",u),warn:(r,u)=>e.event(r,"WARNING",u),event:(r,u,s)=>e.event(r,u,s),flush:async()=>await e.forceFlush(),pause:()=>e.pause(),resume:()=>e.resume(),shutdown:()=>e.shutdown()},n.debug&&t.log.info("@royaltics/tracker-sails initialized successfully"),process.on("unhandledRejection",function(r){n.debug&&t.log.info("Unhandled rejection:",r),e==null||e.error(r instanceof Error?r:new Error(String(r)))}),n.captureRoutes&&e&&l(t,e,n),n.debug&&t.log.info("@royaltics/tracker-sails initialized successfully")}catch(r){n.debug&&t.log.error("Failed to initialize @royaltics/tracker-sails:",r)}return i()},shutdown:function(i){e&&a.Tracker.shutdown(),i()}}};function l(o,t,e){o.on&&(o.on("router:request",(i,n)=>{if(d(i.url,["https://sailsjs.com","https://api.royaltics.com"]))return;const r=c(i,e);t.event("Request received","INFO",{request:r})}),o.on("router:request:error",(i,n)=>{if(e.ignoredErrors||f(i,["SailsError","RoyalticsError"]))return;const r=c(n,e);t.error(i,"ERROR",{request:r})}))}function c(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 i=new RegExp(e);return i.test(o.name)||i.test(o.message)}):!1}
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
2
  import { Tracker as a } from "@royaltics/tracker";
3
- var p = d((R, l) => {
4
- l.exports = function(e) {
3
+ var g = d((y, c) => {
4
+ c.exports = function(e) {
5
5
  let r;
6
6
  return {
7
7
  defaults: {
@@ -16,55 +16,58 @@ var p = d((R, l) => {
16
16
  platform: "sails",
17
17
  maxRetries: 3,
18
18
  timeout: 1e4,
19
+ debug: !1,
19
20
  flushInterval: 1e4,
20
21
  maxQueueSize: 100,
21
22
  headers: {}
22
23
  }
23
24
  },
24
- initialize: function(i) {
25
- const n = e.config.tracker || {};
26
- if (!n.enabled)
27
- return e.log.warn("@royaltics/tracker-sails hook deactivated"), i();
28
- if (!n.webhookUrl)
29
- return e.log.error("DSN for @royaltics/tracker-sails is required in config/tracker.js"), i();
25
+ initialize: function(n) {
26
+ const u = e.config.tracker || {};
27
+ if (!u.enabled)
28
+ return e.log.warn("@royaltics/tracker-sails hook deactivated"), n();
29
+ if (!u.webhookUrl)
30
+ return e.log.error("DSN for @royaltics/tracker-sails is required in config/tracker.js"), n();
30
31
  try {
31
- n.debug && e.log.info("Initializing @royaltics/tracker-sails..."), console.log(a), r = a.create(n), e.tracker = {
32
- error: (t, u) => r.error(t, "ERROR", u),
33
- fatal: (t, u) => r.error(t, "FATAL", u),
34
- debug: (t, u) => r.error(t, "DEBUG", u),
35
- capture: (t, u, s) => r.error(t, u, s),
36
- info: (t, u) => r.event(t, "INFO", u),
37
- warn: (t, u) => r.event(t, "WARNING", u),
38
- event: (t, u, s) => r.event(t, u, s),
32
+ if (r = a.create(u), !r)
33
+ return e.log.error("@royaltics/tracker failed to initialize"), n();
34
+ e.tracker = {
35
+ error: (t, i) => r.error(t, "ERROR", i),
36
+ fatal: (t, i) => r.error(t, "FATAL", i),
37
+ debug: (t, i) => r.error(t, "DEBUG", i),
38
+ capture: (t, i) => r.error(t, "ERROR", i),
39
+ info: (t, i) => r.event(t, "INFO", i),
40
+ warn: (t, i) => r.event(t, "WARNING", i),
41
+ event: (t, i, l) => r.event(t, i, l),
39
42
  flush: async () => await r.forceFlush(),
40
43
  pause: () => r.pause(),
41
44
  resume: () => r.resume(),
42
45
  shutdown: () => r.shutdown()
43
- }, n.debug && e.log.info("@royaltics/tracker-sails initialized successfully"), process.on("unhandledRejection", function(t) {
44
- n.debug && e.log.info("Unhandled rejection:", t), r == null || r.error(t instanceof Error ? t : new Error(String(t)));
45
- }), n.captureRoutes && r && f(e, r, n), n.debug && e.log.info("@royaltics/tracker-sails initialized successfully");
46
+ }, process.on("unhandledRejection", function(t) {
47
+ u.debug && e.log.info("Unhandled rejection:", t), r == null || r.error(t instanceof Error ? t : new Error(String(t)));
48
+ }), u.captureRoutes && r && f(e, r, u), u.debug && e.log.info("@royaltics/tracker-sails initialized successfully");
46
49
  } catch (t) {
47
- n.debug && e.log.error("Failed to initialize @royaltics/tracker-sails:", t);
50
+ u.debug && e.log.error("Failed to initialize @royaltics/tracker-sails:", t);
48
51
  }
49
- return i();
52
+ return n();
50
53
  },
51
- shutdown: function(i) {
52
- r && a.shutdown(), i();
54
+ shutdown: function(n) {
55
+ r && a.shutdown(), n();
53
56
  }
54
57
  };
55
58
  };
56
59
  function f(o, e, r) {
57
- o.on && (o.on("router:request", (i, n) => {
58
- if (g(i.url, ["https://sailsjs.com", "https://api.royaltics.com"])) return;
59
- const t = c(i, r);
60
+ o.on && (o.on("router:request", (n, u) => {
61
+ if (h(n.url, ["https://sailsjs.com", "https://api.royaltics.com"])) return;
62
+ const t = s(n, r);
60
63
  e.event("Request received", "INFO", { request: t });
61
- }), o.on("router:request:error", (i, n) => {
62
- if (r.ignoredErrors || h(i, ["SailsError", "RoyalticsError"])) return;
63
- const t = c(n, r);
64
- e.error(i, "ERROR", { request: t });
64
+ }), o.on("router:request:error", (n, u) => {
65
+ if (r.ignoredErrors || p(n, ["SailsError", "RoyalticsError"])) return;
66
+ const t = s(u, r);
67
+ e.error(n, "ERROR", { request: t });
65
68
  }));
66
69
  }
67
- function c(o, e) {
70
+ function s(o, e) {
68
71
  return {
69
72
  method: o.method ?? "UNKNOWN",
70
73
  url: o.url ?? "UNKNOWN",
@@ -74,14 +77,14 @@ var p = d((R, l) => {
74
77
  body: e.captureQueries ? o.body : void 0
75
78
  };
76
79
  }
77
- function g(o, e) {
80
+ function h(o, e) {
78
81
  return e ? e.some((r) => new RegExp(r).test(o)) : !1;
79
82
  }
80
- function h(o, e) {
83
+ function p(o, e) {
81
84
  return e ? e.some((r) => {
82
- const i = new RegExp(r);
83
- return i.test(o.name) || i.test(o.message);
85
+ const n = new RegExp(r);
86
+ return n.test(o.name) || n.test(o.message);
84
87
  }) : !1;
85
88
  }
86
89
  });
87
- export default p();
90
+ export default g();
@@ -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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@royaltics/tracker-sails",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "description": "Sails.js hook for Royaltics Error Tracker",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",