@moneybar.online/moneybar 3.3.0 → 3.5.0

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.
@@ -91,17 +91,87 @@
91
91
  </div>
92
92
  </div>
93
93
 
94
- <!-- Import map for dependencies -->
95
- <script type="importmap">
96
- {
97
- "imports": {
98
- "@supabase/supabase-js": "https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2/+esm"
94
+ <!-- MoneyBar self-contained bundle (no import map needed) -->
95
+ <script type="module">
96
+ console.log('🚀 Loading MoneyBar...');
97
+
98
+ try {
99
+ const { MoneyBar } = await import('https://cdn.jsdelivr.net/npm/@moneybar.online/moneybar/dist/index.bundle.js');
100
+
101
+ // Use FEEDBACK_INTELLIGENCE_CONFIG by default (you can change this)
102
+ const config = {
103
+ actionFunction: 'runAnalysis',
104
+ appId: 'saas-analytics',
105
+ freeAttemptLimit: 3,
106
+ supabase: {
107
+ url: 'https://qhlzdkwcrrjjcqvupyaa.supabase.co',
108
+ anonKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InFobHpka3djcnJqamNxdnVweWFhIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjQzNDYyNTYsImV4cCI6MjA3OTkyMjI1Nn0.Qy-IsmGxakvZ6JBtSoEjFefeXMBsUuSD551f6hfIIZw'
109
+ },
110
+ payment: [{
111
+ provider: 'dodo',
112
+ productId: 'pdt_BSS7M6oKqRTEaxqgJfprq',
113
+ mode: 'test'
114
+ }],
115
+ feedback: {
116
+ form: {
117
+ title: 'Quick Feedback',
118
+ description: 'What stopped you from upgrading?',
119
+ option1: 'Too complex to implement',
120
+ option2: 'Not enough ROI for my team',
121
+ option3: 'Need more features first'
122
+ },
123
+ email: [
124
+ {
125
+ provider: 'resend',
126
+ apiKey: 'your-resend-api-key',
127
+ fromEmail: 'feedback@yourapp.com'
128
+ }
129
+ ]
130
+ },
131
+ theme: {
132
+ name: 'corporate',
133
+ primaryColor: '#0066cc'
134
+ },
135
+ titleBar: {
136
+ title: '📈 Analytics Tool',
137
+ links: [
138
+ { text: 'Features', url: '#features', target: '_self' },
139
+ { text: 'ROI Calculator', url: '#roi', target: '_self' }
140
+ ]
141
+ }
142
+ };
143
+
144
+ console.log('✅ Creating MoneyBar instance...');
145
+ const moneyBar = new MoneyBar(config);
146
+
147
+ console.log('✅ Attaching to button...');
148
+ moneyBar.attachToButton('#action-btn', runAnalysis);
149
+
150
+ console.log('🎉 MoneyBar loaded successfully!');
151
+
152
+ } catch (error) {
153
+ console.error('❌ MoneyBar failed to load:', error);
154
+ document.body.innerHTML += `<div style="background: red; color: white; padding: 1rem; margin: 1rem 0;">
155
+ <strong>Error:</strong> ${error.message}
156
+ </div>`;
99
157
  }
100
- }
101
- </script>
102
158
 
103
- <!-- Load MoneyBar configuration and initialization -->
104
- <script type="module" src="moneybar-config-template.js"></script>
159
+ // Action function for the demo
160
+ function runAnalysis(userContext) {
161
+ console.log('🎯 FEEDBACK INTELLIGENCE: Running analysis...');
162
+
163
+ if (userContext.isPremium) {
164
+ console.log('✅ Full analytics suite access');
165
+ alert('Complete analysis ready! Access to all metrics, exports, and AI insights.');
166
+ } else {
167
+ console.log(`📊 Basic analysis complete. ${userContext.remaining} attempts remaining`);
168
+ alert(`Analysis complete! Limited data shown. ${userContext.remaining} attempts left.`);
169
+ }
170
+ }
171
+
172
+ // Make function global for debugging
173
+ window.runAnalysis = runAnalysis;
174
+ </script>
105
175
 
106
176
  <div class="demo-section">
107
177
  <h2>📚 Setup Checklist</h2>
@@ -120,13 +190,74 @@
120
190
  <li><strong>Add</strong> the import map to your HTML</li>
121
191
  </ol>
122
192
 
123
- <h3>🎛️ Integration Options:</h3>
124
- <ul>
125
- <li><strong>CDN + Import Map</strong> - Simple, no build step (current demo)</li>
126
- <li><strong>Self-contained Bundle</strong> - No import map needed</li>
127
- <li><strong>NPM Install</strong> - For projects with bundlers</li>
128
- <li><strong>UMD Script Tags</strong> - Traditional non-module usage</li>
129
- </ul>
193
+ <h3>🎛️ Live Integration Examples:</h3>
194
+ <details>
195
+ <summary><strong>Method 1: CDN + Import Map</strong> (Current Demo)</summary>
196
+ <pre><code>&lt;script type="importmap"&gt;
197
+ {
198
+ "imports": {
199
+ "@supabase/supabase-js": "https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2/+esm"
200
+ }
201
+ }
202
+ &lt;/script&gt;
203
+ &lt;script type="module" src="moneybar-config-template.js"&gt;&lt;/script&gt;</code></pre>
204
+ </details>
205
+
206
+ <details>
207
+ <summary><strong>Method 2: Self-contained Bundle</strong> (No import map needed)</summary>
208
+ <pre><code>&lt;script type="module"&gt;
209
+ import { MoneyBar } from 'https://cdn.jsdelivr.net/npm/@moneybar.online/moneybar/dist/index.bundle.js';
210
+
211
+ const moneyBar = new MoneyBar({
212
+ actionFunction: 'generatePDF',
213
+ appId: 'pdf-generator',
214
+ freeAttemptLimit: 3,
215
+ supabase: {
216
+ url: 'https://qhlzdkwcrrjjcqvupyaa.supabase.co',
217
+ anonKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
218
+ },
219
+ payment: [{
220
+ provider: 'dodo',
221
+ productId: 'pdt_BSS7M6oKqRTEaxqgJfprq',
222
+ mode: 'test'
223
+ }]
224
+ });
225
+
226
+ moneyBar.attachToButton('#action-btn', generatePDF);
227
+
228
+ function generatePDF(userContext) {
229
+ if (userContext.isPremium) {
230
+ alert('Premium PDF generated!');
231
+ } else {
232
+ alert(`Basic PDF generated! ${userContext.remaining} attempts left.`);
233
+ }
234
+ }
235
+ &lt;/script&gt;</code></pre>
236
+ </details>
237
+
238
+ <details>
239
+ <summary><strong>Method 3: NPM Install</strong> (For projects with bundlers)</summary>
240
+ <pre><code>npm install @moneybar.online/moneybar
241
+
242
+ import { MoneyBar } from '@moneybar.online/moneybar';
243
+
244
+ const moneyBar = new MoneyBar({
245
+ actionFunction: 'generatePDF',
246
+ appId: 'pdf-generator',
247
+ freeAttemptLimit: 3,
248
+ supabase: {
249
+ url: 'https://qhlzdkwcrrjjcqvupyaa.supabase.co',
250
+ anonKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
251
+ },
252
+ payment: [{
253
+ provider: 'dodo',
254
+ productId: 'pdt_BSS7M6oKqRTEaxqgJfprq',
255
+ mode: 'test'
256
+ }]
257
+ });
258
+
259
+ moneyBar.attachToButton('#action-btn', generatePDF);</code></pre>
260
+ </details>
130
261
 
131
262
  <p><small>See <code>moneybar-config-template.js</code> for all integration options and detailed examples!</small></p>
132
263
  </div>
@@ -50,14 +50,16 @@ const VALUE_FIRST_CONFIG = {
50
50
  actionFunction: 'generatePDF',
51
51
  appId: 'pdf-generator',
52
52
  freeAttemptLimit: 3, // Give enough attempts to prove value
53
+
53
54
  supabase: {
54
- url: 'your-supabase-url',
55
- anonKey: 'your-anon-key'
55
+ url: 'https://qhlzdkwcrrjjcqvupyaa.supabase.co',
56
+ anonKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InFobHpka3djcnJqamNxdnVweWFhIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjQzNDYyNTYsImV4cCI6MjA3OTkyMjI1Nn0.Qy-IsmGxakvZ6JBtSoEjFefeXMBsUuSD551f6hfIIZw'
56
57
  },
57
- payment: {
58
- productId: 'your-product-id',
58
+ payment: [{
59
+ provider: 'dodo',
60
+ productId: 'pdt_BSS7M6oKqRTEaxqgJfprq',
59
61
  mode: 'test'
60
- },
62
+ }],
61
63
  theme: {
62
64
  name: 'emerald', // Trustworthy, fresh
63
65
  primaryColor: '#059669'
@@ -83,13 +85,14 @@ const FEEDBACK_INTELLIGENCE_CONFIG = {
83
85
  appId: 'saas-analytics',
84
86
  freeAttemptLimit: 3,
85
87
  supabase: {
86
- url: 'your-supabase-url',
87
- anonKey: 'your-anon-key'
88
+ url: 'https://qhlzdkwcrrjjcqvupyaa.supabase.co',
89
+ anonKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InFobHpka3djcnJqamNxdnVweWFhIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjQzNDYyNTYsImV4cCI6MjA3OTkyMjI1Nn0.Qy-IsmGxakvZ6JBtSoEjFefeXMBsUuSD551f6hfIIZw'
88
90
  },
89
- payment: {
90
- productId: 'your-product-id',
91
+ payment: [{
92
+ provider: 'dodo',
93
+ productId: 'pdt_BSS7M6oKqRTEaxqgJfprq',
91
94
  mode: 'test'
92
- },
95
+ }],
93
96
  // KEY FEATURE: Feedback collection on cancel/exit
94
97
  feedback: {
95
98
  form: {
@@ -133,13 +136,14 @@ const INSTANT_PAYMENT_CONFIG = {
133
136
  appId: 'template-creator',
134
137
  freeAttemptLimit: 5, // Lower to trigger payment faster
135
138
  supabase: {
136
- url: 'your-supabase-url',
137
- anonKey: 'your-anon-key'
139
+ url: 'https://qhlzdkwcrrjjcqvupyaa.supabase.co',
140
+ anonKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InFobHpka3djcnJqamNxdnVweWFhIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjQzNDYyNTYsImV4cCI6MjA3OTkyMjI1Nn0.Qy-IsmGxakvZ6JBtSoEjFefeXMBsUuSD551f6hfIIZw'
138
141
  },
139
- payment: {
140
- productId: 'your-product-id',
142
+ payment: [{
143
+ provider: 'dodo',
144
+ productId: 'pdt_BSS7M6oKqRTEaxqgJfprq',
141
145
  mode: 'test'
142
- },
146
+ }],
143
147
  theme: {
144
148
  name: 'dark', // Modern, premium feel
145
149
  primaryColor: '#7c3aed'
@@ -184,10 +188,11 @@ window.APP_CONFIG = {
184
188
  },
185
189
 
186
190
  // REQUIRED: Payment configuration
187
- payment: {
191
+ payment: [{
192
+ provider: 'dodo',
188
193
  productId: 'your-dodo-payments-product-id',
189
194
  mode: 'test' // Change to 'live' for production
190
- },
195
+ }],
191
196
 
192
197
  // OPTIONAL: UI Theme (29 themes available)
193
198
  theme: {
package/package.json CHANGED
@@ -1,17 +1,16 @@
1
1
  {
2
2
  "name": "@moneybar.online/moneybar",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "description": "The navbar of monetization. Fix the 3 money-blocking stages: forced sign-ins, silent drop-offs, and broken payment flows. Turn browsers into buyers.",
5
- "main": "dist/index.cjs.js",
5
+ "main": "dist/index.esm.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "browser": "dist/index.browser.js",
8
- "unpkg": "dist/index.umd.js",
8
+ "unpkg": "dist/index.bundle.js",
9
9
  "types": "dist/index.d.ts",
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
13
13
  "import": "./dist/index.esm.js",
14
- "require": "./dist/index.cjs.js",
15
14
  "browser": "./dist/index.browser.js",
16
15
  "types": "./dist/index.d.ts"
17
16
  }
package/src/index.ts CHANGED
@@ -333,26 +333,37 @@ export class MoneyBar {
333
333
  throw new Error('Payment configuration not provided');
334
334
  }
335
335
 
336
+ const payment = this.config.payment?.find(p => p.provider === 'dodo');
337
+ if (!payment) {
338
+ throw new Error('No dodo payment provider configured');
339
+ }
340
+
336
341
  const requestBody = {
337
342
  email: this.currentUser.email,
338
- product_id: this.config.payment.productId,
339
- mode: this.config.payment.mode || 'test',
343
+ product_id: payment.productId,
344
+ mode: payment.mode || 'test',
340
345
  app_id: this.config.appId,
341
346
  return_url: `${window.location.origin}${window.location.pathname}?payment=success`
342
347
  };
343
348
 
344
- console.log(`🔥 [SUPABASE API] createPayment called for email: ${this.currentUser.email} | Time: ${new Date().toISOString()}`);
349
+ console.log(`🔥 [PAYMENT API] createPayment called for provider: ${payment.provider}, email: ${this.currentUser.email} | Time: ${new Date().toISOString()}`);
345
350
 
346
351
  try {
347
- const response = await fetch(`${this.config.supabase.url}/functions/v1/create-payment`, {
348
- method: 'POST',
349
- headers: {
350
- 'Content-Type': 'application/json',
351
- 'Authorization': `Bearer ${this.config.supabase.anonKey}`
352
- },
353
- body: JSON.stringify(requestBody)
354
- });
355
- console.log(`🔥 [SUPABASE API] createPayment response: ${response.status}`);
352
+ // Route to appropriate payment API based on provider
353
+ let response;
354
+ if (payment.provider === 'dodo') {
355
+ response = await fetch(`${this.config.supabase.url}/functions/v1/create-payment`, {
356
+ method: 'POST',
357
+ headers: {
358
+ 'Content-Type': 'application/json',
359
+ 'Authorization': `Bearer ${this.config.supabase.anonKey}`
360
+ },
361
+ body: JSON.stringify(requestBody)
362
+ });
363
+ } else {
364
+ throw new Error(`Payment provider '${payment.provider}' is not yet supported`);
365
+ }
366
+ console.log(`🔥 [PAYMENT API] createPayment response for ${payment.provider}: ${response.status}`);
356
367
 
357
368
  if (this.config.options?.debug) {
358
369
  //console.log('🔍 DEBUG: createPayment response status:', response.status);
@@ -3010,7 +3021,15 @@ User Agent: ${feedbackData.userAgent}
3010
3021
  }
3011
3022
 
3012
3023
  // Validate product ID format
3013
- const productId = this.config.payment.productId;
3024
+ const payment = this.config.payment?.find(p => p.provider === 'dodo');
3025
+ if (!payment) {
3026
+ this.paymentConnectionFailed = true;
3027
+ if (this.config.options?.debug) {
3028
+ console.warn('No dodo payment provider configured');
3029
+ }
3030
+ return;
3031
+ }
3032
+ const productId = payment.productId;
3014
3033
  if (!productId || !productId.startsWith('pdt_') || productId.length < 10) {
3015
3034
  this.paymentConnectionFailed = true;
3016
3035
  if (this.config.options?.debug) {
package/src/types.ts CHANGED
@@ -11,11 +11,14 @@ export interface MoneyBarConfig {
11
11
  anonKey: string;
12
12
  };
13
13
 
14
- /** DodoPayments product configuration */
15
- payment?: {
14
+ /** Payment configuration - extensible for multiple providers */
15
+ payment?: Array<{
16
+ provider: 'dodo' | 'stripe' | 'paypal' | 'square' | 'paddle'; // Extensible for future providers
16
17
  productId: string;
17
18
  mode?: 'test' | 'live';
18
- };
19
+ apiKey?: string; // For providers that need API keys
20
+ publishableKey?: string; // For client-side keys (Stripe, etc.)
21
+ }>;
19
22
 
20
23
  /** Optional: Feedback form configuration */
21
24
  feedback?: {