@meet-sudo/sdk 0.1.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.
- package/README.md +192 -0
- package/dist/index.d.mts +86 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.js +496 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +468 -0
- package/dist/index.mjs.map +1 -0
- package/dist/meetsudo.global.js +2 -0
- package/dist/meetsudo.global.js.map +1 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# @meet-sudo/sdk
|
|
2
|
+
|
|
3
|
+
Official JavaScript SDK for MeetSudo - the unified customer platform with chat, analytics, and session replay.
|
|
4
|
+
|
|
5
|
+
**[Documentation](https://@meet-sudo/sdk.com/docs)** | **[Website](https://@meet-sudo/sdk.com)** | **[Dashboard](https://@meet-sudo/sdk.com/login)**
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
### npm / yarn / pnpm
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @meet-sudo/sdk
|
|
13
|
+
# or
|
|
14
|
+
yarn add @meet-sudo/sdk
|
|
15
|
+
# or
|
|
16
|
+
pnpm add @meet-sudo/sdk
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Script Tag (CDN)
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<script src="https://cdn.@meet-sudo/sdk.com/sdk/@meet-sudo/sdk.js"></script>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
### ES Modules
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
import { @meet-sudo/sdk } from '@meet-sudo/sdk';
|
|
31
|
+
|
|
32
|
+
// Initialize with your API key
|
|
33
|
+
await @meet-sudo/sdk.init({
|
|
34
|
+
apiKey: 'your-api-key'
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Track events
|
|
38
|
+
@meet-sudo/sdk.track('button_clicked', { buttonId: 'signup' });
|
|
39
|
+
|
|
40
|
+
// Identify users
|
|
41
|
+
await @meet-sudo/sdk.identify('user-123', {
|
|
42
|
+
email: 'user@example.com',
|
|
43
|
+
name: 'John Doe'
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Script Tag
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<script src="https://cdn.@meet-sudo/sdk.com/sdk/@meet-sudo/sdk.js"></script>
|
|
51
|
+
<script>
|
|
52
|
+
MeetSudo.init({
|
|
53
|
+
apiKey: 'your-api-key'
|
|
54
|
+
}).then(function() {
|
|
55
|
+
MeetSudo.track('page_loaded');
|
|
56
|
+
});
|
|
57
|
+
</script>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## API Reference
|
|
61
|
+
|
|
62
|
+
### `init(config)`
|
|
63
|
+
|
|
64
|
+
Initialize the SDK. Must be called before any other methods.
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
interface MeetSudoConfig {
|
|
68
|
+
apiKey: string; // Required: Your MeetSudo API key
|
|
69
|
+
apiUrl?: string; // Optional: API URL (default: https://api.@meet-sudo/sdk.com)
|
|
70
|
+
widgetUrl?: string; // Optional: Widget URL (default: https://widget.@meet-sudo/sdk.com)
|
|
71
|
+
disableChat?: boolean; // Optional: Disable chat widget
|
|
72
|
+
disableReplay?: boolean; // Optional: Disable session replay
|
|
73
|
+
disableEvents?: boolean; // Optional: Disable event tracking
|
|
74
|
+
disableAutoPageView?: boolean; // Optional: Disable automatic page view tracking
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### `identify(userId, traits?)`
|
|
79
|
+
|
|
80
|
+
Identify a user with their unique ID and optional traits.
|
|
81
|
+
|
|
82
|
+
```javascript
|
|
83
|
+
await @meet-sudo/sdk.identify('user-123', {
|
|
84
|
+
email: 'user@example.com',
|
|
85
|
+
name: 'John Doe',
|
|
86
|
+
plan: 'pro',
|
|
87
|
+
signupDate: '2024-01-15'
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### `track(eventName, properties?)`
|
|
92
|
+
|
|
93
|
+
Track a custom event with optional properties.
|
|
94
|
+
|
|
95
|
+
```javascript
|
|
96
|
+
@meet-sudo/sdk.track('purchase_completed', {
|
|
97
|
+
orderId: 'ord-123',
|
|
98
|
+
amount: 99.99,
|
|
99
|
+
currency: 'USD'
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### `page(properties?)`
|
|
104
|
+
|
|
105
|
+
Track a page view. Called automatically on init unless `disableAutoPageView` is set.
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
@meet-sudo/sdk.page({
|
|
109
|
+
title: 'Product Page',
|
|
110
|
+
category: 'E-commerce'
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### `chat(action)`
|
|
115
|
+
|
|
116
|
+
Control the chat widget programmatically.
|
|
117
|
+
|
|
118
|
+
```javascript
|
|
119
|
+
// Open the chat widget
|
|
120
|
+
@meet-sudo/sdk.chat('open');
|
|
121
|
+
|
|
122
|
+
// Close the chat widget
|
|
123
|
+
@meet-sudo/sdk.chat('close');
|
|
124
|
+
|
|
125
|
+
// Hide the chat widget
|
|
126
|
+
@meet-sudo/sdk.chat('hide');
|
|
127
|
+
|
|
128
|
+
// Show the chat widget
|
|
129
|
+
@meet-sudo/sdk.chat('show');
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Helper Methods
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
// Check if SDK is initialized
|
|
136
|
+
@meet-sudo/sdk.isInitialized(); // boolean
|
|
137
|
+
|
|
138
|
+
// Get anonymous ID
|
|
139
|
+
@meet-sudo/sdk.getAnonymousId(); // string | null
|
|
140
|
+
|
|
141
|
+
// Get customer ID (after identify)
|
|
142
|
+
@meet-sudo/sdk.getCustomerId(); // string | null
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Features
|
|
146
|
+
|
|
147
|
+
### Chat Widget
|
|
148
|
+
|
|
149
|
+
The chat widget is automatically loaded if enabled in your MeetSudo dashboard. You can control it programmatically using the `chat()` method.
|
|
150
|
+
|
|
151
|
+
### Event Tracking
|
|
152
|
+
|
|
153
|
+
Events are batched and sent every 5 seconds for optimal performance. On page unload, any remaining events are sent using `keepalive` fetch.
|
|
154
|
+
|
|
155
|
+
### Session Replay
|
|
156
|
+
|
|
157
|
+
Session replay automatically captures user interactions for debugging and UX analysis. Sensitive inputs (passwords, credit cards) are automatically masked.
|
|
158
|
+
|
|
159
|
+
To exclude specific elements from recording:
|
|
160
|
+
|
|
161
|
+
```html
|
|
162
|
+
<!-- Using class -->
|
|
163
|
+
<div class="@meet-sudo/sdk-no-record">Sensitive content</div>
|
|
164
|
+
|
|
165
|
+
<!-- Using data attribute -->
|
|
166
|
+
<div data-@meet-sudo/sdk-no-record>Sensitive content</div>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## TypeScript
|
|
170
|
+
|
|
171
|
+
Full TypeScript support is included. Types are exported from the main package:
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
import type {
|
|
175
|
+
MeetSudoConfig,
|
|
176
|
+
UserTraits,
|
|
177
|
+
EventProperties,
|
|
178
|
+
PageProperties,
|
|
179
|
+
ChatAction
|
|
180
|
+
} from '@meet-sudo/sdk';
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Browser Support
|
|
184
|
+
|
|
185
|
+
- Chrome 60+
|
|
186
|
+
- Firefox 55+
|
|
187
|
+
- Safari 11+
|
|
188
|
+
- Edge 79+
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
interface MeetSudoConfig {
|
|
2
|
+
/** Your MeetSudo API key */
|
|
3
|
+
apiKey: string;
|
|
4
|
+
/** API URL (defaults to https://api.meetsudo.com) */
|
|
5
|
+
apiUrl?: string;
|
|
6
|
+
/** Widget URL (defaults to https://widget.meetsudo.com) */
|
|
7
|
+
widgetUrl?: string;
|
|
8
|
+
/** Disable chat widget */
|
|
9
|
+
disableChat?: boolean;
|
|
10
|
+
/** Disable session replay */
|
|
11
|
+
disableReplay?: boolean;
|
|
12
|
+
/** Disable event tracking */
|
|
13
|
+
disableEvents?: boolean;
|
|
14
|
+
/** Disable automatic page view tracking */
|
|
15
|
+
disableAutoPageView?: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface UserTraits {
|
|
18
|
+
email?: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
[key: string]: string | number | boolean | undefined;
|
|
21
|
+
}
|
|
22
|
+
interface EventProperties {
|
|
23
|
+
[key: string]: string | number | boolean | null | undefined;
|
|
24
|
+
}
|
|
25
|
+
interface PageProperties {
|
|
26
|
+
url?: string;
|
|
27
|
+
title?: string;
|
|
28
|
+
referrer?: string;
|
|
29
|
+
[key: string]: string | number | boolean | null | undefined;
|
|
30
|
+
}
|
|
31
|
+
type ChatAction = "open" | "close" | "show" | "hide";
|
|
32
|
+
|
|
33
|
+
declare class MeetSudo {
|
|
34
|
+
private state;
|
|
35
|
+
private config;
|
|
36
|
+
/**
|
|
37
|
+
* Initialize the MeetSudo SDK
|
|
38
|
+
*/
|
|
39
|
+
init(config: MeetSudoConfig): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Identify a user
|
|
42
|
+
*/
|
|
43
|
+
identify(userId: string, traits?: UserTraits): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Track a custom event
|
|
46
|
+
*/
|
|
47
|
+
track(eventName: string, properties?: EventProperties): void;
|
|
48
|
+
/**
|
|
49
|
+
* Track a page view
|
|
50
|
+
*/
|
|
51
|
+
page(properties?: PageProperties): void;
|
|
52
|
+
/**
|
|
53
|
+
* Control the chat widget
|
|
54
|
+
*/
|
|
55
|
+
chat(action: ChatAction): void;
|
|
56
|
+
/**
|
|
57
|
+
* Check if SDK is initialized
|
|
58
|
+
*/
|
|
59
|
+
isInitialized(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Get the anonymous ID
|
|
62
|
+
*/
|
|
63
|
+
getAnonymousId(): string | null;
|
|
64
|
+
/**
|
|
65
|
+
* Get the customer ID (after identify)
|
|
66
|
+
*/
|
|
67
|
+
getCustomerId(): string | null;
|
|
68
|
+
private getAnonId;
|
|
69
|
+
private generateUUID;
|
|
70
|
+
private api;
|
|
71
|
+
private createIframe;
|
|
72
|
+
private flushEvents;
|
|
73
|
+
private shouldSampleReplay;
|
|
74
|
+
private startReplay;
|
|
75
|
+
private initRrweb;
|
|
76
|
+
private isSensitiveInput;
|
|
77
|
+
private flushReplayChunk;
|
|
78
|
+
private setupRageClickDetection;
|
|
79
|
+
private setupErrorCapture;
|
|
80
|
+
private setupEmailCapture;
|
|
81
|
+
private handleUnload;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare const meetsudo: MeetSudo;
|
|
85
|
+
|
|
86
|
+
export { type ChatAction, type EventProperties, MeetSudo, type MeetSudoConfig, type PageProperties, type UserTraits, meetsudo };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
interface MeetSudoConfig {
|
|
2
|
+
/** Your MeetSudo API key */
|
|
3
|
+
apiKey: string;
|
|
4
|
+
/** API URL (defaults to https://api.meetsudo.com) */
|
|
5
|
+
apiUrl?: string;
|
|
6
|
+
/** Widget URL (defaults to https://widget.meetsudo.com) */
|
|
7
|
+
widgetUrl?: string;
|
|
8
|
+
/** Disable chat widget */
|
|
9
|
+
disableChat?: boolean;
|
|
10
|
+
/** Disable session replay */
|
|
11
|
+
disableReplay?: boolean;
|
|
12
|
+
/** Disable event tracking */
|
|
13
|
+
disableEvents?: boolean;
|
|
14
|
+
/** Disable automatic page view tracking */
|
|
15
|
+
disableAutoPageView?: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface UserTraits {
|
|
18
|
+
email?: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
[key: string]: string | number | boolean | undefined;
|
|
21
|
+
}
|
|
22
|
+
interface EventProperties {
|
|
23
|
+
[key: string]: string | number | boolean | null | undefined;
|
|
24
|
+
}
|
|
25
|
+
interface PageProperties {
|
|
26
|
+
url?: string;
|
|
27
|
+
title?: string;
|
|
28
|
+
referrer?: string;
|
|
29
|
+
[key: string]: string | number | boolean | null | undefined;
|
|
30
|
+
}
|
|
31
|
+
type ChatAction = "open" | "close" | "show" | "hide";
|
|
32
|
+
|
|
33
|
+
declare class MeetSudo {
|
|
34
|
+
private state;
|
|
35
|
+
private config;
|
|
36
|
+
/**
|
|
37
|
+
* Initialize the MeetSudo SDK
|
|
38
|
+
*/
|
|
39
|
+
init(config: MeetSudoConfig): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Identify a user
|
|
42
|
+
*/
|
|
43
|
+
identify(userId: string, traits?: UserTraits): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Track a custom event
|
|
46
|
+
*/
|
|
47
|
+
track(eventName: string, properties?: EventProperties): void;
|
|
48
|
+
/**
|
|
49
|
+
* Track a page view
|
|
50
|
+
*/
|
|
51
|
+
page(properties?: PageProperties): void;
|
|
52
|
+
/**
|
|
53
|
+
* Control the chat widget
|
|
54
|
+
*/
|
|
55
|
+
chat(action: ChatAction): void;
|
|
56
|
+
/**
|
|
57
|
+
* Check if SDK is initialized
|
|
58
|
+
*/
|
|
59
|
+
isInitialized(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Get the anonymous ID
|
|
62
|
+
*/
|
|
63
|
+
getAnonymousId(): string | null;
|
|
64
|
+
/**
|
|
65
|
+
* Get the customer ID (after identify)
|
|
66
|
+
*/
|
|
67
|
+
getCustomerId(): string | null;
|
|
68
|
+
private getAnonId;
|
|
69
|
+
private generateUUID;
|
|
70
|
+
private api;
|
|
71
|
+
private createIframe;
|
|
72
|
+
private flushEvents;
|
|
73
|
+
private shouldSampleReplay;
|
|
74
|
+
private startReplay;
|
|
75
|
+
private initRrweb;
|
|
76
|
+
private isSensitiveInput;
|
|
77
|
+
private flushReplayChunk;
|
|
78
|
+
private setupRageClickDetection;
|
|
79
|
+
private setupErrorCapture;
|
|
80
|
+
private setupEmailCapture;
|
|
81
|
+
private handleUnload;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare const meetsudo: MeetSudo;
|
|
85
|
+
|
|
86
|
+
export { type ChatAction, type EventProperties, MeetSudo, type MeetSudoConfig, type PageProperties, type UserTraits, meetsudo };
|