Email templates for Tracked Training Platform
npm install @tracked/emailsEmail templates and utilities for Tracked Training Platform.
- ๐ง Pre-built React Email templates for common use cases
- โ
Email and username validation utilities
- ๐จ Consistent branding and styling
- ๐ฆ TypeScript support with full type definitions
- ๐งช Comprehensive test coverage
``bash`
npm install @tracked/emailsor
yarn add @tracked/emailsor
pnpm add @tracked/emails
Import and use any of the pre-built email templates:
`typescript
import { TrackedMagicLink, WelcomeEmail } from '@tracked/emails';
import { render } from '@react-email/components';
// Magic link email
const magicLinkHtml = render(
);
// Welcome email
const welcomeHtml = render(
);
`
- TrackedMagicLink - Magic link authentication emailsTrackedMagicLinkActivate
- - Account activation emailsWelcomeEmail
- - Welcome new usersCoachInviteEmail
- - Coach invitation emailsTeamInviteEmail
- - Team invitation emailsFirstWorkoutAssignedEmail
- - First workout assignment notificationFirstWorkoutCompletedEmail
- - First workout completion celebrationNewFollowerEmail
- - New follower notificationsDirectMessageEmail
- - Direct message notificationsSupportEmail
- - Support request confirmationsFeatureDiscoveryEmail
- - Feature announcement emailsWeekOneCheckinEmail
- - First week check-inClientAcceptedInvitationEmail
- - Client acceptance notificationCoachRemovedClientEmail
- - Client removal notificationTeamMemberRemovedEmail
- - Team member removal notificationSubscriptionCanceledEmail
- - Subscription cancellation confirmationBodyweightGoalReachedEmail
- - Goal achievement celebration
#### Email Validation
`typescript
import {
isValidEmailFormat,
isPrivateRelayEmail,
shouldSendEmailTo
} from '@tracked/emails';
// Check email format
isValidEmailFormat('user@example.com'); // true
isValidEmailFormat('invalid-email'); // false
// Detect Apple private relay emails
isPrivateRelayEmail('abc123@privaterelay.appleid.com'); // true
isPrivateRelayEmail('user@gmail.com'); // false
// Main validation function (recommended)
shouldSendEmailTo('user@example.com'); // true
shouldSendEmailTo('abc@privaterelay.appleid.com'); // false
shouldSendEmailTo(null); // false
`
#### Username Validation
`typescript
import {
isAnonymousUsername,
getSafeDisplayName
} from '@tracked/emails';
// Detect auto-generated UUIDs
isAnonymousUsername('01944f9e-8e64-7a78-9e1e-3daba7b13e9f'); // true
isAnonymousUsername('john_doe'); // false
// Get safe display name with intelligent fallback
getSafeDisplayName('john_doe', 'John', 'John Smith'); // 'john_doe'
getSafeDisplayName('01944f9e-...', 'John', 'John Smith'); // 'John'
getSafeDisplayName('01944f9e-...', null, 'John Smith'); // 'John Smith'
getSafeDisplayName('01944f9e-...', null, null); // 'there'
getSafeDisplayName('01944f9e-...', null, null, 'friend'); // 'friend'
`
`bashInstall dependencies
yarn install
$3
This package uses React Email for email development.
`bash
Start the email preview server
yarn dev:email
`Then open http://localhost:3000 to preview all email templates.
Testing
The package includes comprehensive tests for all validation utilities:
`bash
Run all tests
yarn testRun with coverage
yarn test:coverageWatch mode for development
yarn test:watch
`Building
`bash
yarn build
`This will:
1. Clean the
dist/ directory
2. Compile TypeScript to ESM format
3. Generate type definitions and source mapsPublishing
`bash
Version bump (patch/minor/major)
npm version patchPublish to npm
npm publish --access public
`Package Structure
`
@tracked/emails/
โโโ src/
โ โโโ emails/ # Email template components
โ โโโ utils/ # Validation utilities
โ โโโ index.ts # Main entry point
โโโ static/ # Static assets (logos, images)
โโโ dist/ # Build output
โโโ package.json
``This package is written in TypeScript and includes full type definitions. All exports are fully typed for the best developer experience.
MIT ยฉ Tracked Training Platform Inc.
This package is part of the Tracked Training Platform ecosystem. For issues or feature requests, please contact the development team.