-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.d.ts
More file actions
365 lines (357 loc) · 11.1 KB
/
index.d.ts
File metadata and controls
365 lines (357 loc) · 11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
export namespace Gleap {
function initialize(sdkKey: string, disablePing?: boolean): void;
function sendSilentCrashReport(
description: string,
priority?: "LOW" | "MEDIUM" | "HIGH",
excludeData?: {
customData?: Boolean;
metaData?: Boolean;
attachments?: Boolean;
consoleLog?: Boolean;
networkLogs?: Boolean;
customEventLog?: Boolean;
screenshot?: Boolean;
replays?: Boolean;
}
): void;
function sendSilentCrashReportWithFormData(
formData: {
[key: string]: string;
},
priority?: "LOW" | "MEDIUM" | "HIGH",
excludeData?: {
customData: Boolean;
metaData: Boolean;
attachments: Boolean;
consoleLog: Boolean;
networkLogs: Boolean;
customEventLog: Boolean;
screenshot: Boolean;
replays: Boolean;
}
): void;
function startClassicForm(
formId: string,
showBackButton?: boolean
): void;
function startBot(botId: string, showBackButton?: boolean): void;
function startConversation(showBackButton?: boolean): void;
function attachCustomData(customData: any): void;
function setTicketAttribute(key: string, value: string): void;
function unsetTicketAttribute(key: string): void;
function clearTicketAttributes(): void;
function setCustomData(key: string, value: string): void;
function removeCustomData(key: string): void;
function clearCustomData(): void;
function playSound(play: boolean): void;
function destroy(): void;
function showAiChatbar(): void;
function hideAiChatbar(): void;
function askAI(question: string, showBackButton?: boolean): void;
function setAiChatbarQuickActions(quickActions: string[]): void;
function isOpened(): boolean;
function setApiUrl(apiUrl: string): void;
function setWSApiUrl(wsApiUrl: string): void;
function setFrameUrl(frameUrl: string): void;
function closeBanner(): void;
function closeModal(): void;
function setBannerUrl(bannerUrl: string): void;
function setModalUrl(modalUrl: string): void;
function startAgent(
agentId: string,
options?: { context?: any; primaryColor?: string; initialMessage?: string }
): void;
function setAIAgent(
agentId: string,
options?: { context?: any; primaryColor?: string }
): void;
function setMaxNetworkRequests(maxRequests: number): void;
function startNetworkLogger(): void;
function setNetworkLogsBlacklist(networkLogBlacklist: string[]): void;
function setNetworkLogPropsToIgnore(filters: string[]): void;
function registerAgentToolAction(
callback: (toolAction: {
name: string;
params: Record<string, any>;
result: any;
message: string;
toolCallId: string;
}) => void
): void;
function registerCustomAction(
customAction: (action: { name: string }) => void
): void;
function log(message: string, logLevel?: "INFO" | "WARNING" | "ERROR"): void;
/**
* @deprecated Please use trackEvent instead.
*/
function logEvent(name: string, data?: any): void;
function trackEvent(name: string, data?: any): void;
function setAppBuildNumber(buildNumber: string): void;
function setAppVersionCode(versionCode: string): void;
function setStyles(styles: {
primaryColor: string;
headerColor: string;
buttonColor: string;
backgroundColor: string;
borderRadius?: number;
buttonX?: number;
buttonY?: number;
buttonStyle?: string;
}): void;
function disableConsoleLogOverwrite(): void;
function setLiveSite(isLiveSite: boolean): void;
function enableShortcuts(enabled: boolean): void;
function setLanguage(language: string): void;
function preFillForm(data: object): void;
function setAiTools(tools: {
name: string;
description: string;
response?: string;
executionType?: 'button' | 'auto';
parameters?: {
name: string;
description: string;
type: "string" | "number" | "boolean";
required: boolean;
enum?: string[];
}[];
}[]): void;
function showTabNotificationBadge(showNotificationBadge: boolean): void;
function attachNetworkLogs(networkLogs: string): void;
function clearIdentity(): void;
function setTags(tags: string[]): void;
function setDisableInAppNotifications(
disableInAppNotifications: boolean
): void;
function setDisablePageTracking(
disablePageTracking: boolean
): void;
function identify(
userId: string,
customerData: {
name?: string | null;
email?: string | null;
phone?: string | null;
value?: number | null;
companyId?: string | null;
companyName?: string | null;
sla?: number | null;
plan?: string | null;
customData?: object | null;
avatar?: string | null;
createdAt?: Date | null;
},
userHash?: string
): void;
function updateContact(
customerData: {
name?: string | null;
email?: string | null;
phone?: string | null;
value?: number | null;
companyId?: string | null;
companyName?: string | null;
sla?: number | null;
plan?: string | null;
avatar?: string | null;
customData?: object | null;
}
): void;
function getInstance(): any;
function open(): void;
function openChecklists(showBackButton?: boolean): void;
function openChecklist(checklistId: string, showBackButton?: boolean): void;
function startChecklist(outboundId: string, showBackButton?: boolean, sharedKey?: string): void;
function openNews(showBackButton?: boolean): void;
function openNewsArticle(id: string, showBackButton?: boolean): void;
function openConversations(showBackButton?: boolean): void;
function startProductTour(tourId: string): void;
function openConversation(
shareToken?: string,
showBackButton?: boolean
): void;
function setUrlHandler(
urlHandler: (url: string, newTab?: boolean) => void
): void;
function openHelpCenter(showBackButton?: boolean): void;
function openHelpCenterCollection(
collectionId: string,
showBackButton?: boolean
): void;
function openHelpCenterArticle(
articleId: string,
showBackButton?: boolean
): void;
function searchHelpCenter(term: string, showBackButton?: boolean): void;
function openFeatureRequests(showBackButton?: boolean): void;
function close(): void;
function hide(): void;
function setUseCookies(useCookies: boolean): void;
function setEnvironment(environment: "dev" | "staging" | "prod"): void;
function showFeedbackButton(show: boolean): void;
function startFeedbackFlow(
feedbackFlow: string,
showBackButton?: boolean
): void;
function showSurvey(surveyId: string, format?: string): void;
function on(
event:
| "initialized"
| "open"
| "close"
| "flow-started"
| "checklist-loaded"
| "checklist-step-completed"
| "checklist-completed"
| "agent-message-sent"
| "agent-reply-received"
| "agent-error"
| "agent-conversation-created"
| "agent-tool-executed"
| string,
callback: (data?: any) => void
): void;
function sendAgentMessage(
agentId: string,
message: string,
options?: {
conversationId?: string;
additionalContext?: Record<string, any>;
}
): Promise<{
runId: string;
status: string;
response: string;
conversationId?: string;
outcome?: { type: string };
}>;
function clearAgentConversation(): void;
interface AgentChatMessage {
id: string;
role: 'user' | 'assistant';
content: string;
createdAt: string;
}
interface AgentChatState {
messages: AgentChatMessage[];
isExecuting: boolean;
error: any;
conversationId: string | null;
}
interface AgentChatOptions {
/** The agent ID to talk to. */
agentId: string;
/** Additional context sent with every message to the AI. */
context?: Record<string, any>;
/** Resume an existing conversation by ID. */
conversationId?: string;
/** Called on every state change (messages, loading, error). */
onChange?: (state: AgentChatState) => void;
/** Called when the agent replies. */
onReplyReceived?: (data: any) => void;
/** Called on error. */
onError?: (error: any) => void;
/** Called when a new conversation is created. */
onConversationCreated?: (conversationId: string) => void;
}
interface AgentChatInstance {
/** Send a message to the agent. */
sendMessage(content: string): Promise<void>;
/** Clear all messages and start a new conversation. */
clearMessages(): void;
/** Update the context sent with future messages. */
setContext(context: Record<string, any>): void;
/** Get the current state snapshot. */
getState(): AgentChatState;
/** Destroy this instance and stop all callbacks. */
destroy(): void;
}
/**
* Create a headless agent chat instance.
* Framework-agnostic — wire onChange to React setState, Vue ref, Svelte store, etc.
*
* @example
* ```js
* const chat = Gleap.createAgentChat({
* agentId: 'abc123',
* context: { page: '/billing' },
* onChange: ({ messages, isExecuting }) => { ... },
* });
* chat.sendMessage('Hello!');
* ```
*/
function createAgentChat(options: AgentChatOptions): AgentChatInstance;
function getIdentity(): any;
function isUserIdentified(): boolean;
function setReplayOptions(options: {
blockClass?: string | RegExp;
blockSelector?: string;
ignoreClass?: string | RegExp;
ignoreSelector?: string;
ignoreCSSAttributes?: string[];
maskTextClass?: string | RegExp;
maskTextSelector?: string;
maskAllInputs?: boolean;
maskInputOptions?: {
password?: boolean;
[key: string]: any;
};
maskInputFn?: (text: string) => string;
maskTextFn?: (text: string) => string;
slimDOMOptions?: {
[key: string]: any;
};
dataURLOptions?: {
[key: string]: any;
};
hooks?: {
[key: string]: any;
};
packFn?: (events: any) => any;
sampling?: any;
recordCanvas?: boolean;
recordCrossOriginIframes?: boolean;
recordAfter?: 'DOMContentLoaded' | 'load';
inlineImages?: boolean;
collectFonts?: boolean;
userTriggeredOnInput?: boolean;
plugins?: {
[key: string]: any;
}[];
errorHandler?: (error: Error) => void;
}): void;
}
export default Gleap;
// Custom element type declarations — makes <gleap-*> work in JSX without extra setup
// Covers both React 18 (global JSX) and React 19+ (React.JSX)
declare global {
namespace JSX {
interface IntrinsicElements {
'gleap-agent-conversation': any;
'gleap-agent-input': any;
'gleap-agent-profile-image': any;
'gleap-agent-reply-bubble': any;
'gleap-agent-user-bubble': any;
'gleap-agent-typing-indicator': any;
'gleap-agent-send-button': any;
'gleap-agent-message-list': any;
'gleap-checklist': any;
}
}
}
declare module 'react' {
namespace JSX {
interface IntrinsicElements {
'gleap-agent-conversation': any;
'gleap-agent-input': any;
'gleap-agent-profile-image': any;
'gleap-agent-reply-bubble': any;
'gleap-agent-user-bubble': any;
'gleap-agent-typing-indicator': any;
'gleap-agent-send-button': any;
'gleap-agent-message-list': any;
'gleap-checklist': any;
}
}
}