Skip to content

Commit 79ec4f1

Browse files
committed
feat: create example app for rokt kit
1 parent 8393291 commit 79ec4f1

13 files changed

Lines changed: 5263 additions & 868 deletions

example-app/.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Rokt mParticle API Key
2+
ROKT_API_KEY=your_api_key_here
3+
# Rokt Account ID
4+
ROKT_ACCOUNT_ID=your_account_id_here

example-app/.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Dependency directories
2+
node_modules/
3+
dist/
4+
5+
# Environment files
6+
.env
7+
.env.local
8+
.env.*.local
9+
10+
# IDE files
11+
.vscode/
12+
.idea/
13+
14+
# Logs
15+
*.log
16+
npm-debug.log*
17+
yarn-debug.log*
18+
yarn-error.log*
19+
20+
# OS generated files
21+
.DS_Store
22+
.DS_Store?
23+
._*
24+
.Spotlight-V100
25+
.Trashes
26+
ehthumbs.db
27+
Thumbs.db

example-app/README.md

Lines changed: 78 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,82 @@
1-
# Rokt Kit Snippet Example
1+
# mParticle Rokt Kit Example App
22

3-
This is a simple example application that demonstrates the integration between mParticle and Rokt using the snippet approach.
4-
5-
## Overview
6-
7-
This example shows how to:
8-
9-
1. Initialize the mParticle Web SDK using the standard snippet approach
10-
2. Load and register the Rokt Kit with mParticle
11-
3. Display the Rokt Layout when a button is clicked
3+
This is an example web application that demonstrates the integration of the mParticle Rokt Kit using webpack.
124

135
## Setup
146

15-
1. Build the Rokt Kit by running the following command in the root directory:
16-
```
17-
npm run build
18-
```
19-
20-
2. Navigate to the example app directory:
21-
```
22-
cd example-app
23-
```
24-
25-
3. Install the dependencies:
26-
```
27-
npm install
28-
```
29-
30-
4. Open `index.html` and replace the API key placeholders with your mParticle API key:
31-
- Look for `'REPLACE_WITH_API_KEY'` in two places and update with your API key
32-
33-
5. Start the example server:
34-
```
35-
npm start
36-
```
37-
38-
6. Open your browser and navigate to http://localhost:3000
39-
40-
## Usage
41-
42-
The example app provides a simple UI with a button that, when clicked, triggers the display of the Rokt Layout component.
43-
44-
1. Click the "Show Rokt Layout" button
45-
2. If everything is set up correctly, the Rokt Layout should be displayed
46-
3. Check the console output in the app for logs and any potential errors
47-
48-
## Troubleshooting
49-
50-
If the Rokt Layout isn't displaying:
51-
52-
1. Make sure you've correctly set your mParticle API key
53-
2. Check the console output for any error messages
54-
3. Verify that the Rokt Kit has been properly initialized by checking the logs
55-
4. Ensure that your Rokt account is properly configured with placements
7+
1. Clone the repository
8+
2. Build the parent project first to create the Rokt Kit:
9+
```
10+
cd ..
11+
npm run build
12+
```
13+
3. Install dependencies in the example app:
14+
```
15+
cd example-app
16+
npm install
17+
```
18+
4. Set up your environment variables:
19+
```
20+
cp .env.example .env
21+
```
22+
5. Update the `.env` file with your actual Rokt API key and Account ID:
23+
```
24+
ROKT_API_KEY=your-api-key-here
25+
ROKT_ACCOUNT_ID=your-account-id-here
26+
```
27+
28+
## Development
29+
30+
To start the development server with hot-reloading:
31+
```
32+
npm start
33+
```
34+
35+
This will open the application in your default browser at http://localhost:3000.
36+
37+
## Building for Production
38+
39+
To build the application for production (this will automatically build the parent project first):
40+
```
41+
npm run build
42+
```
43+
44+
This will create a `dist` directory with the bundled application.
45+
46+
## Project Structure
47+
48+
- `src/` - Source code directory
49+
- `index.html` - HTML template
50+
- `index.js` - Main JavaScript file
51+
- `styles.css` - CSS styles
52+
- `dist/` - Production build output (created after running build)
53+
- `.env` - Environment variables (not tracked in git)
54+
- `.env.example` - Example environment variables template
55+
- `.gitignore` - Git ignore configuration
56+
- `webpack.config.js` - Webpack configuration
57+
- `package.json` - Project dependencies and scripts
58+
- `../dist/Rokt-Kit.iife.js` - Rokt Kit integration from parent project
59+
60+
## Environment Variables
61+
62+
The application uses the following environment variables:
63+
64+
- `ROKT_API_KEY`: Your mParticle API key for Rokt integration
65+
- `ROKT_ACCOUNT_ID`: Your Rokt Account ID used for configuring the Rokt kit
66+
67+
These variables should be stored in a `.env` file that is not committed to version control.
68+
69+
## Features
70+
71+
- Webpack bundling for modern JavaScript development
72+
- CSS loading with style-loader and css-loader
73+
- Development server with hot reloading
74+
- Production build optimization
75+
- Integration with the parent project's Rokt Kit
76+
- Environment variable configuration for secure API key management
77+
78+
## Using the Example App
79+
80+
1. Click the "Fire Event" button to trigger a test event in mParticle
81+
2. Click the "Show Rokt Offer" button to display a Rokt placement
82+
3. Check the console output area at the bottom of the page for debug information

example-app/index.html

Lines changed: 0 additions & 189 deletions
This file was deleted.

0 commit comments

Comments
 (0)