@bliptarjs/sdk 0.3.0 → 0.3.2
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.
- package/README.md +93 -186
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -1,39 +1,52 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
1
3
|
# @bliptarjs/sdk
|
|
2
4
|
|
|
3
|
-
**
|
|
5
|
+
**Micro-feedback that users actually respond to.**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@bliptarjs/sdk)
|
|
8
|
+
[](https://bundlephobia.com/package/@bliptarjs/sdk)
|
|
9
|
+
[](LICENSE)
|
|
4
10
|
|
|
5
|
-
|
|
11
|
+
[Website](https://bliptar.com) · [Documentation](https://app.bliptar.com/docs)
|
|
6
12
|
|
|
7
|
-
|
|
13
|
+
</div>
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
---
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
Users abandon your app, churn from your service, and leave features unused – **without ever telling you why**. Traditional surveys are too long. Pop-ups are annoying. You're left guessing.
|
|
12
18
|
|
|
13
|
-
**
|
|
19
|
+
**Bliptar** captures real-time user sentiment with **nano feedback forms** – quick 1-2 question surveys that appear at exactly the right moment.
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
- **Thumbs up/down** – "Was this helpful?"
|
|
17
|
-
- **Emoji scales** – "How was your experience?"
|
|
18
|
-
- **Star ratings** – "Rate this feature"
|
|
19
|
-
- **NPS** – "How likely are you to recommend us?"
|
|
20
|
-
- **Single choice** – Quick multiple choice
|
|
21
|
-
- **Text input** – Open-ended feedback
|
|
21
|
+
> One question. Two seconds. Real insights.
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
- **Page view** – When user lands on a page
|
|
25
|
-
- **Scroll depth** – When user scrolls to X%
|
|
26
|
-
- **Time on page** – After X seconds
|
|
27
|
-
- **Exit intent** – When user is about to leave
|
|
28
|
-
- **Custom events** – After checkout, signup, or any action
|
|
23
|
+
## Features
|
|
29
24
|
|
|
30
|
-
|
|
25
|
+
- **Thumbs up/down** · **Emoji scales** · **Star ratings** · **NPS** · **Single choice** · **Text input**
|
|
26
|
+
- **Smart triggers** – Page view, scroll depth, time on page, exit intent, custom events
|
|
31
27
|
- **Dashboard controlled** – No code changes to update campaigns
|
|
32
|
-
- **Lightweight
|
|
33
|
-
- **Works everywhere** – React, Next.js, Vue, or vanilla JS
|
|
28
|
+
- **Lightweight** – ~8KB gzipped, zero dependencies
|
|
34
29
|
- **Privacy first** – No cookies, GDPR friendly
|
|
35
30
|
|
|
36
|
-
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Works With
|
|
34
|
+
|
|
35
|
+
<p align="center">
|
|
36
|
+
<img src="https://raw.githubusercontent.com/devicons/devicon/master/icons/react/react-original.svg" alt="React" width="40" height="40"/>
|
|
37
|
+
|
|
38
|
+
<img src="https://raw.githubusercontent.com/devicons/devicon/master/icons/nextjs/nextjs-original.svg" alt="Next.js" width="40" height="40"/>
|
|
39
|
+
|
|
40
|
+
<img src="https://raw.githubusercontent.com/devicons/devicon/master/icons/vuejs/vuejs-original.svg" alt="Vue" width="40" height="40"/>
|
|
41
|
+
|
|
42
|
+
<img src="https://raw.githubusercontent.com/devicons/devicon/master/icons/angularjs/angularjs-original.svg" alt="Angular" width="40" height="40"/>
|
|
43
|
+
|
|
44
|
+
<img src="https://raw.githubusercontent.com/devicons/devicon/master/icons/javascript/javascript-original.svg" alt="JavaScript" width="40" height="40"/>
|
|
45
|
+
|
|
46
|
+
<img src="https://raw.githubusercontent.com/devicons/devicon/master/icons/typescript/typescript-original.svg" alt="TypeScript" width="40" height="40"/>
|
|
47
|
+
</p>
|
|
48
|
+
|
|
49
|
+
---
|
|
37
50
|
|
|
38
51
|
## Installation
|
|
39
52
|
|
|
@@ -53,93 +66,44 @@ const bliptar = createBliptar({
|
|
|
53
66
|
bliptar.init();
|
|
54
67
|
```
|
|
55
68
|
|
|
56
|
-
That's it! The SDK automatically
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
- Shows feedback forms when conditions are met
|
|
60
|
-
- Submits responses to your Bliptar dashboard
|
|
69
|
+
That's it! The SDK automatically fetches your campaigns and sets up triggers.
|
|
70
|
+
|
|
71
|
+
---
|
|
61
72
|
|
|
62
73
|
## How It Works
|
|
63
74
|
|
|
64
75
|
1. **Create campaigns** in the [Bliptar Dashboard](https://app.bliptar.com)
|
|
65
|
-
2. **Configure triggers**
|
|
66
|
-
- Page View - when user visits a page
|
|
67
|
-
- Scroll Depth - when user scrolls to X%
|
|
68
|
-
- Time on Page - after X seconds
|
|
69
|
-
- Exit Intent - when user is about to leave
|
|
70
|
-
- Custom Event - triggered via `bliptar.track()`
|
|
76
|
+
2. **Configure triggers** – page view, scroll depth, time on page, exit intent, or custom events
|
|
71
77
|
3. **Add the SDK** to your app with your API key
|
|
72
|
-
4. **Done**
|
|
78
|
+
4. **Done** – forms appear automatically based on your campaign rules
|
|
73
79
|
|
|
74
|
-
|
|
80
|
+
---
|
|
75
81
|
|
|
76
|
-
|
|
77
|
-
const bliptar = createBliptar({
|
|
78
|
-
apiKey: 'your-api-key', // Required
|
|
79
|
-
debug: false, // Enable console logging
|
|
80
|
-
userId: 'user-123', // Pre-set user ID
|
|
81
|
-
userAttributes: { // User attributes for targeting
|
|
82
|
-
plan: 'pro',
|
|
83
|
-
company: 'Acme',
|
|
84
|
-
},
|
|
85
|
-
onShow: (form) => {}, // Callback when form appears
|
|
86
|
-
onSubmit: (answers) => {}, // Callback when form is submitted
|
|
87
|
-
onDismiss: () => {}, // Callback when form is dismissed
|
|
88
|
-
onError: (error) => {}, // Callback on errors
|
|
89
|
-
});
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## API Reference
|
|
82
|
+
## Core API
|
|
93
83
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
84
|
+
| Method | Description |
|
|
85
|
+
|--------|-------------|
|
|
86
|
+
| `init()` | Initialize SDK and fetch campaigns |
|
|
87
|
+
| `identify(userId, attributes?)` | Associate feedback with a user |
|
|
88
|
+
| `track(event, data?)` | Trigger custom events |
|
|
89
|
+
| `destroy()` | Cleanup listeners and timers |
|
|
97
90
|
|
|
98
91
|
```javascript
|
|
99
|
-
|
|
100
|
-
|
|
92
|
+
// Identify user when they log in
|
|
93
|
+
bliptar.identify('user-123', { plan: 'pro' });
|
|
101
94
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
Associates feedback with a user. Call when user logs in.
|
|
105
|
-
|
|
106
|
-
```javascript
|
|
107
|
-
bliptar.identify('user-123', {
|
|
108
|
-
email: 'user@example.com',
|
|
109
|
-
plan: 'pro',
|
|
110
|
-
});
|
|
95
|
+
// Track custom events
|
|
96
|
+
bliptar.track('checkout_complete', { total: 99.99 });
|
|
111
97
|
```
|
|
112
98
|
|
|
113
|
-
|
|
99
|
+
For the full API reference, see the [Documentation](https://app.bliptar.com/docs).
|
|
114
100
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
```javascript
|
|
118
|
-
bliptar.track('checkout_complete', {
|
|
119
|
-
orderId: 'order-123',
|
|
120
|
-
total: 99.99,
|
|
121
|
-
});
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
### `showForm(formId)`
|
|
125
|
-
|
|
126
|
-
Manually show a specific form, bypassing campaign rules.
|
|
127
|
-
|
|
128
|
-
```javascript
|
|
129
|
-
await bliptar.showForm('form_abc123');
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### `destroy()`
|
|
133
|
-
|
|
134
|
-
Cleanup - removes listeners and timers. Call when unmounting.
|
|
135
|
-
|
|
136
|
-
```javascript
|
|
137
|
-
bliptar.destroy();
|
|
138
|
-
```
|
|
101
|
+
---
|
|
139
102
|
|
|
140
103
|
## Framework Examples
|
|
141
104
|
|
|
142
|
-
|
|
105
|
+
<details>
|
|
106
|
+
<summary><strong>React</strong></summary>
|
|
143
107
|
|
|
144
108
|
```jsx
|
|
145
109
|
import { useEffect } from 'react';
|
|
@@ -158,8 +122,10 @@ function App() {
|
|
|
158
122
|
return <div>Your app</div>;
|
|
159
123
|
}
|
|
160
124
|
```
|
|
125
|
+
</details>
|
|
161
126
|
|
|
162
|
-
|
|
127
|
+
<details>
|
|
128
|
+
<summary><strong>Next.js</strong></summary>
|
|
163
129
|
|
|
164
130
|
```jsx
|
|
165
131
|
// app/providers.js
|
|
@@ -176,25 +142,13 @@ export function BliptarProvider({ children }) {
|
|
|
176
142
|
bliptar?.init();
|
|
177
143
|
return () => bliptar?.destroy();
|
|
178
144
|
}, []);
|
|
179
|
-
|
|
180
145
|
return children;
|
|
181
146
|
}
|
|
182
|
-
|
|
183
|
-
// app/layout.js
|
|
184
|
-
import { BliptarProvider } from './providers';
|
|
185
|
-
|
|
186
|
-
export default function RootLayout({ children }) {
|
|
187
|
-
return (
|
|
188
|
-
<html>
|
|
189
|
-
<body>
|
|
190
|
-
<BliptarProvider>{children}</BliptarProvider>
|
|
191
|
-
</body>
|
|
192
|
-
</html>
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
147
|
```
|
|
148
|
+
</details>
|
|
196
149
|
|
|
197
|
-
|
|
150
|
+
<details>
|
|
151
|
+
<summary><strong>Vue</strong></summary>
|
|
198
152
|
|
|
199
153
|
```vue
|
|
200
154
|
<script setup>
|
|
@@ -209,96 +163,49 @@ onMounted(() => bliptar.init());
|
|
|
209
163
|
onUnmounted(() => bliptar.destroy());
|
|
210
164
|
</script>
|
|
211
165
|
```
|
|
166
|
+
</details>
|
|
212
167
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
Track feedback by user:
|
|
216
|
-
|
|
217
|
-
```javascript
|
|
218
|
-
// When user logs in
|
|
219
|
-
bliptar.identify(user.id, {
|
|
220
|
-
email: user.email,
|
|
221
|
-
plan: user.subscription.plan,
|
|
222
|
-
signupDate: user.createdAt,
|
|
223
|
-
});
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
User attributes can be used in campaign targeting rules.
|
|
227
|
-
|
|
228
|
-
## Advanced: Manual Triggers
|
|
229
|
-
|
|
230
|
-
For advanced use cases, you can manually set up triggers:
|
|
168
|
+
<details>
|
|
169
|
+
<summary><strong>Angular</strong></summary>
|
|
231
170
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
171
|
+
```typescript
|
|
172
|
+
// bliptar.service.ts
|
|
173
|
+
import { Injectable, OnDestroy } from '@angular/core';
|
|
174
|
+
import { createBliptar, BliptarInstance } from '@bliptarjs/sdk';
|
|
175
|
+
|
|
176
|
+
@Injectable({ providedIn: 'root' })
|
|
177
|
+
export class BliptarService implements OnDestroy {
|
|
178
|
+
private bliptar: BliptarInstance;
|
|
179
|
+
|
|
180
|
+
constructor() {
|
|
181
|
+
this.bliptar = createBliptar({ apiKey: environment.bliptarKey });
|
|
182
|
+
this.bliptar.init();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
ngOnDestroy() {
|
|
186
|
+
this.bliptar.destroy();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
242
189
|
```
|
|
190
|
+
</details>
|
|
243
191
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
Manually enable exit intent detection:
|
|
247
|
-
|
|
248
|
-
```javascript
|
|
249
|
-
bliptar.enableExitIntent({
|
|
250
|
-
threshold: 50, // Pixels from top
|
|
251
|
-
cooldown: 10000, // Ms before can trigger again
|
|
252
|
-
once: true, // Only trigger once per session
|
|
253
|
-
});
|
|
254
|
-
```
|
|
192
|
+
---
|
|
255
193
|
|
|
256
194
|
## TypeScript
|
|
257
195
|
|
|
258
|
-
Full TypeScript support included
|
|
196
|
+
Full TypeScript support included.
|
|
259
197
|
|
|
260
198
|
```typescript
|
|
261
|
-
import { createBliptar, BliptarConfig } from '@bliptarjs/sdk';
|
|
262
|
-
|
|
263
|
-
const config: BliptarConfig = {
|
|
264
|
-
apiKey: 'your-api-key',
|
|
265
|
-
debug: true,
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
const bliptar = createBliptar(config);
|
|
199
|
+
import { createBliptar, BliptarConfig, BliptarInstance } from '@bliptarjs/sdk';
|
|
269
200
|
```
|
|
270
201
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
- **ESM:** ~26KB (minified)
|
|
274
|
-
- **Gzipped:** ~8KB
|
|
275
|
-
|
|
276
|
-
Zero dependencies.
|
|
202
|
+
---
|
|
277
203
|
|
|
278
|
-
##
|
|
204
|
+
## Links
|
|
279
205
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
| Firefox | Latest 2 versions |
|
|
284
|
-
| Safari | Latest 2 versions |
|
|
285
|
-
| Edge | Latest 2 versions |
|
|
286
|
-
|
|
287
|
-
## Troubleshooting
|
|
288
|
-
|
|
289
|
-
### Forms not showing?
|
|
290
|
-
|
|
291
|
-
1. **Check API key** - ensure it's valid
|
|
292
|
-
2. **Check campaigns** - verify campaign is active in dashboard
|
|
293
|
-
3. **Enable debug mode** - set `debug: true` to see logs
|
|
294
|
-
4. **Check throttling** - campaigns have frequency limits
|
|
295
|
-
|
|
296
|
-
```javascript
|
|
297
|
-
const bliptar = createBliptar({
|
|
298
|
-
apiKey: 'your-key',
|
|
299
|
-
debug: true, // See what's happening
|
|
300
|
-
});
|
|
301
|
-
```
|
|
206
|
+
- [Website](https://bliptar.com)
|
|
207
|
+
- [Documentation](https://app.bliptar.com/docs)
|
|
208
|
+
- [npm](https://www.npmjs.com/package/@bliptarjs/sdk)
|
|
302
209
|
|
|
303
210
|
## License
|
|
304
211
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var x=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var D=(o,e)=>{for(var t in e)x(o,t,{get:e[t],enumerable:!0})},A=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of L(e))!P.call(o,i)&&i!==t&&x(o,i,{get:()=>e[i],enumerable:!(r=I(e,i))||r.enumerable});return o};var B=o=>A(x({},"__esModule",{value:!0}),o);var F={};D(F,{Bliptar:()=>h,createBliptar:()=>
|
|
1
|
+
"use strict";var x=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var D=(o,e)=>{for(var t in e)x(o,t,{get:e[t],enumerable:!0})},A=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of L(e))!P.call(o,i)&&i!==t&&x(o,i,{get:()=>e[i],enumerable:!(r=I(e,i))||r.enumerable});return o};var B=o=>A(x({},"__esModule",{value:!0}),o);var F={};D(F,{Bliptar:()=>h,createBliptar:()=>C});module.exports=B(F);var b={mode:"light",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",textPrimary:"#1a1a1a",textSecondary:"#666666",primaryColor:"#3b82f6",primaryHover:"#2563eb",borderColor:"#e0e0e0",shadowColor:"rgba(0, 0, 0, 0.15)",starColor:"#fbbf24"},u={mode:"dark",backgroundColor:"#1a1a1a",surfaceColor:"#2a2a2a",textPrimary:"#ffffff",textSecondary:"#a0a0a0",primaryColor:"#3b82f6",primaryHover:"#60a5fa",borderColor:"#333333",shadowColor:"rgba(0, 0, 0, 0.4)",starColor:"#fbbf24"};function j(o,e){try{let r=window.getComputedStyle(o).getPropertyValue(e);return r&&r!=="rgba(0, 0, 0, 0)"?r:null}catch{return null}}function H(o){try{return getComputedStyle(document.documentElement).getPropertyValue(o).trim()||null}catch{return null}}function w(o){let e=o.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(e)return{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)};let t=o.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return t?{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}:null}function M(o,e,t){let[r,i,a]=[o,e,t].map(n=>(n=n/255,n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)));return .2126*r+.7152*i+.0722*a}function _(o){let e=w(o);return e?M(e.r,e.g,e.b)<.5:!1}function g(o,e){let t=w(o);if(!t)return o;let r=i=>Math.min(255,Math.max(0,Math.round(i+e/100*255)));return`rgb(${r(t.r)}, ${r(t.g)}, ${r(t.b)})`}function z(o){return _(o)?"#ffffff":"#1a1a1a"}function R(o,e){let t={},r=null;o&&(r=document.querySelector(o)),r||(r=document.body);let i=j(r,"background-color");if(i){let a=_(i);t.mode=a?"dark":"light",t.backgroundColor=i,t.surfaceColor=g(i,a?10:-5),t.textPrimary=z(i),t.textSecondary=g(t.textPrimary,a?-30:30),t.borderColor=g(i,a?20:-15),t.shadowColor=a?"rgba(0, 0, 0, 0.4)":"rgba(0, 0, 0, 0.15)"}if(e){let a={"--primary":"primaryColor","--primary-color":"primaryColor","--accent":"primaryColor","--accent-color":"primaryColor","--brand":"primaryColor","--brand-color":"primaryColor","--color-primary":"primaryColor","--background":"backgroundColor","--bg":"backgroundColor","--bg-color":"backgroundColor","--text":"textPrimary","--text-color":"textPrimary","--foreground":"textPrimary","--border":"borderColor","--border-color":"borderColor"};for(let[n,l]of Object.entries(a)){let c=H(n);c&&l!=="mode"&&(t[l]=c)}}return t.primaryColor&&(t.primaryHover=g(t.primaryColor,t.mode==="dark"?15:-10)),Object.keys(t).length>0?t:null}function T(o){let{theme:e,customTheme:t,adaptiveOptions:r}=o;if(e==="custom"&&t)return{mode:_(t.backgroundColor)?"dark":"light",backgroundColor:t.backgroundColor,surfaceColor:t.surfaceColor,textPrimary:t.textPrimary,textSecondary:t.textSecondary,primaryColor:t.primaryColor,primaryHover:t.primaryHover,borderColor:t.borderColor,shadowColor:t.shadowColor,starColor:"#fbbf24"};if(e==="adaptive"){let i=r||{fallback:"light",autoContrast:!0},a=R(i.sourceElement,i.inheritCssVars);return a?{...a.mode==="dark"?u:b,...a}:i.fallback==="dark"?u:b}return e==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?u:b:e==="dark"?u:b}function $(o){return`
|
|
2
2
|
--bliptar-bg: ${o.backgroundColor};
|
|
3
3
|
--bliptar-surface: ${o.surfaceColor};
|
|
4
4
|
--bliptar-text: ${o.textPrimary};
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
--bliptar-border: ${o.borderColor};
|
|
9
9
|
--bliptar-shadow: ${o.shadowColor};
|
|
10
10
|
--bliptar-star: ${o.starColor};
|
|
11
|
-
`}var f=class{constructor(e,t){this.container=null;this.currentIndex=0;this.answers={};this.form=e,this.options=t,this.theme=
|
|
12
|
-
:root { ${
|
|
11
|
+
`}var f=class{constructor(e,t){this.container=null;this.currentIndex=0;this.answers={};this.form=e,this.options=t,this.theme=T(e.appearance)}render(){this.createContainer(),this.injectStyles(),this.renderQuestion()}destroy(){if(this.container){let e=this.container.querySelector(".bliptar__card");e?(e.classList.add("bliptar__card--exit"),setTimeout(()=>{this.container?.remove(),this.container=null},200)):(this.container.remove(),this.container=null)}}createContainer(){this.container=document.createElement("div"),this.container.id="bliptar-form",this.container.className=`bliptar bliptar--${this.form.appearance.position}`,document.body.appendChild(this.container)}injectStyles(){let e=document.getElementById("bliptar-styles");e&&e.remove();let t=document.createElement("style");t.id="bliptar-styles",t.textContent=this.getStyles(),document.head.appendChild(t)}getStyles(){let{appearance:e}=this.form,t=this.theme,r=e.animation||"slide-up";return`
|
|
12
|
+
:root { ${$(t)} }
|
|
13
13
|
|
|
14
14
|
.bliptar {
|
|
15
15
|
position: fixed;
|
|
@@ -388,4 +388,4 @@
|
|
|
388
388
|
<div class="bliptar__thankyou-emoji">\u{1F389}</div>
|
|
389
389
|
<div class="bliptar__thankyou-text">${this.escapeHtml(t.thankYouMessage||"Thank you for your feedback!")}</div>
|
|
390
390
|
</div>
|
|
391
|
-
</div>`,this.container.innerHTML=r}};function
|
|
391
|
+
</div>`,this.container.innerHTML=r}};function y(){let o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="";for(let t=0;t<16;t++)e+=o.charAt(Math.floor(Math.random()*o.length));return`sess_${e}`}function k(){if(typeof navigator>"u")return"desktop";let o=navigator.userAgent;return/tablet|ipad|playbook|silk/i.test(o)?"tablet":/mobile|iphone|ipod|android|blackberry|opera mini|iemobile/i.test(o)?"mobile":"desktop"}function S(o,e){let t;return(...r)=>{clearTimeout(t),t=setTimeout(()=>o(...r),e)}}var O="https://api.bliptar.com",h=class{constructor(e){this.renderer=null;this.scrollDepth=0;this.maxScrollDepth=0;this.isInitialized=!1;this.eventListeners=[];this.trackedClicks=new Set;this.exitIntentTriggered=!1;this.exitIntentCooldownTimer=null;this.timeOnPageTimers=[];this.scrollDepthThresholds=new Set;this.triggeredScrollThresholds=new Set;this.campaigns=[];this.config={apiUrl:O,debug:!1,onShow:()=>{},onSubmit:()=>{},onDismiss:()=>{},onError:()=>{},...e},this.sessionId=this.loadOrCreateSessionId(),this.pageLoadTime=Date.now()}async init(){if(typeof window>"u"||this.isInitialized)return;this.isInitialized=!0,this.log("Initializing Bliptar SDK"),await this.fetchConfigAndSetupTriggers();let e=S(()=>{let t=document.documentElement,r=window.scrollY||t.scrollTop,i=t.scrollHeight-t.clientHeight;this.scrollDepth=i>0?r/i:0;let a=Math.round(this.scrollDepth*100);a>this.maxScrollDepth&&(this.maxScrollDepth=a,this.checkScrollThresholds(a))},100);this.addEventListener(window,"scroll",e),this.track("page_view")}async fetchConfigAndSetupTriggers(){try{let e=await fetch(`${this.config.apiUrl}/api/sdk/config`,{headers:{Authorization:`Bearer ${this.config.apiKey}`}});if(!e.ok){this.log("Failed to fetch config:",e.status);return}let t=await e.json();this.campaigns=t.campaigns||[],this.log("Loaded campaigns:",this.campaigns.length),this.setupTriggersFromCampaigns()}catch(e){this.handleError(e)}}setupTriggersFromCampaigns(){let e=new Set;for(let t of this.campaigns){if(e.add(t.trigger_event),t.trigger_event==="scroll_depth"){let r=t.trigger_conditions?.find(i=>i.field==="scroll_depth_percent");r?.value&&this.scrollDepthThresholds.add(Number(r.value))}if(t.trigger_event==="time_on_page"){let r=t.trigger_conditions?.find(i=>i.field==="time_on_page_seconds");if(r?.value){let i=Number(r.value);this.setupTimeOnPageTrigger(i)}}}this.log("Active trigger types:",Array.from(e)),e.has("exit_intent")&&(this.log("Auto-enabling exit intent detection"),this.enableExitIntent({once:!0})),this.scrollDepthThresholds.size>0&&this.log("Scroll depth thresholds:",Array.from(this.scrollDepthThresholds))}setupTimeOnPageTrigger(e){this.log("Setting up time on page trigger:",e,"seconds");let t=setTimeout(()=>{this.track("time_on_page",{seconds:e,actual_time:Math.floor((Date.now()-this.pageLoadTime)/1e3)})},e*1e3);this.timeOnPageTimers.push(t)}checkScrollThresholds(e){for(let t of this.scrollDepthThresholds)e>=t&&!this.triggeredScrollThresholds.has(t)&&(this.triggeredScrollThresholds.add(t),this.log("Scroll threshold reached:",t+"%"),this.track("scroll_depth",{threshold:t,actual_depth:e}))}identify(e,t){this.config.userId=e,this.config.userAttributes={...this.config.userAttributes,...t},this.log("User identified:",e)}async track(e,t){this.log("Tracking event:",e,t);let r=this.getContext();try{let i=await fetch(`${this.config.apiUrl}/api/sdk/trigger`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({session_id:this.sessionId,user_id:this.config.userId,event:e,event_data:t||{},context:r})});if(!i.ok)throw new Error(`API error: ${i.status}`);let a=await i.json();a.show_form&&a.form&&await this.displayForm(a.form,a.campaign_id)}catch(i){this.handleError(i)}}async showForm(e){this.log("Manually showing form:",e);try{let t=await fetch(`${this.config.apiUrl}/api/sdk/form/${e}`,{headers:{Authorization:`Bearer ${this.config.apiKey}`}});if(!t.ok)throw new Error(`Failed to fetch form: ${t.status}`);let r=await t.json();await this.displayForm(r)}catch(t){this.handleError(t)}}trackClicks(e){let{selector:t,name:r,once:i=!1}=e,a=r||t;this.log("Setting up click tracking for:",t);let n=l=>{let p=l.target.closest(t);p&&(i&&this.trackedClicks.has(a)||(this.log("Button click detected:",a),i&&this.trackedClicks.add(a),this.track("button_click",{selector:t,name:a,element_text:p.textContent?.trim().slice(0,100)||"",element_id:p.id||null,element_class:p.className||null})))};this.addEventListener(document,"click",n)}enableExitIntent(e={}){let{threshold:t=50,cooldown:r=1e4,once:i=!0}=e;this.log("Enabling exit intent detection");let a=l=>{l.clientY>t||i&&this.exitIntentTriggered||this.exitIntentCooldownTimer||(this.log("Exit intent detected"),this.exitIntentTriggered=!0,this.track("exit_intent",{trigger:"mouse_leave",mouse_y:l.clientY}),i||(this.exitIntentCooldownTimer=setTimeout(()=>{this.exitIntentCooldownTimer=null},r)))};this.addEventListener(document,"mouseleave",a);let n=()=>{if(document.visibilityState==="hidden"){if(i&&this.exitIntentTriggered)return;this.log("Exit intent detected (visibility change)"),this.exitIntentTriggered=!0,this.track("exit_intent",{trigger:"visibility_change"})}};k()!=="desktop"&&this.addEventListener(document,"visibilitychange",n)}destroy(){this.log("Destroying Bliptar SDK"),this.eventListeners.forEach(({target:e,type:t,handler:r})=>{e.removeEventListener(t,r)}),this.eventListeners=[],this.renderer&&(this.renderer.destroy(),this.renderer=null),this.exitIntentCooldownTimer&&(clearTimeout(this.exitIntentCooldownTimer),this.exitIntentCooldownTimer=null),this.timeOnPageTimers.forEach(e=>clearTimeout(e)),this.timeOnPageTimers=[],this.trackedClicks.clear(),this.exitIntentTriggered=!1,this.scrollDepthThresholds.clear(),this.triggeredScrollThresholds.clear(),this.campaigns=[],this.maxScrollDepth=0,this.isInitialized=!1}async displayForm(e,t){this.log("Displaying form:",e.formId),this.config.onShow?.(e),this.renderer=new f(e,{onSubmit:async r=>{await this.submitResponse(e.formId,r,t),this.config.onSubmit?.(r)},onDismiss:()=>{this.config.onDismiss?.(),this.renderer?.destroy(),this.renderer=null}}),this.renderer.render()}async submitResponse(e,t,r){this.log("Submitting response:",e,t);let i=this.getContext(),a=new Date().toISOString();try{await fetch(`${this.config.apiUrl}/api/sdk/submit`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({session_id:this.sessionId,user_id:this.config.userId,form_id:e,campaign_id:r,answers:t,context:i,completed_at:a})})}catch(n){this.handleError(n)}}getContext(){return{pageUrl:window.location.href,referrer:document.referrer,timeOnPage:Math.floor((Date.now()-this.pageLoadTime)/1e3),scrollDepth:Math.round(this.scrollDepth*100)/100,deviceType:k()}}loadOrCreateSessionId(){let e="bliptar_session";if(typeof sessionStorage>"u")return y();let t=sessionStorage.getItem(e);return t||(t=y(),sessionStorage.setItem(e,t)),t}addEventListener(e,t,r){e.addEventListener(t,r),this.eventListeners.push({target:e,type:t,handler:r})}log(...e){this.config.debug&&console.log("[Bliptar]",...e)}handleError(e){this.log("Error:",e),this.config.onError?.(e)}};function C(o){return new h(o)}if(typeof window<"u"){let o=document.currentScript;if(o?.dataset.apiKey){let e=C({apiKey:o.dataset.apiKey,debug:o.dataset.debug==="true"});window.bliptar=e,e.init()}}0&&(module.exports={Bliptar,createBliptar});
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var b={mode:"light",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",textPrimary:"#1a1a1a",textSecondary:"#666666",primaryColor:"#3b82f6",primaryHover:"#2563eb",borderColor:"#e0e0e0",shadowColor:"rgba(0, 0, 0, 0.15)",starColor:"#fbbf24"},u={mode:"dark",backgroundColor:"#1a1a1a",surfaceColor:"#2a2a2a",textPrimary:"#ffffff",textSecondary:"#a0a0a0",primaryColor:"#3b82f6",primaryHover:"#60a5fa",borderColor:"#333333",shadowColor:"rgba(0, 0, 0, 0.4)",starColor:"#fbbf24"};function E(o,e){try{let r=window.getComputedStyle(o).getPropertyValue(e);return r&&r!=="rgba(0, 0, 0, 0)"?r:null}catch{return null}}function I(o){try{return getComputedStyle(document.documentElement).getPropertyValue(o).trim()||null}catch{return null}}function
|
|
1
|
+
var b={mode:"light",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",textPrimary:"#1a1a1a",textSecondary:"#666666",primaryColor:"#3b82f6",primaryHover:"#2563eb",borderColor:"#e0e0e0",shadowColor:"rgba(0, 0, 0, 0.15)",starColor:"#fbbf24"},u={mode:"dark",backgroundColor:"#1a1a1a",surfaceColor:"#2a2a2a",textPrimary:"#ffffff",textSecondary:"#a0a0a0",primaryColor:"#3b82f6",primaryHover:"#60a5fa",borderColor:"#333333",shadowColor:"rgba(0, 0, 0, 0.4)",starColor:"#fbbf24"};function E(o,e){try{let r=window.getComputedStyle(o).getPropertyValue(e);return r&&r!=="rgba(0, 0, 0, 0)"?r:null}catch{return null}}function I(o){try{return getComputedStyle(document.documentElement).getPropertyValue(o).trim()||null}catch{return null}}function k(o){let e=o.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(e)return{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)};let t=o.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return t?{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}:null}function L(o,e,t){let[r,i,a]=[o,e,t].map(n=>(n=n/255,n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)));return .2126*r+.7152*i+.0722*a}function x(o){let e=k(o);return e?L(e.r,e.g,e.b)<.5:!1}function g(o,e){let t=k(o);if(!t)return o;let r=i=>Math.min(255,Math.max(0,Math.round(i+e/100*255)));return`rgb(${r(t.r)}, ${r(t.g)}, ${r(t.b)})`}function P(o){return x(o)?"#ffffff":"#1a1a1a"}function D(o,e){let t={},r=null;o&&(r=document.querySelector(o)),r||(r=document.body);let i=E(r,"background-color");if(i){let a=x(i);t.mode=a?"dark":"light",t.backgroundColor=i,t.surfaceColor=g(i,a?10:-5),t.textPrimary=P(i),t.textSecondary=g(t.textPrimary,a?-30:30),t.borderColor=g(i,a?20:-15),t.shadowColor=a?"rgba(0, 0, 0, 0.4)":"rgba(0, 0, 0, 0.15)"}if(e){let a={"--primary":"primaryColor","--primary-color":"primaryColor","--accent":"primaryColor","--accent-color":"primaryColor","--brand":"primaryColor","--brand-color":"primaryColor","--color-primary":"primaryColor","--background":"backgroundColor","--bg":"backgroundColor","--bg-color":"backgroundColor","--text":"textPrimary","--text-color":"textPrimary","--foreground":"textPrimary","--border":"borderColor","--border-color":"borderColor"};for(let[n,l]of Object.entries(a)){let c=I(n);c&&l!=="mode"&&(t[l]=c)}}return t.primaryColor&&(t.primaryHover=g(t.primaryColor,t.mode==="dark"?15:-10)),Object.keys(t).length>0?t:null}function C(o){let{theme:e,customTheme:t,adaptiveOptions:r}=o;if(e==="custom"&&t)return{mode:x(t.backgroundColor)?"dark":"light",backgroundColor:t.backgroundColor,surfaceColor:t.surfaceColor,textPrimary:t.textPrimary,textSecondary:t.textSecondary,primaryColor:t.primaryColor,primaryHover:t.primaryHover,borderColor:t.borderColor,shadowColor:t.shadowColor,starColor:"#fbbf24"};if(e==="adaptive"){let i=r||{fallback:"light",autoContrast:!0},a=D(i.sourceElement,i.inheritCssVars);return a?{...a.mode==="dark"?u:b,...a}:i.fallback==="dark"?u:b}return e==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?u:b:e==="dark"?u:b}function w(o){return`
|
|
2
2
|
--bliptar-bg: ${o.backgroundColor};
|
|
3
3
|
--bliptar-surface: ${o.surfaceColor};
|
|
4
4
|
--bliptar-text: ${o.textPrimary};
|
|
@@ -8,8 +8,8 @@ var b={mode:"light",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",textPrimary
|
|
|
8
8
|
--bliptar-border: ${o.borderColor};
|
|
9
9
|
--bliptar-shadow: ${o.shadowColor};
|
|
10
10
|
--bliptar-star: ${o.starColor};
|
|
11
|
-
`}var f=class{constructor(e,t){this.container=null;this.currentIndex=0;this.answers={};this.form=e,this.options=t,this.theme=
|
|
12
|
-
:root { ${
|
|
11
|
+
`}var f=class{constructor(e,t){this.container=null;this.currentIndex=0;this.answers={};this.form=e,this.options=t,this.theme=C(e.appearance)}render(){this.createContainer(),this.injectStyles(),this.renderQuestion()}destroy(){if(this.container){let e=this.container.querySelector(".bliptar__card");e?(e.classList.add("bliptar__card--exit"),setTimeout(()=>{this.container?.remove(),this.container=null},200)):(this.container.remove(),this.container=null)}}createContainer(){this.container=document.createElement("div"),this.container.id="bliptar-form",this.container.className=`bliptar bliptar--${this.form.appearance.position}`,document.body.appendChild(this.container)}injectStyles(){let e=document.getElementById("bliptar-styles");e&&e.remove();let t=document.createElement("style");t.id="bliptar-styles",t.textContent=this.getStyles(),document.head.appendChild(t)}getStyles(){let{appearance:e}=this.form,t=this.theme,r=e.animation||"slide-up";return`
|
|
12
|
+
:root { ${w(t)} }
|
|
13
13
|
|
|
14
14
|
.bliptar {
|
|
15
15
|
position: fixed;
|
|
@@ -388,4 +388,4 @@ var b={mode:"light",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",textPrimary
|
|
|
388
388
|
<div class="bliptar__thankyou-emoji">\u{1F389}</div>
|
|
389
389
|
<div class="bliptar__thankyou-text">${this.escapeHtml(t.thankYouMessage||"Thank you for your feedback!")}</div>
|
|
390
390
|
</div>
|
|
391
|
-
</div>`,this.container.innerHTML=r}};function
|
|
391
|
+
</div>`,this.container.innerHTML=r}};function _(){let o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="";for(let t=0;t<16;t++)e+=o.charAt(Math.floor(Math.random()*o.length));return`sess_${e}`}function y(){if(typeof navigator>"u")return"desktop";let o=navigator.userAgent;return/tablet|ipad|playbook|silk/i.test(o)?"tablet":/mobile|iphone|ipod|android|blackberry|opera mini|iemobile/i.test(o)?"mobile":"desktop"}function T(o,e){let t;return(...r)=>{clearTimeout(t),t=setTimeout(()=>o(...r),e)}}var A="https://api.bliptar.com",m=class{constructor(e){this.renderer=null;this.scrollDepth=0;this.maxScrollDepth=0;this.isInitialized=!1;this.eventListeners=[];this.trackedClicks=new Set;this.exitIntentTriggered=!1;this.exitIntentCooldownTimer=null;this.timeOnPageTimers=[];this.scrollDepthThresholds=new Set;this.triggeredScrollThresholds=new Set;this.campaigns=[];this.config={apiUrl:A,debug:!1,onShow:()=>{},onSubmit:()=>{},onDismiss:()=>{},onError:()=>{},...e},this.sessionId=this.loadOrCreateSessionId(),this.pageLoadTime=Date.now()}async init(){if(typeof window>"u"||this.isInitialized)return;this.isInitialized=!0,this.log("Initializing Bliptar SDK"),await this.fetchConfigAndSetupTriggers();let e=T(()=>{let t=document.documentElement,r=window.scrollY||t.scrollTop,i=t.scrollHeight-t.clientHeight;this.scrollDepth=i>0?r/i:0;let a=Math.round(this.scrollDepth*100);a>this.maxScrollDepth&&(this.maxScrollDepth=a,this.checkScrollThresholds(a))},100);this.addEventListener(window,"scroll",e),this.track("page_view")}async fetchConfigAndSetupTriggers(){try{let e=await fetch(`${this.config.apiUrl}/api/sdk/config`,{headers:{Authorization:`Bearer ${this.config.apiKey}`}});if(!e.ok){this.log("Failed to fetch config:",e.status);return}let t=await e.json();this.campaigns=t.campaigns||[],this.log("Loaded campaigns:",this.campaigns.length),this.setupTriggersFromCampaigns()}catch(e){this.handleError(e)}}setupTriggersFromCampaigns(){let e=new Set;for(let t of this.campaigns){if(e.add(t.trigger_event),t.trigger_event==="scroll_depth"){let r=t.trigger_conditions?.find(i=>i.field==="scroll_depth_percent");r?.value&&this.scrollDepthThresholds.add(Number(r.value))}if(t.trigger_event==="time_on_page"){let r=t.trigger_conditions?.find(i=>i.field==="time_on_page_seconds");if(r?.value){let i=Number(r.value);this.setupTimeOnPageTrigger(i)}}}this.log("Active trigger types:",Array.from(e)),e.has("exit_intent")&&(this.log("Auto-enabling exit intent detection"),this.enableExitIntent({once:!0})),this.scrollDepthThresholds.size>0&&this.log("Scroll depth thresholds:",Array.from(this.scrollDepthThresholds))}setupTimeOnPageTrigger(e){this.log("Setting up time on page trigger:",e,"seconds");let t=setTimeout(()=>{this.track("time_on_page",{seconds:e,actual_time:Math.floor((Date.now()-this.pageLoadTime)/1e3)})},e*1e3);this.timeOnPageTimers.push(t)}checkScrollThresholds(e){for(let t of this.scrollDepthThresholds)e>=t&&!this.triggeredScrollThresholds.has(t)&&(this.triggeredScrollThresholds.add(t),this.log("Scroll threshold reached:",t+"%"),this.track("scroll_depth",{threshold:t,actual_depth:e}))}identify(e,t){this.config.userId=e,this.config.userAttributes={...this.config.userAttributes,...t},this.log("User identified:",e)}async track(e,t){this.log("Tracking event:",e,t);let r=this.getContext();try{let i=await fetch(`${this.config.apiUrl}/api/sdk/trigger`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({session_id:this.sessionId,user_id:this.config.userId,event:e,event_data:t||{},context:r})});if(!i.ok)throw new Error(`API error: ${i.status}`);let a=await i.json();a.show_form&&a.form&&await this.displayForm(a.form,a.campaign_id)}catch(i){this.handleError(i)}}async showForm(e){this.log("Manually showing form:",e);try{let t=await fetch(`${this.config.apiUrl}/api/sdk/form/${e}`,{headers:{Authorization:`Bearer ${this.config.apiKey}`}});if(!t.ok)throw new Error(`Failed to fetch form: ${t.status}`);let r=await t.json();await this.displayForm(r)}catch(t){this.handleError(t)}}trackClicks(e){let{selector:t,name:r,once:i=!1}=e,a=r||t;this.log("Setting up click tracking for:",t);let n=l=>{let p=l.target.closest(t);p&&(i&&this.trackedClicks.has(a)||(this.log("Button click detected:",a),i&&this.trackedClicks.add(a),this.track("button_click",{selector:t,name:a,element_text:p.textContent?.trim().slice(0,100)||"",element_id:p.id||null,element_class:p.className||null})))};this.addEventListener(document,"click",n)}enableExitIntent(e={}){let{threshold:t=50,cooldown:r=1e4,once:i=!0}=e;this.log("Enabling exit intent detection");let a=l=>{l.clientY>t||i&&this.exitIntentTriggered||this.exitIntentCooldownTimer||(this.log("Exit intent detected"),this.exitIntentTriggered=!0,this.track("exit_intent",{trigger:"mouse_leave",mouse_y:l.clientY}),i||(this.exitIntentCooldownTimer=setTimeout(()=>{this.exitIntentCooldownTimer=null},r)))};this.addEventListener(document,"mouseleave",a);let n=()=>{if(document.visibilityState==="hidden"){if(i&&this.exitIntentTriggered)return;this.log("Exit intent detected (visibility change)"),this.exitIntentTriggered=!0,this.track("exit_intent",{trigger:"visibility_change"})}};y()!=="desktop"&&this.addEventListener(document,"visibilitychange",n)}destroy(){this.log("Destroying Bliptar SDK"),this.eventListeners.forEach(({target:e,type:t,handler:r})=>{e.removeEventListener(t,r)}),this.eventListeners=[],this.renderer&&(this.renderer.destroy(),this.renderer=null),this.exitIntentCooldownTimer&&(clearTimeout(this.exitIntentCooldownTimer),this.exitIntentCooldownTimer=null),this.timeOnPageTimers.forEach(e=>clearTimeout(e)),this.timeOnPageTimers=[],this.trackedClicks.clear(),this.exitIntentTriggered=!1,this.scrollDepthThresholds.clear(),this.triggeredScrollThresholds.clear(),this.campaigns=[],this.maxScrollDepth=0,this.isInitialized=!1}async displayForm(e,t){this.log("Displaying form:",e.formId),this.config.onShow?.(e),this.renderer=new f(e,{onSubmit:async r=>{await this.submitResponse(e.formId,r,t),this.config.onSubmit?.(r)},onDismiss:()=>{this.config.onDismiss?.(),this.renderer?.destroy(),this.renderer=null}}),this.renderer.render()}async submitResponse(e,t,r){this.log("Submitting response:",e,t);let i=this.getContext(),a=new Date().toISOString();try{await fetch(`${this.config.apiUrl}/api/sdk/submit`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({session_id:this.sessionId,user_id:this.config.userId,form_id:e,campaign_id:r,answers:t,context:i,completed_at:a})})}catch(n){this.handleError(n)}}getContext(){return{pageUrl:window.location.href,referrer:document.referrer,timeOnPage:Math.floor((Date.now()-this.pageLoadTime)/1e3),scrollDepth:Math.round(this.scrollDepth*100)/100,deviceType:y()}}loadOrCreateSessionId(){let e="bliptar_session";if(typeof sessionStorage>"u")return _();let t=sessionStorage.getItem(e);return t||(t=_(),sessionStorage.setItem(e,t)),t}addEventListener(e,t,r){e.addEventListener(t,r),this.eventListeners.push({target:e,type:t,handler:r})}log(...e){this.config.debug&&console.log("[Bliptar]",...e)}handleError(e){this.log("Error:",e),this.config.onError?.(e)}};function $(o){return new m(o)}if(typeof window<"u"){let o=document.currentScript;if(o?.dataset.apiKey){let e=$({apiKey:o.dataset.apiKey,debug:o.dataset.debug==="true"});window.bliptar=e,e.init()}}export{m as Bliptar,$ as createBliptar};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bliptarjs/sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Bliptar SDK - Lightweight micro-feedback for web apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"bugs": {
|
|
25
25
|
"url": "https://github.com/bliptar/sdk/issues"
|
|
26
26
|
},
|
|
27
|
-
"homepage": "https://bliptar.com/docs
|
|
27
|
+
"homepage": "https://www.bliptar.com/docs",
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "tsup src/index.ts --format esm,cjs --dts --minify",
|
|
30
30
|
"dev": "tsup src/index.ts --format esm,cjs --dts --watch",
|
|
@@ -41,7 +41,10 @@
|
|
|
41
41
|
"micro-feedback",
|
|
42
42
|
"nps",
|
|
43
43
|
"user-feedback",
|
|
44
|
-
"analytics"
|
|
44
|
+
"analytics",
|
|
45
|
+
"angular",
|
|
46
|
+
"react",
|
|
47
|
+
"vue"
|
|
45
48
|
],
|
|
46
49
|
"author": "",
|
|
47
50
|
"license": "MIT",
|