Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analytics + metrics #359

Open
rglover opened this issue Oct 25, 2023 · 0 comments
Open

Analytics + metrics #359

rglover opened this issue Oct 25, 2023 · 0 comments
Assignees
Labels
feature Something new to add @joystick.js/node Related to the @joystick.js/node package. @joystick.js/ui Related to the @joystick.js/ui package.
Projects

Comments

@rglover
Copy link
Contributor

rglover commented Oct 25, 2023

This is for Push but I want to implement it at the framework level. Idea would be to have a way to do this...

import joystick, { track } from '@joystick.js/ui';

const MyPage = joystick.component({
  lifecycle: {
    onMount: () => {
       track.analytics.visit(location?.pathname, { someMetadata: 'blah' });
    },
  },
  events: {
    'click button': () => {
      track.metrics.event('clicked_button', { someMetadata: 'blah' });
    },
  },
  render: () => {
    return `
      <button></button>
    `;
  },
});

On the server, you could define hooks that could be used to output tracked events to any service. Internally, we'd check to see if the app is push deployed, and if it is, route data to the in-memory DB for Push.

import joystick from '@joystick.js/node';

joystick.app({
  track: {
    analytics: {
      on_visit: (url = '', metadata = {}) => {}
    },
    metrics: {
      on_event: (event = '', metadata = {}) => {}
    },
  },
  routes: { ... },
});

The ultimate goal being to avoid getting tied to a single service's way of doing things. If a service goes away or you change, you don't have to reinstrument your app, just update the hook logic on the server.

@rglover rglover added feature Something new to add @joystick.js/ui Related to the @joystick.js/ui package. @joystick.js/node Related to the @joystick.js/node package. labels Oct 25, 2023
@rglover rglover self-assigned this Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Something new to add @joystick.js/node Related to the @joystick.js/node package. @joystick.js/ui Related to the @joystick.js/ui package.
Projects
1.x.x
Awaiting triage
Development

No branches or pull requests

1 participant