capacitor-gleap-plugin 18.0.0 → 19.0.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/CapacitorGleapPlugin.podspec +7 -2
- package/Package.swift +31 -0
- package/README.md +307 -761
- package/android/build.gradle +1 -1
- package/android/src/main/java/io/gleapplugins/capacitor/GleapPlugin.java +228 -37
- package/dist/docs.json +323 -3907
- package/dist/esm/definitions.d.ts +168 -3
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.js +9 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/logs/body.d.ts +58 -0
- package/dist/esm/logs/body.js +303 -0
- package/dist/esm/logs/body.js.map +1 -0
- package/dist/esm/logs/consoleCapture.d.ts +29 -0
- package/dist/esm/logs/consoleCapture.js +189 -0
- package/dist/esm/logs/consoleCapture.js.map +1 -0
- package/dist/esm/logs/format.d.ts +16 -0
- package/dist/esm/logs/format.js +394 -0
- package/dist/esm/logs/format.js.map +1 -0
- package/dist/esm/logs/networkCapture.d.ts +65 -0
- package/dist/esm/logs/networkCapture.js +654 -0
- package/dist/esm/logs/networkCapture.js.map +1 -0
- package/dist/esm/logs/redaction.d.ts +54 -0
- package/dist/esm/logs/redaction.js +388 -0
- package/dist/esm/logs/redaction.js.map +1 -0
- package/dist/esm/logs/webViewLogs.d.ts +70 -0
- package/dist/esm/logs/webViewLogs.js +297 -0
- package/dist/esm/logs/webViewLogs.js.map +1 -0
- package/dist/esm/logs/zone.d.ts +5 -0
- package/dist/esm/logs/zone.js +15 -0
- package/dist/esm/logs/zone.js.map +1 -0
- package/dist/esm/web.d.ts +47 -2
- package/dist/esm/web.js +43 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +2263 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +2263 -1
- package/dist/plugin.js.map +1 -1
- package/ios/{Plugin → Sources/GleapPlugin}/GleapPlugin.swift +222 -12
- package/package.json +27 -6
- package/ios/Plugin/GleapPlugin.h +0 -10
- package/ios/Plugin/GleapPlugin.m +0 -66
- package/ios/Plugin/Info.plist +0 -24
|
@@ -5,6 +5,53 @@ export interface GleapEventMessage {
|
|
|
5
5
|
data?: any;
|
|
6
6
|
}
|
|
7
7
|
export declare type GleapEventCallback = (message: GleapEventMessage | null, err?: any) => void;
|
|
8
|
+
/**
|
|
9
|
+
* A console log entry as the plugin hands it to the native SDK.
|
|
10
|
+
*/
|
|
11
|
+
export interface GleapConsoleLogEntry {
|
|
12
|
+
/** ISO-8601 UTC timestamp with milliseconds. */
|
|
13
|
+
date: string;
|
|
14
|
+
priority: 'ERROR' | 'WARNING' | 'INFO';
|
|
15
|
+
log: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A network log entry (fetch / XMLHttpRequest) as the plugin hands it to the native SDK.
|
|
19
|
+
*/
|
|
20
|
+
export interface GleapNetworkLogEntry {
|
|
21
|
+
/** ISO-8601 UTC timestamp of the request start. */
|
|
22
|
+
date: string;
|
|
23
|
+
/** HTTP method, uppercase. */
|
|
24
|
+
type: string;
|
|
25
|
+
url: string;
|
|
26
|
+
/** Milliseconds from the request start to the response headers (or the failure). */
|
|
27
|
+
duration?: number;
|
|
28
|
+
/** true when an HTTP response arrived (any status), false on a transport error, abort or timeout. */
|
|
29
|
+
success?: boolean;
|
|
30
|
+
request?: {
|
|
31
|
+
headers?: {
|
|
32
|
+
[name: string]: string;
|
|
33
|
+
};
|
|
34
|
+
payload?: string;
|
|
35
|
+
};
|
|
36
|
+
response?: {
|
|
37
|
+
status?: number;
|
|
38
|
+
statusText?: string;
|
|
39
|
+
headers?: {
|
|
40
|
+
[name: string]: string;
|
|
41
|
+
};
|
|
42
|
+
responseText?: string;
|
|
43
|
+
/** Set instead of status and body when the request failed. */
|
|
44
|
+
errorText?: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The network log settings of your Gleap project, sent by the native SDK once its config is loaded.
|
|
49
|
+
*/
|
|
50
|
+
export interface GleapLogConfig {
|
|
51
|
+
enableNetworkLogs: boolean;
|
|
52
|
+
networkLogPropsToIgnore: string[];
|
|
53
|
+
networkLogBlacklist: string[];
|
|
54
|
+
}
|
|
8
55
|
export interface GleapPlugin {
|
|
9
56
|
/**
|
|
10
57
|
* Initialize Gleap with an API key
|
|
@@ -105,7 +152,7 @@ export interface GleapPlugin {
|
|
|
105
152
|
sla?: number;
|
|
106
153
|
plan?: string;
|
|
107
154
|
value?: number;
|
|
108
|
-
customData?:
|
|
155
|
+
customData?: Record<string, any>;
|
|
109
156
|
}): Promise<{
|
|
110
157
|
identify: boolean;
|
|
111
158
|
}>;
|
|
@@ -124,7 +171,7 @@ export interface GleapPlugin {
|
|
|
124
171
|
sla?: number;
|
|
125
172
|
plan?: string;
|
|
126
173
|
value?: number;
|
|
127
|
-
customData?:
|
|
174
|
+
customData?: Record<string, any>;
|
|
128
175
|
}): Promise<{
|
|
129
176
|
identify: boolean;
|
|
130
177
|
}>;
|
|
@@ -221,6 +268,43 @@ export interface GleapPlugin {
|
|
|
221
268
|
propsToIgnoreSet: boolean;
|
|
222
269
|
}>;
|
|
223
270
|
/**
|
|
271
|
+
* Hands the network requests made inside the app's WebView (fetch and XMLHttpRequest) to the native SDK, so they
|
|
272
|
+
* show up in the network logs of tickets. The plugin calls this for you on iOS and Android; each call replaces
|
|
273
|
+
* the previously attached WebView network logs. No-op on web, where the JavaScript SDK records requests itself.
|
|
274
|
+
*
|
|
275
|
+
* @since 19.0.0
|
|
276
|
+
*/
|
|
277
|
+
attachNetworkLogs(options: {
|
|
278
|
+
logs: GleapNetworkLogEntry[];
|
|
279
|
+
}): Promise<{
|
|
280
|
+
networkLogsAttached: boolean;
|
|
281
|
+
}>;
|
|
282
|
+
/**
|
|
283
|
+
* Hands the console output of the app's WebView (console.log/info/warn/error/debug, uncaught errors and
|
|
284
|
+
* unhandled promise rejections) to the native SDK, so it shows up in the console logs of tickets. The plugin
|
|
285
|
+
* calls this for you on iOS and Android; each call replaces the previously attached WebView console logs.
|
|
286
|
+
* No-op on web, where the JavaScript SDK records the console itself.
|
|
287
|
+
*
|
|
288
|
+
* @since 19.0.0
|
|
289
|
+
*/
|
|
290
|
+
attachConsoleLogs(options: {
|
|
291
|
+
logs: GleapConsoleLogEntry[];
|
|
292
|
+
}): Promise<{
|
|
293
|
+
consoleLogsAttached: boolean;
|
|
294
|
+
}>;
|
|
295
|
+
/**
|
|
296
|
+
* Set env data props to ignore. The given env data keys (exact and case-sensitive, e.g. "deviceName" or "currentUrl")
|
|
297
|
+
* are removed before a ticket or conversation is sent. Each call replaces the previous list, an empty list resets it.
|
|
298
|
+
* Can be called before or after initialize.
|
|
299
|
+
*
|
|
300
|
+
* @since 18.1.0
|
|
301
|
+
*/
|
|
302
|
+
setEnvDataPropsToIgnore(options: {
|
|
303
|
+
propsToIgnore: string[];
|
|
304
|
+
}): Promise<{
|
|
305
|
+
envDataPropsToIgnoreSet: boolean;
|
|
306
|
+
}>;
|
|
307
|
+
/**
|
|
224
308
|
* Registers a Frontend tool defined on your AI agent in the Gleap dashboard.
|
|
225
309
|
* Prefer the `registerAgentTool(name, handler)` helper exported by this
|
|
226
310
|
* package — it wires the agentToolExecution event and result round-trip for
|
|
@@ -252,6 +336,13 @@ export interface GleapPlugin {
|
|
|
252
336
|
params: any;
|
|
253
337
|
}) => void): Promise<PluginListenerHandle>;
|
|
254
338
|
/**
|
|
339
|
+
* Called on iOS and Android when the project config is loaded, with the network log settings the plugin's
|
|
340
|
+
* WebView log capture needs (network logs are only recorded when they are enabled for your project).
|
|
341
|
+
*
|
|
342
|
+
* @since 19.0.0
|
|
343
|
+
*/
|
|
344
|
+
addListener(eventName: 'logConfigLoaded', listenerFunc: (config: GleapLogConfig) => void): Promise<PluginListenerHandle>;
|
|
345
|
+
/**
|
|
255
346
|
* Sets the value of a ticket attribute
|
|
256
347
|
*
|
|
257
348
|
* @since 13.5.0
|
|
@@ -395,6 +486,38 @@ export interface GleapPlugin {
|
|
|
395
486
|
openedWidget: boolean;
|
|
396
487
|
}>;
|
|
397
488
|
/**
|
|
489
|
+
* Open checklists
|
|
490
|
+
*
|
|
491
|
+
* @since 19.0.0
|
|
492
|
+
*/
|
|
493
|
+
openChecklists(options: {
|
|
494
|
+
showBackButton?: boolean;
|
|
495
|
+
}): Promise<{
|
|
496
|
+
opened: boolean;
|
|
497
|
+
}>;
|
|
498
|
+
/**
|
|
499
|
+
* Open checklist
|
|
500
|
+
*
|
|
501
|
+
* @since 19.0.0
|
|
502
|
+
*/
|
|
503
|
+
openChecklist(options: {
|
|
504
|
+
checklistId: string;
|
|
505
|
+
showBackButton?: boolean;
|
|
506
|
+
}): Promise<{
|
|
507
|
+
opened: boolean;
|
|
508
|
+
}>;
|
|
509
|
+
/**
|
|
510
|
+
* Start checklist
|
|
511
|
+
*
|
|
512
|
+
* @since 19.0.0
|
|
513
|
+
*/
|
|
514
|
+
startChecklist(options: {
|
|
515
|
+
outboundId: string;
|
|
516
|
+
showBackButton?: boolean;
|
|
517
|
+
}): Promise<{
|
|
518
|
+
opened: boolean;
|
|
519
|
+
}>;
|
|
520
|
+
/**
|
|
398
521
|
* Open news
|
|
399
522
|
*
|
|
400
523
|
* @since 8.4.0
|
|
@@ -538,6 +661,16 @@ export interface GleapPlugin {
|
|
|
538
661
|
conversationsOpened: boolean;
|
|
539
662
|
}>;
|
|
540
663
|
/**
|
|
664
|
+
* Opens the conversations tab (same as openConversation).
|
|
665
|
+
*
|
|
666
|
+
* @since 19.0.0
|
|
667
|
+
*/
|
|
668
|
+
openConversations(options: {
|
|
669
|
+
showBackButton?: boolean;
|
|
670
|
+
}): Promise<{
|
|
671
|
+
conversationsOpened: boolean;
|
|
672
|
+
}>;
|
|
673
|
+
/**
|
|
541
674
|
* Start bot
|
|
542
675
|
*
|
|
543
676
|
* @since 10.0.3
|
|
@@ -569,6 +702,37 @@ export interface GleapPlugin {
|
|
|
569
702
|
inAppNotificationsDisabled: boolean;
|
|
570
703
|
}>;
|
|
571
704
|
/**
|
|
705
|
+
* Disable env data. While disabled (true), no env data (device, OS, screen size, locale, URL, ...) is collected
|
|
706
|
+
* and tickets are sent without it. Pass false to collect env data again. Can be called before or after initialize.
|
|
707
|
+
*
|
|
708
|
+
* @since 18.1.0
|
|
709
|
+
*/
|
|
710
|
+
setDisableEnvData(options: {
|
|
711
|
+
disableEnvData: boolean;
|
|
712
|
+
}): Promise<{
|
|
713
|
+
envDataDisabled: boolean;
|
|
714
|
+
}>;
|
|
715
|
+
/**
|
|
716
|
+
* Set the color scheme of the widget. Overrides the color scheme configured in the Gleap dashboard.
|
|
717
|
+
* Only takes effect when "Adapt to dark / light mode" is enabled in the dashboard; otherwise the widget
|
|
718
|
+
* always keeps its normal colors. Before the first call the dashboard setting applies.
|
|
719
|
+
* "auto" follows the device appearance (dark/light mode) on iOS and Android, and the page theme on web.
|
|
720
|
+
* Apps with their own in-app theme toggle should pass "light" / "dark" explicitly and call it again whenever
|
|
721
|
+
* the theme changes.
|
|
722
|
+
* In dark mode the widget uses the dark mode colors, logo, header image and composer glow set in the Gleap dashboard;
|
|
723
|
+
* without dark colors it keeps its normal colors. lightBackgroundColor / darkBackgroundColor override the background.
|
|
724
|
+
* Can be called before or after initialize and applies live.
|
|
725
|
+
*
|
|
726
|
+
* @since 19.0.0
|
|
727
|
+
*/
|
|
728
|
+
setColorScheme(options: {
|
|
729
|
+
colorScheme: 'auto' | 'light' | 'dark';
|
|
730
|
+
lightBackgroundColor?: string;
|
|
731
|
+
darkBackgroundColor?: string;
|
|
732
|
+
}): Promise<{
|
|
733
|
+
colorScheme: string;
|
|
734
|
+
}>;
|
|
735
|
+
/**
|
|
572
736
|
* Set Language
|
|
573
737
|
*
|
|
574
738
|
* @since 7.0.0
|
|
@@ -579,7 +743,8 @@ export interface GleapPlugin {
|
|
|
579
743
|
setLanguage: string;
|
|
580
744
|
}>;
|
|
581
745
|
/**
|
|
582
|
-
* Disable console log overwrite
|
|
746
|
+
* Disable console log overwrite: stops recording the console output of the app's WebView
|
|
747
|
+
* (console methods are restored) and drops the WebView console logs recorded so far.
|
|
583
748
|
*
|
|
584
749
|
* @since 7.0.0
|
|
585
750
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport type CallbackID = string;\n\nexport interface GleapEventMessage {\n name: string,\n data?: any,\n}\n\nexport type GleapEventCallback = (message: GleapEventMessage | null, err?: any) => void;\n\nexport interface GleapPlugin {\n /**\n * Initialize Gleap with an API key\n *\n * @since 7.0.0\n */\n initialize(options: {\n API_KEY: string;\n }): Promise<{\n initialized: boolean;\n }>;\n\n /**\n * Set the data region of your Gleap project (\"eu\" is the default).\n * Sets the API, websocket and realtime hosts at once. Must be called before initialize.\n * A manual setter (setApiUrl, setWSApiUrl, setRealtimeHost) called afterwards overrides that single host.\n *\n * @since 18.0.0\n */\n setRegion(options: {\n region: 'eu' | 'us';\n }): Promise<{\n region: string;\n }>;\n\n /**\n * Set a custom API url. Must be called before initialize.\n *\n * @since 18.0.0\n */\n setApiUrl(options: {\n url: string;\n }): Promise<{\n url: string;\n }>;\n\n /**\n * Set a custom websocket API url. Must be called before initialize.\n *\n * @since 18.0.0\n */\n setWSApiUrl(options: {\n url: string;\n }): Promise<{\n url: string;\n }>;\n\n /**\n * Set a custom realtime host (hostname only, without protocol or path). Must be called before initialize.\n *\n * @since 18.0.0\n */\n setRealtimeHost(options: {\n host: string;\n }): Promise<{\n host: string;\n }>;\n\n /**\n * Set a custom widget frame url. Must be called before initialize.\n *\n * @since 18.0.0\n */\n setFrameUrl(options: {\n url: string;\n }): Promise<{\n url: string;\n }>;\n\n /**\n * Set a custom banner url. Must be called before initialize.\n *\n * @since 18.0.0\n */\n setBannerUrl(options: {\n url: string;\n }): Promise<{\n url: string;\n }>;\n\n /**\n * Set a custom modal url. Must be called before initialize.\n *\n * @since 18.0.0\n */\n setModalUrl(options: {\n url: string;\n }): Promise<{\n url: string;\n }>;\n\n /**\n * Set user identity\n *\n * @since 7.0.0\n */\n identify(options: {\n userId: string;\n userHash?: string;\n name?: string;\n email?: string;\n phone?: string;\n companyId?: string;\n companyName?: string;\n avatar?: string;\n sla?: number;\n plan?: string;\n value?: number;\n customData?: Object;\n }): Promise<{\n identify: boolean;\n }>;\n\n /**\n * Update user properties\n *\n * @since 13.2.1\n */\n updateContact(options: {\n name?: string;\n email?: string;\n phone?: string;\n companyId?: string;\n companyName?: string;\n avatar?: string;\n sla?: number;\n plan?: string;\n value?: number;\n customData?: Object;\n }): Promise<{\n identify: boolean;\n }>;\n\n /**\n * Clear user identity\n *\n * @since 7.0.0\n */\n clearIdentity(): Promise<{\n clearIdentity: boolean;\n }>;\n\n /**\n * Get the current user identity\n *\n * @since 8.1.0\n */\n getIdentity(): Promise<{\n identity: {\n userId: string;\n name?: string;\n email?: string;\n phone?: string;\n value?: number;\n };\n }>;\n\n /**\n * User identified status.\n *\n * @since 8.1.0\n */\n isUserIdentified(): Promise<{\n isUserIdentified: boolean;\n }>;\n\n /**\n * Submit a custom log message with the given level\n *\n * @since 7.0.0\n */\n log(options: {\n message: string;\n logLevel?: \"ERROR\" | \"WARNING\" | \"INFO\";\n }): Promise<{\n logged: boolean;\n }>;\n\n /**\n * Manually show a survey.\n *\n * @since 8.5.1\n */\n showSurvey(options: {\n surveyId: string;\n format?: \"survey\" | \"survey_full\";\n }): Promise<{\n opened: boolean;\n }>;\n\n /**\n * Add custom data\n *\n * @since 7.0.0\n */\n attachCustomData(options: {\n data: any;\n }): Promise<{\n attachedCustomData: boolean;\n }>;\n\n /**\n * Set tags\n *\n * @since 8.6.0\n */\n setTags(options: {\n tags: string[];\n }): Promise<{\n tagsSet: boolean;\n }>;\n\n /**\n * Set network logs blacklist\n *\n * @since 13.2.1\n */\n setNetworkLogsBlacklist(options: {\n blacklist: string[];\n }): Promise<{\n blacklistSet: boolean;\n }>;\n\n /**\n * Set network logs props to ignore\n *\n * @since 13.2.1\n */\n setNetworkLogPropsToIgnore(options: {\n propsToIgnore: string[];\n }): Promise<{\n propsToIgnoreSet: boolean;\n }>;\n\n /**\n * Registers a Frontend tool defined on your AI agent in the Gleap dashboard.\n * Prefer the `registerAgentTool(name, handler)` helper exported by this\n * package — it wires the agentToolExecution event and result round-trip for\n * you.\n *\n * @since 15.0.0\n */\n registerAgentTool(options: {\n name: string;\n }): Promise<void>;\n\n /**\n * Resolves a pending agent tool execution with the handler's result.\n * Used by the `registerAgentTool(name, handler)` helper.\n *\n * @since 15.0.0\n */\n sendAgentToolResult(options: {\n executionId: string;\n result: string;\n }): Promise<void>;\n\n /**\n * Called when a registered agent tool should execute.\n *\n * @since 15.0.0\n */\n addListener(\n eventName: 'agentToolExecution',\n listenerFunc: (data: {\n executionId: string;\n name: string;\n params: any;\n }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Sets the value of a ticket attribute\n *\n * @since 13.5.0\n */\n setTicketAttribute(options: {\n key: string;\n value: string;\n }): Promise<{\n setTicketAttribute: boolean;\n }>;\n\n /**\n * Unset a ticket attribute\n *\n * @since 14.1.0\n */\n unsetTicketAttribute(options: {\n key: string;\n }): Promise<{\n unsetTicketAttribute: boolean;\n }>;\n\n /**\n * Clear all ticket attributes\n *\n * @since 14.1.0\n */\n clearTicketAttributes(): Promise<{\n clearTicketAttributes: boolean;\n }>;\n\n /**\n * Set custom data\n *\n * @since 7.0.0\n */\n setCustomData(options: {\n key: string;\n value: string;\n }): Promise<{\n setCustomData: boolean;\n }>;\n\n /**\n * Remove custom data by key\n *\n * @since 7.0.0\n */\n removeCustomData(options: {\n key: string;\n }): Promise<{\n removedCustomData: boolean;\n }>;\n\n /**\n * Clear custom data\n *\n * @since 7.0.0\n */\n clearCustomData(): Promise<{\n clearedCustomData: boolean;\n }>;\n\n /**\n * Log event to Gleap\n *\n * @since 8.0.0\n */\n trackEvent(options: {\n name: string;\n data?: any;\n }): Promise<{\n loggedEvent: boolean;\n }>;\n\n /**\n * Track a page view\n *\n * @since 8.4.1\n */\n trackPage(options: {\n pageName: string;\n }): Promise<{\n trackedPage: boolean;\n }>;\n\n /**\n * \n *\n * @since 7.0.0\n */\n setEventCallback(\n callback: GleapEventCallback,\n ): Promise<CallbackID>;\n\n /**\n * Log event to Gleap\n *\n * @since 7.0.0\n */\n sendSilentCrashReport(options: {\n description: string,\n severity?: \"LOW\" | \"MEDIUM\" | \"HIGH\";\n dataExclusion?: {\n customData: Boolean;\n metaData: Boolean;\n attachments: Boolean;\n consoleLog: Boolean;\n networkLogs: Boolean;\n customEventLog: Boolean;\n screenshot: Boolean;\n replays: Boolean;\n };\n }): Promise<{\n sentSilentBugReport: boolean;\n }>;\n\n /**\n * Prefills the widget's form data\n *\n * @since 7.0.0\n */\n preFillForm(options: {\n data: any;\n }): Promise<{\n preFilledForm: boolean;\n }>;\n\n /**\n * Add attachment as bas64 string\n *\n * @since 7.0.0\n */\n addAttachment(options: {\n base64data: string;\n name: string;\n }): Promise<{\n attachmentAdded: boolean;\n }>;\n\n /**\n * All attachments removed\n *\n * @since 7.0.0\n */\n removeAllAttachments(): Promise<{\n allAttachmentsRemoved: boolean;\n }>;\n\n /**\n * Open widget\n *\n * @since 7.0.0\n */\n open(): Promise<{\n openedWidget: boolean;\n }>;\n\n /**\n * Open news\n *\n * @since 8.4.0\n */\n openNews(options: {\n showBackButton?: boolean;\n }): Promise<{\n openedNews: boolean;\n }>;\n\n /**\n * Open news article\n *\n * @since 8.4.0\n */\n openNewsArticle(options: {\n articleId: string;\n showBackButton?: boolean;\n }): Promise<{\n opened: boolean;\n }>;\n\n /**\n * Open help center\n *\n * @since 8.4.0\n */\n openHelpCenter(options: {\n showBackButton?: boolean;\n }): Promise<{\n opened: boolean;\n }>;\n\n /**\n * Open help center article\n *\n * @since 8.4.0\n */\n openHelpCenterArticle(options: {\n articleId: string;\n showBackButton?: boolean;\n }): Promise<{\n opened: boolean;\n }>;\n\n /**\n * Ask the AI a question\n *\n * @since 15.0.0\n */\n askAI(options: {\n question: string;\n showBackButton?: boolean;\n }): Promise<{\n opened: boolean;\n }>;\n\n /**\n * Open help center collection\n *\n * @since 8.4.0\n */\n openHelpCenterCollection(options: {\n collectionId: string;\n showBackButton?: boolean;\n }): Promise<{\n opened: boolean;\n }>;\n\n /**\n * Search help center\n *\n * @since 8.4.0\n */\n searchHelpCenter(options: {\n term: string;\n showBackButton?: boolean;\n }): Promise<{\n opened: boolean;\n }>;\n\n /**\n * Open feature requests\n *\n * @since 8.4.0\n */\n openFeatureRequests(options: {\n showBackButton?: boolean;\n }): Promise<{\n openedFeatureRequests: boolean;\n }>;\n\n /**\n * Close widget\n *\n * @since 7.0.0\n */\n close(): Promise<{\n closedWidget: boolean;\n }>;\n\n /**\n * Check widget status code\n *\n * @since 7.0.0\n */\n isOpened(): Promise<{\n isOpened: boolean;\n }>;\n\n /**\n * Start feedback flow\n *\n * @since 7.0.0\n */\n startFeedbackFlow(options: {\n feedbackFlow?: string;\n showBackButton?: boolean;\n }): Promise<{\n startedFeedbackFlow: boolean;\n }>;\n\n /**\n * Start a classic form\n *\n * @since 13.1.0\n */\n startClassicForm(options: {\n formId?: string;\n showBackButton?: boolean;\n }): Promise<{\n classicFormStarted: boolean;\n }>;\n\n /**\n * Start a new conversation\n *\n * @since 13.1.0\n */\n startConversation(options: {\n showBackButton?: boolean;\n }): Promise<{\n conversationStarted: boolean;\n }>;\n\n /**\n * Opens the conversations tab.\n *\n * @since 13.9.0\n */\n openConversation(options: {\n showBackButton?: boolean;\n }): Promise<{\n conversationsOpened: boolean;\n }>;\n\n /**\n * Start bot\n *\n * @since 10.0.3\n */\n startBot(options: {\n botId?: string;\n showBackButton?: boolean;\n }): Promise<{\n startedBot: boolean;\n }>;\n\n /**\n * Show or hide the feedback button.\n *\n * @since 8.0.0\n */\n showFeedbackButton(options: {\n show?: boolean;\n }): Promise<{\n feedbackButtonShown: boolean;\n }>;\n\n /**\n* Disable in app notifications.\n*\n* @since 8.6.1\n*/\n setDisableInAppNotifications(options: {\n disableInAppNotifications?: boolean;\n }): Promise<{\n inAppNotificationsDisabled: boolean;\n }>;\n\n /**\n * Set Language\n *\n * @since 7.0.0\n */\n setLanguage(options: {\n languageCode: string;\n }): Promise<{\n setLanguage: string;\n }>;\n\n /**\n * Disable console log overwrite\n *\n * @since 7.0.0\n */\n disableConsoleLogOverwrite(): Promise<{\n consoleLogDisabled: boolean;\n }>;\n\n /**\n * Enable debug console log\n *\n * @since 7.0.0\n */\n enableDebugConsoleLog(): Promise<{\n debugConsoleLogEnabled: boolean;\n }>;\n\n /**\n * Set the notification container offset\n *\n * @since 15.2.0\n */\n setNotificationContainerOffset(options: {\n x: number;\n y: number;\n }): Promise<{\n notificationContainerOffsetSet: boolean;\n }>;\n\n}"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport type CallbackID = string;\n\nexport interface GleapEventMessage {\n name: string,\n data?: any,\n}\n\nexport type GleapEventCallback = (message: GleapEventMessage | null, err?: any) => void;\n\n/**\n * A console log entry as the plugin hands it to the native SDK.\n */\nexport interface GleapConsoleLogEntry {\n /** ISO-8601 UTC timestamp with milliseconds. */\n date: string;\n priority: 'ERROR' | 'WARNING' | 'INFO';\n log: string;\n}\n\n/**\n * A network log entry (fetch / XMLHttpRequest) as the plugin hands it to the native SDK.\n */\nexport interface GleapNetworkLogEntry {\n /** ISO-8601 UTC timestamp of the request start. */\n date: string;\n /** HTTP method, uppercase. */\n type: string;\n url: string;\n /** Milliseconds from the request start to the response headers (or the failure). */\n duration?: number;\n /** true when an HTTP response arrived (any status), false on a transport error, abort or timeout. */\n success?: boolean;\n request?: {\n headers?: { [name: string]: string };\n payload?: string;\n };\n response?: {\n status?: number;\n statusText?: string;\n headers?: { [name: string]: string };\n responseText?: string;\n /** Set instead of status and body when the request failed. */\n errorText?: string;\n };\n}\n\n/**\n * The network log settings of your Gleap project, sent by the native SDK once its config is loaded.\n */\nexport interface GleapLogConfig {\n enableNetworkLogs: boolean;\n networkLogPropsToIgnore: string[];\n networkLogBlacklist: string[];\n}\n\nexport interface GleapPlugin {\n /**\n * Initialize Gleap with an API key\n *\n * @since 7.0.0\n */\n initialize(options: {\n API_KEY: string;\n }): Promise<{\n initialized: boolean;\n }>;\n\n /**\n * Set the data region of your Gleap project (\"eu\" is the default).\n * Sets the API, websocket and realtime hosts at once. Must be called before initialize.\n * A manual setter (setApiUrl, setWSApiUrl, setRealtimeHost) called afterwards overrides that single host.\n *\n * @since 18.0.0\n */\n setRegion(options: {\n region: 'eu' | 'us';\n }): Promise<{\n region: string;\n }>;\n\n /**\n * Set a custom API url. Must be called before initialize.\n *\n * @since 18.0.0\n */\n setApiUrl(options: {\n url: string;\n }): Promise<{\n url: string;\n }>;\n\n /**\n * Set a custom websocket API url. Must be called before initialize.\n *\n * @since 18.0.0\n */\n setWSApiUrl(options: {\n url: string;\n }): Promise<{\n url: string;\n }>;\n\n /**\n * Set a custom realtime host (hostname only, without protocol or path). Must be called before initialize.\n *\n * @since 18.0.0\n */\n setRealtimeHost(options: {\n host: string;\n }): Promise<{\n host: string;\n }>;\n\n /**\n * Set a custom widget frame url. Must be called before initialize.\n *\n * @since 18.0.0\n */\n setFrameUrl(options: {\n url: string;\n }): Promise<{\n url: string;\n }>;\n\n /**\n * Set a custom banner url. Must be called before initialize.\n *\n * @since 18.0.0\n */\n setBannerUrl(options: {\n url: string;\n }): Promise<{\n url: string;\n }>;\n\n /**\n * Set a custom modal url. Must be called before initialize.\n *\n * @since 18.0.0\n */\n setModalUrl(options: {\n url: string;\n }): Promise<{\n url: string;\n }>;\n\n /**\n * Set user identity\n *\n * @since 7.0.0\n */\n identify(options: {\n userId: string;\n userHash?: string;\n name?: string;\n email?: string;\n phone?: string;\n companyId?: string;\n companyName?: string;\n avatar?: string;\n sla?: number;\n plan?: string;\n value?: number;\n customData?: Record<string, any>;\n }): Promise<{\n identify: boolean;\n }>;\n\n /**\n * Update user properties\n *\n * @since 13.2.1\n */\n updateContact(options: {\n name?: string;\n email?: string;\n phone?: string;\n companyId?: string;\n companyName?: string;\n avatar?: string;\n sla?: number;\n plan?: string;\n value?: number;\n customData?: Record<string, any>;\n }): Promise<{\n identify: boolean;\n }>;\n\n /**\n * Clear user identity\n *\n * @since 7.0.0\n */\n clearIdentity(): Promise<{\n clearIdentity: boolean;\n }>;\n\n /**\n * Get the current user identity\n *\n * @since 8.1.0\n */\n getIdentity(): Promise<{\n identity: {\n userId: string;\n name?: string;\n email?: string;\n phone?: string;\n value?: number;\n };\n }>;\n\n /**\n * User identified status.\n *\n * @since 8.1.0\n */\n isUserIdentified(): Promise<{\n isUserIdentified: boolean;\n }>;\n\n /**\n * Submit a custom log message with the given level\n *\n * @since 7.0.0\n */\n log(options: {\n message: string;\n logLevel?: \"ERROR\" | \"WARNING\" | \"INFO\";\n }): Promise<{\n logged: boolean;\n }>;\n\n /**\n * Manually show a survey.\n *\n * @since 8.5.1\n */\n showSurvey(options: {\n surveyId: string;\n format?: \"survey\" | \"survey_full\";\n }): Promise<{\n opened: boolean;\n }>;\n\n /**\n * Add custom data\n *\n * @since 7.0.0\n */\n attachCustomData(options: {\n data: any;\n }): Promise<{\n attachedCustomData: boolean;\n }>;\n\n /**\n * Set tags\n *\n * @since 8.6.0\n */\n setTags(options: {\n tags: string[];\n }): Promise<{\n tagsSet: boolean;\n }>;\n\n /**\n * Set network logs blacklist\n *\n * @since 13.2.1\n */\n setNetworkLogsBlacklist(options: {\n blacklist: string[];\n }): Promise<{\n blacklistSet: boolean;\n }>;\n\n /**\n * Set network logs props to ignore\n *\n * @since 13.2.1\n */\n setNetworkLogPropsToIgnore(options: {\n propsToIgnore: string[];\n }): Promise<{\n propsToIgnoreSet: boolean;\n }>;\n\n /**\n * Hands the network requests made inside the app's WebView (fetch and XMLHttpRequest) to the native SDK, so they\n * show up in the network logs of tickets. The plugin calls this for you on iOS and Android; each call replaces\n * the previously attached WebView network logs. No-op on web, where the JavaScript SDK records requests itself.\n *\n * @since 19.0.0\n */\n attachNetworkLogs(options: {\n logs: GleapNetworkLogEntry[];\n }): Promise<{\n networkLogsAttached: boolean;\n }>;\n\n /**\n * Hands the console output of the app's WebView (console.log/info/warn/error/debug, uncaught errors and\n * unhandled promise rejections) to the native SDK, so it shows up in the console logs of tickets. The plugin\n * calls this for you on iOS and Android; each call replaces the previously attached WebView console logs.\n * No-op on web, where the JavaScript SDK records the console itself.\n *\n * @since 19.0.0\n */\n attachConsoleLogs(options: {\n logs: GleapConsoleLogEntry[];\n }): Promise<{\n consoleLogsAttached: boolean;\n }>;\n\n /**\n * Set env data props to ignore. The given env data keys (exact and case-sensitive, e.g. \"deviceName\" or \"currentUrl\")\n * are removed before a ticket or conversation is sent. Each call replaces the previous list, an empty list resets it.\n * Can be called before or after initialize.\n *\n * @since 18.1.0\n */\n setEnvDataPropsToIgnore(options: {\n propsToIgnore: string[];\n }): Promise<{\n envDataPropsToIgnoreSet: boolean;\n }>;\n\n /**\n * Registers a Frontend tool defined on your AI agent in the Gleap dashboard.\n * Prefer the `registerAgentTool(name, handler)` helper exported by this\n * package — it wires the agentToolExecution event and result round-trip for\n * you.\n *\n * @since 15.0.0\n */\n registerAgentTool(options: {\n name: string;\n }): Promise<void>;\n\n /**\n * Resolves a pending agent tool execution with the handler's result.\n * Used by the `registerAgentTool(name, handler)` helper.\n *\n * @since 15.0.0\n */\n sendAgentToolResult(options: {\n executionId: string;\n result: string;\n }): Promise<void>;\n\n /**\n * Called when a registered agent tool should execute.\n *\n * @since 15.0.0\n */\n addListener(\n eventName: 'agentToolExecution',\n listenerFunc: (data: {\n executionId: string;\n name: string;\n params: any;\n }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Called on iOS and Android when the project config is loaded, with the network log settings the plugin's\n * WebView log capture needs (network logs are only recorded when they are enabled for your project).\n *\n * @since 19.0.0\n */\n addListener(\n eventName: 'logConfigLoaded',\n listenerFunc: (config: GleapLogConfig) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Sets the value of a ticket attribute\n *\n * @since 13.5.0\n */\n setTicketAttribute(options: {\n key: string;\n value: string;\n }): Promise<{\n setTicketAttribute: boolean;\n }>;\n\n /**\n * Unset a ticket attribute\n *\n * @since 14.1.0\n */\n unsetTicketAttribute(options: {\n key: string;\n }): Promise<{\n unsetTicketAttribute: boolean;\n }>;\n\n /**\n * Clear all ticket attributes\n *\n * @since 14.1.0\n */\n clearTicketAttributes(): Promise<{\n clearTicketAttributes: boolean;\n }>;\n\n /**\n * Set custom data\n *\n * @since 7.0.0\n */\n setCustomData(options: {\n key: string;\n value: string;\n }): Promise<{\n setCustomData: boolean;\n }>;\n\n /**\n * Remove custom data by key\n *\n * @since 7.0.0\n */\n removeCustomData(options: {\n key: string;\n }): Promise<{\n removedCustomData: boolean;\n }>;\n\n /**\n * Clear custom data\n *\n * @since 7.0.0\n */\n clearCustomData(): Promise<{\n clearedCustomData: boolean;\n }>;\n\n /**\n * Log event to Gleap\n *\n * @since 8.0.0\n */\n trackEvent(options: {\n name: string;\n data?: any;\n }): Promise<{\n loggedEvent: boolean;\n }>;\n\n /**\n * Track a page view\n *\n * @since 8.4.1\n */\n trackPage(options: {\n pageName: string;\n }): Promise<{\n trackedPage: boolean;\n }>;\n\n /**\n * \n *\n * @since 7.0.0\n */\n setEventCallback(\n callback: GleapEventCallback,\n ): Promise<CallbackID>;\n\n /**\n * Log event to Gleap\n *\n * @since 7.0.0\n */\n sendSilentCrashReport(options: {\n description: string,\n severity?: \"LOW\" | \"MEDIUM\" | \"HIGH\";\n dataExclusion?: {\n customData: Boolean;\n metaData: Boolean;\n attachments: Boolean;\n consoleLog: Boolean;\n networkLogs: Boolean;\n customEventLog: Boolean;\n screenshot: Boolean;\n replays: Boolean;\n };\n }): Promise<{\n sentSilentBugReport: boolean;\n }>;\n\n /**\n * Prefills the widget's form data\n *\n * @since 7.0.0\n */\n preFillForm(options: {\n data: any;\n }): Promise<{\n preFilledForm: boolean;\n }>;\n\n /**\n * Add attachment as bas64 string\n *\n * @since 7.0.0\n */\n addAttachment(options: {\n base64data: string;\n name: string;\n }): Promise<{\n attachmentAdded: boolean;\n }>;\n\n /**\n * All attachments removed\n *\n * @since 7.0.0\n */\n removeAllAttachments(): Promise<{\n allAttachmentsRemoved: boolean;\n }>;\n\n /**\n * Open widget\n *\n * @since 7.0.0\n */\n open(): Promise<{\n openedWidget: boolean;\n }>;\n\n /**\n * Open checklists\n *\n * @since 19.0.0\n */\n openChecklists(options: {\n showBackButton?: boolean;\n }): Promise<{\n opened: boolean;\n }>;\n\n /**\n * Open checklist\n *\n * @since 19.0.0\n */\n openChecklist(options: {\n checklistId: string;\n showBackButton?: boolean;\n }): Promise<{\n opened: boolean;\n }>;\n\n /**\n * Start checklist\n *\n * @since 19.0.0\n */\n startChecklist(options: {\n outboundId: string;\n showBackButton?: boolean;\n }): Promise<{\n opened: boolean;\n }>;\n\n /**\n * Open news\n *\n * @since 8.4.0\n */\n openNews(options: {\n showBackButton?: boolean;\n }): Promise<{\n openedNews: boolean;\n }>;\n\n /**\n * Open news article\n *\n * @since 8.4.0\n */\n openNewsArticle(options: {\n articleId: string;\n showBackButton?: boolean;\n }): Promise<{\n opened: boolean;\n }>;\n\n /**\n * Open help center\n *\n * @since 8.4.0\n */\n openHelpCenter(options: {\n showBackButton?: boolean;\n }): Promise<{\n opened: boolean;\n }>;\n\n /**\n * Open help center article\n *\n * @since 8.4.0\n */\n openHelpCenterArticle(options: {\n articleId: string;\n showBackButton?: boolean;\n }): Promise<{\n opened: boolean;\n }>;\n\n /**\n * Ask the AI a question\n *\n * @since 15.0.0\n */\n askAI(options: {\n question: string;\n showBackButton?: boolean;\n }): Promise<{\n opened: boolean;\n }>;\n\n /**\n * Open help center collection\n *\n * @since 8.4.0\n */\n openHelpCenterCollection(options: {\n collectionId: string;\n showBackButton?: boolean;\n }): Promise<{\n opened: boolean;\n }>;\n\n /**\n * Search help center\n *\n * @since 8.4.0\n */\n searchHelpCenter(options: {\n term: string;\n showBackButton?: boolean;\n }): Promise<{\n opened: boolean;\n }>;\n\n /**\n * Open feature requests\n *\n * @since 8.4.0\n */\n openFeatureRequests(options: {\n showBackButton?: boolean;\n }): Promise<{\n openedFeatureRequests: boolean;\n }>;\n\n /**\n * Close widget\n *\n * @since 7.0.0\n */\n close(): Promise<{\n closedWidget: boolean;\n }>;\n\n /**\n * Check widget status code\n *\n * @since 7.0.0\n */\n isOpened(): Promise<{\n isOpened: boolean;\n }>;\n\n /**\n * Start feedback flow\n *\n * @since 7.0.0\n */\n startFeedbackFlow(options: {\n feedbackFlow?: string;\n showBackButton?: boolean;\n }): Promise<{\n startedFeedbackFlow: boolean;\n }>;\n\n /**\n * Start a classic form\n *\n * @since 13.1.0\n */\n startClassicForm(options: {\n formId?: string;\n showBackButton?: boolean;\n }): Promise<{\n classicFormStarted: boolean;\n }>;\n\n /**\n * Start a new conversation\n *\n * @since 13.1.0\n */\n startConversation(options: {\n showBackButton?: boolean;\n }): Promise<{\n conversationStarted: boolean;\n }>;\n\n /**\n * Opens the conversations tab.\n *\n * @since 13.9.0\n */\n openConversation(options: {\n showBackButton?: boolean;\n }): Promise<{\n conversationsOpened: boolean;\n }>;\n\n /**\n * Opens the conversations tab (same as openConversation).\n *\n * @since 19.0.0\n */\n openConversations(options: {\n showBackButton?: boolean;\n }): Promise<{\n conversationsOpened: boolean;\n }>;\n\n /**\n * Start bot\n *\n * @since 10.0.3\n */\n startBot(options: {\n botId?: string;\n showBackButton?: boolean;\n }): Promise<{\n startedBot: boolean;\n }>;\n\n /**\n * Show or hide the feedback button.\n *\n * @since 8.0.0\n */\n showFeedbackButton(options: {\n show?: boolean;\n }): Promise<{\n feedbackButtonShown: boolean;\n }>;\n\n /**\n* Disable in app notifications.\n*\n* @since 8.6.1\n*/\n setDisableInAppNotifications(options: {\n disableInAppNotifications?: boolean;\n }): Promise<{\n inAppNotificationsDisabled: boolean;\n }>;\n\n /**\n * Disable env data. While disabled (true), no env data (device, OS, screen size, locale, URL, ...) is collected\n * and tickets are sent without it. Pass false to collect env data again. Can be called before or after initialize.\n *\n * @since 18.1.0\n */\n setDisableEnvData(options: {\n disableEnvData: boolean;\n }): Promise<{\n envDataDisabled: boolean;\n }>;\n\n /**\n * Set the color scheme of the widget. Overrides the color scheme configured in the Gleap dashboard.\n * Only takes effect when \"Adapt to dark / light mode\" is enabled in the dashboard; otherwise the widget\n * always keeps its normal colors. Before the first call the dashboard setting applies.\n * \"auto\" follows the device appearance (dark/light mode) on iOS and Android, and the page theme on web.\n * Apps with their own in-app theme toggle should pass \"light\" / \"dark\" explicitly and call it again whenever\n * the theme changes.\n * In dark mode the widget uses the dark mode colors, logo, header image and composer glow set in the Gleap dashboard;\n * without dark colors it keeps its normal colors. lightBackgroundColor / darkBackgroundColor override the background.\n * Can be called before or after initialize and applies live.\n *\n * @since 19.0.0\n */\n setColorScheme(options: {\n colorScheme: 'auto' | 'light' | 'dark';\n lightBackgroundColor?: string;\n darkBackgroundColor?: string;\n }): Promise<{\n colorScheme: string;\n }>;\n\n /**\n * Set Language\n *\n * @since 7.0.0\n */\n setLanguage(options: {\n languageCode: string;\n }): Promise<{\n setLanguage: string;\n }>;\n\n /**\n * Disable console log overwrite: stops recording the console output of the app's WebView\n * (console methods are restored) and drops the WebView console logs recorded so far.\n *\n * @since 7.0.0\n */\n disableConsoleLogOverwrite(): Promise<{\n consoleLogDisabled: boolean;\n }>;\n\n /**\n * Enable debug console log\n *\n * @since 7.0.0\n */\n enableDebugConsoleLog(): Promise<{\n debugConsoleLogEnabled: boolean;\n }>;\n\n /**\n * Set the notification container offset\n *\n * @since 15.2.0\n */\n setNotificationContainerOffset(options: {\n x: number;\n y: number;\n }): Promise<{\n notificationContainerOffsetSet: boolean;\n }>;\n\n}"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { registerPlugin } from '@capacitor/core';
|
|
2
|
-
|
|
2
|
+
import { installWebViewLogCapture, wrapPluginWithLogCapture, } from './logs/webViewLogs';
|
|
3
|
+
const GleapNative = registerPlugin('Gleap', {
|
|
3
4
|
web: () => import('./web').then(m => new m.GleapWeb()),
|
|
4
5
|
});
|
|
6
|
+
// On iOS and Android, record the WebView's console from the moment the plugin is imported (and its
|
|
7
|
+
// fetch/XHR traffic once the project config enables network logs), and hand both to the native SDK,
|
|
8
|
+
// which cannot see either on its own.
|
|
9
|
+
const webViewLogCapture = installWebViewLogCapture(GleapNative);
|
|
10
|
+
const Gleap = webViewLogCapture
|
|
11
|
+
? wrapPluginWithLogCapture(GleapNative, webViewLogCapture)
|
|
12
|
+
: GleapNative;
|
|
5
13
|
const registeredAgentTools = {};
|
|
6
14
|
let agentToolListenerAttached = false;
|
|
7
15
|
/**
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,GAAG,cAAc,CAAc,OAAO,EAAE;IACvD,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;CACvD,CAAC,CAAC;AAEH,mGAAmG;AACnG,oGAAoG;AACpG,sCAAsC;AACtC,MAAM,iBAAiB,GAAG,wBAAwB,CAAC,WAAW,CAAC,CAAC;AAEhE,MAAM,KAAK,GAAgB,iBAAiB;IAC1C,CAAC,CAAC,wBAAwB,CAAC,WAAW,EAAE,iBAAiB,CAAC;IAC1D,CAAC,CAAC,WAAW,CAAC;AAEhB,MAAM,oBAAoB,GAEtB,EAAE,CAAC;AACP,IAAI,yBAAyB,GAAG,KAAK,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,KAAK,EAC7B,IAAY,EACZ,OAA4C,EAC7B,EAAE;IACjB,IAAI,CAAC,IAAI,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;QAC1C,OAAO;KACR;IAED,oBAAoB,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IAErC,IAAI,CAAC,yBAAyB,EAAE;QAC9B,yBAAyB,GAAG,IAAI,CAAC;QAEjC,MAAM,KAAK,CAAC,WAAW,CAAC,oBAAoB,EAAE,KAAK,EAAC,IAAI,EAAC,EAAE;;YACzD,IAAI;gBACF,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAK,EAAU,CAAC;gBACpE,IAAI,CAAC,WAAW,IAAI,CAAC,QAAQ,EAAE;oBAC7B,OAAO;iBACR;gBAED,IAAI,MAAM,CAAC;gBACX,MAAM,WAAW,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;gBACnD,IAAI,CAAC,WAAW,EAAE;oBAChB,MAAM,GAAG,mCAAmC,QAAQ,2DAA2D,QAAQ,cAAc,CAAC;iBACvI;qBAAM;oBACL,IAAI;wBACF,MAAM,aAAa,GAAG,MAAM,WAAW,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,CAAC;wBACtD,MAAM;4BACJ,OAAO,aAAa,KAAK,QAAQ;gCAC/B,CAAC,CAAC,aAAa;gCACf,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,EAAE,CAAC,CAAC;wBAC1C,IAAI,CAAC,MAAM,EAAE;4BACX,MAAM,GAAG,kDAAkD,CAAC;yBAC7D;qBACF;oBAAC,OAAO,KAAU,EAAE;wBACnB,MAAM,GAAG,0BACP,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,mCAAI,eACpB,EAAE,CAAC;qBACJ;iBACF;gBAED,MAAM,KAAK,CAAC,mBAAmB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;aAC1D;YAAC,OAAO,GAAG,EAAE;gBACZ,UAAU;aACX;QACH,CAAC,CAAC,CAAC;KACJ;IAED,MAAM,KAAK,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1C,CAAC,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { GleapPlugin } from './definitions';\nimport {\n installWebViewLogCapture,\n wrapPluginWithLogCapture,\n} from './logs/webViewLogs';\n\nconst GleapNative = registerPlugin<GleapPlugin>('Gleap', {\n web: () => import('./web').then(m => new m.GleapWeb()),\n});\n\n// On iOS and Android, record the WebView's console from the moment the plugin is imported (and its\n// fetch/XHR traffic once the project config enables network logs), and hand both to the native SDK,\n// which cannot see either on its own.\nconst webViewLogCapture = installWebViewLogCapture(GleapNative);\n\nconst Gleap: GleapPlugin = webViewLogCapture\n ? wrapPluginWithLogCapture(GleapNative, webViewLogCapture)\n : GleapNative;\n\nconst registeredAgentTools: {\n [name: string]: (params: any) => any | Promise<any>;\n} = {};\nlet agentToolListenerAttached = false;\n\n/**\n * Registers the handler for a Frontend tool defined on your AI agent in the\n * Gleap dashboard. The agent calls the handler with the configured parameters\n * and waits for the returned result (string or object, which gets\n * stringified).\n */\nconst registerAgentTool = async (\n name: string,\n handler: (params: any) => any | Promise<any>,\n): Promise<void> => {\n if (!name || typeof handler !== 'function') {\n return;\n }\n\n registeredAgentTools[name] = handler;\n\n if (!agentToolListenerAttached) {\n agentToolListenerAttached = true;\n\n await Gleap.addListener('agentToolExecution', async data => {\n try {\n const { executionId, name: toolName, params } = data ?? ({} as any);\n if (!executionId || !toolName) {\n return;\n }\n\n let result;\n const toolHandler = registeredAgentTools[toolName];\n if (!toolHandler) {\n result = `No handler registered for tool '${toolName}' in the app. Register one via Gleap.registerAgentTool('${toolName}', handler).`;\n } else {\n try {\n const handlerResult = await toolHandler(params ?? {});\n result =\n typeof handlerResult === 'string'\n ? handlerResult\n : JSON.stringify(handlerResult ?? '');\n if (!result) {\n result = 'The action completed without returning a result.';\n }\n } catch (error: any) {\n result = `Tool execution failed: ${\n error?.message ?? 'unknown error'\n }`;\n }\n }\n\n await Gleap.sendAgentToolResult({ executionId, result });\n } catch (exp) {\n // Ignore.\n }\n });\n }\n\n await Gleap.registerAgentTool({ name });\n};\n\nexport * from './definitions';\nexport { Gleap, registerAgentTool };\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** Maximum captured size per body (request payload or response text). */
|
|
2
|
+
export declare const MAX_BODY_SIZE = 150000;
|
|
3
|
+
export declare const BINARY_BODY_OMITTED = "[binary body omitted]";
|
|
4
|
+
export declare const STREAMING_BODY_OMITTED = "[streaming body omitted]";
|
|
5
|
+
export declare const BODY_NOT_CAPTURED = "[body not captured]";
|
|
6
|
+
export declare const BODY_PENDING = "[body pending]";
|
|
7
|
+
/**
|
|
8
|
+
* text: capture; unknown (no content type): capture when it decodes as UTF-8;
|
|
9
|
+
* streaming / binary: never read, only a marker.
|
|
10
|
+
*/
|
|
11
|
+
export declare type BodyKind = 'text' | 'unknown' | 'streaming' | 'binary';
|
|
12
|
+
export declare function classifyContentType(contentType: unknown): BodyKind;
|
|
13
|
+
export declare function markerForKind(kind: BodyKind): string | null;
|
|
14
|
+
/** UTF-8 byte length without allocating an encoded copy. */
|
|
15
|
+
export declare function utf8ByteLength(text: string): number;
|
|
16
|
+
/** Cuts a string at max chars without splitting a surrogate pair. */
|
|
17
|
+
export declare function sliceHead(text: string, max: number): string;
|
|
18
|
+
export declare function truncationMarker(totalBytes: number | null): string;
|
|
19
|
+
/** Caps a text body at MAX_BODY_SIZE chars: keeps the head and appends the truncation marker. */
|
|
20
|
+
export declare function capBodyText(text: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Decodes bytes as UTF-8. With fatal (unknown content type) invalid UTF-8 yields null, so the caller
|
|
23
|
+
* can mark the body as binary. A cut-off (incomplete) body keeps a split trailing character pending
|
|
24
|
+
* instead of failing on it.
|
|
25
|
+
*/
|
|
26
|
+
export declare function decodeUtf8(bytes: Uint8Array, fatal: boolean, complete: boolean): string | null;
|
|
27
|
+
/**
|
|
28
|
+
* Turns (at most MAX_BODY_SIZE) bytes into the logged text: decoded, capped, marked as truncated
|
|
29
|
+
* when the body was longer, or the binary marker when it is not UTF-8 text.
|
|
30
|
+
*/
|
|
31
|
+
export declare function bytesToBodyText(bytes: Uint8Array, kind: BodyKind, complete: boolean, totalBytes: number | null): string;
|
|
32
|
+
/**
|
|
33
|
+
* Reads at most MAX_BODY_SIZE bytes (plus the rest of the chunk that crossed it) and cancels the
|
|
34
|
+
* stream after that, so an endless or huge body is never read into memory.
|
|
35
|
+
*/
|
|
36
|
+
export declare function readStreamHead(stream: ReadableStream<Uint8Array>): Promise<{
|
|
37
|
+
bytes: Uint8Array;
|
|
38
|
+
complete: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
/** Reads the head of a blob (never the whole blob) and turns it into the logged text. */
|
|
41
|
+
export declare function readBlobHead(blob: Blob, kind: BodyKind): Promise<string>;
|
|
42
|
+
export declare function isBlob(value: unknown): value is Blob;
|
|
43
|
+
export declare function isFormData(value: unknown): boolean;
|
|
44
|
+
export declare function isUrlSearchParams(value: unknown): value is URLSearchParams;
|
|
45
|
+
export declare function isReadableStream(value: unknown): boolean;
|
|
46
|
+
export declare function isDocument(value: unknown): boolean;
|
|
47
|
+
/** Byte view of an ArrayBuffer or ArrayBufferView, or null for anything else. */
|
|
48
|
+
export declare function toBytes(value: unknown): Uint8Array | null;
|
|
49
|
+
/**
|
|
50
|
+
* The logged request payload for a fetch/XHR body. Strings and buffers are captured synchronously;
|
|
51
|
+
* blobs are read asynchronously (head only). Form data, streams and documents are not captured.
|
|
52
|
+
*/
|
|
53
|
+
export declare function captureRequestBody(body: unknown, kind: BodyKind): string | Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* JSON.stringify for a parsed JSON value (XHR responseType "json") that stops once the output
|
|
56
|
+
* exceeds MAX_BODY_SIZE, so a huge response is not serialised in full.
|
|
57
|
+
*/
|
|
58
|
+
export declare function stringifyJsonHead(value: unknown): string;
|