Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit a25f140

Browse files
authored
fix(handlers): handle env vars in node (#116)
1 parent b8397b6 commit a25f140

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

src/handlers.js

+24-12
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,6 @@ const WRAPPER_CODE = ({
1818
labels,
1919
}) => {
2020
const commonNode = `
21-
if (!process.env.EPSAGON_IGNORED_KEYS) {
22-
process.env.EPSAGON_IGNORED_KEYS = "${ignoredKeys || ''}";
23-
}
24-
25-
if (!process.env.EPSAGON_URLS_TO_IGNORE) {
26-
process.env.EPSAGON_URLS_TO_IGNORE = "${urlsToIgnore || ''}";
27-
}
28-
29-
if (!process.env.EPSAGON_PAYLOADS_TO_IGNORE) {
30-
process.env.EPSAGON_PAYLOADS_TO_IGNORE = '${payloadsToIgnore}';
31-
}
32-
3321
epsagon.init({
3422
token: '${token}',
3523
appName: '${appName}',
@@ -64,6 +52,18 @@ except:
6452
print('Warning: Epsagon package not found. The function will not be monitored')
6553
`,
6654
node: `
55+
if (!process.env.EPSAGON_IGNORED_KEYS) {
56+
process.env.EPSAGON_IGNORED_KEYS = "${ignoredKeys || ''}";
57+
}
58+
59+
if (!process.env.EPSAGON_URLS_TO_IGNORE) {
60+
process.env.EPSAGON_URLS_TO_IGNORE = "${urlsToIgnore || ''}";
61+
}
62+
63+
if (!process.env.EPSAGON_PAYLOADS_TO_IGNORE) {
64+
process.env.EPSAGON_PAYLOADS_TO_IGNORE = '${payloadsToIgnore}';
65+
}
66+
6767
const epsagon = require('epsagon');
6868
const epsagonHandler = require('../${relativePath}.js');
6969
@@ -72,6 +72,18 @@ ${commonNode}
7272
exports.${method} = epsagon.${wrapper}(epsagonHandler.${method});
7373
`,
7474
tsnode: `
75+
if (!process.env.EPSAGON_IGNORED_KEYS) {
76+
process.env.EPSAGON_IGNORED_KEYS = "${ignoredKeys || ''}";
77+
}
78+
79+
if (!process.env.EPSAGON_URLS_TO_IGNORE) {
80+
process.env.EPSAGON_URLS_TO_IGNORE = "${urlsToIgnore || ''}";
81+
}
82+
83+
if (!process.env.EPSAGON_PAYLOADS_TO_IGNORE) {
84+
process.env.EPSAGON_PAYLOADS_TO_IGNORE = '${payloadsToIgnore}';
85+
}
86+
7587
import * as epsagon from 'epsagon';
7688
import * as epsagonHandler from '../${relativePath}';
7789

0 commit comments

Comments
 (0)