diff --git a/package-lock.json b/package-lock.json index 87b0829b5..62c965355 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6959,6 +6959,25 @@ "@lezer/common": "^1.0.0" } }, + "node_modules/@lukeed/csprng": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@lukeed/csprng/-/csprng-1.1.0.tgz", + "integrity": "sha512-Z7C/xXCiGWsg0KuKsHTKJxbWhpI3Vs5GwLfOean7MGyVFGqdRgBbAjOCh6u4bbjPc/8MJ2pZmK/0DLdCbivLDA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@lukeed/uuid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@lukeed/uuid/-/uuid-2.0.1.tgz", + "integrity": "sha512-qC72D4+CDdjGqJvkFMMEAtancHUQ7/d/tAiHf64z8MopFDmcrtbcJuerDtFceuAfQJ2pDSfCKCtbqoGBNnwg0w==", + "dependencies": { + "@lukeed/csprng": "^1.1.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@mongodb-js/compass-components": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/@mongodb-js/compass-components/-/compass-components-1.8.0.tgz", @@ -9444,15 +9463,98 @@ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" } }, - "node_modules/@segment/loosely-validate-event": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@segment/loosely-validate-event/-/loosely-validate-event-2.0.0.tgz", - "integrity": "sha512-ZMCSfztDBqwotkl848ODgVcAmN4OItEWDCkshcKz0/W6gGSQayuuCtWV/MlodFivAZD793d6UgANd6wCXUfrIw==", + "node_modules/@segment/analytics-core": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@segment/analytics-core/-/analytics-core-1.4.1.tgz", + "integrity": "sha512-kV0Pf33HnthuBOVdYNani21kYyj118Fn+9757bxqoksiXoZlYvBsFq6giNdCsKcTIE1eAMqNDq3xE1VQ0cfsHA==", + "dependencies": { + "@lukeed/uuid": "^2.0.0", + "@segment/analytics-generic-utils": "1.1.1", + "dset": "^3.1.2", + "tslib": "^2.4.1" + } + }, + "node_modules/@segment/analytics-core/node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + }, + "node_modules/@segment/analytics-generic-utils": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@segment/analytics-generic-utils/-/analytics-generic-utils-1.1.1.tgz", + "integrity": "sha512-THTIzBPHnvu1HYJU3fARdJ3qIkukO3zDXsmDm+kAeUks5R9CBXOQ6rPChiASVzSmwAIIo5uFIXXnCraojlq/Gw==", + "dependencies": { + "tslib": "^2.4.1" + } + }, + "node_modules/@segment/analytics-generic-utils/node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + }, + "node_modules/@segment/analytics-node": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@segment/analytics-node/-/analytics-node-1.3.0.tgz", + "integrity": "sha512-lRLz1WZaDokMoUe299yP5JkInc3OgJuqNNlxb6j0q22umCiq6b5iDo2gRmFn93reirIvJxWIicQsGrHd93q8GQ==", "dependencies": { - "component-type": "^1.2.1", - "join-component": "^1.1.0" + "@lukeed/uuid": "^2.0.0", + "@segment/analytics-core": "1.4.1", + "@segment/analytics-generic-utils": "1.1.1", + "buffer": "^6.0.3", + "node-fetch": "^2.6.7", + "tslib": "^2.4.1" + }, + "engines": { + "node": ">=14" } }, + "node_modules/@segment/analytics-node/node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/@segment/analytics-node/node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/@segment/analytics-node/node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + }, "node_modules/@sideway/address": { "version": "4.1.4", "resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.4.tgz", @@ -9727,12 +9829,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@types/analytics-node": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/@types/analytics-node/-/analytics-node-3.1.10.tgz", - "integrity": "sha512-dvn8iy2EQZDlQGgRNT9SW2Ljn9L3VgwcrpJvonufnNygZWB1XEufXNvDhUtwNUqNyHhD0hbDCCFb9j+B7vE5cA==", - "dev": true - }, "node_modules/@types/ansi-escape-sequences": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@types/ansi-escape-sequences/-/ansi-escape-sequences-4.0.0.tgz", @@ -11096,32 +11192,6 @@ "ajv": "^6.9.1" } }, - "node_modules/analytics-node": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/analytics-node/-/analytics-node-5.1.2.tgz", - "integrity": "sha512-WZ8gkXtLuqD2Q2xEOr/2/LJiR0AnhWHfXZhfPnMZpB7vEwCsh3HapYAUmA1cPj1abrhAqBX7POWuWo/1wUu/Fw==", - "dependencies": { - "@segment/loosely-validate-event": "^2.0.0", - "axios": "^0.21.4", - "axios-retry": "3.2.0", - "lodash.isstring": "^4.0.1", - "md5": "^2.2.1", - "ms": "^2.0.0", - "remove-trailing-slash": "^0.1.0", - "uuid": "^8.3.2" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/analytics-node/node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/ansi-colors": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", @@ -11621,22 +11691,6 @@ "node": ">=4" } }, - "node_modules/axios": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", - "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", - "dependencies": { - "follow-redirects": "^1.14.0" - } - }, - "node_modules/axios-retry": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/axios-retry/-/axios-retry-3.2.0.tgz", - "integrity": "sha512-RK2cLMgIsAQBDhlIsJR5dOhODPigvel18XUv1dDXW+4k1FzebyfRk+C+orot6WPZOYFKSfhLwHPwVmTVOODQ5w==", - "dependencies": { - "is-retry-allowed": "^1.1.0" - } - }, "node_modules/axobject-query": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz", @@ -12567,14 +12621,6 @@ "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", "optional": true }, - "node_modules/charenc": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", - "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==", - "engines": { - "node": "*" - } - }, "node_modules/check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", @@ -12957,11 +13003,6 @@ "dot-prop": "^5.1.0" } }, - "node_modules/component-type": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/component-type/-/component-type-1.2.1.tgz", - "integrity": "sha512-Kgy+2+Uwr75vAi6ChWXgHuLvd+QLD7ssgpaRq2zCvt80ptvAfMc/hijcJxXkBa2wMlEZcJvC2H8Ubo+A9ATHIg==" - }, "node_modules/compress-brotli": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/compress-brotli/-/compress-brotli-1.3.8.tgz", @@ -13443,14 +13484,6 @@ "node": ">= 8" } }, - "node_modules/crypt": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", - "integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==", - "engines": { - "node": "*" - } - }, "node_modules/crypto-browserify": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", @@ -14425,6 +14458,14 @@ "node": ">=10" } }, + "node_modules/dset": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/dset/-/dset-3.1.3.tgz", + "integrity": "sha512-20TuZZHCEZ2O71q9/+8BwKwZ0QtD9D8ObhrihJPr+vLLYlSuAU3/zL4cSlgbfeoGHTjCSJBa7NGcrF9/Bx/WJQ==", + "engines": { + "node": ">=4" + } + }, "node_modules/duplexer": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", @@ -16076,6 +16117,7 @@ "version": "1.15.4", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz", "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==", + "devOptional": true, "funding": [ { "type": "individual", @@ -17893,11 +17935,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" - }, "node_modules/is-callable": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", @@ -18642,11 +18679,6 @@ "@sideway/pinpoint": "^2.0.0" } }, - "node_modules/join-component": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/join-component/-/join-component-1.1.0.tgz", - "integrity": "sha512-bF7vcQxbODoGK1imE2P9GS9aw4zD0Sd+Hni68IMZLj7zRnquH7dXUmMw9hDI5S/Jzt7q+IyTXN0rSg2GI0IKhQ==" - }, "node_modules/jose": { "version": "4.14.4", "resolved": "https://registry.npmjs.org/jose/-/jose-4.14.4.tgz", @@ -21302,7 +21334,8 @@ "node_modules/lodash.isstring": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", - "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==" + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "dev": true }, "node_modules/lodash.memoize": { "version": "3.0.4", @@ -21831,16 +21864,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/md5": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", - "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", - "dependencies": { - "charenc": "0.0.2", - "crypt": "0.0.2", - "is-buffer": "~1.1.6" - } - }, "node_modules/md5.js": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", @@ -26461,11 +26484,6 @@ "integrity": "sha512-MXW/jtHyl5F1PZI7NbpS8SOtympdLuF20aoWJT5lELR1p/HJDd5nqW8Eu9uLh/hCRY3FgvrIT5AwDCgBODklcA==", "dev": true }, - "node_modules/remove-trailing-slash": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/remove-trailing-slash/-/remove-trailing-slash-0.1.1.tgz", - "integrity": "sha512-o4S4Qh6L2jpnCy83ysZDau+VORNvnFw07CKSAymkd6ICNVEPisMyzlc00KlvvicsxKck94SEwhDnMNdICzO+tA==" - }, "node_modules/renderkid": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/renderkid/-/renderkid-3.0.0.tgz", @@ -30897,7 +30915,7 @@ "@mongosh/shell-evaluator": "0.0.0-dev.0", "@mongosh/snippet-manager": "0.0.0-dev.0", "@mongosh/types": "0.0.0-dev.0", - "analytics-node": "^5.1.2", + "@segment/analytics-node": "^1.3.0", "ansi-escape-sequences": "^5.1.2", "askcharacter": "^1.0.0", "askpassword": "^1.2.4", @@ -30920,7 +30938,6 @@ "@mongodb-js/prettier-config-devtools": "^1.0.1", "@mongodb-js/sbom-tools": "^0.5.2", "@mongodb-js/tsconfig-mongosh": "^1.0.0", - "@types/analytics-node": "^3.1.3", "@types/ansi-escape-sequences": "^4.0.0", "@types/chai-as-promised": "^7.1.3", "@types/js-yaml": "^4.0.5", @@ -37015,6 +37032,19 @@ "@lezer/common": "^1.0.0" } }, + "@lukeed/csprng": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@lukeed/csprng/-/csprng-1.1.0.tgz", + "integrity": "sha512-Z7C/xXCiGWsg0KuKsHTKJxbWhpI3Vs5GwLfOean7MGyVFGqdRgBbAjOCh6u4bbjPc/8MJ2pZmK/0DLdCbivLDA==" + }, + "@lukeed/uuid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@lukeed/uuid/-/uuid-2.0.1.tgz", + "integrity": "sha512-qC72D4+CDdjGqJvkFMMEAtancHUQ7/d/tAiHf64z8MopFDmcrtbcJuerDtFceuAfQJ2pDSfCKCtbqoGBNnwg0w==", + "requires": { + "@lukeed/csprng": "^1.1.0" + } + }, "@mongodb-js/compass-components": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/@mongodb-js/compass-components/-/compass-components-1.8.0.tgz", @@ -37736,7 +37766,7 @@ "@mongosh/shell-evaluator": "0.0.0-dev.0", "@mongosh/snippet-manager": "0.0.0-dev.0", "@mongosh/types": "0.0.0-dev.0", - "@types/analytics-node": "^3.1.3", + "@segment/analytics-node": "^1.3.0", "@types/ansi-escape-sequences": "^4.0.0", "@types/chai-as-promised": "^7.1.3", "@types/js-yaml": "^4.0.5", @@ -37744,7 +37774,6 @@ "@types/numeral": "^2.0.2", "@types/text-table": "^0.2.1", "@types/yargs-parser": "^15.0.0", - "analytics-node": "^5.1.2", "ansi-escape-sequences": "^5.1.2", "askcharacter": "^1.0.0", "askpassword": "^1.2.4", @@ -39512,13 +39541,71 @@ "@react-types/shared": "^3.17.0" } }, - "@segment/loosely-validate-event": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@segment/loosely-validate-event/-/loosely-validate-event-2.0.0.tgz", - "integrity": "sha512-ZMCSfztDBqwotkl848ODgVcAmN4OItEWDCkshcKz0/W6gGSQayuuCtWV/MlodFivAZD793d6UgANd6wCXUfrIw==", + "@segment/analytics-core": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@segment/analytics-core/-/analytics-core-1.4.1.tgz", + "integrity": "sha512-kV0Pf33HnthuBOVdYNani21kYyj118Fn+9757bxqoksiXoZlYvBsFq6giNdCsKcTIE1eAMqNDq3xE1VQ0cfsHA==", "requires": { - "component-type": "^1.2.1", - "join-component": "^1.1.0" + "@lukeed/uuid": "^2.0.0", + "@segment/analytics-generic-utils": "1.1.1", + "dset": "^3.1.2", + "tslib": "^2.4.1" + }, + "dependencies": { + "tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + } + } + }, + "@segment/analytics-generic-utils": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@segment/analytics-generic-utils/-/analytics-generic-utils-1.1.1.tgz", + "integrity": "sha512-THTIzBPHnvu1HYJU3fARdJ3qIkukO3zDXsmDm+kAeUks5R9CBXOQ6rPChiASVzSmwAIIo5uFIXXnCraojlq/Gw==", + "requires": { + "tslib": "^2.4.1" + }, + "dependencies": { + "tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + } + } + }, + "@segment/analytics-node": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@segment/analytics-node/-/analytics-node-1.3.0.tgz", + "integrity": "sha512-lRLz1WZaDokMoUe299yP5JkInc3OgJuqNNlxb6j0q22umCiq6b5iDo2gRmFn93reirIvJxWIicQsGrHd93q8GQ==", + "requires": { + "@lukeed/uuid": "^2.0.0", + "@segment/analytics-core": "1.4.1", + "@segment/analytics-generic-utils": "1.1.1", + "buffer": "^6.0.3", + "node-fetch": "^2.6.7", + "tslib": "^2.4.1" + }, + "dependencies": { + "buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" + }, + "tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + } } }, "@sideway/address": { @@ -39764,12 +39851,6 @@ } } }, - "@types/analytics-node": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/@types/analytics-node/-/analytics-node-3.1.10.tgz", - "integrity": "sha512-dvn8iy2EQZDlQGgRNT9SW2Ljn9L3VgwcrpJvonufnNygZWB1XEufXNvDhUtwNUqNyHhD0hbDCCFb9j+B7vE5cA==", - "dev": true - }, "@types/ansi-escape-sequences": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@types/ansi-escape-sequences/-/ansi-escape-sequences-4.0.0.tgz", @@ -40939,28 +41020,6 @@ "dev": true, "requires": {} }, - "analytics-node": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/analytics-node/-/analytics-node-5.1.2.tgz", - "integrity": "sha512-WZ8gkXtLuqD2Q2xEOr/2/LJiR0AnhWHfXZhfPnMZpB7vEwCsh3HapYAUmA1cPj1abrhAqBX7POWuWo/1wUu/Fw==", - "requires": { - "@segment/loosely-validate-event": "^2.0.0", - "axios": "^0.21.4", - "axios-retry": "3.2.0", - "lodash.isstring": "^4.0.1", - "md5": "^2.2.1", - "ms": "^2.0.0", - "remove-trailing-slash": "^0.1.0", - "uuid": "^8.3.2" - }, - "dependencies": { - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" - } - } - }, "ansi-colors": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", @@ -41358,22 +41417,6 @@ "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.7.2.tgz", "integrity": "sha512-zIURGIS1E1Q4pcrMjp+nnEh+16G56eG/MUllJH8yEvw7asDo7Ac9uhC9KIH5jzpITueEZolfYglnCGIuSBz39g==" }, - "axios": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", - "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", - "requires": { - "follow-redirects": "^1.14.0" - } - }, - "axios-retry": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/axios-retry/-/axios-retry-3.2.0.tgz", - "integrity": "sha512-RK2cLMgIsAQBDhlIsJR5dOhODPigvel18XUv1dDXW+4k1FzebyfRk+C+orot6WPZOYFKSfhLwHPwVmTVOODQ5w==", - "requires": { - "is-retry-allowed": "^1.1.0" - } - }, "axobject-query": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz", @@ -42100,11 +42143,6 @@ "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", "optional": true }, - "charenc": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", - "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==" - }, "check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", @@ -42399,11 +42437,6 @@ "dot-prop": "^5.1.0" } }, - "component-type": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/component-type/-/component-type-1.2.1.tgz", - "integrity": "sha512-Kgy+2+Uwr75vAi6ChWXgHuLvd+QLD7ssgpaRq2zCvt80ptvAfMc/hijcJxXkBa2wMlEZcJvC2H8Ubo+A9ATHIg==" - }, "compress-brotli": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/compress-brotli/-/compress-brotli-1.3.8.tgz", @@ -42807,11 +42840,6 @@ "which": "^2.0.1" } }, - "crypt": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", - "integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==" - }, "crypto-browserify": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", @@ -43550,6 +43578,11 @@ "pify": "^4.0.1" } }, + "dset": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/dset/-/dset-3.1.3.tgz", + "integrity": "sha512-20TuZZHCEZ2O71q9/+8BwKwZ0QtD9D8ObhrihJPr+vLLYlSuAU3/zL4cSlgbfeoGHTjCSJBa7NGcrF9/Bx/WJQ==" + }, "duplexer": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", @@ -44833,7 +44866,8 @@ "follow-redirects": { "version": "1.15.4", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz", - "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==" + "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==", + "devOptional": true }, "for-each": { "version": "0.3.3", @@ -46225,11 +46259,6 @@ "has-tostringtag": "^1.0.0" } }, - "is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" - }, "is-callable": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", @@ -46747,11 +46776,6 @@ "@sideway/pinpoint": "^2.0.0" } }, - "join-component": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/join-component/-/join-component-1.1.0.tgz", - "integrity": "sha512-bF7vcQxbODoGK1imE2P9GS9aw4zD0Sd+Hni68IMZLj7zRnquH7dXUmMw9hDI5S/Jzt7q+IyTXN0rSg2GI0IKhQ==" - }, "jose": { "version": "4.14.4", "resolved": "https://registry.npmjs.org/jose/-/jose-4.14.4.tgz", @@ -48836,7 +48860,8 @@ "lodash.isstring": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", - "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==" + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "dev": true }, "lodash.memoize": { "version": "3.0.4", @@ -49253,16 +49278,6 @@ "integrity": "sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==", "optional": true }, - "md5": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", - "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", - "requires": { - "charenc": "0.0.2", - "crypt": "0.0.2", - "is-buffer": "~1.1.6" - } - }, "md5.js": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", @@ -52776,11 +52791,6 @@ "integrity": "sha512-MXW/jtHyl5F1PZI7NbpS8SOtympdLuF20aoWJT5lELR1p/HJDd5nqW8Eu9uLh/hCRY3FgvrIT5AwDCgBODklcA==", "dev": true }, - "remove-trailing-slash": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/remove-trailing-slash/-/remove-trailing-slash-0.1.1.tgz", - "integrity": "sha512-o4S4Qh6L2jpnCy83ysZDau+VORNvnFw07CKSAymkd6ICNVEPisMyzlc00KlvvicsxKck94SEwhDnMNdICzO+tA==" - }, "renderkid": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/renderkid/-/renderkid-3.0.0.tgz", diff --git a/packages/cli-repl/package.json b/packages/cli-repl/package.json index 9c090c9eb..5ca8ae5de 100644 --- a/packages/cli-repl/package.json +++ b/packages/cli-repl/package.json @@ -72,7 +72,7 @@ "@mongosh/shell-evaluator": "0.0.0-dev.0", "@mongosh/snippet-manager": "0.0.0-dev.0", "@mongosh/types": "0.0.0-dev.0", - "analytics-node": "^5.1.2", + "@segment/analytics-node": "^1.3.0", "ansi-escape-sequences": "^5.1.2", "askcharacter": "^1.0.0", "askpassword": "^1.2.4", @@ -93,7 +93,6 @@ "@mongodb-js/prettier-config-devtools": "^1.0.1", "@mongodb-js/sbom-tools": "^0.5.2", "@mongodb-js/tsconfig-mongosh": "^1.0.0", - "@types/analytics-node": "^3.1.3", "@types/ansi-escape-sequences": "^4.0.0", "@types/js-yaml": "^4.0.5", "@types/node": "^14.14.6", diff --git a/packages/cli-repl/src/cli-repl.spec.ts b/packages/cli-repl/src/cli-repl.spec.ts index f8eb21669..f007d5215 100644 --- a/packages/cli-repl/src/cli-repl.spec.ts +++ b/packages/cli-repl/src/cli-repl.spec.ts @@ -1202,6 +1202,7 @@ describe('CliRepl', function () { let srv: http.Server; let host: string; let requests: any[]; + let totalEventsTracked = 0; let telemetryDelay = 0; const setTelemetryDelay = (val: number) => { telemetryDelay = val; @@ -1210,6 +1211,7 @@ describe('CliRepl', function () { beforeEach(async function () { process.env.MONGOSH_ANALYTICS_SAMPLE = 'true'; requests = []; + totalEventsTracked = 0; srv = http .createServer((req, res) => { let body = ''; @@ -1220,8 +1222,9 @@ describe('CliRepl', function () { }) .on('end', async () => { requests.push({ req, body }); - res.writeHead(200); + totalEventsTracked += JSON.parse(body).batch.length; await delay(telemetryDelay); + res.writeHead(200); res.end('Ok\n'); }); }) @@ -1244,19 +1247,26 @@ describe('CliRepl', function () { }); it('timeouts fast', async function () { - setTelemetryDelay(10000); + // The `httpRequestTimeout` of our Segment Analytics is set to + // 1000ms which makes these requests fail as they exceed the timeout. + // Segment will silently fail http request errors when tracking and flushing. + // This will cause the test to fail if the system running the tests is + // unable to flush telemetry in 1500ms. + this.timeout(2500); + setTelemetryDelay(5000); await cliRepl.start(await testServer.connectionString(), {}); input.write('use somedb;\n'); input.write('exit\n'); await waitBus(cliRepl.bus, 'mongosh:closed'); - const analyticsLog = (await log()).find( + const analyticsLog = (await log()).filter( (entry) => entry.ctx === 'analytics' && entry.msg === 'Flushed outstanding data' ); - expect(analyticsLog).to.have.nested.property( + expect(analyticsLog).to.have.lengthOf(1); + expect(analyticsLog[0]).to.have.nested.property( 'attr.flushError', - 'timeout of 1000ms exceeded' + null // Although the flush request will time out, it does not error. ); }); @@ -1386,7 +1396,7 @@ describe('CliRepl', function () { ); expect(flushEntry.attr.flushError).to.equal(null); expect(flushEntry.attr.flushDuration).to.be.a('number'); - expect(requests).to.have.lengthOf(2); + expect(totalEventsTracked).to.equal(4); }); it('sends out telemetry data for command line scripts', async function () { @@ -1396,7 +1406,7 @@ describe('CliRepl', function () { cliRepl, await testServer.connectionString() ); - expect(requests).to.have.lengthOf(2); + expect(totalEventsTracked).to.equal(5); }); it('sends out telemetry if the repl is running in an interactive mode in a containerized environment', async function () { @@ -1408,7 +1418,7 @@ describe('CliRepl', function () { input.write('db.hello()\n'); input.write('exit\n'); await waitBus(cliRepl.bus, 'mongosh:closed'); - expect(requests).to.have.lengthOf(2); + expect(totalEventsTracked).to.equal(4); }); it('does not send out telemetry if the user starts with a no-telemetry config', async function () { diff --git a/packages/cli-repl/src/cli-repl.ts b/packages/cli-repl/src/cli-repl.ts index 8bc119455..aaddd7812 100644 --- a/packages/cli-repl/src/cli-repl.ts +++ b/packages/cli-repl/src/cli-repl.ts @@ -12,7 +12,7 @@ import type { CliOptions, DevtoolsConnectOptions } from '@mongosh/arg-parser'; import { SnippetManager } from '@mongosh/snippet-manager'; import { Editor } from '@mongosh/editor'; import { redactSensitiveData } from '@mongosh/history'; -import type Analytics from 'analytics-node'; +import type { Analytics as SegmentAnalytics } from '@segment/analytics-node'; import askpassword from 'askpassword'; import { EventEmitter, once } from 'events'; import yaml from 'js-yaml'; @@ -44,7 +44,6 @@ import { } from '@mongosh/types'; import { promises as fs } from 'fs'; import path from 'path'; -import { promisify } from 'util'; import { getOsInfo } from './get-os-info'; import { UpdateNotificationManager } from './update-notification-manager'; import { getTimingData, markTime, summariseTimingData } from './startup-timing'; @@ -113,7 +112,7 @@ export class CliRepl implements MongoshIOProvider { input: Readable; output: Writable; analyticsOptions?: AnalyticsOptions; - segmentAnalytics?: Analytics; + segmentAnalytics?: SegmentAnalytics; toggleableAnalytics: ToggleableAnalytics = new ToggleableAnalytics(); warnedAboutInaccessibleFiles = false; onExit: (code?: number) => Promise; @@ -510,17 +509,13 @@ export class CliRepl implements MongoshIOProvider { } // 'http' is not supported in startup snapshots yet. // eslint-disable-next-line @typescript-eslint/no-var-requires - const Analytics = require('analytics-node'); - this.segmentAnalytics = new Analytics( - apiKey, - { - ...this.analyticsOptions, - axiosConfig: { - timeout: 1000, - }, - axiosRetryConfig: { retries: 0 }, - } as any /* axiosConfig and axiosRetryConfig are existing options, but don't have type definitions */ - ); + const { Analytics } = require('@segment/analytics-node'); + this.segmentAnalytics = new Analytics({ + writeKey: apiKey, + maxRetries: 0, + httpRequestTimeout: 1000, + ...this.analyticsOptions, + }); this.toggleableAnalytics = new ToggleableAnalytics( new SampledAnalytics({ target: new ThrottledAnalytics({ @@ -1028,7 +1023,7 @@ export class CliRepl implements MongoshIOProvider { if (analytics) { const flushStart = Date.now(); try { - await promisify(analytics.flush.bind(analytics))(); + await analytics.flush(); markTime(TimingCategories.Telemetry, 'flushed analytics'); } catch (err: any) { flushError = err.message; diff --git a/packages/logging/src/analytics-helpers.spec.ts b/packages/logging/src/analytics-helpers.spec.ts index 9efda4e1e..5030e46f0 100644 --- a/packages/logging/src/analytics-helpers.spec.ts +++ b/packages/logging/src/analytics-helpers.spec.ts @@ -27,8 +27,8 @@ describe('analytics helpers', function () { track(info: any) { events.push(['track', info]); }, - flush(cb) { - cb(); + async flush() { + return Promise.resolve(); }, }; }); @@ -153,7 +153,7 @@ describe('analytics helpers', function () { analytics.track(tEvt); analytics.track(tEvt); analytics.track(tEvt); - await promisify(analytics.flush.bind(analytics))(); + await analytics.flush(); expect(events).to.have.lengthOf(5); }); @@ -166,7 +166,7 @@ describe('analytics helpers', function () { for (let i = 0; i < 100; i++) { analytics.track(tEvt); } - await promisify(analytics.flush.bind(analytics))(); + await analytics.flush(); expect(events).to.have.lengthOf(5); }); @@ -184,7 +184,7 @@ describe('analytics helpers', function () { for (let i = 0; i < 100; i++) { analytics.track(tEvt); } - await promisify(analytics.flush.bind(analytics))(); + await analytics.flush(); expect(events).to.have.lengthOf(10); }); @@ -199,7 +199,7 @@ describe('analytics helpers', function () { a1.identify(iEvt); a1.track(tEvt); a1.track(tEvt); - await promisify(a1.flush.bind(a1))(); + await a1.flush(); expect(events).to.have.lengthOf(3); // second "session" @@ -211,7 +211,7 @@ describe('analytics helpers', function () { for (let i = 0; i < 100; i++) { a2.track(tEvt); } - await promisify(a2.flush.bind(a2))(); + await a2.flush(); expect(events).to.have.lengthOf(5); }); @@ -236,8 +236,8 @@ describe('analytics helpers', function () { a1.track(tEvt); a2.track(t2Evt); - await promisify(a1.flush.bind(a1))(); - await promisify(a2.flush.bind(a2))(); + await a1.flush(); + await a2.flush(); expect(events).to.have.lengthOf(4); expect( diff --git a/packages/logging/src/analytics-helpers.ts b/packages/logging/src/analytics-helpers.ts index dc0b162d8..4bdecf5a3 100644 --- a/packages/logging/src/analytics-helpers.ts +++ b/packages/logging/src/analytics-helpers.ts @@ -34,9 +34,7 @@ export interface MongoshAnalytics { track(message: AnalyticsTrackMessage): void; - // NB: Callback and not a promise to match segment analytics interface so it's - // easier to pass it to the helpers constructor - flush(callback: (err?: Error) => void): void; + flush(): Promise; } class Queue { @@ -84,8 +82,8 @@ class Queue { export class NoopAnalytics implements MongoshAnalytics { identify(): void {} track(): void {} - flush(cb: () => void) { - cb(); + flush() { + return Promise.resolve(); } } @@ -170,8 +168,8 @@ export class ToggleableAnalytics implements MongoshAnalytics { } } - flush(callback: (err?: Error | undefined) => void): void { - return this._target.flush(callback); + async flush(): Promise { + return await this._target.flush(); } } @@ -351,31 +349,28 @@ export class ThrottledAnalytics implements MongoshAnalytics { return this.throttleState.count < this.throttleOptions.rate; } - flush(callback: (err?: Error | undefined) => void): void { + async flush(): Promise { if (!this.throttleOptions) { - this.target.flush(callback); + await this.target.flush(); return; } if (!this.currentUserId) { - callback( - new Error('Trying to persist throttle state before userId is set') - ); - return; + throw new Error('Trying to persist throttle state before userId is set'); } - this.restorePromise.finally(async () => { - try { - await fs.promises.writeFile( - this.metadataPath, - JSON.stringify(this.throttleState) - ); - await this.unlock(); - this.target.flush(callback); - } catch (e) { - callback(e as Error); - } - }); + try { + await this.restorePromise; + } catch { + // Ignored. + } + + await fs.promises.writeFile( + this.metadataPath, + JSON.stringify(this.throttleState) + ); + await this.unlock(); + await this.target.flush(); } } @@ -405,7 +400,7 @@ export class SampledAnalytics implements MongoshAnalytics { this.isEnabled && this.target.track(message); } - flush(callback: (err?: Error | undefined) => void): void { - this.target.flush(callback); + async flush(): Promise { + return await this.target.flush(); } } diff --git a/packages/logging/src/setup-logger-and-telemetry.spec.ts b/packages/logging/src/setup-logger-and-telemetry.spec.ts index 7d6dac90a..65d677cb8 100644 --- a/packages/logging/src/setup-logger-and-telemetry.spec.ts +++ b/packages/logging/src/setup-logger-and-telemetry.spec.ts @@ -52,7 +52,9 @@ describe('setupLoggerAndTelemetry', function () { track(info: any) { analyticsOutput.push(['track', info]); }, - flush() {}, + async flush() { + return Promise.resolve(); + }, }; beforeEach(function () {