Skip to content

jonathanleane/Tapistry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Tapistry Analytics Platform

A privacy-first, high-performance web analytics platform delivering click heatmaps, session replays, and funnel analytics through a single JavaScript snippet.

πŸš€ Quick Start

What's Built So Far

βœ… Phase 1 Foundation (Complete)

  • SDK core with event collection (clicks, page views, scroll tracking)
  • Session management with 30-minute timeout
  • Event batching and transport layer
  • Privacy features (DNT respect, data masking)
  • Monorepo structure with TypeScript

⏳ Still Needed

  • Cloudflare Workers for data ingestion
  • ClickHouse database setup
  • Next.js dashboard
  • Session replay (Phase 2)
  • Funnel analytics (Phase 3)

πŸ“‹ Prerequisites

Before you begin, you'll need accounts for these services:

  1. Cloudflare (for Workers & R2 storage)

  2. ClickHouse Cloud (for analytics data)

  3. Neon (for PostgreSQL metadata)

    • Sign up at neon.tech
    • Create a new project and get the connection string
  4. Vercel (for dashboard hosting)

    • Sign up at vercel.com
    • Connect your GitHub account

πŸ› οΈ Local Development Setup

1. Clone and Install

# Clone the repository
git clone https://github.com/jonathanleane/Tapistry.git
cd Tapistry

# Install dependencies
npm install

2. Environment Configuration

Create a .env file in the root:

# Cloudflare
CF_ACCOUNT_ID=your_account_id
CF_API_TOKEN=your_api_token
R2_ACCESS_KEY_ID=your_r2_access_key
R2_SECRET_ACCESS_KEY=your_r2_secret_key

# ClickHouse Cloud
CLICKHOUSE_HOST=your_host.clickhouse.cloud
CLICKHOUSE_USER=default
CLICKHOUSE_PASSWORD=your_password

# Neon PostgreSQL
DATABASE_URL=postgresql://user:pass@host/dbname

# Dashboard (for local development)
NEXTAUTH_SECRET=generate_a_secret_here
NEXTAUTH_URL=http://localhost:3000

3. Build the SDK

# Build shared types first
npm run build:shared

# Build the SDK
npm run build:sdk

# The SDK will be available at packages/sdk/dist/tapistry.js

🚧 Next Steps to Get Running

Step 1: Set Up Cloudflare Workers (Required)

The SDK needs an ingestion endpoint to send data to. Create the Cloudflare Worker:

# Navigate to edge package
cd packages/edge

# Create the worker files (TODO: implement these)
# - src/index.ts (main worker)
# - src/routes/ingest.ts (handles /i endpoint)
# - src/validation.ts (validates events)
# - wrangler.toml (Cloudflare config)

# Deploy to Cloudflare
npx wrangler deploy

Step 2: Initialize Databases (Required)

ClickHouse Setup

-- Run these in your ClickHouse Cloud console
-- See migrations/clickhouse/001_initial.sql (needs to be created)

Neon PostgreSQL Setup

-- Run these in your Neon console
-- See migrations/postgres/001_initial.sql (needs to be created)

Step 3: Test the SDK

Create a test HTML file:

<!DOCTYPE html>
<html>
<head>
  <title>Tapistry Test</title>
</head>
<body>
  <h1>Testing Tapistry Analytics</h1>
  <button id="test-button">Click Me</button>
  
  <!-- Tapistry SDK -->
  <script>
    (function(w,d,s,u,k){w.tapistry=w.tapistry||function(){(w.tapistry.q=w.tapistry.q||[]).push(arguments)};
      var js=d.createElement(s);js.async=1;js.src=u;js.dataset.project=k;
      d.head.appendChild(js);
    })(window,document,'script','./packages/sdk/dist/tapistry.js','YOUR_PROJECT_KEY');
    
    tapistry('config', {
      apiUrl: 'http://localhost:8787', // Your local Cloudflare Worker
      debug: true
    });
  </script>
</body>
</html>

Step 4: Build the Dashboard (Optional for now)

cd packages/dashboard

# Create Next.js app structure (TODO)
# Implement pages:
# - Overview
# - Heatmaps
# - Session Replays
# - Funnels

npm run dev
# Dashboard will be at http://localhost:3000

πŸ“ Project Structure

Tapistry/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ sdk/              βœ… Client-side JavaScript SDK
β”‚   β”œβ”€β”€ shared/           βœ… Shared TypeScript types
β”‚   β”œβ”€β”€ edge/             ❌ Cloudflare Workers (TODO)
β”‚   └── dashboard/        ❌ Next.js dashboard (TODO)
β”œβ”€β”€ migrations/
β”‚   β”œβ”€β”€ clickhouse/       ❌ ClickHouse schemas (TODO)
β”‚   └── postgres/         ❌ Neon schemas (TODO)
β”œβ”€β”€ plan.md               βœ… Detailed technical specification
β”œβ”€β”€ CLAUDE.md            βœ… AI development guide
└── README.md            βœ… This file

πŸ§ͺ Testing

# Run all tests
npm test

# Run specific package tests
npm run test --workspace=@tapistry/sdk

# Check bundle size
npm run size --workspace=@tapistry/sdk

πŸ“Š Current Implementation Status

SDK Features

  • βœ… Event collection (clicks, page views, scroll)
  • βœ… Session management
  • βœ… Event batching
  • βœ… SPA route detection
  • βœ… Privacy controls (DNT, masking)
  • ❌ Session replay recording
  • ❌ Custom event tracking
  • ❌ User identification

Infrastructure

  • ❌ Cloudflare Worker ingestion
  • ❌ ClickHouse event storage
  • ❌ PostgreSQL metadata
  • ❌ R2 replay storage
  • ❌ Dashboard UI
  • ❌ Authentication system

🀝 Contributing

This project is in active development. The Phase 1 SDK foundation is complete, but the backend infrastructure and dashboard still need to be built.

Priority tasks:

  1. Implement Cloudflare Worker for data ingestion
  2. Set up ClickHouse schemas and materialized views
  3. Create basic dashboard with heatmap viewer
  4. Add authentication system

See plan.md for the complete technical specification.

πŸ“ License

Private project - not yet licensed for public use.

πŸ†˜ Troubleshooting

SDK not loading?

  • Check browser console for errors
  • Verify project key is set
  • Ensure Cloudflare Worker is deployed

No data showing up?

  • Check SDK debug mode: tapistry('debug', true)
  • Verify ingestion endpoint is accessible
  • Check browser network tab for failed requests

Build errors?

  • Run npm run clean and reinstall
  • Ensure Node.js >= 18.0.0
  • Check TypeScript errors: npm run typecheck

πŸ“š Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors