@prosdevlab/experience-sdk 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +147 -0
  3. package/package.json +13 -13
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 prosdevlab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,147 @@
1
+ # @prosdevlab/experience-sdk
2
+
3
+ A lightweight, explainable client-side experience runtime built on [@lytics/sdk-kit](https://github.com/lytics/sdk-kit).
4
+
5
+ **Size:** 6.9 KB gzipped (includes core + 3 plugins)
6
+
7
+ ## Features
8
+
9
+ - **Explainability-First** - Every decision includes structured reasons
10
+ - **Plugin-Based** - Built on sdk-kit's powerful plugin system
11
+ - **Multiple Buttons** - Primary, secondary, and link variants
12
+ - **Frequency Capping** - Control impression limits per session/day/week
13
+ - **Responsive Layout** - Automatically adapts to mobile/desktop
14
+ - **Script Tag Ready** - Works without build tools
15
+ - **Type-Safe** - Full TypeScript support
16
+
17
+ ## Installation
18
+
19
+ ### npm
20
+
21
+ ```bash
22
+ npm install @prosdevlab/experience-sdk
23
+ ```
24
+
25
+ ### Script Tag
26
+
27
+ ```html
28
+ <script src="https://unpkg.com/@prosdevlab/experience-sdk/dist/experience-sdk.global.js"></script>
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ ### For Bundlers (ESM)
34
+
35
+ ```typescript
36
+ import { createInstance } from '@prosdevlab/experience-sdk';
37
+
38
+ // Create instance
39
+ const experiences = createInstance({ debug: true });
40
+
41
+ // Initialize
42
+ await experiences.init();
43
+
44
+ // Register a banner
45
+ experiences.register('welcome', {
46
+ type: 'banner',
47
+ targeting: {
48
+ url: { contains: '/' }
49
+ },
50
+ content: {
51
+ title: 'Welcome!',
52
+ message: 'Thanks for visiting.',
53
+ buttons: [
54
+ { text: 'Get Started', url: '/start', variant: 'primary' }
55
+ ]
56
+ },
57
+ frequency: {
58
+ max: 3,
59
+ per: 'session'
60
+ }
61
+ });
62
+
63
+ // Evaluate and show
64
+ const decision = experiences.evaluate();
65
+ console.log(decision.reasons);
66
+ ```
67
+
68
+ ### For Script Tag
69
+
70
+ ```html
71
+ <script src="https://unpkg.com/@prosdevlab/experience-sdk/dist/experience-sdk.global.js"></script>
72
+ <script>
73
+ // Global 'experiences' available
74
+ experiences.init({ debug: true });
75
+
76
+ experiences.register('cookie-consent', {
77
+ type: 'banner',
78
+ content: {
79
+ message: 'We use cookies to improve your experience',
80
+ buttons: [
81
+ { text: 'Accept', action: 'accept', variant: 'primary' },
82
+ { text: 'Reject', action: 'reject', variant: 'secondary' }
83
+ ],
84
+ position: 'bottom'
85
+ }
86
+ });
87
+
88
+ experiences.evaluate();
89
+ </script>
90
+ ```
91
+
92
+ ## Multiple Buttons
93
+
94
+ Banners support multiple buttons with visual variants:
95
+
96
+ ```typescript
97
+ buttons: [
98
+ { text: 'Accept all', variant: 'primary', action: 'accept' },
99
+ { text: 'Reject', variant: 'secondary', action: 'reject' },
100
+ { text: 'Preferences', variant: 'link', url: '/preferences' }
101
+ ]
102
+ ```
103
+
104
+ - **primary** - Blue button for main actions
105
+ - **secondary** - Gray outlined button for secondary actions
106
+ - **link** - Text link style for tertiary actions
107
+
108
+ ## Events
109
+
110
+ Listen to experience interactions:
111
+
112
+ ```typescript
113
+ // Banner shown
114
+ experiences.on('experiences:shown', ({ experienceId }) => {
115
+ console.log('Shown:', experienceId);
116
+ });
117
+
118
+ // Button clicked
119
+ experiences.on('experiences:action', ({ experienceId, action, variant, metadata }) => {
120
+ analytics.track('Experience Action', { experienceId, action });
121
+ });
122
+
123
+ // Banner dismissed
124
+ experiences.on('experiences:dismissed', ({ experienceId }) => {
125
+ console.log('Dismissed:', experienceId);
126
+ });
127
+ ```
128
+
129
+ ## Included Plugins
130
+
131
+ This package includes three official plugins:
132
+
133
+ - **Banner Plugin** - DOM rendering with responsive layout
134
+ - **Frequency Plugin** - Impression tracking and capping
135
+ - **Debug Plugin** - Logging and window events
136
+
137
+ ## Documentation
138
+
139
+ - [Full Documentation](https://prosdevlab.github.io/experience-sdk)
140
+ - [API Reference](https://prosdevlab.github.io/experience-sdk/reference)
141
+ - [Plugins Guide](https://prosdevlab.github.io/experience-sdk/reference/plugins)
142
+ - [Examples](https://prosdevlab.github.io/experience-sdk/demo)
143
+
144
+ ## License
145
+
146
+ MIT
147
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prosdevlab/experience-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "A lightweight, explainable client-side experience runtime",
5
5
  "private": false,
6
6
  "type": "module",
@@ -32,25 +32,25 @@
32
32
  },
33
33
  "author": "prosdevlab",
34
34
  "license": "MIT",
35
- "scripts": {
36
- "build": "tsup",
37
- "dev": "tsup --watch",
38
- "clean": "rm -rf dist",
39
- "typecheck": "tsc --noEmit",
40
- "lint": "biome lint ./src",
41
- "format": "biome format --write ./src",
42
- "test": "vitest run",
43
- "test:watch": "vitest"
44
- },
45
35
  "dependencies": {
46
36
  "@lytics/sdk-kit": "^0.1.1",
47
37
  "@lytics/sdk-kit-plugins": "^0.1.2",
48
- "@prosdevlab/experience-sdk-plugins": "workspace:*"
38
+ "@prosdevlab/experience-sdk-plugins": "0.1.0"
49
39
  },
50
40
  "devDependencies": {
51
41
  "@types/node": "^24.0.0",
52
42
  "tsup": "^8.5.1",
53
43
  "typescript": "^5.9.3",
54
44
  "vitest": "^4.0.16"
45
+ },
46
+ "scripts": {
47
+ "build": "tsup",
48
+ "dev": "tsup --watch",
49
+ "clean": "rm -rf dist",
50
+ "typecheck": "tsc --noEmit",
51
+ "lint": "biome lint ./src",
52
+ "format": "biome format --write ./src",
53
+ "test": "vitest run",
54
+ "test:watch": "vitest"
55
55
  }
56
- }
56
+ }