analytics-testing

analytics-testing is a cursor rule for Cursor from brendadeeznuts1111/betting-brain-v3. It costs 1,310 tokens per session, scanned A, original, MIT.

A set of testing rules for analytics calls made through an analytics data service. It uses an in-memory stub that records calls and provides checks for their contents and count.

In plain words
What is it for?
Use it to create mock analytics environments, inspect recorded calls, check call counts and values, and write reusable analytics assertions.
Why use it?
It lets tests verify analytics behavior without network access, waiting, or unreliable external services. It also avoids generic mock checks that may not confirm the recorded data correctly.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is import { createMockEnv } from '../utils/test-helpers';.

Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/brendadeeznuts1111/betting-brain-v3
agentmods
npx agentmods add rules/brendadeeznuts1111/betting-brain-v3/analytics-testing

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for analytics-testing

README.md
[![agentmods](https://agentmods.dev/badge/rules/brendadeeznuts1111/betting-brain-v3/analytics-testing.svg)](https://agentmods.dev/rules/brendadeeznuts1111/betting-brain-v3/analytics-testing)
Your own site
<a href="https://agentmods.dev/rules/brendadeeznuts1111/betting-brain-v3/analytics-testing"><img src="https://agentmods.dev/badge/rules/brendadeeznuts1111/betting-brain-v3/analytics-testing.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,310 This file is loaded in full into every session.
When invoked 1,310 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.01310 $0.01310
Opus 5 $0.00655 $0.00655
Sonnet 5 $0.00262 $0.00262
Haiku 4.5 $0.00131 $0.00131

Measured 6d ago against content hash 7c32f176a7e5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

analytics-testing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/analytics-testing.mdc · 193 lines

How it starts

The opening of the file, as written. The whole thing — 193 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Analytics Testing Rules

Core Principles

Analytics Engine calls are first-class citizens in tests

  • No network dependencies
  • No flakes
  • No waiting

Required Patterns

1. Use AnalyticsEngineStub for All Analytics Testing


// ✅ CORRECT: Use the global stub
import { createMockEnv } from '../utils/test-helpers';

const { env: mockEnv, analytics } = createMockEnv();

// Make analytics calls
await mockEnv.ANALYTICS_ENGINE.writeDataPoint({
  blobs: ['event_type', 'data'],
  doubles: [value1, value2],
  tags: { source: 'test' }
});

// Assert with analytics.getCalls()
expect(analytics.callCount()).toBe(1);
expect(analytics.getCalls()[0].blobs).toEqual(['event_type', 'data']);

2. Never Use toHaveBeenCalledWith for Analytics


// ❌ WRONG: Generic mock assertions
expect(mockAnalytics.writeDataPoint).toHaveBeenCalledWith({
  blobs: ['event_type', 'data']
});

// ✅ CORRECT: First-class analytics assertions
expect(analytics.wasCalledWith({
  blobs: ['event_type', 'data']
})).toBe(true);

3. Use Helper Functions for Common Assertions


import { 
  expectAnalyticsCall, 
  expectAnalyticsCallCount,
  expectAnalyticsDoubles 
} from '../utils/test-helpers';

// Clean, readable assertions
expectAnalyticsCall(analytics, {
  blobs: ['event_type', 'data'],
  doubles: [1.5, 1000]
});

expectAnalyticsCallCount(analytics, 1);
expectAnalyticsDoubles(analytics, [1.5, 1000], 0.001);

4. Test Name Detection for Auto-Flush


// ✅ CORRECT: Set test name for auto-flush
test('should track analytics calls with stub', async () => {
  setCurrentTestName('should track analytics calls with stub');
  // Test implementation
});

File Organization

Analytics Test Files

  • Location: tests/unit/analytics-*.test.ts
  • Pattern: analytics-[feature].test.ts
  • Example: analytics-tracking.test.ts

Test Utilities

  • tests/utils/analytics-engine-stub.ts - Core stub implementation
  • tests/utils/test-helpers.ts - Helper functions and assertions
  • tests/setup/test-setup.ts - Global test configuration

Read the full file on GitHub · 193 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 193 lines · 1,310 tokens per session scan A 7c32f176a7e5

Subscribe to this mod's changes

analytics-testing is a cursor rule published in the GitHub repository brendadeeznuts1111/betting-brain-v3 (8 stars, last pushed 11mo ago), licensed MIT. It adds 1,310 tokens to every session, about $0.0066 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.