Skip to content

Commit

Permalink
analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
ankushKun committed Aug 20, 2024
1 parent 5f04837 commit a5d0ca4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
5 changes: 2 additions & 3 deletions next_app/backend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ type TBody = {
cellId: string
appName: string
messageId?: string
domain: string
path: string
referrer: string
}

const codecell_load_table = `CREATE TABLE IF NOT EXISTS codecell_loads (
Expand Down Expand Up @@ -51,7 +50,7 @@ app.post('/analytics', (req, res) => {
const body = req.body as TBody;
const ipAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress;

console.log(timestamp, ipAddress, body)
console.log(timestamp + " - " + ipAddress + " - " + body)

switch (body.action) {
case "codecell_load":
Expand Down
9 changes: 4 additions & 5 deletions next_app/src/pages/codecell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ export default function CodeCell() {
//this is in an iframe, get the parent websites domain and path
const body = {
...data, userId,
domain: document.referrer,
path: window.parent.location.pathname
referrer: document.referrer,
};

await fetch(`${BASE}/analytics`, {
Expand All @@ -70,10 +69,10 @@ export default function CodeCell() {
}

useEffect(() => {
console.log(sendAnalytics({
sendAnalytics({
action: "codecell_load",
appname: appname,
}))
}).then(console.log)
}, [appname]);

useEffect(() => {
Expand Down Expand Up @@ -335,7 +334,7 @@ export default function CodeCell() {
]);
const out = parseOutupt(r);
if (r.Error) return toast.error(r.Error);
console.log(sendAnalytics({ appname: appname, action: "codecell_run", messageId: (r as any).id }))
sendAnalytics({ appname: appname, action: "codecell_run", messageId: (r as any).id }).then(console.log);
console.log(out);
setOutput(out);
setRunning(false);
Expand Down
2 changes: 1 addition & 1 deletion next_app/src/pages/dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function Dev() {
cellId="1" // any unique cell id
appName="BetterIDEa" // Your unique app name
code="print('Portable code cell ftw!')" // initial code (optional)
// devMode
devMode
nowallet
onNewMessage={(message) => {
message.forEach((m) => {
Expand Down

0 comments on commit a5d0ca4

Please sign in to comment.