Browse Source

chore: sentry init correction and handle search event in docs

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/6431/head
Pranav C 1 year ago
parent
commit
e255e87578
  1. 14
      packages/noco-docs/package-lock.json
  2. 2
      packages/noco-docs/package.json
  3. 26
      packages/noco-docs/src/modules/tele.js
  4. 6
      packages/nocodb/src/Noco.ts

14
packages/noco-docs/package-lock.json generated

@ -15,7 +15,7 @@
"clsx": "^1.2.1", "clsx": "^1.2.1",
"docusaurus-plugin-sass": "^0.2.5", "docusaurus-plugin-sass": "^0.2.5",
"docusaurus-theme-search-typesense": "^0.12.0-0", "docusaurus-theme-search-typesense": "^0.12.0-0",
"nc-analytics": "^0.0.3", "nc-analytics": "^0.0.4",
"prism-react-renderer": "^1.3.5", "prism-react-renderer": "^1.3.5",
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
@ -8276,9 +8276,9 @@
} }
}, },
"node_modules/nc-analytics": { "node_modules/nc-analytics": {
"version": "0.0.3", "version": "0.0.4",
"resolved": "https://registry.npmjs.org/nc-analytics/-/nc-analytics-0.0.3.tgz", "resolved": "https://registry.npmjs.org/nc-analytics/-/nc-analytics-0.0.4.tgz",
"integrity": "sha512-enZVnSr4RvvalD9dmF+Af6+v5YEW+bCIDmP2cxyZ0Ppyj1BKfzQUngoZ75a3Imr6c+O0u3tWKcPB9Y5lEZIkQA==" "integrity": "sha512-OXz94rXQh4zdJLEBqsJAa4N8JMrbiV57n5KfUQ1CjaynVr5X4NH5onqnKE1O6ixlsIFklCsipZ7xueriNPMR4g=="
}, },
"node_modules/negotiator": { "node_modules/negotiator": {
"version": "0.6.3", "version": "0.6.3",
@ -18901,9 +18901,9 @@
"integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==" "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA=="
}, },
"nc-analytics": { "nc-analytics": {
"version": "0.0.3", "version": "0.0.4",
"resolved": "https://registry.npmjs.org/nc-analytics/-/nc-analytics-0.0.3.tgz", "resolved": "https://registry.npmjs.org/nc-analytics/-/nc-analytics-0.0.4.tgz",
"integrity": "sha512-enZVnSr4RvvalD9dmF+Af6+v5YEW+bCIDmP2cxyZ0Ppyj1BKfzQUngoZ75a3Imr6c+O0u3tWKcPB9Y5lEZIkQA==" "integrity": "sha512-OXz94rXQh4zdJLEBqsJAa4N8JMrbiV57n5KfUQ1CjaynVr5X4NH5onqnKE1O6ixlsIFklCsipZ7xueriNPMR4g=="
}, },
"negotiator": { "negotiator": {
"version": "0.6.3", "version": "0.6.3",

2
packages/noco-docs/package.json

@ -34,7 +34,7 @@
"clsx": "^1.2.1", "clsx": "^1.2.1",
"docusaurus-plugin-sass": "^0.2.5", "docusaurus-plugin-sass": "^0.2.5",
"docusaurus-theme-search-typesense": "^0.12.0-0", "docusaurus-theme-search-typesense": "^0.12.0-0",
"nc-analytics": "^0.0.3", "nc-analytics": "^0.0.4",
"prism-react-renderer": "^1.3.5", "prism-react-renderer": "^1.3.5",
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",

26
packages/noco-docs/src/modules/tele.js

@ -1,10 +1,34 @@
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment'; import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
let push; let push;
const clickListener = (e) => {
if(e.nc_handled) return
e.nc_handled = true
let target = e.target;
while (target && !target['classList'].contains('DocSearch-Hit')) {
target = target['parentElement'];
}
if (target) {
const searchInput = document.querySelector('.DocSearch-Input')
push({
event: 'search',
$current_url: location.pathname,
hash: location.hash,
item_clicked: target.innerText.trim(),
search_query: searchInput && searchInput.value
});
}
}
if (ExecutionEnvironment.canUseDOM) { if (ExecutionEnvironment.canUseDOM) {
const { init, push: _push } = require('nc-analytics'); const { init, push: _push } = require('nc-analytics');
push = _push; push = _push;
init(); init();
document.body.removeEventListener('click', clickListener, true);
document.body.addEventListener('click', clickListener, true);
} }
export function onRouteDidUpdate({ location, previousLocation }) { export function onRouteDidUpdate({ location, previousLocation }) {
@ -18,3 +42,5 @@ export function onRouteDidUpdate({ location, previousLocation }) {
}); });
} }
} }

6
packages/nocodb/src/Noco.ts

@ -1,5 +1,5 @@
import path from 'path'; import path from 'path';
import Sentry, { Handlers } from '@sentry/node'; import * as Sentry from '@sentry/node';
import { Logger } from '@nestjs/common'; import { Logger } from '@nestjs/common';
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import clear from 'clear'; import clear from 'clear';
@ -183,7 +183,7 @@ export default class Noco {
private static initSentryErrorHandler(router) { private static initSentryErrorHandler(router) {
if (process.env.NC_SENTRY_DSN) { if (process.env.NC_SENTRY_DSN) {
router.use(Handlers.errorHandler()); router.use(Sentry.Handlers.errorHandler());
} }
} }
@ -192,7 +192,7 @@ export default class Noco {
Sentry.init({ dsn: process.env.NC_SENTRY_DSN }); Sentry.init({ dsn: process.env.NC_SENTRY_DSN });
// The request handler must be the first middleware on the app // The request handler must be the first middleware on the app
router.use(Handlers.requestHandler()); router.use(Sentry.Handlers.requestHandler());
} }
} }
} }

Loading…
Cancel
Save