Skip to content

Commit 5d701c3

Browse files
committed
add json file for some type
1 parent dc4cd9b commit 5d701c3

File tree

11 files changed

+1056
-28
lines changed

11 files changed

+1056
-28
lines changed

docs/campaign-system.md

Lines changed: 637 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"version": "1.0.0",
3+
"campaigns": [
4+
{
5+
"id": "feature-discovery",
6+
"name": "Feature Discovery Tour",
7+
"description": "Tour that starts when user clicks on a specific element",
8+
"active": true,
9+
"mode": "tour",
10+
"triggers": [
11+
{
12+
"type": "element_click",
13+
"selector": ".help-button",
14+
"delay": 500
15+
}
16+
],
17+
"frequency": {
18+
"type": "session"
19+
},
20+
"tourOptions": {
21+
"steps": [
22+
{
23+
"element": ".feature-panel",
24+
"intro": "This is our main feature panel where you can access advanced tools.",
25+
"position": "left"
26+
},
27+
{
28+
"element": ".settings-icon",
29+
"intro": "Click here to customize your preferences.",
30+
"position": "bottom"
31+
},
32+
{
33+
"element": ".export-button",
34+
"intro": "Use this button to export your data in various formats.",
35+
"position": "top"
36+
}
37+
],
38+
"showProgress": true,
39+
"showBullets": false
40+
}
41+
}
42+
]
43+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"version": "1.0.0",
3+
"campaigns": [
4+
{
5+
"id": "exit-intent-promotion",
6+
"name": "Exit Intent - Special Offer",
7+
"description": "Show special offer when user tries to leave the page",
8+
"active": true,
9+
"mode": "tour",
10+
"triggers": [
11+
{
12+
"type": "exit_intent",
13+
"sensitivity": 10
14+
}
15+
],
16+
"frequency": {
17+
"type": "once"
18+
},
19+
"tourOptions": {
20+
"steps": [
21+
{
22+
"intro": "<h3>Wait! Don't leave yet!</h3><p>We have a special offer just for you. Get 20% off your first purchase!</p>",
23+
"position": "floating"
24+
},
25+
{
26+
"element": ".promo-code",
27+
"intro": "Use code <strong>WELCOME20</strong> at checkout to get your discount.",
28+
"position": "bottom"
29+
}
30+
],
31+
"exitOnEsc": true,
32+
"exitOnOverlayClick": true
33+
},
34+
"analytics": {
35+
"trackViews": true,
36+
"trackCompletions": true
37+
}
38+
}
39+
]
40+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"version": "1.0.0",
3+
"campaigns": [
4+
{
5+
"id": "welcome-tour",
6+
"name": "Welcome Tour - First Visit",
7+
"description": "A welcome tour that appears when a user visits the site for the first time",
8+
"active": true,
9+
"mode": "tour",
10+
"triggers": [
11+
{
12+
"type": "first_visit",
13+
"delay": 1000
14+
}
15+
],
16+
"frequency": {
17+
"type": "once"
18+
},
19+
"tourOptions": {
20+
"steps": [
21+
{
22+
"element": "#header",
23+
"intro": "Welcome to our application! Let's take a quick tour.",
24+
"position": "bottom"
25+
},
26+
{
27+
"element": "#navigation",
28+
"intro": "This is the main navigation menu. You can access all features from here.",
29+
"position": "right"
30+
},
31+
{
32+
"element": "#content",
33+
"intro": "Your main content will appear here.",
34+
"position": "top"
35+
},
36+
{
37+
"element": "#footer",
38+
"intro": "That's it! Enjoy using our application.",
39+
"position": "top"
40+
}
41+
],
42+
"showProgress": true,
43+
"showBullets": true,
44+
"exitOnOverlayClick": false
45+
}
46+
}
47+
]
48+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"version": "1.0.0",
3+
"campaigns": [
4+
{
5+
"id": "form-help-tour",
6+
"name": "Form Assistance Tour",
7+
"description": "Provide help when user starts filling out a form",
8+
"active": true,
9+
"mode": "tour",
10+
"triggers": [
11+
{
12+
"type": "form_interaction",
13+
"selector": "#signup-form input",
14+
"interactionType": "focus"
15+
}
16+
],
17+
"frequency": {
18+
"type": "once"
19+
},
20+
"tourOptions": {
21+
"steps": [
22+
{
23+
"element": "#email-field",
24+
"intro": "Enter your email address. We'll never share it with anyone.",
25+
"position": "right"
26+
},
27+
{
28+
"element": "#password-field",
29+
"intro": "Choose a strong password with at least 8 characters, including numbers and symbols.",
30+
"position": "right"
31+
},
32+
{
33+
"element": "#terms-checkbox",
34+
"intro": "Please review and accept our terms of service and privacy policy.",
35+
"position": "top"
36+
}
37+
],
38+
"exitOnEsc": true,
39+
"showBullets": false
40+
}
41+
}
42+
]
43+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"version": "1.0.0",
3+
"campaigns": [
4+
{
5+
"id": "idle-engagement",
6+
"name": "Idle User Engagement",
7+
"description": "Re-engage users who have been idle for a certain period",
8+
"active": true,
9+
"mode": "tour",
10+
"triggers": [
11+
{
12+
"type": "idle_user",
13+
"idleTime": 30000
14+
}
15+
],
16+
"frequency": {
17+
"type": "session"
18+
},
19+
"tourOptions": {
20+
"steps": [
21+
{
22+
"intro": "Still here? Let us show you some features you might have missed!",
23+
"position": "floating"
24+
},
25+
{
26+
"element": ".shortcuts-panel",
27+
"intro": "Did you know you can use keyboard shortcuts? Press '?' to see all available shortcuts.",
28+
"position": "right"
29+
},
30+
{
31+
"element": ".recent-items",
32+
"intro": "Your recently accessed items are always available here for quick access.",
33+
"position": "left"
34+
}
35+
],
36+
"exitOnEsc": true,
37+
"exitOnOverlayClick": true
38+
}
39+
}
40+
]
41+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"version": "1.0.0",
3+
"campaigns": [
4+
{
5+
"id": "returning-user-advanced",
6+
"name": "Advanced Features for Returning Users",
7+
"description": "Show advanced features to users who have visited before",
8+
"active": true,
9+
"mode": "tour",
10+
"triggers": [
11+
{
12+
"type": "returning_user",
13+
"minVisits": 2,
14+
"delay": 2000
15+
}
16+
],
17+
"frequency": {
18+
"type": "once"
19+
},
20+
"tourOptions": {
21+
"steps": [
22+
{
23+
"intro": "Welcome back! We noticed you've been here before. Let us show you some advanced features!",
24+
"position": "floating"
25+
},
26+
{
27+
"element": ".keyboard-shortcuts",
28+
"intro": "Press 'Ctrl+K' to access the command palette for quick navigation.",
29+
"position": "bottom"
30+
},
31+
{
32+
"element": ".advanced-filters",
33+
"intro": "Use advanced filters to find exactly what you need quickly.",
34+
"position": "left"
35+
},
36+
{
37+
"element": ".bulk-actions",
38+
"intro": "Select multiple items and perform bulk actions to save time.",
39+
"position": "top"
40+
}
41+
],
42+
"showProgress": true
43+
},
44+
"analytics": {
45+
"trackViews": true,
46+
"trackCompletions": true
47+
}
48+
}
49+
]
50+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"version": "1.0.0",
3+
"campaigns": [
4+
{
5+
"id": "newsletter-signup-50",
6+
"name": "Newsletter Signup at 50% Scroll",
7+
"description": "Prompt newsletter signup when user scrolls 50% down the page",
8+
"active": true,
9+
"mode": "tour",
10+
"triggers": [
11+
{
12+
"type": "scroll_depth",
13+
"percentage": 50
14+
}
15+
],
16+
"frequency": {
17+
"type": "once"
18+
},
19+
"tourOptions": {
20+
"steps": [
21+
{
22+
"intro": "<h3>Enjoying our content?</h3><p>Subscribe to our newsletter for weekly updates and exclusive content!</p>",
23+
"position": "floating"
24+
},
25+
{
26+
"element": "#newsletter-form",
27+
"intro": "Enter your email here to stay updated with our latest articles and news.",
28+
"position": "top"
29+
}
30+
],
31+
"exitOnEsc": true,
32+
"exitOnOverlayClick": true
33+
},
34+
"analytics": {
35+
"trackViews": true,
36+
"trackCompletions": true
37+
}
38+
}
39+
]
40+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"version": "1.0.0",
3+
"campaigns": [
4+
{
5+
"id": "pricing-tour",
6+
"name": "Pricing Section Tour",
7+
"description": "Tour that triggers when user scrolls to pricing section",
8+
"active": true,
9+
"mode": "tour",
10+
"triggers": [
11+
{
12+
"type": "scroll_to_element",
13+
"selector": "#pricing-section",
14+
"threshold": 0.6
15+
}
16+
],
17+
"frequency": {
18+
"type": "session"
19+
},
20+
"tourOptions": {
21+
"steps": [
22+
{
23+
"element": ".pricing-card-basic",
24+
"intro": "Our Basic plan is perfect for individuals just getting started.",
25+
"position": "top"
26+
},
27+
{
28+
"element": ".pricing-card-pro",
29+
"intro": "The Pro plan includes all features plus priority support.",
30+
"position": "top"
31+
},
32+
{
33+
"element": ".pricing-card-enterprise",
34+
"intro": "Enterprise plan offers custom solutions for large teams.",
35+
"position": "top"
36+
},
37+
{
38+
"element": ".pricing-comparison",
39+
"intro": "Compare all plans side-by-side to find the perfect fit.",
40+
"position": "bottom"
41+
}
42+
],
43+
"showBullets": true
44+
}
45+
}
46+
]
47+
}

