Browse Source

♻️ Make analytics and Sentry setup optional, remove hard-coded Sentry DSN

master
KaKi87 1 month ago
parent
commit
b089d5935d
3 changed files with 15 additions and 185 deletions
  1. +7
    -5
      index.js
  2. +4
    -2
      package.json
  3. +4
    -178
      yarn.lock

+ 7
- 5
index.js View File

@@ -1,16 +1,18 @@
const { SENTRY_DSN, ENABLE_ANALYTICS } = process.env;

const
GPlay = require('google-play-scraper').memoized(),
Analytics = require('anonymous-analytics');
Analytics = ENABLE_ANALYTICS === '1' ? require('anonymous-analytics') : undefined;

const fastify = require('fastify')();

const searchAnalytics = new Analytics('search');
const searchAnalytics = Analytics ? new Analytics('search') : undefined;

fastify.register(require('fastify-sentry'), { dsn: 'https://ddff463fd7ef7f52d11ff1ccd3887a7c@glitchgit.kaki87.net/1' });
if(SENTRY_DSN) fastify.register(require('fastify-sentry'), { dsn: SENTRY_DSN });
fastify.register(require('fastify-static'), { root: require('path').join(__dirname, 'public') });
fastify.get('/categories', async (request, reply) => reply.send((await GPlay.categories()).sort()));
fastify.post('/search', async (request, reply) => {
searchAnalytics.addFromFastify(request).catch(console.log);
if(searchAnalytics) searchAnalytics.addFromFastify(request).catch(console.log);
const res = await GPlay.search({ term: request.body.name, num: request.body.number, price: request.body.price });
for(let i = 0; i < res.length; i++){
Object.assign(res[i], {
@@ -21,5 +23,5 @@ fastify.post('/search', async (request, reply) => {
}
reply.send(res);
});
fastify.get('/stats', async (request, reply) => reply.send(await searchAnalytics.getStats(undefined, undefined, true)));
if(searchAnalytics) fastify.get('/stats', async (request, reply) => reply.send(await searchAnalytics.getStats(undefined, undefined, true)));
fastify.listen(3030).then(() => console.log('Server running'));

+ 4
- 2
package.json View File

@@ -6,12 +6,14 @@
"author": "KaKi87",
"license": "MIT",
"dependencies": {
"anonymous-analytics": "https://git.kaki87.net/KaKi87/anonymous-analytics.git",
"fastify": "^3.4.1",
"fastify-sentry": "^1.4.0",
"fastify-static": "^3.2.0",
"google-play-scraper": "*"
},
"peerDependencies": {
"anonymous-analytics": "https://git.kaki87.net/KaKi87/anonymous-analytics.git",
"fastify-sentry": "^1.4.0"
},
"scripts": {
"start": "node index.js"
}


+ 4
- 178
yarn.lock View File

@@ -23,80 +23,6 @@
chalk "^2.0.0"
js-tokens "^4.0.0"

"@kxpvcr/ip-to-country@filipecatraia/ip-to-country":
version "1.0.3"
resolved "https://codeload.github.com/filipecatraia/ip-to-country/tar.gz/d434c049985c36656969480dfc14a8c0b5aa229c"
dependencies:
request "^2.88.0"

"@sentry/core@5.24.2":
version "5.24.2"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.24.2.tgz#1724652855c0887a690c3fc6acd2519d4072b511"
integrity sha512-nuAwCGU1l9hgMinl5P/8nIQGRXDP2FI9cJnq5h1qiP/XIOvJkJz2yzBR6nTyqr4vBth0tvxQJbIpDNGd7vHJLg==
dependencies:
"@sentry/hub" "5.24.2"
"@sentry/minimal" "5.24.2"
"@sentry/types" "5.24.2"
"@sentry/utils" "5.24.2"
tslib "^1.9.3"

"@sentry/hub@5.24.2":
version "5.24.2"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.24.2.tgz#64a02fd487599945e488ae23aba4ce4df44ee79e"
integrity sha512-xmO1Ivvpb5Qr9WgekinuZZlpl9Iw7iPETUe84HQOhUrXf+2gKO+LaUYMMsYSVDwXQEmR6/tTMyOtS6iavldC6w==
dependencies:
"@sentry/types" "5.24.2"
"@sentry/utils" "5.24.2"
tslib "^1.9.3"

"@sentry/minimal@5.24.2":
version "5.24.2"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.24.2.tgz#14e8b136842398a32987459f0574359b6dc57a1f"
integrity sha512-biFpux5bI3R8xiD/Zzvrk1kRE6bqPtfWXmZYAHRtaUMCAibprTKSY9Ta8QYHynOAEoJ5Akedy6HUsEkK5DoZfA==
dependencies:
"@sentry/hub" "5.24.2"
"@sentry/types" "5.24.2"
tslib "^1.9.3"

"@sentry/node@^5.9.0":
version "5.24.2"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-5.24.2.tgz#6e06bf26f1e0b23e122a14f17aa57671d3428c4d"
integrity sha512-ddfU2tLTvhnY+NqzLIA/gxMt/uxq7R204Nb2J5qqE0WAgbh0dtylNAzfKZTizLdbZfRnpeISmd+CBILh3tavog==
dependencies:
"@sentry/core" "5.24.2"
"@sentry/hub" "5.24.2"
"@sentry/tracing" "5.24.2"
"@sentry/types" "5.24.2"
"@sentry/utils" "5.24.2"
cookie "^0.4.1"
https-proxy-agent "^5.0.0"
lru_map "^0.3.3"
tslib "^1.9.3"

"@sentry/tracing@5.24.2":
version "5.24.2"
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-5.24.2.tgz#a36b4f9bf699c5e07e99a148360091c8e727c51f"
integrity sha512-1uDgvGGVF8lb3hRXbhNnns+8DBUKjhRKOFR5Z3RExjrDFYTDbHmoNtV73Q12Ra+Iht9HTZnIBOqYD3oSZIbJ0w==
dependencies:
"@sentry/hub" "5.24.2"
"@sentry/minimal" "5.24.2"
"@sentry/types" "5.24.2"
"@sentry/utils" "5.24.2"
tslib "^1.9.3"

"@sentry/types@5.24.2":
version "5.24.2"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.24.2.tgz#e2c25d1e75d8dbec5dbbd9a309a321425b61c2ca"
integrity sha512-HcOK00R0tQG5vzrIrqQ0jC28+z76jWSgQCzXiessJ5SH/9uc6NzdO7sR7K8vqMP2+nweCHckFohC8G0T1DLzuQ==

"@sentry/utils@5.24.2":
version "5.24.2"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.24.2.tgz#90b7dff939bbbf4bb8edcac6aac2d04a0552af80"
integrity sha512-oPGde4tNEDHKk0Cg9q2p0qX649jLDUOwzJXHKpd0X65w3A6eJByDevMr8CSzKV9sesjrUpxqAv6f9WWlz185tA==
dependencies:
"@sentry/types" "5.24.2"
tslib "^1.9.3"

abstract-logging@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/abstract-logging/-/abstract-logging-2.0.0.tgz#08a85814946c98ef06f4256ad470aba1886d4490"
@@ -112,13 +38,6 @@ acorn@^6.0.7:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.1.tgz#531e58ba3f51b9dacb9a6646ca4debf5b14ca474"
integrity sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==

agent-base@6:
version "6.0.1"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.1.tgz#808007e4e5867decb0ab6ab2f928fbdb5a596db4"
integrity sha512-01q25QQDwLSsyfhrKbn8yuur+JNw0H+0Y4JiGIKd3z9aYk/w/2kxD/Upc+t2ZBBSUNff50VjPsSW2YxM8QYKVg==
dependencies:
debug "4"

ajv@^6.10.2, ajv@^6.12.3, ajv@^6.9.1:
version "6.12.4"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.4.tgz#0614facc4522127fa713445c6bfd3ebd376e2234"
@@ -139,14 +58,6 @@ ajv@^6.11.0, ajv@^6.12.2:
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"

"anonymous-analytics@https://git.kaki87.net/KaKi87/anonymous-analytics.git":
version "1.0.0"
resolved "https://git.kaki87.net/KaKi87/anonymous-analytics.git#8e2410d9f4ddad0d247d90b557cd93de8e0c0a16"
dependencies:
"@kxpvcr/ip-to-country" filipecatraia/ip-to-country
jshashes "^1.0.8"
nedb "^1.8.0"

ansi-escapes@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b"
@@ -198,11 +109,6 @@ astral-regex@^1.0.0:
resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9"
integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==

async@0.2.10:
version "0.2.10"
resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1"
integrity sha1-trvgsGdLnXGXCMo43owjfLUmw9E=

asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
@@ -245,13 +151,6 @@ bcrypt-pbkdf@^1.0.0:
dependencies:
tweetnacl "^0.14.3"

binary-search-tree@0.2.5:
version "0.2.5"
resolved "https://registry.yarnpkg.com/binary-search-tree/-/binary-search-tree-0.2.5.tgz#7dbb3b210fdca082450dad2334c304af39bdc784"
integrity sha1-fbs7IQ/coIJFDa0jNMMErzm9x4Q=
dependencies:
underscore "~1.4.4"

boolbase@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e"
@@ -347,7 +246,7 @@ concat-map@0.0.1:
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=

cookie@^0.4.0, cookie@^0.4.1:
cookie@^0.4.0:
version "0.4.1"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.1.tgz#afd713fe26ebd21ba95ceb61f9a8116e50a537d1"
integrity sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==
@@ -405,7 +304,7 @@ debug@2.6.9, debug@^2.2.0:
dependencies:
ms "2.0.0"

debug@4, debug@^4.0.0:
debug@^4.0.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.2.0.tgz#7f150f93920e94c58f5574c2fd01a3110effe7f1"
integrity sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==
@@ -772,13 +671,6 @@ fastify-error@^0.2.0:
resolved "https://registry.yarnpkg.com/fastify-error/-/fastify-error-0.2.0.tgz#9a1c28d4f42b6259e7a549671c8e5e2d85660634"
integrity sha512-zabxsBatj59ROG0fhP36zNdc5Q1/eYeH9oSF9uvfrurZf8/JKfrJbMcIGrLpLWcf89rS6L91RHWm20A/X85hcA==

fastify-plugin@^1.2.1:
version "1.6.1"
resolved "https://registry.yarnpkg.com/fastify-plugin/-/fastify-plugin-1.6.1.tgz#122f5a5eeb630d55c301713145a9d188e6d5dd5b"
integrity sha512-APBcb27s+MjaBIerFirYmBLatoPCgmHZM6XP0K+nDL9k0yX8NJPWDY1RAC3bh6z+AB5ULS2j31BUfLMT3uaZ4A==
dependencies:
semver "^6.3.0"

fastify-plugin@^2.0.0:
version "2.3.4"
resolved "https://registry.yarnpkg.com/fastify-plugin/-/fastify-plugin-2.3.4.tgz#b17abdc36a97877d88101fb86ad8a07f2c07de87"
@@ -786,14 +678,6 @@ fastify-plugin@^2.0.0:
dependencies:
semver "^7.3.2"

fastify-sentry@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/fastify-sentry/-/fastify-sentry-1.4.0.tgz#dbe98c93b329e38a97bb60c3bcd1a3826803ed49"
integrity sha512-U4uhbiYt1kodMzp6Ph/aAYSJtZoFm/PaH5h4LOdcwFX/mf3qv4n+CYF0NGZquDa8V4k0B7qXzJGmuWoyvWeRYQ==
dependencies:
"@sentry/node" "^5.9.0"
fastify-plugin "^1.2.1"

fastify-static@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/fastify-static/-/fastify-static-3.2.0.tgz#1c5f433274b310b1c82de6870cc8f4206cedb2bc"
@@ -1000,14 +884,6 @@ http-signature@~1.2.0:
jsprim "^1.2.2"
sshpk "^1.7.0"

https-proxy-agent@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz#e2a90542abb68a762e0a0850f6c9edadfd8506b2"
integrity sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==
dependencies:
agent-base "6"
debug "4"

iconv-lite@^0.4.24:
version "0.4.24"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b"
@@ -1020,11 +896,6 @@ ignore@^4.0.6:
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==

immediate@~3.0.5:
version "3.0.6"
resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b"
integrity sha1-nbHb0Pr43m++D13V5Wu2BigN5ps=

import-fresh@^3.0.0:
version "3.2.1"
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.2.1.tgz#633ff618506e793af5ac91bf48b72677e15cbe66"
@@ -1118,11 +989,6 @@ jsbn@~0.1.0:
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM=

jshashes@^1.0.8:
version "1.0.8"
resolved "https://registry.yarnpkg.com/jshashes/-/jshashes-1.0.8.tgz#f60d837428383abf73ab022e1542e6614bd75514"
integrity sha512-btmQZ/w1rj8Lb6nEwvhjM7nBYoj54yaEFo2PWh3RkxZ8qNwuvOxvQYN/JxVuwoMmdIluL+XwYVJ+pEEZoSYybQ==

json-schema-traverse@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
@@ -1161,13 +1027,6 @@ levn@^0.3.0, levn@~0.3.0:
prelude-ls "~1.1.2"
type-check "~0.3.2"

lie@3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/lie/-/lie-3.1.1.tgz#9a436b2cc7746ca59de7a41fa469b3efb76bd87e"
integrity sha1-mkNrLMd0bKWd56QfpGmz77dr2H4=
dependencies:
immediate "~3.0.5"

light-my-request@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/light-my-request/-/light-my-request-4.0.2.tgz#e80ebbbac512f0f45b9e54cb274b8f121248b924"
@@ -1178,13 +1037,6 @@ light-my-request@^4.0.2:
readable-stream "^3.6.0"
set-cookie-parser "^2.4.1"

localforage@^1.3.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/localforage/-/localforage-1.9.0.tgz#f3e4d32a8300b362b4634cc4e066d9d00d2f09d1"
integrity sha512-rR1oyNrKulpe+VM9cYmcFn6tsHuokyVHFaCM3+osEmxaHTbEk8oQu6eGDfS6DQLWi/N67XRmB8ECG37OES368g==
dependencies:
lie "3.1.1"

lodash.assignin@^4.0.9:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.assignin/-/lodash.assignin-4.2.0.tgz#ba8df5fb841eb0a3e8044232b0e263a8dc6a28a2"
@@ -1257,11 +1109,6 @@ lru-queue@0.1:
dependencies:
es5-ext "~0.10.2"

lru_map@^0.3.3:
version "0.3.3"
resolved "https://registry.yarnpkg.com/lru_map/-/lru_map-0.3.3.tgz#b5c8351b9464cbd750335a79650a0ec0e56118dd"
integrity sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0=

memoizee@^0.4.11:
version "0.4.14"
resolved "https://registry.yarnpkg.com/memoizee/-/memoizee-0.4.14.tgz#07a00f204699f9a95c2d9e77218271c7cd610d57"
@@ -1310,7 +1157,7 @@ minimist@^1.2.5:
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==

mkdirp@^0.5.1, mkdirp@~0.5.1:
mkdirp@^0.5.1:
version "0.5.5"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def"
integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==
@@ -1342,17 +1189,6 @@ natural-compare@^1.4.0:
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=

nedb@^1.8.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/nedb/-/nedb-1.8.0.tgz#0e3502cd82c004d5355a43c9e55577bd7bd91d88"
integrity sha1-DjUCzYLABNU1WkPJ5VV3vXvZHYg=
dependencies:
async "0.2.10"
binary-search-tree "0.2.5"
localforage "^1.3.0"
mkdirp "~0.5.1"
underscore "~1.4.4"

next-tick@1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.1.0.tgz#1836ee30ad56d67ef281b22bd199f709449b35eb"
@@ -1634,11 +1470,6 @@ semver@^5.5.0, semver@^5.5.1:
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==

semver@^6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

semver@^7.3.2:
version "7.3.2"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938"
@@ -1845,7 +1676,7 @@ tough-cookie@~2.5.0:
psl "^1.1.28"
punycode "^2.1.1"

tslib@^1.9.0, tslib@^1.9.3:
tslib@^1.9.0:
version "1.13.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043"
integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==
@@ -1879,11 +1710,6 @@ type@^2.0.0:
resolved "https://registry.yarnpkg.com/type/-/type-2.1.0.tgz#9bdc22c648cf8cf86dd23d32336a41cfb6475e3f"
integrity sha512-G9absDWvhAWCV2gmF1zKud3OyC61nZDwWvBL2DApaVFogI07CprggiQAOOjvp2NRjYWFzPyu7vwtDrQFq8jeSA==

underscore@~1.4.4:
version "1.4.4"
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.4.4.tgz#61a6a32010622afa07963bf325203cf12239d604"
integrity sha1-YaajIBBiKvoHljvzJSA88SI51gQ=

uri-js@^4.2.2:
version "4.4.0"
resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.0.tgz#aa714261de793e8a82347a7bcc9ce74e86f28602"


Loading…
Cancel
Save