Skip to content

Commit

Permalink
Add hawk integration (#83)
Browse files Browse the repository at this point in the history
* Add hawk integration

* Fix eslint errors

* Rewrite to plugin
  • Loading branch information
TatianaFomina authored Feb 24, 2024
1 parent c21c0df commit f617aec
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ VITE_PRODUCTION_HOSTNAME=notex.so

# Google OAuth redirect url
VITE_GOOGLE_OAUTH_URL=https://api.notex.so/oauth/google/login

# Hawk integration token. See https://hawk.so/
VITE_HAWK_TOKEN=
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@editorjs/raw": "^2.4.0",
"@editorjs/table": "^2.2.2",
"@editorjs/warning": "^1.3.0",
"@hawk.so/javascript": "^3.0.2",
"@vueuse/core": "^10.3.0",
"codex-ui": "workspace:^",
"jwt-decode": "^3.1.2",
Expand All @@ -44,6 +45,8 @@
"vue-router": "^4.2.4"
},
"devDependencies": {
"@hawk.so/vite-plugin": "^1.0.2",
"@types/node": "^20.10.7",
"@vitejs/plugin-vue": "^4.1.0",
"eslint": "^8.51.0",
"eslint-config-codex": "^1.9.1",
Expand Down
26 changes: 26 additions & 0 deletions src/application/error-catcher/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { App } from 'vue';
import HawkCatcher from '@hawk.so/javascript';

declare global {
interface Window {
/**
* Release id added by hawk-vite-plugin
*/
HAWK_RELEASE: string;
}
}

/**
* Vue app plugin that initializes Hawk error catcher
*/
const HawkPlugin = {
install(app: App) {
new HawkCatcher({
token: import.meta.env.VITE_HAWK_TOKEN,
vue: app,
release: window.HAWK_RELEASE,
});
},
};

export default HawkPlugin;
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createApp } from 'vue';
import { createHead } from 'unhead';
import App from './App.vue';
import i18n from '@/application/i18n';
import hawk from '@/application/error-catcher';
import router from '@/application/router/index';
import 'codex-ui/styles';
import '@/presentation/styles/index.pcss';
Expand All @@ -11,4 +12,5 @@ const app = createApp(App);
app.use(createHead);
app.use(router);
app.use(i18n);
app.use(hawk);
app.mount('#app');
27 changes: 19 additions & 8 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import { defineConfig } from 'vite';
import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
/* eslint-disable-next-line @typescript-eslint/naming-convention */
'@/': '/src/',
import hawkVitePlugin from '@hawk.so/vite-plugin';

export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());

return {
plugins: [
vue(),
hawkVitePlugin({
token: env.VITE_HAWK_TOKEN,
}),
],
resolve: {
alias: {
/* eslint-disable-next-line @typescript-eslint/naming-convention */
'@/': '/src/',
},
},
},
};
});
77 changes: 76 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,34 @@ __metadata:
languageName: node
linkType: hard

"@hawk.so/javascript@npm:^3.0.2":
version: 3.0.2
resolution: "@hawk.so/javascript@npm:3.0.2"
dependencies:
"@hawk.so/types": ^0.1.13
error-stack-parser: ^2.0.6
checksum: 139d9e93c899d158e23062554c6f95d2fe1dc2ba53aa1e3686c982da9ed43da6e72536b457007ced76c5ac5650200fcbaaac99c8ff0ad2b8d947f116e1478480
languageName: node
linkType: hard

"@hawk.so/types@npm:^0.1.13":
version: 0.1.18
resolution: "@hawk.so/types@npm:0.1.18"
dependencies:
"@types/mongodb": ^3.5.34
checksum: ce417dc5e0d5d3bbb2e4c9886b7d117a782fe987f77350c77b7e84210e6832d599de617634a1f480ca0fbfc6731eea398f6bbf77d9d4d4b7fc28d7b04139fe1e
languageName: node
linkType: hard

"@hawk.so/vite-plugin@npm:^1.0.2":
version: 1.0.2
resolution: "@hawk.so/vite-plugin@npm:1.0.2"
dependencies:
magic-string: ^0.30.5
checksum: 7a30021288914056334311d4934c3faae06b68c1b448a85a1a9aa8e7fe5f24a858adfee99e367b49af055211b5bbfeb509d31f61b2daacec4dd743b8445a3974
languageName: node
linkType: hard

