Skip to content

feat: analytics - #917

Merged
jim-at-stink merged 4 commits into
go-v2/mainfrom
go-v2/feat/analytics
Apr 10, 2026
Merged

feat: analytics#917
jim-at-stink merged 4 commits into
go-v2/mainfrom
go-v2/feat/analytics

Conversation

@jim-at-stink

@jim-at-stink jim-at-stink commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

Adding simple event tracking, using the shared postAnalyticsEvent() function.

Currently triggers for all of the events originally mentioned in the doc shared with @dominoweir.

  • versus-banner
  • hero-animation-first-capture
  • hero-animation-critical-hit
  • hero-animation-...
  • annotation-komi
  • annotation-false-eye
  • annotation-...
  • info-open
  • info-closed
  • settings-open
  • settings-closed
  • settings-reduce-motion-on
  • settings-hero-animation-off
  • settings-...-on/off
  • sound-on
  • sound-off
  • game-over

But I know some of these are not so interesting for the Kaggle team so might be taken out, it was more to try out how the naming events would work and if simple strings for each are ok. Or if using the ability to pass in an object to postAnalyticsEvent and more structured events would be handy.

To make it easier to check if the events are triggering rather than having to watch the parent window for messages being posted , added logging that can be enabled in .env with VITE_LOG_ANALYTICS.

Just currently not sending a game property to postAnalyticsEvent, should this be go or go-v2?

@jim-at-stink
jim-at-stink changed the base branch from master to go-v2/main April 7, 2026 17:26
@google-cla

google-cla Bot commented Apr 7, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@jim-at-stink
jim-at-stink force-pushed the go-v2/feat/analytics branch 2 times, most recently from 7cc8437 to 05172ac Compare April 7, 2026 17:52
@jim-at-stink

Copy link
Copy Markdown
Collaborator Author

@dominoweir Is this the kind of thing you were thinking, that we'd grab the postAnalyticsEvent from the web/core folder and use it in this kind of way? Let me know what you think!

cc: @kjsutherland

@jim-at-stink
jim-at-stink force-pushed the go-v2/feat/analytics branch from 05172ac to b3f94ec Compare April 7, 2026 18:04

@dominoweir dominoweir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, this is precisely what I was thinking!

Comment on lines +3 to +8
export function trackEvent(event: string) {
if (import.meta.env.DEV && import.meta.env.VITE_LOG_ANALYTICS) {
console.log(`Track Event: ${event}`);
}

postAnalyticsEvent(event);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this added logging- I'm guessing that dev environment variable is specific to this visualizer? if not we should consider moving this to web/core

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use of .env for a few things like this, from logging out the board from the game object to picking a replay file to preview with, so yep it's specific here just now.

We'd generally leave this kind of logging as a project specific thing, as we'll log just what we're sending to our trackEvent function formatting it to be easier to read in the console and omitting common stuff that's repeated across all the final tracking calls that we're not so interested in when while we're implementing and testing it.

But as the data in the tracking events are nice and simple how you've set it up having in in core would totally work too.

@@ -0,0 +1,9 @@
import { postAnalyticsEvent } from '../../../../../../../../../web/core/src/analytics';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I'm guessing I forgot to export this and hence it doesn't show up as an export from @kaggle-environments/core, I can fix that real quick

@dominoweir dominoweir Apr 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh wait it's exported- you should be able to do import { postAnalyticsEvent } from "@kaggle-environments/core" which is a bit cleaner

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's much nicer, my bad I should have spotted that and tidied it up. Thanks!

@dominoweir

Copy link
Copy Markdown
Contributor

Just currently not sending a game property to postAnalyticsEvent, should this be go or go-v2?

I'm fine with it just being go, the basic one ofc doesn't have any logging and if we say v2 we'll have to go back and edit it later

@jim-at-stink
jim-at-stink force-pushed the go-v2/feat/analytics branch from 3aad564 to 15b82b9 Compare April 8, 2026 09:28
@jim-at-stink

jim-at-stink commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

I'm fine with it just being go, the basic one ofc doesn't have any logging and if we say v2 we'll have to go back and edit it later

When I log out gameName where it's being used in ReasoningLogs.tsx it's the name from where creating the ReplayAdapter.

const gameName = 'open_spiel_go';
const ui = 'side-panel';
const adapter = new ReplayAdapter({
gameName,
GameRenderer,
ui,
transformer,
getStepRenderTime,
getStepLabel,
});
createReplayVisualizer(element, adapter);

So our case it's currently open_spiel_go since this used to relate to the transformer to use when it was in the core stuff.

Now the transformer is in our visualizer's code I seem to be able to change this without anything breaking. I'm not sure if it's still used anywhere apart from your new postAnalyticsEvent calls in ReasoningLogs though.

Is this correct @dominoweir that we can change this without effecting anything else now?

So I'm thinking we need to make sure our tracking calls set game to the same thing as gameName in ReplayAdapter to make sure the events you've added and the visualizer specific ones I've added all end up under the same name. (1a0281f)

open_spiel_go or go?

@jim-at-stink
jim-at-stink marked this pull request as ready for review April 8, 2026 13:32
@dominoweir

Copy link
Copy Markdown
Contributor

So I'm thinking we need to make sure our tracking calls set game to the same thing as gameName in ReplayAdapter to make sure the events you've added and the visualizer specific ones I've added all end up under the same name.

Totally agree with this take- I think for sanity purposes as we scale up the number of games, having confidence that the name we should look up is the same as the name in replays will be great. open_spiel_go makes sense to me.

@jim-at-stink
jim-at-stink merged commit 9f5dc7f into go-v2/main Apr 10, 2026
3 checks passed
@jim-at-stink
jim-at-stink deleted the go-v2/feat/analytics branch April 10, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants