@adalo/metrics 0.1.62 → 0.1.63

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.
@@ -1,20 +1,22 @@
1
1
  /**
2
- * Creates a configured setClientName function.
2
+ * Creates a configured setClientName function for node-redis v3.
3
3
  *
4
4
  * @param {string} [defaultAppName='undefined-app'] - Fallback app name if METRICS_APP_NAME is not set.
5
- * @returns {(client: import('redis').RedisClient, name: string) => void}
5
+ * @returns {(client: any, name: string) => void}
6
6
  */
7
- export function createSetClientNameForRedisV3(defaultAppName?: string | undefined): (client: import('redis').RedisClient, name: string) => void;
7
+ export function createSetClientNameForRedisV3(defaultAppName?: string | undefined): (client: any, name: string) => void;
8
8
  /**
9
- * Creates a function to set Redis client name for node-redis v4
10
- * @param {string} defaultAppName
11
- * @returns {(client: ReturnType<createClient>, name: string) => void}
9
+ * Creates a function to set Redis client name for node-redis v4.
10
+ *
11
+ * @param {string} [defaultAppName='undefined-app']
12
+ * @returns {(client: any, name: string) => void}
12
13
  */
13
- export function createSetClientNameForRedisV4(defaultAppName?: string): (client: ReturnType<createClient>, name: string) => void;
14
+ export function createSetClientNameForRedisV4(defaultAppName?: string | undefined): (client: any, name: string) => void;
14
15
  /**
15
- * Creates a function to set Redis client name for ioredis
16
- * @param {string} defaultAppName
17
- * @returns {(client: Redis, name: string) => void}
16
+ * Creates a function to set Redis client name for ioredis.
17
+ *
18
+ * @param {string} [defaultAppName='undefined-app']
19
+ * @returns {(client: any, name: string) => void}
18
20
  */
19
- export function createSetClientNameForIoredis(defaultAppName?: string): (client: Redis, name: string) => void;
21
+ export function createSetClientNameForIoredis(defaultAppName?: string | undefined): (client: any, name: string) => void;
20
22
  //# sourceMappingURL=redisUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"redisUtils.d.ts","sourceRoot":"","sources":["../src/redisUtils.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,6FAFsB,OAAO,OAAO,EAAE,WAAW,QAAQ,MAAM,KAAK,IAAI,CAuBvE;AA2BD;;;;GAIG;AACH,+DAHW,MAAM,YACK,wBAAwB,QAAQ,MAAM,KAAK,IAAI,CAsBpE;AAlDD;;;;GAIG;AACH,+DAHW,MAAM,yBACkB,MAAM,KAAK,IAAI,CAoBjD"}