"@humanwhocodes/config-array@npm:^0.11.11":
version: 0.11.12
resolution: "@humanwhocodes/config-array@npm:0.11.12"
Expand Down Expand Up @@ -1232,6 +1260,15 @@ __metadata:
languageName: node
linkType: hard

"@types/bson@npm:*":
version: 4.0.5
resolution: "@types/bson@npm:4.0.5"
dependencies:
"@types/node": "*"
checksum: f6c74a68eec836010170e7091399b45fe39e2f7724372441cc00a0fbd0b9f44d901688504174d558edbf220922fa0c7c52fbc4aa0f2136194fa713101b8f2ec9
languageName: node
linkType: hard

"@types/estree@npm:1.0.5":
version: 1.0.5
resolution: "@types/estree@npm:1.0.5"
Expand All @@ -1253,6 +1290,25 @@ __metadata:
languageName: node
linkType: hard

"@types/mongodb@npm:^3.5.34":
version: 3.6.20
resolution: "@types/mongodb@npm:3.6.20"
dependencies:
"@types/bson": "*"
"@types/node": "*"
checksum: e5397ada2ed728997f7c3f5424e8c28f682a635488be967c9c18a5de27b1641cf28bb42bc12026ac6d475c457a880e27097e13c8120350ba13219f4ccc030656
languageName: node
linkType: hard

"@types/node@npm:*, @types/node@npm:^20.10.7":
version: 20.10.7
resolution: "@types/node@npm:20.10.7"
dependencies:
undici-types: ~5.26.4
checksum: 86f4f96f5169538f47bbd652ab8e3712cd307701481ff3e9ce0c1ea7d8424a38b5ac4a1d33088cdd9ea1bfe68fd27bbae005a21969aa6d9a36295904da6f09f2
languageName: node
linkType: hard

"@types/node@npm:^20.11.15":
version: 20.11.15
resolution: "@types/node@npm:20.11.15"
Expand Down Expand Up @@ -2543,6 +2599,15 @@ __metadata:
languageName: node
linkType: hard

"error-stack-parser@npm:^2.0.6":
version: 2.1.4
resolution: "error-stack-parser@npm:2.1.4"
dependencies:
stackframe: ^1.3.4
checksum: 3b916d2d14c6682f287c8bfa28e14672f47eafe832701080e420e7cdbaebb2c50293868256a95706ac2330fe078cf5664713158b49bc30d7a5f2ac229ded0e18
languageName: node
linkType: hard

"es-abstract@npm:^1.22.1":
version: 1.22.2
resolution: "es-abstract@npm:1.22.2"
Expand Down Expand Up @@ -3982,7 +4047,7 @@ __metadata:
languageName: node
linkType: hard

"magic-string@npm:^0.30.0":
"magic-string@npm:^0.30.0, magic-string@npm:^0.30.5":
version: 0.30.5
resolution: "magic-string@npm:0.30.5"
dependencies:
Expand Down Expand Up @@ -4283,6 +4348,9 @@ __metadata:
"@editorjs/raw": ^2.4.0
"@editorjs/table": ^2.2.2
"@editorjs/warning": ^1.3.0
"@hawk.so/javascript": ^3.0.2
"@hawk.so/vite-plugin": ^1.0.2
"@types/node": ^20.10.7
"@vitejs/plugin-vue": ^4.1.0
"@vueuse/core": ^10.3.0
codex-ui: "workspace:^"
Expand Down Expand Up @@ -5453,6 +5521,13 @@ __metadata:
languageName: node
linkType: hard

"stackframe@npm:^1.3.4":
version: 1.3.4
resolution: "stackframe@npm:1.3.4"
checksum: bae1596873595c4610993fa84f86a3387d67586401c1816ea048c0196800c0646c4d2da98c2ee80557fd9eff05877efe33b91ba6cd052658ed96ddc85d19067d
languageName: node
linkType: hard

"string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^1.0.2 || 2 || 3 || 4, string-width@npm:^4.1.0, string-width@npm:^4.2.3":
version: 4.2.3
resolution: "string-width@npm:4.2.3"
Expand Down

0 comments on commit f617aec

Please sign in to comment.