A Next.js application to check Lytics expression mappings and see parsed results. This tool allows you to test Lytics expressions with field mappings and visualize the results.
- Input Lytics expressions
- Define field mappings (field name → input value)
- Check mappings and see parsed results
- Clean, modern UI with dark mode support
- Node.js 18+ installed
- npm or yarn package manager
- Install dependencies:
npm install-
Set up environment variables:
- Copy
env.exampleto.env.local:
cp env.example .env.local
- Edit
.env.localand add your Lytics auth token:
LYTICS_AUTH_TOKEN=your_actual_auth_token_here
- Copy
-
Run the development server:
npm run dev- Open http://localhost:3000 in your browser
├── app/
│ ├── api/
│ │ └── check-mapping/
│ │ └── route.ts # API route for Lytics integration
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout
│ └── page.tsx # Main page component
├── components/
│ ├── MappingInput.tsx # Field mapping input component
│ └── ResultDisplay.tsx # Result display component
└── package.json
The application is integrated with the Lytics API endpoint:
- Endpoint:
https://api.lytics.io/v2/schema/expression/evaluate - Method: POST
- Authentication: Uses Authorization token header from environment variable
The API route is located at app/api/check-mapping/route.ts. It:
- Takes the Lytics expression from the input
- Converts field mappings to the data object format
- Uses the auth token from
LYTICS_AUTH_TOKENenvironment variable - Sends the request to Lytics API
- Returns the parsed result
The application requires a .env.local file with your Lytics auth token:
LYTICS_AUTH_TOKEN: Your Lytics API authentication token
Security: The .env.local file is gitignored and will not be committed to version control.
npm run build
npm start- Next.js 14 - React framework with App Router
- TypeScript - Type safety
- Tailwind CSS - Styling
- React 18 - UI library
- Enter a Lytics expression in the expression input box
- Add field mappings (field name and corresponding input value)
- Click "Check Mapping" to evaluate the expression
- View the parsed result from Lytics API
Note: The auth token is securely stored in .env.local and is not exposed in the UI.
- The frontend collects the expression and field mappings
- Field mappings are converted to a data object:
{ fieldName: inputValue } - The API route sends a POST request to Lytics with:
expression: The Lytics expression stringdata: Object containing field name → value mappings
- Lytics evaluates the expression and returns the result
- The result is displayed in the UI