agentleFS
linuxfoundationlinuxfoundation/insights/.claude/skills/event-tracking/SKILL.md

event-tracking

Skill288 starsChanged 52 days agoMITView on GitHub

Add event tracking calls to Vue/Nuxt components in the Insights app using the useTrackEvent composable. Use this skill whenever a developer asks to "track" a user action or page view, "add analytics", "instrument" a component, "fire an event", implement an event from the events catalog, or wire up tracking for anything in the Insights frontend — even if they just say "track when the user clicks X" or "add tracking to this page".

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. dilolabs/nosia★ 211same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository12 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 3 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Adding events for a new feature: create events/<feature>.ts, define its <Feature>EventKey enum and <FEATURE>_EVENT_DEFINITIONS record, then …

    line 33
  2. Very specific:

    Always use the feature-specific key enum (e.g.

    line 47
  3. Very specific:

    Always start by reading references/events-catalog.md to find the event that matches what the developer described.

    line 71
  4. Distinctive:

    If no catalog entry matches, note this to the developer and suggest the closest match or a new entry following the conventions at the …

    line 73
  5. Distinctive:

    Read the target component or page file before making any changes.

    line 84
  6. Very specific:

    Place trackEvent(...) inside the action handler, after the main logic succeeds.

    line 94
  7. Very specific:

    Place inside onMounted(). Add to an existing onMounted if one already exists.

    line 111
  8. Very specific:

    If the event requires data that loads asynchronously (e.g.

    line 121
  9. Distinctive:

    No TypeScript errors introduced

    line 158
  10. Very specific:

    Place after the await so it only fires on success:

    line 176
  11. Very specific:

    Add EventFeature.MY_FEATURE to the EventFeature enum in base.ts.

    line 222
  12. Very specific:

    Add the new events to references/events-catalog.md under a new section.

    line 224

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Event Tracking — Insights App

Status: Ready for rollout, but Segment dispatch is currently disabled in frontend/composables/useTrackEvent.ts pending alignment with the analytics team. Events still persist to the internal events table via /api/events. Re-enable by uncommenting the $track block in the composable.

What this skill does

Helps you add the right trackEvent() call to the right place in the codebase, using the catalog-approved event definitions.

File structure

frontend/app/components/shared/types/events/
├── base.ts           # EventType, EventFeature enums; EventDefinition interface
├── index.ts          # EventKey union type; aggregated EVENT_DEFINITIONS record
└── collections.ts    # CollectionsEventKey enum + COLLECTIONS_EVENT_DEFINITIONS
    <feature>.ts      # (future) FeatureEventKey enum + FEATURE_EVENT_DEFINITIONS

frontend/composables/useTrackEvent.ts   # just the tracking function

Adding events for a new feature: create events/<feature>.ts, define its <Feature>EventKey enum and <FEATURE>_EVENT_DEFINITIONS record, then re-export both from index.ts.

index.ts shape:

export type EventKey = CollectionsEventKey; // | FutureFeatureEventKey | ...
export const EVENT_DEFINITIONS: Record<EventKey, EventDefinition> = {
  ...COLLECTIONS_EVENT_DEFINITIONS,
  // ...FUTURE_FEATURE_EVENT_DEFINITIONS,
};

How to use

Always use the feature-specific key enum (e.g. CollectionsEventKey), not the union EventKey type. The composable itself only needs useTrackEvent — the key enum comes from the feature's events file.

import { useTrackEvent } from '~~/composables/useTrackEvent';
import { CollectionsEventKey } from '~/components/shared/types/events/collections';

const { trackEvent } = useTrackEvent();

trackEvent({
  key: CollectionsEventKey.CREATE_COLLECTION,
  properties: { newCollectionId, isPrivate }, // catalog-defined fields only — optional
});

name, type, and feature are looked up automatically from EVENT_DEFINITIONS — never pass them in the call.

source (current URL) and entrySource (referrer) are captured automatically — never pass them manually.

The call is always fire-and-forget: errors are caught inside the composable and never bubble up.

Step-by-step workflow

1. Read the events catalog

Always start by reading references/events-catalog.md to find the event that matches what the developer described. The catalog is organized by feature section (e.g. "Community Collections"). Note the enum value and properties columns — use those exactly.

If no catalog entry matches, note this to the developer and suggest the closest match or a new entry following the conventions at the bottom of the catalog.

2. Identify the target file and feature

Infer the feature from context (e.g. "track when the user creates a collection" → Community Collections). This tells you which key enum to import:

FeatureKey enumImport path
Community CollectionsCollectionsEventKey~/components/shared/types/events/collections
(future features)<Feature>EventKey~/components/shared/types/events/<feature>

Read the target component or page file before making any changes. You need to understand:

  • Whether useTrackEvent is already imported
  • For feature events: which function handles the user action
  • For page events: whether onMounted already exists

3. Insert the tracking call

Feature events

Place trackEvent(...) inside the action handler, after the main logic succeeds.

const handleCreateCollection = async () => {
  const result = await createCollection(...)

  trackEvent({
    key: CollectionsEventKey.CREATE_COLLECTION,
    properties: { newCollectionId: result.id, isPrivate: form.isPrivate },
  })
}

For abandonment events, fire when the user dismisses or navigates away without completing the flow — typically on modal close before the success state is reached.

Page events

Place inside onMounted(). Add to an existing onMounted if one already exists.

onMounted(() => {
  trackEvent({ key: CollectionsEventKey.VIEW_DISCOVER_COLLECTIONS });
});

Events that need async data (e.g. viewerType)

If the event requires data that loads asynchronously (e.g. collection details needed to determine viewerType), use watch with { once: true } instead of onMounted:

watch(
  data,
  (collection) => {
    if (!collection) return;
    trackEvent({
      key: CollectionsEventKey.VIEW_COLLECTION,
      properties: {
        collectionId: collection.id,
        viewerType:
          collection.ssoUserId && user.value?.sub === collection.ssoUserId ? 'owner' : 'guest',
      },
    });
  },
  { once: true },
);

4. Add the imports (if missing)

import { useTrackEvent } from '~~/composables/useTrackEvent';
import { CollectionsEventKey } from '~/components/shared/types/events/collections';

Then destructure at the top level of <script setup>:

const { trackEvent } = useTrackEvent();

The ~~ alias points to frontend/, ~ points to frontend/app/. Neither is auto-imported.

5. Verify

  • No TypeScript errors introduced
  • The tracking call does not change the control flow of existing logic
  • Properties only include fields listed in the catalog for that event

Common patterns

Properties with runtime values

// Good
properties: { collectionId: collection.id, isPrivate: collection.isPrivate }

// Bad
properties: { collectionId: 'collectionId', isPrivate: 'isPrivate' }

Tracking after async operations

Place after the await so it only fires on success:

await updateCollection(payload);
trackEvent({
  key: CollectionsEventKey.UPDATE_COLLECTION,
  properties: { collectionId, changedFields },
});

Multiple events in one handler

Track each separately in the right order.

Adding events for a new feature

  1. Create frontend/app/components/shared/types/events/<feature>.ts:

    import { EventFeature, EventType, type EventDefinition } from './base';
    
    export enum MyFeatureEventKey {
      DO_THING = 'do-thing',
    }
    
    export const MY_FEATURE_EVENT_DEFINITIONS: Record<MyFeatureEventKey, EventDefinition> = {
      [MyFeatureEventKey.DO_THING]: {
        key: MyFeatureEventKey.DO_THING,
        type: EventType.FEATURE,
        name: 'Do thing',
        feature: EventFeature.MY_FEATURE,
        allowedProperties: [],
      },
    };
  2. In index.ts, extend the union and spread into EVENT_DEFINITIONS:

    export type EventKey = CollectionsEventKey | MyFeatureEventKey;
    export const EVENT_DEFINITIONS = {
      ...COLLECTIONS_EVENT_DEFINITIONS,
      ...MY_FEATURE_EVENT_DEFINITIONS,
    };
  3. Add EventFeature.MY_FEATURE to the EventFeature enum in base.ts.
  4. Add the new events to references/events-catalog.md under a new section.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.