Skip to content

Commit

Permalink
feat(app): add Ackee
Browse files Browse the repository at this point in the history
  • Loading branch information
exuanbo committed Dec 9, 2023
1 parent 4dd9391 commit 7e8c51a
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .yarn/patches/ackee-tracker-npm-5.1.0-0db5cc0193.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/src/scripts/main.js b/src/scripts/main.js
index 47294e9b4f4f2dc6628d7e0549028bc11c5a0712..9a3c03ec47ff26e35dac3d51a19156c221fbf262 100644
--- a/src/scripts/main.js
+++ b/src/scripts/main.js
@@ -429,10 +429,3 @@ export const create = function(server, opts) {
}

}
-
-// Only run Ackee automatically when executed in a browser environment
-if (isBrowser === true) {
-
- detect()
-
-}
\ No newline at end of file
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@reduxjs/toolkit": "2.0.1",
"@replit/codemirror-vim": "6.1.0",
"@unocss/reset": "0.58.0",
"ackee-tracker": "patch:ackee-tracker@npm%3A5.1.0#~/.yarn/patches/ackee-tracker-npm-5.1.0-0db5cc0193.patch",
"immer": "10.0.3",
"js-base64": "3.7.5",
"pako": "2.1.0",
Expand All @@ -35,6 +36,7 @@
"rxjs": "8.0.0-alpha.12"
},
"devDependencies": {
"@types/ackee-tracker": "5.0.4",
"@types/eslint": "^8",
"@types/jest": "29.5.11",
"@types/pako": "2.0.3",
Expand Down
2 changes: 2 additions & 0 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import { useGlobalExceptionHandler } from '@/features/exception/hooks'
import IoDevices from '@/features/io/IoDevices'
import Memory from '@/features/memory/Memory'

import { useAckee } from './hooks'
import ReloadPrompt from './ReloadPrompt'
import ResizablePanel from './ResizablePanel'

const App = (): JSX.Element => {
useGlobalExceptionHandler()
useAckee()

return (
<>
Expand Down
23 changes: 23 additions & 0 deletions src/app/hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as tracker from 'ackee-tracker'
import { useEffect } from 'react'

import { useSingleton } from '@/common/hooks'

const DETAILED = true

export const useAckee = () => {
const instance = useSingleton(() => tracker.create('https://ackee.exuanbo.xyz/'))

useEffect(() => {
const attributes = tracker.attributes(DETAILED)

const { pathname, origin } = window.location
const url = new URL(pathname, origin)

const { stop } = instance.record('bc75fd47-884f-4723-aaf6-3384103e0095', {
...attributes,
siteLocation: url.href,
})
return stop
}, [instance])
}
34 changes: 34 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2440,6 +2440,13 @@ __metadata:
languageName: node
linkType: hard

"@types/ackee-tracker@npm:5.0.4":
version: 5.0.4
resolution: "@types/ackee-tracker@npm:5.0.4"
checksum: f4c935ab715bad81e5c8d1c710dd205b2c6184971cb5b1f95a38c6680e27309ca011fc8c49632933b76138ff25cb84de7f06287f24b4c88aef298fcdab386105
languageName: node
linkType: hard

"@types/babel__core@npm:^7.1.14, @types/babel__core@npm:^7.20.5":
version: 7.20.5
resolution: "@types/babel__core@npm:7.20.5"
Expand Down Expand Up @@ -3099,6 +3106,24 @@ __metadata:
languageName: node
linkType: hard

"ackee-tracker@npm:5.1.0":
version: 5.1.0
resolution: "ackee-tracker@npm:5.1.0"
dependencies:
platform: "npm:^1.3.6"
checksum: c2861a86023bd51fcb433f85d69c134fa22f53e1d389a8036f49ba44fb1ec093ca8847bf2003a0db84aac835e9dd61b62b66e957d021bb06f21ddbccca8145cc
languageName: node
linkType: hard

"ackee-tracker@patch:ackee-tracker@npm%3A5.1.0#~/.yarn/patches/ackee-tracker-npm-5.1.0-0db5cc0193.patch":
version: 5.1.0
resolution: "ackee-tracker@patch:ackee-tracker@npm%3A5.1.0#~/.yarn/patches/ackee-tracker-npm-5.1.0-0db5cc0193.patch::version=5.1.0&hash=7e078a"
dependencies:
platform: "npm:^1.3.6"
checksum: d4d3bb0f1cc651b18053e6b35b1b7778c6d15d733b262c5540a73575a87779f36888f4113b9ccef9d0e169158f9fb683b961272a2c505303d9cce6454014cb89
languageName: node
linkType: hard

"acorn-globals@npm:^7.0.0":
version: 7.0.1
resolution: "acorn-globals@npm:7.0.1"
Expand Down Expand Up @@ -3364,6 +3389,7 @@ __metadata:
"@codemirror/view": "npm:6.22.1"
"@reduxjs/toolkit": "npm:2.0.1"
"@replit/codemirror-vim": "npm:6.1.0"
"@types/ackee-tracker": "npm:5.0.4"
"@types/eslint": "npm:^8"
"@types/jest": "npm:29.5.11"
"@types/pako": "npm:2.0.3"
Expand All @@ -3377,6 +3403,7 @@ __metadata:
"@unocss/transformer-directives": "npm:0.58.0"
"@unocss/transformer-variant-group": "npm:0.58.0"
"@vitejs/plugin-react": "npm:4.2.1"
ackee-tracker: "patch:ackee-tracker@npm%3A5.1.0#~/.yarn/patches/ackee-tracker-npm-5.1.0-0db5cc0193.patch"
eslint: "npm:8.55.0"
eslint-config-prettier: "npm:9.1.0"
eslint-plugin-react: "npm:7.33.2"
Expand Down Expand Up @@ -7197,6 +7224,13 @@ __metadata:
languageName: node
linkType: hard

"platform@npm:^1.3.6":
version: 1.3.6
resolution: "platform@npm:1.3.6"
checksum: 69f2eb692e15f1a343dd0d9347babd9ca933824c8673096be746ff66f99f2bdc909fadd8609076132e6ec768349080babb7362299f2a7f885b98f1254ae6224b
languageName: node
linkType: hard

"postcss@npm:^8.4.32":
version: 8.4.32
resolution: "postcss@npm:8.4.32"
Expand Down

0 comments on commit 7e8c51a

Please sign in to comment.