src/packages/campaign/index.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Intro.js Campaign System
3+
*
4+
* A no-code campaign management system for Intro.js that allows you to create
5+
* and manage guided tours and hints using JSON configuration files.
6+
*
7+
* @example
8+
* ```typescript
9+
* import { initializeCampaigns } from 'intro.js/campaign';
10+
*
11+
* // Load campaigns from JSON file
12+
* await initializeCampaigns('/campaigns.json');
13+
*
14+
* // Or load campaigns from object
15+
* await initializeCampaigns({
16+
* version: '1.0.0',
17+
* campaigns: [
18+
* {
19+
* id: 'welcome-tour',
20+
* name: 'Welcome Tour',
21+
* active: true,
22+
* mode: 'tour',
23+
* triggers: [{ type: 'first_visit' }],
24+
* tourOptions: {
25+
* steps: [
26+
* { element: '#step1', intro: 'Welcome!' }
27+
* ]
28+
* }
29+
* }
30+
* ]
31+
* });
32+
* ```
33+
*/
34+
35+
export * from "./types";
36+
export { CampaignManager, getCampaignManager, initializeCampaigns } from "./manager";
37+
export { TriggerDetector } from "./triggers";
38+
export { UserTracker } from "./userTracker";
39+
export { CampaignStorage } from "./storage";

0 commit comments

Comments
 (0)