1
+ {"version":3,"file":"redisUtils.d.ts","sourceRoot":"","sources":["../src/redisUtils.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,6FAFsB,GAAG,QAAQ,MAAM,KAAK,IAAI,CAuB/C;AA4BD;;;;;GAKG;AACH,6FAFsB,GAAG,QAAQ,MAAM,KAAK,IAAI,CAsB/C;AApDD;;;;;GAKG;AACH,6FAFsB,GAAG,QAAQ,MAAM,KAAK,IAAI,CAoB/C"}
package/lib/redisUtils.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
 
3
3
  /**
4
- * Creates a configured setClientName function.
4
+ * Creates a configured setClientName function for node-redis v3.
5
5
  *
6
6
  * @param {string} [defaultAppName='undefined-app'] - Fallback app name if METRICS_APP_NAME is not set.
7
- * @returns {(client: import('redis').RedisClient, name: string) => void}
7
+ * @returns {(client: any, name: string) => void}
8
8
  */
9
9
  const createSetClientNameForRedisV3 = (defaultAppName = 'undefined-app') => {
10
10
  return (client, name) => {
@@ -25,9 +25,10 @@ const createSetClientNameForRedisV3 = (defaultAppName = 'undefined-app') => {
25
25
  };
26
26
 
27
27
  /**
28
- * Creates a function to set Redis client name for ioredis
29
- * @param {string} defaultAppName
30
- * @returns {(client: Redis, name: string) => void}
28
+ * Creates a function to set Redis client name for ioredis.
29
+ *
30
+ * @param {string} [defaultAppName='undefined-app']
31
+ * @returns {(client: any, name: string) => void}
31
32
  */
32
33
  const createSetClientNameForIoredis = (defaultAppName = 'undefined-app') => {
33
34
  return (client, name) => {
@@ -46,9 +47,10 @@ const createSetClientNameForIoredis = (defaultAppName = 'undefined-app') => {
46
47
  };
47
48
 
48
49
  /**
49
- * Creates a function to set Redis client name for node-redis v4
50
- * @param {string} defaultAppName
51
- * @returns {(client: ReturnType<createClient>, name: string) => void}
50
+ * Creates a function to set Redis client name for node-redis v4.
51
+ *
52
+ * @param {string} [defaultAppName='undefined-app']
53
+ * @returns {(client: any, name: string) => void}
52
54
  */
53
55
  const createSetClientNameForRedisV4 = (defaultAppName = 'undefined-app') => {
54
56
  return (client, name) => {
@@ -1 +1 @@
1
- {"version":3,"file":"redisUtils.js","names":["createSetClientNameForRedisV3","defaultAppName","client","name","appName","process","env","METRICS_APP_NAME","dyno","BUILD_DYNO_PROCESS_TYPE","NODE_ENV","on","send_command","err","console","error","log","pid","createSetClientNameForIoredis","once","call","then","catch","createSetClientNameForRedisV4","sendCommand","module","exports"],"sources":["../src/redisUtils.js"],"sourcesContent":["/**\n * Creates a configured setClientName function.\n *\n * @param {string} [defaultAppName='undefined-app'] - Fallback app name if METRICS_APP_NAME is not set.\n * @returns {(client: import('redis').RedisClient, name: string) => void}\n */\nconst createSetClientNameForRedisV3 = (defaultAppName = 'undefined-app') => {\n return (client, name) => {\n const appName = process.env.METRICS_APP_NAME || defaultAppName\n const dyno = process.env.BUILD_DYNO_PROCESS_TYPE || 'undefined-dyno'\n\n if (process.env.NODE_ENV !== 'test') {\n client.on('connect', () => {\n client.send_command(\n 'CLIENT',\n ['SETNAME', `${appName}:${dyno}:${name}`],\n err => {\n if (err) {\n console.error(`Failed to set client name for ${name}:`, err)\n } else {\n console.log(`Connected to Redis for pid:${process.pid} (${name})`)\n }\n }\n )\n })\n }\n }\n}\n\n/**\n * Creates a function to set Redis client name for ioredis\n * @param {string} defaultAppName\n * @returns {(client: Redis, name: string) => void}\n */\nconst createSetClientNameForIoredis = (defaultAppName = 'undefined-app') => {\n return (client, name) => {\n const appName = process.env.METRICS_APP_NAME || defaultAppName\n const dyno = process.env.BUILD_DYNO_PROCESS_TYPE || 'undefined-dyno'\n\n if (process.env.NODE_ENV !== 'test') {\n client.once('connect', () => {\n client\n .call('CLIENT', ['SETNAME', `${appName}:${dyno}:${name}`])\n .then(() => {\n console.log(`Connected to Redis for pid:${process.pid} (${name})`)\n })\n .catch(err => {\n console.error(`Failed to set client name for ${name}:`, err)\n })\n })\n }\n }\n}\n\n/**\n * Creates a function to set Redis client name for node-redis v4\n * @param {string} defaultAppName\n * @returns {(client: ReturnType<createClient>, name: string) => void}\n */\nconst createSetClientNameForRedisV4 = (defaultAppName = 'undefined-app') => {\n return (client, name) => {\n const appName = process.env.METRICS_APP_NAME || defaultAppName\n const dyno = process.env.BUILD_DYNO_PROCESS_TYPE || 'undefined-dyno'\n\n if (process.env.NODE_ENV !== 'test') {\n client.on('ready', async () => {\n try {\n await client.sendCommand([\n 'CLIENT',\n 'SETNAME',\n `${appName}:${dyno}:${name}`,\n ])\n console.log(`Connected to Redis for pid:${process.pid} (${name})`)\n } catch (err) {\n console.error(`Failed to set client name for ${name}:`, err)\n }\n })\n }\n }\n}\n\nmodule.exports = {\n createSetClientNameForRedisV3,\n createSetClientNameForRedisV4,\n createSetClientNameForIoredis,\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,6BAA6B,GAAGA,CAACC,cAAc,GAAG,eAAe,KAAK;EAC1E,OAAO,CAACC,MAAM,EAAEC,IAAI,KAAK;IACvB,MAAMC,OAAO,GAAGC,OAAO,CAACC,GAAG,CAACC,gBAAgB,IAAIN,cAAc;IAC9D,MAAMO,IAAI,GAAGH,OAAO,CAACC,GAAG,CAACG,uBAAuB,IAAI,gBAAgB;IAEpE,IAAIJ,OAAO,CAACC,GAAG,CAACI,QAAQ,KAAK,MAAM,EAAE;MACnCR,MAAM,CAACS,EAAE,CAAC,SAAS,EAAE,MAAM;QACzBT,MAAM,CAACU,YAAY,CACjB,QAAQ,EACR,CAAC,SAAS,EAAE,GAAGR,OAAO,IAAII,IAAI,IAAIL,IAAI,EAAE,CAAC,EACzCU,GAAG,IAAI;UACL,IAAIA,GAAG,EAAE;YACPC,OAAO,CAACC,KAAK,CAAC,iCAAiC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I,GAAGH,OAAO,CAACC,GAAG,CAACG,uBAAuB,IAAI,gBAAgB;IAEpE,IAAIJ,OAAO,CAACC,GAAG,CAACI,QAAQ,KAAK,MAAM,EAAE;MACnCR,MAAM,CAACS,EAAE,CAAC,OAAO,EAAE,YAAY;QAC7B,IAAI;UACF,MAAMT,MAAM,CAACsB,WAAW,CAAC,CACvB,QAAQ,EACR,SAAS,EACT,GAAGpB,OAAO,IAAII,IAAI,IAAIL,IAAI,EAAE,CAC7B,CAAC;UACFW,OAAO,CAACE,GAAG,CAAC,8BAA8BX,OAAO,CAACY,GAAG,KAAKd,IAAI,GAAG,CAAC;QACpE,CAAC,CAAC,OAAOU,GAAG,EAAE;UACZC,OAAO,CAACC,KAAK,CAAC,iCAAiCZ,IAAI,GAAG,EAAEU,GAAG,CAAC;QAC9D;MACF,CAAC,CAAC;IACJ;EACF,CAAC;AACH,CAAC;AAEDY,MAAM,CAACC,OAAO,GAAG;EACf1B,6BAA6B;EAC7BuB,6BAA6B;EAC7BL;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"redisUtils.js","names":["createSetClientNameForRedisV3","defaultAppName","client","name","appName","process","env","METRICS_APP_NAME","dyno","BUILD_DYNO_PROCESS_TYPE","NODE_ENV","on","send_command","err","console","error","log","pid","createSetClientNameForIoredis","once","call","then","catch","createSetClientNameForRedisV4","sendCommand","module","exports"],"sources":["../src/redisUtils.js"],"sourcesContent":["/**\n * Creates a configured setClientName function for node-redis v3.\n *\n * @param {string} [defaultAppName='undefined-app'] - Fallback app name if METRICS_APP_NAME is not set.\n * @returns {(client: any, name: string) => void}\n */\nconst createSetClientNameForRedisV3 = (defaultAppName = 'undefined-app') => {\n return (client, name) => {\n const appName = process.env.METRICS_APP_NAME || defaultAppName\n const dyno = process.env.BUILD_DYNO_PROCESS_TYPE || 'undefined-dyno'\n\n if (process.env.NODE_ENV !== 'test') {\n client.on('connect', () => {\n client.send_command(\n 'CLIENT',\n ['SETNAME', `${appName}:${dyno}:${name}`],\n err => {\n if (err) {\n console.error(`Failed to set client name for ${name}:`, err)\n } else {\n console.log(`Connected to Redis for pid:${process.pid} (${name})`)\n }\n }\n )\n })\n }\n }\n}\n\n/**\n * Creates a function to set Redis client name for ioredis.\n *\n * @param {string} [defaultAppName='undefined-app']\n * @returns {(client: any, name: string) => void}\n */\nconst createSetClientNameForIoredis = (defaultAppName = 'undefined-app') => {\n return (client, name) => {\n const appName = process.env.METRICS_APP_NAME || defaultAppName\n const dyno = process.env.BUILD_DYNO_PROCESS_TYPE || 'undefined-dyno'\n\n if (process.env.NODE_ENV !== 'test') {\n client.once('connect', () => {\n client\n .call('CLIENT', ['SETNAME', `${appName}:${dyno}:${name}`])\n .then(() => {\n console.log(`Connected to Redis for pid:${process.pid} (${name})`)\n })\n .catch(err => {\n console.error(`Failed to set client name for ${name}:`, err)\n })\n })\n }\n }\n}\n\n/**\n * Creates a function to set Redis client name for node-redis v4.\n *\n * @param {string} [defaultAppName='undefined-app']\n * @returns {(client: any, name: string) => void}\n */\nconst createSetClientNameForRedisV4 = (defaultAppName = 'undefined-app') => {\n return (client, name) => {\n const appName = process.env.METRICS_APP_NAME || defaultAppName\n const dyno = process.env.BUILD_DYNO_PROCESS_TYPE || 'undefined-dyno'\n\n if (process.env.NODE_ENV !== 'test') {\n client.on('ready', async () => {\n try {\n await client.sendCommand([\n 'CLIENT',\n 'SETNAME',\n `${appName}:${dyno}:${name}`,\n ])\n console.log(`Connected to Redis for pid:${process.pid} (${name})`)\n } catch (err) {\n console.error(`Failed to set client name for ${name}:`, err)\n }\n })\n }\n }\n}\n\nmodule.exports = {\n createSetClientNameForRedisV3,\n createSetClientNameForRedisV4,\n createSetClientNameForIoredis,\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,6BAA6B,GAAGA,CAACC,cAAc,GAAG,eAAe,KAAK;EAC1E,OAAO,CAACC,MAAM,EAAEC,IAAI,KAAK;IACvB,MAAMC,OAAO,GAAGC,OAAO,C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d,IAAI,GAAG,CAAC;QACpE,CAAC,CAAC,CACDmB,KAAK,CAACT,GAAG,IAAI;UACZC,OAAO,CAACC,KAAK,CAAC,iCAAiCZ,IAAI,GAAG,EAAEU,GAAG,CAAC;QAC9D,CAAC,CAAC;MACN,CAAC,CAAC;IACJ;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMU,6BAA6B,GAAGA,CAACtB,cAAc,GAAG,eAAe,KAAK;EAC1E,OAAO,CAACC,MAAM,EAAEC,IAAI,KAAK;IACvB,MAAMC,OAAO,GAAGC,OAAO,CAACC,GAAG,CAACC,gBAAgB,IAAIN,cAAc;IAC9D,MAAMO,IAAI,GAAGH,OAAO,CAACC,GAAG,CAACG,uBAAuB,IAAI,gBAAgB;IAEpE,IAAIJ,OAAO,CAACC,GAAG,CAACI,QAAQ,KAAK,MAAM,EAAE;MACnCR,MAAM,CAACS,EAAE,CAAC,OAAO,EAAE,YAAY;QAC7B,IAAI;UACF,MAAMT,MAAM,CAACsB,WAAW,CAAC,CACvB,QAAQ,EACR,SAAS,EACT,GAAGpB,OAAO,IAAII,IAAI,IAAIL,IAAI,EAAE,CAC7B,CAAC;UACFW,OAAO,CAACE,GAAG,CAAC,8BAA8BX,OAAO,CAACY,GAAG,KAAKd,IAAI,GAAG,CAAC;QACpE,CAAC,CAAC,OAAOU,GAAG,EAAE;UACZC,OAAO,CAACC,KAAK,CAAC,iCAAiCZ,IAAI,GAAG,EAAEU,GAAG,CAAC;QAC9D;MACF,CAAC,CAAC;IACJ;EACF,CAAC;AACH,CAAC;AAEDY,MAAM,CAACC,OAAO,GAAG;EACf1B,6BAA6B;EAC7BuB,6BAA6B;EAC7BL;AACF,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adalo/metrics",
3
- "version": "0.1.62",
3
+ "version": "0.1.63",
4
4
  "description": "Reusable metrics utilities for Node.js and Laravel apps",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/redisUtils.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Creates a configured setClientName function.
2
+ * Creates a configured setClientName function for node-redis v3.
3
3
  *
4
4
  * @param {string} [defaultAppName='undefined-app'] - Fallback app name if METRICS_APP_NAME is not set.
5
- * @returns {(client: import('redis').RedisClient, name: string) => void}
5
+ * @returns {(client: any, name: string) => void}
6
6
  */
7
7
  const createSetClientNameForRedisV3 = (defaultAppName = 'undefined-app') => {
8
8
  return (client, name) => {
@@ -28,9 +28,10 @@ const createSetClientNameForRedisV3 = (defaultAppName = 'undefined-app') => {
28
28
  }
29
29
 
30
30
  /**
31
- * Creates a function to set Redis client name for ioredis
32
- * @param {string} defaultAppName
33
- * @returns {(client: Redis, name: string) => void}
31
+ * Creates a function to set Redis client name for ioredis.
32
+ *
33
+ * @param {string} [defaultAppName='undefined-app']
34
+ * @returns {(client: any, name: string) => void}
34
35
  */
35
36
  const createSetClientNameForIoredis = (defaultAppName = 'undefined-app') => {
36
37
  return (client, name) => {
@@ -53,9 +54,10 @@ const createSetClientNameForIoredis = (defaultAppName = 'undefined-app') => {
53
54
  }
54
55
 
55
56
  /**
56
- * Creates a function to set Redis client name for node-redis v4
57
- * @param {string} defaultAppName
58
- * @returns {(client: ReturnType<createClient>, name: string) => void}
57
+ * Creates a function to set Redis client name for node-redis v4.
58
+ *
59
+ * @param {string} [defaultAppName='undefined-app']
60
+ * @returns {(client: any, name: string) => void}
59
61
  */
60
62
  const createSetClientNameForRedisV4 = (defaultAppName = 'undefined-app') => {
61
63
  return (client, name) => {