capacitor-gleap-plugin 19.0.1 → 19.2.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 +1 -1
- package/Package.swift +1 -1
- package/README.md +93 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/io/gleapplugins/capacitor/GleapPlugin.java +125 -0
- package/dist/docs.json +91 -0
- package/dist/esm/definitions.d.ts +49 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/logs/webViewLogs.d.ts +18 -2
- package/dist/esm/logs/webViewLogs.js +45 -7
- package/dist/esm/logs/webViewLogs.js.map +1 -1
- package/dist/esm/web.d.ts +11 -0
- package/dist/esm/web.js +25 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +70 -7
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +70 -7
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/GleapPlugin/GleapPlugin.swift +68 -0
- package/package.json +2 -2
|
@@ -61,6 +61,7 @@ export class WebViewLogCapture {
|
|
|
61
61
|
// logs are enabled (like the JavaScript SDK), so nothing is held in memory before that.
|
|
62
62
|
this.networkCapture.install();
|
|
63
63
|
this.listenForConfig();
|
|
64
|
+
this.listenForFlush();
|
|
64
65
|
}
|
|
65
66
|
/**
|
|
66
67
|
* Android debug builds (Capacitor's loggingBehavior) write the WebView console to logcat, which the
|
|
@@ -83,6 +84,36 @@ export class WebViewLogCapture {
|
|
|
83
84
|
// The native side predates the event: network logs stay off.
|
|
84
85
|
}
|
|
85
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Capture requests: right before the native SDK collects the logs for a request, it asks for what is still
|
|
89
|
+
* buffered here (pushed at most every PUSH_DELAY_MS otherwise) and waits up to 500 ms for the answer.
|
|
90
|
+
*/
|
|
91
|
+
listenForFlush() {
|
|
92
|
+
try {
|
|
93
|
+
const handle = this.target.addListener('flushLogs', (data) => {
|
|
94
|
+
const flushId = data && typeof data.flushId === 'string' ? data.flushId : null;
|
|
95
|
+
runOutsideZone(() => this.flushNow().then(() => {
|
|
96
|
+
if (flushId) {
|
|
97
|
+
this.answerFlush(flushId);
|
|
98
|
+
}
|
|
99
|
+
}));
|
|
100
|
+
});
|
|
101
|
+
if (handle && typeof handle.catch === 'function') {
|
|
102
|
+
handle.catch(() => undefined);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
// The native side predates the event: nothing asks for flushes.
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
answerFlush(flushId) {
|
|
110
|
+
try {
|
|
111
|
+
Promise.resolve(this.target.logsFlushed({ flushId })).catch(() => undefined);
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
// The native side gives up waiting after 500 ms.
|
|
115
|
+
}
|
|
116
|
+
}
|
|
86
117
|
applyRemoteConfig(config) {
|
|
87
118
|
try {
|
|
88
119
|
if (!config || typeof config !== 'object') {
|
|
@@ -125,15 +156,20 @@ export class WebViewLogCapture {
|
|
|
125
156
|
this.markDirty(this.consoleChannel);
|
|
126
157
|
this.markDirty(this.networkChannel);
|
|
127
158
|
}
|
|
128
|
-
/**
|
|
159
|
+
/**
|
|
160
|
+
* Pushes pending changes now (before a plugin call that can produce a report, or when the native SDK collects the
|
|
161
|
+
* logs for a capture request). Resolves once the native side took them; never rejects.
|
|
162
|
+
*/
|
|
129
163
|
flushNow() {
|
|
164
|
+
const pushes = [];
|
|
130
165
|
try {
|
|
131
|
-
this.flushChannel(this.consoleChannel);
|
|
132
|
-
this.flushChannel(this.networkChannel);
|
|
166
|
+
pushes.push(this.flushChannel(this.consoleChannel));
|
|
167
|
+
pushes.push(this.flushChannel(this.networkChannel));
|
|
133
168
|
}
|
|
134
169
|
catch (e) {
|
|
135
170
|
// Ignore.
|
|
136
171
|
}
|
|
172
|
+
return Promise.all(pushes).then(() => undefined, () => undefined);
|
|
137
173
|
}
|
|
138
174
|
updateRules() {
|
|
139
175
|
this.rules = createRedactionRules([...this.remoteProps, ...this.localProps], [...this.remoteBlacklist, ...this.localBlacklist]);
|
|
@@ -164,20 +200,21 @@ export class WebViewLogCapture {
|
|
|
164
200
|
channel.timer = null;
|
|
165
201
|
}
|
|
166
202
|
}
|
|
203
|
+
/** Resolves once the push it started (if any) was answered; never rejects. */
|
|
167
204
|
flushChannel(channel) {
|
|
168
205
|
if (channel.timer !== null) {
|
|
169
206
|
clearTimeout(channel.timer);
|
|
170
207
|
channel.timer = null;
|
|
171
208
|
}
|
|
172
209
|
if (!channel.isDirty || !this.canPush(channel)) {
|
|
173
|
-
return;
|
|
210
|
+
return Promise.resolve();
|
|
174
211
|
}
|
|
175
212
|
channel.isDirty = false;
|
|
176
213
|
let push;
|
|
177
214
|
if (channel.name === 'console') {
|
|
178
215
|
const logs = this.consoleCapture ? this.consoleCapture.getEntries() : [];
|
|
179
216
|
if (logs.length === 0 && !channel.hasPushedLogs) {
|
|
180
|
-
return;
|
|
217
|
+
return Promise.resolve();
|
|
181
218
|
}
|
|
182
219
|
channel.hasPushedLogs = logs.length > 0;
|
|
183
220
|
push = runOutsideZone(() => this.target.attachConsoleLogs({ logs }));
|
|
@@ -185,18 +222,19 @@ export class WebViewLogCapture {
|
|
|
185
222
|
else {
|
|
186
223
|
const logs = this.isNetworkEnabled ? this.buildNetworkLogs() : [];
|
|
187
224
|
if (logs.length === 0 && !channel.hasPushedLogs) {
|
|
188
|
-
return;
|
|
225
|
+
return Promise.resolve();
|
|
189
226
|
}
|
|
190
227
|
channel.hasPushedLogs = logs.length > 0;
|
|
191
228
|
push = runOutsideZone(() => this.target.attachNetworkLogs({ logs }));
|
|
192
229
|
}
|
|
193
230
|
try {
|
|
194
|
-
Promise.resolve(push).then(() => {
|
|
231
|
+
return Promise.resolve(push).then(() => {
|
|
195
232
|
channel.failures = 0;
|
|
196
233
|
}, () => this.onPushFailed(channel));
|
|
197
234
|
}
|
|
198
235
|
catch (e) {
|
|
199
236
|
this.onPushFailed(channel);
|
|
237
|
+
return Promise.resolve();
|
|
200
238
|
}
|
|
201
239
|
}
|
|
202
240
|
onPushFailed(channel) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webViewLogs.js","sourceRoot":"","sources":["../../../src/logs/webViewLogs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC,uEAAuE;AACvE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AACjC,uGAAuG;AACvG,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,UAAU,GAAG,0BAA0B,CAAC;AAE9C,4FAA4F;AAC5F,MAAM,oBAAoB,GAAG;IAC3B,uBAAuB;IACvB,MAAM;IACN,mBAAmB;IACnB,kBAAkB;IAClB,mBAAmB;IACnB,kBAAkB;IAClB,mBAAmB;IACnB,UAAU;CACX,CAAC;AAwBF,MAAM,aAAa,GAAG,CAAC,IAAqB,EAAW,EAAE,CAAC,CAAC;IACzD,IAAI;IACJ,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,CAAC;IACX,SAAS,EAAE,KAAK;IAChB,aAAa,EAAE,KAAK;CACrB,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,CAAC,KAAc,EAAY,EAAE,CACjD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAA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BAC9C,KAAK,4BAA4B;oBAC/B,OAAO,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,qBAAqB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;gBACnF,KAAK,yBAAyB;oBAC5B,OAAO,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC3E,KAAK,4BAA4B;oBAC/B,OAAO,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;gBAChD;oBACE,IAAI,oBAAoB,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE;wBAC/C,OAAO,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;qBACzC;oBACD,OAAO,KAAK,CAAC;aAChB;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Capacitor } from '@capacitor/core';\n\nimport type { GleapConsoleLogEntry, GleapLogConfig, GleapNetworkLogEntry } from '../definitions';\n\nimport { ConsoleCapture } from './consoleCapture';\nimport { NetworkCapture } from './networkCapture';\nimport type { RedactionRules } from './redaction';\nimport { createRedactionRules, isBlacklistedUrl, redactNetworkLogEntryOrStrip } from './redaction';\nimport { runOutsideZone } from './zone';\n\n/** Pushes are batched: at most one per channel every PUSH_DELAY_MS. */\nexport const PUSH_DELAY_MS = 500;\n/** A channel stops pushing after this many failed pushes in a row (e.g. an outdated native plugin). */\nconst MAX_FAILED_PUSHES = 3;\nconst GLOBAL_KEY = '__gleapWebViewLogCapture';\n\n/** Plugin calls that can lead to a report: the latest logs are pushed right before them. */\nconst FLUSH_BEFORE_METHODS = [\n 'sendSilentCrashReport',\n 'open',\n 'startFeedbackFlow',\n 'startClassicForm',\n 'startConversation',\n 'openConversation',\n 'openConversations',\n 'startBot',\n];\n\nexport interface LogTarget {\n attachConsoleLogs(options: { logs: GleapConsoleLogEntry[] }): Promise<unknown>;\n attachNetworkLogs(options: { logs: GleapNetworkLogEntry[] }): Promise<unknown>;\n addListener(eventName: 'logConfigLoaded', listenerFunc: (config: GleapLogConfig) => void): Promise<unknown>;\n}\n\ninterface Channel {\n name: 'console' | 'network';\n isDirty: boolean;\n timer: ReturnType<typeof setTimeout> | null;\n failures: number;\n isStopped: boolean;\n /** Whether native currently holds a non-empty list (so an empty list must be pushed to clear it). */\n hasPushedLogs: boolean;\n}\n\ninterface CachedEntry {\n version: number;\n rulesVersion: number;\n entry: GleapNetworkLogEntry | null;\n}\n\nconst createChannel = (name: Channel['name']): Channel => ({\n name,\n isDirty: false,\n timer: null,\n failures: 0,\n isStopped: false,\n hasPushedLogs: false,\n});\n\nconst toStringArray = (value: unknown): string[] =>\n Array.isArray(value) ? value.filter((item): item is string => typeof item === 'string') : [];\n\n/**\n * Captures console output and fetch/XHR traffic inside the WebView of a native (iOS / Android) app\n * and hands them to the native SDK, which attaches them to tickets. The native SDKs cannot see\n * either: WebView requests do not go through URLSession / OkHttp, and console output only reaches\n * the native log in debug builds.\n */\nexport class WebViewLogCapture {\n private consoleCapture: ConsoleCapture | null = null;\n private readonly networkCapture: NetworkCapture;\n private readonly consoleChannel = createChannel('console');\n private readonly networkChannel = createChannel('network');\n private isNetworkEnabled = false;\n private remoteProps: string[] = [];\n private localProps: string[] = [];\n private remoteBlacklist: string[] = [];\n private localBlacklist: string[] = [];\n private rules: RedactionRules = createRedactionRules([], []);\n private rulesVersion = 0;\n private redactedEntries = new Map<number, CachedEntry>();\n\n constructor(\n private readonly win: Window,\n private readonly target: LogTarget,\n private readonly platform: string,\n ) {\n this.networkCapture = new NetworkCapture(win, () => this.markDirty(this.networkChannel));\n }\n\n start(): void {\n if (!this.nativeLogsConsole()) {\n this.consoleCapture = new ConsoleCapture(this.win, () => this.markDirty(this.consoleChannel));\n this.consoleCapture.install();\n }\n // The hooks go in now, but requests are only recorded once the project config says network\n // logs are enabled (like the JavaScript SDK), so nothing is held in memory before that.\n this.networkCapture.install();\n this.listenForConfig();\n }\n\n /**\n * Android debug builds (Capacitor's loggingBehavior) write the WebView console to logcat, which the\n * Android SDK already reads: capturing it here too would log every line twice. On iOS, Capacitor\n * prints it to stdout as \"⚡️ [level] - message\"; the iOS SDK drops those lines for Capacitor apps\n * (application type CAPACITOR, set in initialize), so iOS always captures here.\n */\n private nativeLogsConsole(): boolean {\n const capacitor = (\n this.win as unknown as {\n Capacitor?: { isLoggingEnabled?: unknown };\n }\n ).Capacitor;\n return this.platform === 'android' && !!capacitor && capacitor.isLoggingEnabled === true;\n }\n\n private listenForConfig(): void {\n try {\n const handle = this.target.addListener('logConfigLoaded', (config) => this.applyRemoteConfig(config));\n if (handle && typeof handle.catch === 'function') {\n handle.catch(() => undefined);\n }\n } catch (e) {\n // The native side predates the event: network logs stay off.\n }\n }\n\n applyRemoteConfig(config: GleapLogConfig | null | undefined): void {\n try {\n if (!config || typeof config !== 'object') {\n return;\n }\n this.remoteProps = toStringArray(config.networkLogPropsToIgnore);\n this.remoteBlacklist = toStringArray(config.networkLogBlacklist);\n this.updateRules();\n this.isNetworkEnabled = config.enableNetworkLogs === true;\n this.networkCapture.setActive(this.isNetworkEnabled);\n this.markDirty(this.networkChannel);\n } catch (e) {\n // Ignore.\n }\n }\n\n setLocalPropsToIgnore(props: unknown): void {\n this.localProps = toStringArray(props);\n this.updateRules();\n }\n\n setLocalBlacklist(blacklist: unknown): void {\n this.localBlacklist = toStringArray(blacklist);\n this.updateRules();\n }\n\n /** disableConsoleLogOverwrite(): restore the console and drop what was recorded (also natively). */\n disableConsole(): void {\n try {\n if (this.consoleCapture) {\n this.consoleCapture.uninstall();\n this.consoleCapture = null;\n }\n this.markDirty(this.consoleChannel);\n this.flushChannel(this.consoleChannel);\n } catch (e) {\n // Ignore.\n }\n }\n\n onInitialize(): void {\n this.markDirty(this.consoleChannel);\n this.markDirty(this.networkChannel);\n }\n\n /** Pushes pending changes now (before a plugin call that can produce a report). */\n flushNow(): void {\n try {\n this.flushChannel(this.consoleChannel);\n this.flushChannel(this.networkChannel);\n } catch (e) {\n // Ignore.\n }\n }\n\n private updateRules(): void {\n this.rules = createRedactionRules(\n [...this.remoteProps, ...this.localProps],\n [...this.remoteBlacklist, ...this.localBlacklist],\n );\n this.rulesVersion++;\n this.markDirty(this.networkChannel);\n }\n\n private canPush(channel: Channel): boolean {\n if (channel.isStopped) {\n return false;\n }\n if (channel.name === 'network') {\n return this.isNetworkEnabled || channel.hasPushedLogs;\n }\n return true;\n }\n\n private markDirty(channel: Channel): void {\n channel.isDirty = true;\n if (channel.timer !== null || !this.canPush(channel)) {\n return;\n }\n try {\n channel.timer = runOutsideZone(() =>\n setTimeout(() => {\n channel.timer = null;\n this.flushChannel(channel);\n }, PUSH_DELAY_MS),\n );\n } catch (e) {\n channel.timer = null;\n }\n }\n\n private flushChannel(channel: Channel): void {\n if (channel.timer !== null) {\n clearTimeout(channel.timer);\n channel.timer = null;\n }\n if (!channel.isDirty || !this.canPush(channel)) {\n return;\n }\n channel.isDirty = false;\n\n let push: Promise<unknown>;\n if (channel.name === 'console') {\n const logs = this.consoleCapture ? this.consoleCapture.getEntries() : [];\n if (logs.length === 0 && !channel.hasPushedLogs) {\n return;\n }\n channel.hasPushedLogs = logs.length > 0;\n push = runOutsideZone(() => this.target.attachConsoleLogs({ logs }));\n } else {\n const logs = this.isNetworkEnabled ? this.buildNetworkLogs() : [];\n if (logs.length === 0 && !channel.hasPushedLogs) {\n return;\n }\n channel.hasPushedLogs = logs.length > 0;\n push = runOutsideZone(() => this.target.attachNetworkLogs({ logs }));\n }\n\n try {\n Promise.resolve(push).then(\n () => {\n channel.failures = 0;\n },\n () => this.onPushFailed(channel),\n );\n } catch (e) {\n this.onPushFailed(channel);\n }\n }\n\n private onPushFailed(channel: Channel): void {\n channel.failures++;\n if (channel.failures >= MAX_FAILED_PUSHES) {\n channel.isStopped = true;\n return;\n }\n this.markDirty(channel);\n }\n\n /** Redacted copies of the buffered entries; unchanged entries reuse their previous copy. */\n private buildNetworkLogs(): GleapNetworkLogEntry[] {\n const logs: GleapNetworkLogEntry[] = [];\n const cache = new Map<number, CachedEntry>();\n for (const snapshot of this.networkCapture.getSnapshots()) {\n let cached = this.redactedEntries.get(snapshot.id);\n if (!cached || cached.version !== snapshot.version || cached.rulesVersion !== this.rulesVersion) {\n cached = {\n version: snapshot.version,\n rulesVersion: this.rulesVersion,\n entry: isBlacklistedUrl(snapshot.entry.url, this.rules)\n ? null\n : redactNetworkLogEntryOrStrip(snapshot.entry, this.rules),\n };\n }\n cache.set(snapshot.id, cached);\n if (cached.entry) {\n logs.push(cached.entry);\n }\n }\n this.redactedEntries = cache;\n return logs;\n }\n}\n\n/**\n * Starts the WebView log capture on iOS and Android (not on web, where the JavaScript SDK records\n * the console and network itself). Safe to call more than once.\n */\nexport function installWebViewLogCapture(target: LogTarget): WebViewLogCapture | null {\n try {\n if (typeof window === 'undefined' || !Capacitor.isNativePlatform()) {\n return null;\n }\n const win = window as unknown as { [GLOBAL_KEY]?: WebViewLogCapture };\n const existing = win[GLOBAL_KEY];\n if (existing) {\n return existing;\n }\n const capture = new WebViewLogCapture(window, target, Capacitor.getPlatform());\n win[GLOBAL_KEY] = capture;\n capture.start();\n return capture;\n } catch (e) {\n return null;\n }\n}\n\n/**\n * Wraps the registered plugin so the calls that affect the WebView capture reach it before they go\n * to native. Every other call passes through unchanged.\n */\nexport function wrapPluginWithLogCapture<T extends object>(plugin: T, capture: WebViewLogCapture): T {\n return new Proxy(plugin, {\n get(target, property, receiver) {\n const value = Reflect.get(target, property, receiver);\n if (typeof property !== 'string' || typeof value !== 'function') {\n return value;\n }\n const method = value as (...args: unknown[]) => unknown;\n const before =\n (hook: (options: { [key: string]: unknown }) => void) =>\n (...args: unknown[]) => {\n try {\n const options = args[0];\n hook(options && typeof options === 'object' ? (options as { [key: string]: unknown }) : {});\n } catch (e) {\n // Never break the plugin call.\n }\n return method(...args);\n };\n\n switch (property) {\n case 'initialize':\n return before(() => capture.onInitialize());\n case 'setNetworkLogPropsToIgnore':\n return before((options) => capture.setLocalPropsToIgnore(options.propsToIgnore));\n case 'setNetworkLogsBlacklist':\n return before((options) => capture.setLocalBlacklist(options.blacklist));\n case 'disableConsoleLogOverwrite':\n return before(() => capture.disableConsole());\n default:\n if (FLUSH_BEFORE_METHODS.indexOf(property) > -1) {\n return before(() => capture.flushNow());\n }\n return value;\n }\n },\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"webViewLogs.js","sourceRoot":"","sources":["../../../src/logs/webViewLogs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC,uEAAuE;AACvE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AACjC,uGAAuG;AACvG,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,UAAU,GAAG,0BAA0B,CAAC;AAE9C,4FAA4F;AAC5F,MAAM,oBAAoB,GAAG;IAC3B,uBAAuB;IACvB,MAAM;IACN,mBAAmB;IACnB,kBAAkB;IAClB,mBAAmB;IACnB,kBAAkB;IAClB,mBAAmB;IACnB,UAAU;CACX,CAAC;AA0BF,MAAM,aAAa,GAAG,CAAC,IAAqB,EAAW,EAAE,CAAC,CAAC;IACzD,IAAI;IACJ,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,CAAC;IACX,SAAS,EAAE,KAAK;IAChB,aAAa,EAAE,KAAK;CACrB,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,CAA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,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAE,OAAsC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;iBAC7F;gBAAC,OAAO,CAAC,EAAE;oBACV,+BAA+B;iBAChC;gBACD,OAAO,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;YACzB,CAAC,CAAC;YAEJ,QAAQ,QAAQ,EAAE;gBAChB,KAAK,YAAY;oBACf,OAAO,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;gBAC9C,KAAK,4BAA4B;oBAC/B,OAAO,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,qBAAqB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;gBACnF,KAAK,yBAAyB;oBAC5B,OAAO,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC3E,KAAK,4BAA4B;oBAC/B,OAAO,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;gBAChD;oBACE,IAAI,oBAAoB,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE;wBAC/C,OAAO,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;qBACzC;oBACD,OAAO,KAAK,CAAC;aAChB;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Capacitor } from '@capacitor/core';\n\nimport type { GleapConsoleLogEntry, GleapLogConfig, GleapNetworkLogEntry } from '../definitions';\n\nimport { ConsoleCapture } from './consoleCapture';\nimport { NetworkCapture } from './networkCapture';\nimport type { RedactionRules } from './redaction';\nimport { createRedactionRules, isBlacklistedUrl, redactNetworkLogEntryOrStrip } from './redaction';\nimport { runOutsideZone } from './zone';\n\n/** Pushes are batched: at most one per channel every PUSH_DELAY_MS. */\nexport const PUSH_DELAY_MS = 500;\n/** A channel stops pushing after this many failed pushes in a row (e.g. an outdated native plugin). */\nconst MAX_FAILED_PUSHES = 3;\nconst GLOBAL_KEY = '__gleapWebViewLogCapture';\n\n/** Plugin calls that can lead to a report: the latest logs are pushed right before them. */\nconst FLUSH_BEFORE_METHODS = [\n 'sendSilentCrashReport',\n 'open',\n 'startFeedbackFlow',\n 'startClassicForm',\n 'startConversation',\n 'openConversation',\n 'openConversations',\n 'startBot',\n];\n\nexport interface LogTarget {\n attachConsoleLogs(options: { logs: GleapConsoleLogEntry[] }): Promise<unknown>;\n attachNetworkLogs(options: { logs: GleapNetworkLogEntry[] }): Promise<unknown>;\n logsFlushed(options: { flushId: string }): Promise<unknown>;\n addListener(eventName: 'logConfigLoaded', listenerFunc: (config: GleapLogConfig) => void): Promise<unknown>;\n addListener(eventName: 'flushLogs', listenerFunc: (data: { flushId: string }) => void): Promise<unknown>;\n}\n\ninterface Channel {\n name: 'console' | 'network';\n isDirty: boolean;\n timer: ReturnType<typeof setTimeout> | null;\n failures: number;\n isStopped: boolean;\n /** Whether native currently holds a non-empty list (so an empty list must be pushed to clear it). */\n hasPushedLogs: boolean;\n}\n\ninterface CachedEntry {\n version: number;\n rulesVersion: number;\n entry: GleapNetworkLogEntry | null;\n}\n\nconst createChannel = (name: Channel['name']): Channel => ({\n name,\n isDirty: false,\n timer: null,\n failures: 0,\n isStopped: false,\n hasPushedLogs: false,\n});\n\nconst toStringArray = (value: unknown): string[] =>\n Array.isArray(value) ? value.filter((item): item is string => typeof item === 'string') : [];\n\n/**\n * Captures console output and fetch/XHR traffic inside the WebView of a native (iOS / Android) app\n * and hands them to the native SDK, which attaches them to tickets. The native SDKs cannot see\n * either: WebView requests do not go through URLSession / OkHttp, and console output only reaches\n * the native log in debug builds.\n */\nexport class WebViewLogCapture {\n private consoleCapture: ConsoleCapture | null = null;\n private readonly networkCapture: NetworkCapture;\n private readonly consoleChannel = createChannel('console');\n private readonly networkChannel = createChannel('network');\n private isNetworkEnabled = false;\n private remoteProps: string[] = [];\n private localProps: string[] = [];\n private remoteBlacklist: string[] = [];\n private localBlacklist: string[] = [];\n private rules: RedactionRules = createRedactionRules([], []);\n private rulesVersion = 0;\n private redactedEntries = new Map<number, CachedEntry>();\n\n constructor(\n private readonly win: Window,\n private readonly target: LogTarget,\n private readonly platform: string,\n ) {\n this.networkCapture = new NetworkCapture(win, () => this.markDirty(this.networkChannel));\n }\n\n start(): void {\n if (!this.nativeLogsConsole()) {\n this.consoleCapture = new ConsoleCapture(this.win, () => this.markDirty(this.consoleChannel));\n this.consoleCapture.install();\n }\n // The hooks go in now, but requests are only recorded once the project config says network\n // logs are enabled (like the JavaScript SDK), so nothing is held in memory before that.\n this.networkCapture.install();\n this.listenForConfig();\n this.listenForFlush();\n }\n\n /**\n * Android debug builds (Capacitor's loggingBehavior) write the WebView console to logcat, which the\n * Android SDK already reads: capturing it here too would log every line twice. On iOS, Capacitor\n * prints it to stdout as \"⚡️ [level] - message\"; the iOS SDK drops those lines for Capacitor apps\n * (application type CAPACITOR, set in initialize), so iOS always captures here.\n */\n private nativeLogsConsole(): boolean {\n const capacitor = (\n this.win as unknown as {\n Capacitor?: { isLoggingEnabled?: unknown };\n }\n ).Capacitor;\n return this.platform === 'android' && !!capacitor && capacitor.isLoggingEnabled === true;\n }\n\n private listenForConfig(): void {\n try {\n const handle = this.target.addListener('logConfigLoaded', (config) => this.applyRemoteConfig(config));\n if (handle && typeof handle.catch === 'function') {\n handle.catch(() => undefined);\n }\n } catch (e) {\n // The native side predates the event: network logs stay off.\n }\n }\n\n /**\n * Capture requests: right before the native SDK collects the logs for a request, it asks for what is still\n * buffered here (pushed at most every PUSH_DELAY_MS otherwise) and waits up to 500 ms for the answer.\n */\n private listenForFlush(): void {\n try {\n const handle = this.target.addListener('flushLogs', (data) => {\n const flushId = data && typeof data.flushId === 'string' ? data.flushId : null;\n runOutsideZone(() =>\n this.flushNow().then(() => {\n if (flushId) {\n this.answerFlush(flushId);\n }\n }),\n );\n });\n if (handle && typeof handle.catch === 'function') {\n handle.catch(() => undefined);\n }\n } catch (e) {\n // The native side predates the event: nothing asks for flushes.\n }\n }\n\n private answerFlush(flushId: string): void {\n try {\n Promise.resolve(this.target.logsFlushed({ flushId })).catch(() => undefined);\n } catch (e) {\n // The native side gives up waiting after 500 ms.\n }\n }\n\n applyRemoteConfig(config: GleapLogConfig | null | undefined): void {\n try {\n if (!config || typeof config !== 'object') {\n return;\n }\n this.remoteProps = toStringArray(config.networkLogPropsToIgnore);\n this.remoteBlacklist = toStringArray(config.networkLogBlacklist);\n this.updateRules();\n this.isNetworkEnabled = config.enableNetworkLogs === true;\n this.networkCapture.setActive(this.isNetworkEnabled);\n this.markDirty(this.networkChannel);\n } catch (e) {\n // Ignore.\n }\n }\n\n setLocalPropsToIgnore(props: unknown): void {\n this.localProps = toStringArray(props);\n this.updateRules();\n }\n\n setLocalBlacklist(blacklist: unknown): void {\n this.localBlacklist = toStringArray(blacklist);\n this.updateRules();\n }\n\n /** disableConsoleLogOverwrite(): restore the console and drop what was recorded (also natively). */\n disableConsole(): void {\n try {\n if (this.consoleCapture) {\n this.consoleCapture.uninstall();\n this.consoleCapture = null;\n }\n this.markDirty(this.consoleChannel);\n this.flushChannel(this.consoleChannel);\n } catch (e) {\n // Ignore.\n }\n }\n\n onInitialize(): void {\n this.markDirty(this.consoleChannel);\n this.markDirty(this.networkChannel);\n }\n\n /**\n * Pushes pending changes now (before a plugin call that can produce a report, or when the native SDK collects the\n * logs for a capture request). Resolves once the native side took them; never rejects.\n */\n flushNow(): Promise<void> {\n const pushes: Promise<unknown>[] = [];\n try {\n pushes.push(this.flushChannel(this.consoleChannel));\n pushes.push(this.flushChannel(this.networkChannel));\n } catch (e) {\n // Ignore.\n }\n return Promise.all(pushes).then(\n () => undefined,\n () => undefined,\n );\n }\n\n private updateRules(): void {\n this.rules = createRedactionRules(\n [...this.remoteProps, ...this.localProps],\n [...this.remoteBlacklist, ...this.localBlacklist],\n );\n this.rulesVersion++;\n this.markDirty(this.networkChannel);\n }\n\n private canPush(channel: Channel): boolean {\n if (channel.isStopped) {\n return false;\n }\n if (channel.name === 'network') {\n return this.isNetworkEnabled || channel.hasPushedLogs;\n }\n return true;\n }\n\n private markDirty(channel: Channel): void {\n channel.isDirty = true;\n if (channel.timer !== null || !this.canPush(channel)) {\n return;\n }\n try {\n channel.timer = runOutsideZone(() =>\n setTimeout(() => {\n channel.timer = null;\n this.flushChannel(channel);\n }, PUSH_DELAY_MS),\n );\n } catch (e) {\n channel.timer = null;\n }\n }\n\n /** Resolves once the push it started (if any) was answered; never rejects. */\n private flushChannel(channel: Channel): Promise<void> {\n if (channel.timer !== null) {\n clearTimeout(channel.timer);\n channel.timer = null;\n }\n if (!channel.isDirty || !this.canPush(channel)) {\n return Promise.resolve();\n }\n channel.isDirty = false;\n\n let push: Promise<unknown>;\n if (channel.name === 'console') {\n const logs = this.consoleCapture ? this.consoleCapture.getEntries() : [];\n if (logs.length === 0 && !channel.hasPushedLogs) {\n return Promise.resolve();\n }\n channel.hasPushedLogs = logs.length > 0;\n push = runOutsideZone(() => this.target.attachConsoleLogs({ logs }));\n } else {\n const logs = this.isNetworkEnabled ? this.buildNetworkLogs() : [];\n if (logs.length === 0 && !channel.hasPushedLogs) {\n return Promise.resolve();\n }\n channel.hasPushedLogs = logs.length > 0;\n push = runOutsideZone(() => this.target.attachNetworkLogs({ logs }));\n }\n\n try {\n return Promise.resolve(push).then(\n () => {\n channel.failures = 0;\n },\n () => this.onPushFailed(channel),\n );\n } catch (e) {\n this.onPushFailed(channel);\n return Promise.resolve();\n }\n }\n\n private onPushFailed(channel: Channel): void {\n channel.failures++;\n if (channel.failures >= MAX_FAILED_PUSHES) {\n channel.isStopped = true;\n return;\n }\n this.markDirty(channel);\n }\n\n /** Redacted copies of the buffered entries; unchanged entries reuse their previous copy. */\n private buildNetworkLogs(): GleapNetworkLogEntry[] {\n const logs: GleapNetworkLogEntry[] = [];\n const cache = new Map<number, CachedEntry>();\n for (const snapshot of this.networkCapture.getSnapshots()) {\n let cached = this.redactedEntries.get(snapshot.id);\n if (!cached || cached.version !== snapshot.version || cached.rulesVersion !== this.rulesVersion) {\n cached = {\n version: snapshot.version,\n rulesVersion: this.rulesVersion,\n entry: isBlacklistedUrl(snapshot.entry.url, this.rules)\n ? null\n : redactNetworkLogEntryOrStrip(snapshot.entry, this.rules),\n };\n }\n cache.set(snapshot.id, cached);\n if (cached.entry) {\n logs.push(cached.entry);\n }\n }\n this.redactedEntries = cache;\n return logs;\n }\n}\n\n/**\n * Starts the WebView log capture on iOS and Android (not on web, where the JavaScript SDK records\n * the console and network itself). Safe to call more than once.\n */\nexport function installWebViewLogCapture(target: LogTarget): WebViewLogCapture | null {\n try {\n if (typeof window === 'undefined' || !Capacitor.isNativePlatform()) {\n return null;\n }\n const win = window as unknown as { [GLOBAL_KEY]?: WebViewLogCapture };\n const existing = win[GLOBAL_KEY];\n if (existing) {\n return existing;\n }\n const capture = new WebViewLogCapture(window, target, Capacitor.getPlatform());\n win[GLOBAL_KEY] = capture;\n capture.start();\n return capture;\n } catch (e) {\n return null;\n }\n}\n\n/**\n * Wraps the registered plugin so the calls that affect the WebView capture reach it before they go\n * to native. Every other call passes through unchanged.\n */\nexport function wrapPluginWithLogCapture<T extends object>(plugin: T, capture: WebViewLogCapture): T {\n return new Proxy(plugin, {\n get(target, property, receiver) {\n const value = Reflect.get(target, property, receiver);\n if (typeof property !== 'string' || typeof value !== 'function') {\n return value;\n }\n const method = value as (...args: unknown[]) => unknown;\n const before =\n (hook: (options: { [key: string]: unknown }) => void) =>\n (...args: unknown[]) => {\n try {\n const options = args[0];\n hook(options && typeof options === 'object' ? (options as { [key: string]: unknown }) : {});\n } catch (e) {\n // Never break the plugin call.\n }\n return method(...args);\n };\n\n switch (property) {\n case 'initialize':\n return before(() => capture.onInitialize());\n case 'setNetworkLogPropsToIgnore':\n return before((options) => capture.setLocalPropsToIgnore(options.propsToIgnore));\n case 'setNetworkLogsBlacklist':\n return before((options) => capture.setLocalBlacklist(options.blacklist));\n case 'disableConsoleLogOverwrite':\n return before(() => capture.disableConsole());\n default:\n if (FLUSH_BEFORE_METHODS.indexOf(property) > -1) {\n return before(() => capture.flushNow());\n }\n return value;\n }\n },\n });\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -124,6 +124,16 @@ export declare class GleapWeb extends WebPlugin implements GleapPlugin {
|
|
|
124
124
|
}): Promise<{
|
|
125
125
|
colorScheme: string;
|
|
126
126
|
}>;
|
|
127
|
+
setCaptureEnabled(options: {
|
|
128
|
+
enabled: boolean;
|
|
129
|
+
}): Promise<{
|
|
130
|
+
captureEnabled: boolean;
|
|
131
|
+
}>;
|
|
132
|
+
setRemoteLogCollectionEnabled(options: {
|
|
133
|
+
enabled: boolean;
|
|
134
|
+
}): Promise<{
|
|
135
|
+
remoteLogCollectionEnabled: boolean;
|
|
136
|
+
}>;
|
|
127
137
|
identify(options: {
|
|
128
138
|
userId: string;
|
|
129
139
|
userHash?: string | undefined;
|
|
@@ -167,6 +177,7 @@ export declare class GleapWeb extends WebPlugin implements GleapPlugin {
|
|
|
167
177
|
attachNetworkLogs(): Promise<{
|
|
168
178
|
networkLogsAttached: boolean;
|
|
169
179
|
}>;
|
|
180
|
+
logsFlushed(): Promise<void>;
|
|
170
181
|
attachConsoleLogs(): Promise<{
|
|
171
182
|
consoleLogsAttached: boolean;
|
|
172
183
|
}>;
|
package/dist/esm/web.js
CHANGED
|
@@ -196,6 +196,28 @@ export class GleapWeb extends WebPlugin {
|
|
|
196
196
|
});
|
|
197
197
|
return { colorScheme: options.colorScheme };
|
|
198
198
|
}
|
|
199
|
+
async setCaptureEnabled(options) {
|
|
200
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.enabled) !== 'boolean') {
|
|
201
|
+
throw new Error('No enabled value provided');
|
|
202
|
+
}
|
|
203
|
+
// A JavaScript SDK older than capture requests has nothing to switch.
|
|
204
|
+
const jsSdk = Gleap;
|
|
205
|
+
if (typeof jsSdk.setCaptureEnabled === 'function') {
|
|
206
|
+
jsSdk.setCaptureEnabled(options.enabled);
|
|
207
|
+
}
|
|
208
|
+
return { captureEnabled: options.enabled };
|
|
209
|
+
}
|
|
210
|
+
async setRemoteLogCollectionEnabled(options) {
|
|
211
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.enabled) !== 'boolean') {
|
|
212
|
+
throw new Error('No enabled value provided');
|
|
213
|
+
}
|
|
214
|
+
// A JavaScript SDK older than capture requests has nothing to switch.
|
|
215
|
+
const jsSdk = Gleap;
|
|
216
|
+
if (typeof jsSdk.setRemoteLogCollectionEnabled === 'function') {
|
|
217
|
+
jsSdk.setRemoteLogCollectionEnabled(options.enabled);
|
|
218
|
+
}
|
|
219
|
+
return { remoteLogCollectionEnabled: options.enabled };
|
|
220
|
+
}
|
|
199
221
|
async identify(options) {
|
|
200
222
|
var userData = {
|
|
201
223
|
name: options.name,
|
|
@@ -233,6 +255,9 @@ export class GleapWeb extends WebPlugin {
|
|
|
233
255
|
// The JavaScript SDK records the page's requests itself on web.
|
|
234
256
|
return { networkLogsAttached: false };
|
|
235
257
|
}
|
|
258
|
+
async logsFlushed() {
|
|
259
|
+
// The JavaScript SDK collects the logs on web itself: nothing is buffered here.
|
|
260
|
+
}
|
|
236
261
|
async attachConsoleLogs() {
|
|
237
262
|
// The JavaScript SDK records the page's console itself on web.
|
|
238
263
|
return { consoleLogsAttached: false };
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,OAAO,QAAS,SAAQ,SAAS;IAAvC;;QAKU,+BAA0B,GAE9B,EAAE,CAAC;IAmsBT,CAAC;IAjsBC,KAAK,CAAC,UAAU,CAA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QAGnB;QACC,MAAM,IAAI,CAAC,WAAW,CAAC,0CAA0C,CAAC,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,MAAM,IAAI,CAAC,WAAW,CAAC,iDAAiD,CAAC,CAAC;IAC5E,CAAC;IAED,KAAK,CAAC,8BAA8B,CAAC,QAGpC;QACC,OAAO,EAAE,8BAA8B,EAAE,IAAI,EAAE,CAAC;IAClD,CAAC;IAEO,MAAM,CAAC,MAAc;QAC3B,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,UAAU,GACZ,gEAAgE,CAAC;QACnE,IAAI,gBAAgB,GAAG,UAAU,CAAC,MAAM,CAAC;QACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;YAC/B,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,gBAAgB,CAAC,CAAC,CAAC;SAC3E;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;;AAxsBM,kBAAS,GAA0C,EAAE,CAAC;AACtD,oBAAW,GAAG,KAAK,CAAC;AACpB,kCAAyB,GAAG,CAAC,CAAC","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport Gleap from 'gleap';\n\nimport type { GleapEventCallback, GleapPlugin } from './definitions';\n\nexport class GleapWeb extends WebPlugin implements GleapPlugin {\n static callbacks: { [key: string]: GleapEventCallback } = {};\n static initialized = false;\n static agentToolExecutionCounter = 0;\n\n private pendingAgentToolExecutions: {\n [executionId: string]: (result: string) => void;\n } = {};\n\n async initialize(options: {\n API_KEY: string;\n }): Promise<{ initialized: boolean }> {\n if (GleapWeb.initialized) {\n return { initialized: true };\n }\n\n Gleap.initialize(options.API_KEY);\n\n GleapWeb.initialized = true;\n this.registerCallbackListeners();\n\n return { initialized: true };\n }\n\n async setRegion(options: {\n region: 'eu' | 'us';\n }): Promise<{ region: string }> {\n if (!options?.region) {\n throw new Error('No region provided');\n }\n\n Gleap.setRegion(options.region);\n\n return { region: options.region };\n }\n\n async setApiUrl(options: { url: string }): Promise<{ url: string }> {\n if (!options?.url) {\n throw new Error('No url provided');\n }\n\n Gleap.setApiUrl(options.url);\n\n return { url: options.url };\n }\n\n async setWSApiUrl(options: { url: string }): Promise<{ url: string }> {\n if (!options?.url) {\n throw new Error('No url provided');\n }\n\n Gleap.setWSApiUrl(options.url);\n\n return { url: options.url };\n }\n\n async setRealtimeHost(options: { host: string }): Promise<{ host: string }> {\n if (!options?.host) {\n throw new Error('No host provided');\n }\n\n Gleap.setRealtimeHost(options.host);\n\n return { host: options.host };\n }\n\n async setFrameUrl(options: { url: string }): Promise<{ url: string }> {\n if (!options?.url) {\n throw new Error('No url provided');\n }\n\n Gleap.setFrameUrl(options.url);\n\n return { url: options.url };\n }\n\n async setBannerUrl(options: { url: string }): Promise<{ url: string }> {\n if (!options?.url) {\n throw new Error('No url provided');\n }\n\n Gleap.setBannerUrl(options.url);\n\n return { url: options.url };\n }\n\n async setModalUrl(options: { url: string }): Promise<{ url: string }> {\n if (!options?.url) {\n throw new Error('No url provided');\n }\n\n Gleap.setModalUrl(options.url);\n\n return { url: options.url };\n }\n\n registerCallbackListeners(): void {\n Gleap.on('open', () => {\n this.notifyCallbacks('open', {});\n });\n\n Gleap.on('initialized', () => {\n this.notifyCallbacks('initialized', {});\n });\n\n Gleap.on('close', () => {\n this.notifyCallbacks('close', {});\n });\n\n Gleap.on('feedback-sent', formData => {\n this.notifyCallbacks('feedback-sent', formData);\n });\n\n Gleap.on('outbound-sent', formData => {\n this.notifyCallbacks('outbound-sent', formData);\n });\n\n Gleap.on('tool-execution', toolExecution => {\n this.notifyCallbacks('tool-execution', toolExecution);\n });\n\n Gleap.on('flow-started', flow => {\n this.notifyCallbacks('flow-started', flow);\n });\n\n Gleap.on('error-while-sending', () => {\n this.notifyCallbacks('error-while-sending', {});\n });\n\n Gleap.on('unregister-pushmessage-group', groupName => {\n this.notifyCallbacks('unregister-pushmessage-group', groupName);\n });\n\n Gleap.on('register-pushmessage-group', groupName => {\n this.notifyCallbacks('register-pushmessage-group', groupName);\n });\n\n Gleap.on('unread-count-changed', groupName => {\n this.notifyCallbacks('notification-count-updated', groupName);\n });\n\n Gleap.registerCustomAction(customAction => {\n this.notifyCallbacks('custom-action-called', customAction);\n });\n }\n\n async registerAgentTool(options: { name: string }): Promise<void> {\n const gleapSdk = Gleap as any;\n if (typeof gleapSdk.registerAgentTool !== 'function') {\n console.warn(\n 'Gleap: registerAgentTool requires a newer version of the Gleap JS SDK.',\n );\n return;\n }\n\n gleapSdk.registerAgentTool(\n options.name,\n (params: any) =>\n new Promise<string>(resolve => {\n const executionId = `web-${++GleapWeb.agentToolExecutionCounter}`;\n this.pendingAgentToolExecutions[executionId] = resolve;\n\n this.notifyListeners('agentToolExecution', {\n executionId,\n name: options.name,\n params: params ?? {},\n });\n }),\n );\n }\n\n async sendAgentToolResult(options: {\n executionId: string;\n result: string;\n }): Promise<void> {\n const resolve = this.pendingAgentToolExecutions[options.executionId];\n if (resolve) {\n delete this.pendingAgentToolExecutions[options.executionId];\n resolve(options.result);\n }\n }\n\n async setTicketAttribute(options: {\n key: string;\n value: string;\n }): Promise<{ setTicketAttribute: boolean }> {\n Gleap.setTicketAttribute(options.key, options.value);\n\n return { setTicketAttribute: true };\n }\n\n async unsetTicketAttribute(options: {\n key: string;\n }): Promise<{ unsetTicketAttribute: boolean }> {\n Gleap.unsetTicketAttribute(options.key);\n\n return { unsetTicketAttribute: true };\n }\n\n async clearTicketAttributes(): Promise<{ clearTicketAttributes: boolean }> {\n Gleap.clearTicketAttributes();\n\n return { clearTicketAttributes: true };\n }\n\n notifyCallbacks(event: string, data: any): void {\n if (!GleapWeb.callbacks) {\n return;\n }\n\n for (var callbackId in GleapWeb.callbacks) {\n GleapWeb.callbacks[callbackId]({\n name: event,\n data,\n });\n }\n }\n\n async startClassicForm(options: {\n formId?: string | undefined;\n showBackButton?: boolean | undefined;\n }): Promise<{ classicFormStarted: boolean }> {\n Gleap.startClassicForm(options.formId ?? '', options.showBackButton);\n\n return { classicFormStarted: true };\n }\n\n async startConversation(options: {\n showBackButton?: boolean | undefined;\n }): Promise<{ conversationStarted: boolean }> {\n Gleap.startConversation(options.showBackButton);\n\n return { conversationStarted: true };\n }\n\n async openConversation(options: {\n showBackButton?: boolean | undefined;\n }): Promise<{ conversationsOpened: boolean }> {\n Gleap.openConversations(options.showBackButton);\n\n return { conversationsOpened: true };\n }\n\n async openConversations(options: {\n showBackButton?: boolean | undefined;\n }): Promise<{ conversationsOpened: boolean }> {\n Gleap.openConversations(options.showBackButton);\n\n return { conversationsOpened: true };\n }\n\n // The JavaScript SDK opens `?gleapFile=` links itself on page load.\n async openProtectedFileFromUrl(_options: {\n url: string;\n }): Promise<{ opened: boolean }> {\n return { opened: false };\n }\n\n async showSurvey(options: {\n surveyId: string;\n format?: 'survey' | 'survey_full' | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.showSurvey(options.surveyId, options.format);\n\n return { opened: true };\n }\n\n async showFeedbackButton(options: {\n show: boolean;\n }): Promise<{ feedbackButtonShown: boolean }> {\n Gleap.showFeedbackButton(options.show ? true : false);\n\n return { feedbackButtonShown: true };\n }\n\n async setDisableInAppNotifications(options: {\n disableInAppNotifications?: boolean | undefined;\n }): Promise<{ inAppNotificationsDisabled: boolean }> {\n Gleap.setDisableInAppNotifications(\n options.disableInAppNotifications ?? false,\n );\n\n return { inAppNotificationsDisabled: true };\n }\n\n async setDisableEnvData(options: {\n disableEnvData: boolean;\n }): Promise<{ envDataDisabled: boolean }> {\n Gleap.setDisableEnvData(options.disableEnvData ?? false);\n\n return { envDataDisabled: true };\n }\n\n async setColorScheme(options: {\n colorScheme: 'auto' | 'light' | 'dark';\n lightBackgroundColor?: string;\n darkBackgroundColor?: string;\n }): Promise<{ colorScheme: string }> {\n if (!options?.colorScheme) {\n throw new Error('No colorScheme provided');\n }\n\n Gleap.setColorScheme(options.colorScheme, {\n lightBackgroundColor: options.lightBackgroundColor,\n darkBackgroundColor: options.darkBackgroundColor,\n });\n\n return { colorScheme: options.colorScheme };\n }\n\n async identify(options: {\n userId: string;\n userHash?: string | undefined;\n customData?: Record<string, any> | undefined;\n name?: string | undefined;\n email?: string | undefined;\n phone?: string | undefined;\n companyId?: string | undefined;\n companyName?: string | undefined;\n avatar?: string | undefined;\n sla?: number | undefined;\n plan?: string | undefined;\n value?: number | undefined;\n }): Promise<{ identify: boolean }> {\n var userData = {\n name: options.name,\n email: options.email,\n phone: options.phone,\n companyId: options.companyId,\n companyName: options.companyName,\n avatar: options.avatar,\n sla: options.sla,\n plan: options.plan,\n value: options.value,\n customData: options.customData,\n };\n if (options.userHash) {\n Gleap.identify(options.userId, userData, options.userHash);\n } else {\n Gleap.identify(options.userId, userData);\n }\n\n return { identify: true };\n }\n\n async updateContact(options: {\n name?: string | undefined;\n email?: string | undefined;\n phone?: string | undefined;\n companyId?: string | undefined;\n companyName?: string | undefined;\n avatar?: string | undefined;\n sla?: number | undefined;\n plan?: string | undefined;\n value?: number | undefined;\n customData?: Record<string, any> | undefined;\n }): Promise<{ identify: boolean }> {\n Gleap.updateContact(options);\n\n return { identify: true };\n }\n\n async setNetworkLogsBlacklist(options: {\n blacklist: string[];\n }): Promise<{ blacklistSet: boolean }> {\n Gleap.setNetworkLogsBlacklist(options.blacklist);\n\n return { blacklistSet: true };\n }\n\n async setNetworkLogPropsToIgnore(options: {\n propsToIgnore: string[];\n }): Promise<{ propsToIgnoreSet: boolean }> {\n Gleap.setNetworkLogPropsToIgnore(options.propsToIgnore);\n\n return { propsToIgnoreSet: true };\n }\n\n async attachNetworkLogs(): Promise<{ networkLogsAttached: boolean }> {\n // The JavaScript SDK records the page's requests itself on web.\n return { networkLogsAttached: false };\n }\n\n async attachConsoleLogs(): Promise<{ consoleLogsAttached: boolean }> {\n // The JavaScript SDK records the page's console itself on web.\n return { consoleLogsAttached: false };\n }\n\n async setEnvDataPropsToIgnore(options: {\n propsToIgnore: string[];\n }): Promise<{ envDataPropsToIgnoreSet: boolean }> {\n Gleap.setEnvDataPropsToIgnore(options.propsToIgnore);\n\n return { envDataPropsToIgnoreSet: true };\n }\n\n async setTags(options: { tags: string[] }): Promise<{ tagsSet: boolean }> {\n Gleap.setTags(options.tags);\n\n return { tagsSet: true };\n }\n\n async clearIdentity(): Promise<{ clearIdentity: boolean }> {\n Gleap.clearIdentity();\n\n return { clearIdentity: true };\n }\n\n async getIdentity(): Promise<{\n identity: {\n userId: string;\n name?: string | undefined;\n email?: string | undefined;\n phone?: string | undefined;\n companyId?: string | undefined;\n companyName?: string | undefined;\n avatar?: string | undefined;\n sla?: number | undefined;\n plan?: string | undefined;\n value?: number | undefined;\n };\n }> {\n return { identity: Gleap.getIdentity() };\n }\n\n async isUserIdentified(): Promise<{ isUserIdentified: boolean }> {\n return { isUserIdentified: Gleap.isUserIdentified() };\n }\n\n async attachCustomData(options: {\n data: any;\n }): Promise<{ attachedCustomData: boolean }> {\n Gleap.attachCustomData(options.data);\n\n return { attachedCustomData: true };\n }\n\n async setCustomData(options: {\n key: string;\n value: string;\n }): Promise<{ setCustomData: boolean }> {\n Gleap.setCustomData(options.key, options.value);\n\n return { setCustomData: true };\n }\n\n async removeCustomData(options: {\n key: string;\n }): Promise<{ removedCustomData: boolean }> {\n Gleap.removeCustomData(options.key);\n\n return { removedCustomData: true };\n }\n\n async clearCustomData(): Promise<{ clearedCustomData: boolean }> {\n Gleap.clearCustomData();\n\n return { clearedCustomData: true };\n }\n\n async trackEvent(options: {\n name: string;\n data?: any;\n }): Promise<{ loggedEvent: boolean }> {\n Gleap.trackEvent(options.name, options.data);\n\n return { loggedEvent: true };\n }\n\n async trackPage(options: {\n pageName: string;\n }): Promise<{ trackedPage: boolean }> {\n Gleap.trackEvent('pageView', {\n page: options.pageName,\n });\n\n return { trackedPage: true };\n }\n\n async startFeedbackFlow(options: {\n feedbackFlow?: string | undefined;\n showBackButton?: boolean | undefined;\n }): Promise<{ startedFeedbackFlow: boolean }> {\n if (!options.feedbackFlow) {\n }\n\n Gleap.startFeedbackFlow(\n options.feedbackFlow ?? 'bugreporting',\n options.showBackButton,\n );\n\n return { startedFeedbackFlow: true };\n }\n\n async startBot(options: {\n botId?: string | undefined;\n showBackButton?: boolean | undefined;\n }): Promise<{ startedBot: boolean }> {\n if (!options.botId) {\n }\n\n Gleap.startBot(options.botId ?? '', options.showBackButton);\n\n return { startedBot: true };\n }\n\n async setLanguage(options: {\n languageCode: string;\n }): Promise<{ setLanguage: string }> {\n Gleap.setLanguage(options.languageCode);\n\n return { setLanguage: options.languageCode };\n }\n\n async log(options: {\n message: string;\n logLevel?: 'ERROR' | 'WARNING' | 'INFO' | undefined;\n }): Promise<{ logged: boolean }> {\n Gleap.log(options.message, options.logLevel);\n\n return { logged: true };\n }\n\n async setEventCallback(callback: GleapEventCallback): Promise<string> {\n var callbackId = this.makeid(10);\n GleapWeb.callbacks[callbackId] = callback;\n return callbackId;\n }\n\n async sendSilentCrashReport(options: {\n description: string;\n severity?: 'LOW' | 'MEDIUM' | 'HIGH' | undefined;\n dataExclusion?:\n | {\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 | undefined;\n }): Promise<{ sentSilentBugReport: boolean }> {\n Gleap.sendSilentCrashReport(\n options.description,\n options.severity,\n options.dataExclusion,\n );\n\n return { sentSilentBugReport: true };\n }\n\n async open(): Promise<{ openedWidget: boolean }> {\n Gleap.open();\n\n return { openedWidget: true };\n }\n\n async openChecklists(options: {\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.openChecklists(options.showBackButton);\n\n return { opened: true };\n }\n\n async openChecklist(options: {\n checklistId: string;\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.openChecklist(options.checklistId, options.showBackButton);\n\n return { opened: true };\n }\n\n async startChecklist(options: {\n outboundId: string;\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.startChecklist(options.outboundId, options.showBackButton);\n\n return { opened: true };\n }\n\n async openFeatureRequests(options: {\n showBackButton?: boolean | undefined;\n }): Promise<{ openedFeatureRequests: boolean }> {\n Gleap.openFeatureRequests(options.showBackButton);\n\n return { openedFeatureRequests: true };\n }\n\n async openNews(options: {\n showBackButton?: boolean | undefined;\n }): Promise<{ openedNews: boolean }> {\n Gleap.openNews(options.showBackButton);\n\n return { openedNews: true };\n }\n\n async openNewsArticle(options: {\n articleId: string;\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.openNewsArticle(options.articleId, options.showBackButton);\n\n return { opened: true };\n }\n\n async openHelpCenter(options: {\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.openHelpCenter(options.showBackButton);\n\n return { opened: true };\n }\n\n async openHelpCenterArticle(options: {\n articleId: string;\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.openHelpCenterArticle(options.articleId, options.showBackButton);\n\n return { opened: true };\n }\n\n async askAI(options: {\n question: string;\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.askAI(options.question, options.showBackButton);\n\n return { opened: true };\n }\n\n async openHelpCenterCollection(options: {\n collectionId: string;\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.openHelpCenterCollection(\n options.collectionId,\n options.showBackButton,\n );\n\n return { opened: true };\n }\n\n async searchHelpCenter(options: {\n term: string;\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.searchHelpCenter(options.term, options.showBackButton);\n\n return { opened: true };\n }\n\n async close(): Promise<{ closedWidget: boolean }> {\n Gleap.close();\n\n return { closedWidget: true };\n }\n\n async isOpened(): Promise<{ isOpened: boolean }> {\n return { isOpened: Gleap.isOpened() };\n }\n\n async disableConsoleLogOverwrite(): Promise<{ consoleLogDisabled: boolean }> {\n Gleap.disableConsoleLogOverwrite();\n\n return { consoleLogDisabled: true };\n }\n\n async enableDebugConsoleLog(): Promise<{ debugConsoleLogEnabled: boolean }> {\n return { debugConsoleLogEnabled: true };\n }\n\n async preFillForm(options: {\n data: any;\n }): Promise<{ preFilledForm: boolean }> {\n Gleap.preFillForm(options.data);\n\n return { preFilledForm: true };\n }\n\n async addAttachment(_options: {\n base64data: string;\n name: string;\n }): Promise<{ attachmentAdded: boolean }> {\n throw this.unavailable('addAttachment not available for browsers');\n }\n\n async removeAllAttachments(): Promise<{ allAttachmentsRemoved: boolean }> {\n throw this.unavailable('removeAllAttachments not available for browsers');\n }\n\n async setNotificationContainerOffset(_options: {\n x: number;\n y: number;\n }): Promise<{ notificationContainerOffsetSet: boolean }> {\n return { notificationContainerOffsetSet: true };\n }\n\n private makeid(length: number): string {\n var result = '';\n var characters =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n var charactersLength = characters.length;\n for (var i = 0; i < length; i++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n return result;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,OAAO,QAAS,SAAQ,SAAS;IAAvC;;QAKU,+BAA0B,GAE9B,EAAE,CAAC;IA2uBT,CAAC;IAzuBC,KAAK,CAAC,UAAU,CAAC,OAEhB;QACC,IAAI,QAAQ,CAAC,WAAW,EAAE;YACxB,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;SAC9B;QAED,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAElC,QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,yBAAyB,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KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,gBAAgB,CAAC,CAAC,CAAC;SAC3E;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;;AAhvBM,kBAAS,GAA0C,EAAE,CAAC;AACtD,oBAAW,GAAG,KAAK,CAAC;AACpB,kCAAyB,GAAG,CAAC,CAAC","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport Gleap from 'gleap';\n\nimport type { GleapEventCallback, GleapPlugin } from './definitions';\n\nexport class GleapWeb extends WebPlugin implements GleapPlugin {\n static callbacks: { [key: string]: GleapEventCallback } = {};\n static initialized = false;\n static agentToolExecutionCounter = 0;\n\n private pendingAgentToolExecutions: {\n [executionId: string]: (result: string) => void;\n } = {};\n\n async initialize(options: {\n API_KEY: string;\n }): Promise<{ initialized: boolean }> {\n if (GleapWeb.initialized) {\n return { initialized: true };\n }\n\n Gleap.initialize(options.API_KEY);\n\n GleapWeb.initialized = true;\n this.registerCallbackListeners();\n\n return { initialized: true };\n }\n\n async setRegion(options: {\n region: 'eu' | 'us';\n }): Promise<{ region: string }> {\n if (!options?.region) {\n throw new Error('No region provided');\n }\n\n Gleap.setRegion(options.region);\n\n return { region: options.region };\n }\n\n async setApiUrl(options: { url: string }): Promise<{ url: string }> {\n if (!options?.url) {\n throw new Error('No url provided');\n }\n\n Gleap.setApiUrl(options.url);\n\n return { url: options.url };\n }\n\n async setWSApiUrl(options: { url: string }): Promise<{ url: string }> {\n if (!options?.url) {\n throw new Error('No url provided');\n }\n\n Gleap.setWSApiUrl(options.url);\n\n return { url: options.url };\n }\n\n async setRealtimeHost(options: { host: string }): Promise<{ host: string }> {\n if (!options?.host) {\n throw new Error('No host provided');\n }\n\n Gleap.setRealtimeHost(options.host);\n\n return { host: options.host };\n }\n\n async setFrameUrl(options: { url: string }): Promise<{ url: string }> {\n if (!options?.url) {\n throw new Error('No url provided');\n }\n\n Gleap.setFrameUrl(options.url);\n\n return { url: options.url };\n }\n\n async setBannerUrl(options: { url: string }): Promise<{ url: string }> {\n if (!options?.url) {\n throw new Error('No url provided');\n }\n\n Gleap.setBannerUrl(options.url);\n\n return { url: options.url };\n }\n\n async setModalUrl(options: { url: string }): Promise<{ url: string }> {\n if (!options?.url) {\n throw new Error('No url provided');\n }\n\n Gleap.setModalUrl(options.url);\n\n return { url: options.url };\n }\n\n registerCallbackListeners(): void {\n Gleap.on('open', () => {\n this.notifyCallbacks('open', {});\n });\n\n Gleap.on('initialized', () => {\n this.notifyCallbacks('initialized', {});\n });\n\n Gleap.on('close', () => {\n this.notifyCallbacks('close', {});\n });\n\n Gleap.on('feedback-sent', formData => {\n this.notifyCallbacks('feedback-sent', formData);\n });\n\n Gleap.on('outbound-sent', formData => {\n this.notifyCallbacks('outbound-sent', formData);\n });\n\n Gleap.on('tool-execution', toolExecution => {\n this.notifyCallbacks('tool-execution', toolExecution);\n });\n\n Gleap.on('flow-started', flow => {\n this.notifyCallbacks('flow-started', flow);\n });\n\n Gleap.on('error-while-sending', () => {\n this.notifyCallbacks('error-while-sending', {});\n });\n\n Gleap.on('unregister-pushmessage-group', groupName => {\n this.notifyCallbacks('unregister-pushmessage-group', groupName);\n });\n\n Gleap.on('register-pushmessage-group', groupName => {\n this.notifyCallbacks('register-pushmessage-group', groupName);\n });\n\n Gleap.on('unread-count-changed', groupName => {\n this.notifyCallbacks('notification-count-updated', groupName);\n });\n\n Gleap.registerCustomAction(customAction => {\n this.notifyCallbacks('custom-action-called', customAction);\n });\n }\n\n async registerAgentTool(options: { name: string }): Promise<void> {\n const gleapSdk = Gleap as any;\n if (typeof gleapSdk.registerAgentTool !== 'function') {\n console.warn(\n 'Gleap: registerAgentTool requires a newer version of the Gleap JS SDK.',\n );\n return;\n }\n\n gleapSdk.registerAgentTool(\n options.name,\n (params: any) =>\n new Promise<string>(resolve => {\n const executionId = `web-${++GleapWeb.agentToolExecutionCounter}`;\n this.pendingAgentToolExecutions[executionId] = resolve;\n\n this.notifyListeners('agentToolExecution', {\n executionId,\n name: options.name,\n params: params ?? {},\n });\n }),\n );\n }\n\n async sendAgentToolResult(options: {\n executionId: string;\n result: string;\n }): Promise<void> {\n const resolve = this.pendingAgentToolExecutions[options.executionId];\n if (resolve) {\n delete this.pendingAgentToolExecutions[options.executionId];\n resolve(options.result);\n }\n }\n\n async setTicketAttribute(options: {\n key: string;\n value: string;\n }): Promise<{ setTicketAttribute: boolean }> {\n Gleap.setTicketAttribute(options.key, options.value);\n\n return { setTicketAttribute: true };\n }\n\n async unsetTicketAttribute(options: {\n key: string;\n }): Promise<{ unsetTicketAttribute: boolean }> {\n Gleap.unsetTicketAttribute(options.key);\n\n return { unsetTicketAttribute: true };\n }\n\n async clearTicketAttributes(): Promise<{ clearTicketAttributes: boolean }> {\n Gleap.clearTicketAttributes();\n\n return { clearTicketAttributes: true };\n }\n\n notifyCallbacks(event: string, data: any): void {\n if (!GleapWeb.callbacks) {\n return;\n }\n\n for (var callbackId in GleapWeb.callbacks) {\n GleapWeb.callbacks[callbackId]({\n name: event,\n data,\n });\n }\n }\n\n async startClassicForm(options: {\n formId?: string | undefined;\n showBackButton?: boolean | undefined;\n }): Promise<{ classicFormStarted: boolean }> {\n Gleap.startClassicForm(options.formId ?? '', options.showBackButton);\n\n return { classicFormStarted: true };\n }\n\n async startConversation(options: {\n showBackButton?: boolean | undefined;\n }): Promise<{ conversationStarted: boolean }> {\n Gleap.startConversation(options.showBackButton);\n\n return { conversationStarted: true };\n }\n\n async openConversation(options: {\n showBackButton?: boolean | undefined;\n }): Promise<{ conversationsOpened: boolean }> {\n Gleap.openConversations(options.showBackButton);\n\n return { conversationsOpened: true };\n }\n\n async openConversations(options: {\n showBackButton?: boolean | undefined;\n }): Promise<{ conversationsOpened: boolean }> {\n Gleap.openConversations(options.showBackButton);\n\n return { conversationsOpened: true };\n }\n\n // The JavaScript SDK opens `?gleapFile=` links itself on page load.\n async openProtectedFileFromUrl(_options: {\n url: string;\n }): Promise<{ opened: boolean }> {\n return { opened: false };\n }\n\n async showSurvey(options: {\n surveyId: string;\n format?: 'survey' | 'survey_full' | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.showSurvey(options.surveyId, options.format);\n\n return { opened: true };\n }\n\n async showFeedbackButton(options: {\n show: boolean;\n }): Promise<{ feedbackButtonShown: boolean }> {\n Gleap.showFeedbackButton(options.show ? true : false);\n\n return { feedbackButtonShown: true };\n }\n\n async setDisableInAppNotifications(options: {\n disableInAppNotifications?: boolean | undefined;\n }): Promise<{ inAppNotificationsDisabled: boolean }> {\n Gleap.setDisableInAppNotifications(\n options.disableInAppNotifications ?? false,\n );\n\n return { inAppNotificationsDisabled: true };\n }\n\n async setDisableEnvData(options: {\n disableEnvData: boolean;\n }): Promise<{ envDataDisabled: boolean }> {\n Gleap.setDisableEnvData(options.disableEnvData ?? false);\n\n return { envDataDisabled: true };\n }\n\n async setColorScheme(options: {\n colorScheme: 'auto' | 'light' | 'dark';\n lightBackgroundColor?: string;\n darkBackgroundColor?: string;\n }): Promise<{ colorScheme: string }> {\n if (!options?.colorScheme) {\n throw new Error('No colorScheme provided');\n }\n\n Gleap.setColorScheme(options.colorScheme, {\n lightBackgroundColor: options.lightBackgroundColor,\n darkBackgroundColor: options.darkBackgroundColor,\n });\n\n return { colorScheme: options.colorScheme };\n }\n\n async setCaptureEnabled(options: {\n enabled: boolean;\n }): Promise<{ captureEnabled: boolean }> {\n if (typeof options?.enabled !== 'boolean') {\n throw new Error('No enabled value provided');\n }\n\n // A JavaScript SDK older than capture requests has nothing to switch.\n const jsSdk = Gleap as unknown as {\n setCaptureEnabled?: (enabled: boolean) => void;\n };\n if (typeof jsSdk.setCaptureEnabled === 'function') {\n jsSdk.setCaptureEnabled(options.enabled);\n }\n\n return { captureEnabled: options.enabled };\n }\n\n async setRemoteLogCollectionEnabled(options: {\n enabled: boolean;\n }): Promise<{ remoteLogCollectionEnabled: boolean }> {\n if (typeof options?.enabled !== 'boolean') {\n throw new Error('No enabled value provided');\n }\n\n // A JavaScript SDK older than capture requests has nothing to switch.\n const jsSdk = Gleap as unknown as {\n setRemoteLogCollectionEnabled?: (enabled: boolean) => void;\n };\n if (typeof jsSdk.setRemoteLogCollectionEnabled === 'function') {\n jsSdk.setRemoteLogCollectionEnabled(options.enabled);\n }\n\n return { remoteLogCollectionEnabled: options.enabled };\n }\n\n async identify(options: {\n userId: string;\n userHash?: string | undefined;\n customData?: Record<string, any> | undefined;\n name?: string | undefined;\n email?: string | undefined;\n phone?: string | undefined;\n companyId?: string | undefined;\n companyName?: string | undefined;\n avatar?: string | undefined;\n sla?: number | undefined;\n plan?: string | undefined;\n value?: number | undefined;\n }): Promise<{ identify: boolean }> {\n var userData = {\n name: options.name,\n email: options.email,\n phone: options.phone,\n companyId: options.companyId,\n companyName: options.companyName,\n avatar: options.avatar,\n sla: options.sla,\n plan: options.plan,\n value: options.value,\n customData: options.customData,\n };\n if (options.userHash) {\n Gleap.identify(options.userId, userData, options.userHash);\n } else {\n Gleap.identify(options.userId, userData);\n }\n\n return { identify: true };\n }\n\n async updateContact(options: {\n name?: string | undefined;\n email?: string | undefined;\n phone?: string | undefined;\n companyId?: string | undefined;\n companyName?: string | undefined;\n avatar?: string | undefined;\n sla?: number | undefined;\n plan?: string | undefined;\n value?: number | undefined;\n customData?: Record<string, any> | undefined;\n }): Promise<{ identify: boolean }> {\n Gleap.updateContact(options);\n\n return { identify: true };\n }\n\n async setNetworkLogsBlacklist(options: {\n blacklist: string[];\n }): Promise<{ blacklistSet: boolean }> {\n Gleap.setNetworkLogsBlacklist(options.blacklist);\n\n return { blacklistSet: true };\n }\n\n async setNetworkLogPropsToIgnore(options: {\n propsToIgnore: string[];\n }): Promise<{ propsToIgnoreSet: boolean }> {\n Gleap.setNetworkLogPropsToIgnore(options.propsToIgnore);\n\n return { propsToIgnoreSet: true };\n }\n\n async attachNetworkLogs(): Promise<{ networkLogsAttached: boolean }> {\n // The JavaScript SDK records the page's requests itself on web.\n return { networkLogsAttached: false };\n }\n\n async logsFlushed(): Promise<void> {\n // The JavaScript SDK collects the logs on web itself: nothing is buffered here.\n }\n\n async attachConsoleLogs(): Promise<{ consoleLogsAttached: boolean }> {\n // The JavaScript SDK records the page's console itself on web.\n return { consoleLogsAttached: false };\n }\n\n async setEnvDataPropsToIgnore(options: {\n propsToIgnore: string[];\n }): Promise<{ envDataPropsToIgnoreSet: boolean }> {\n Gleap.setEnvDataPropsToIgnore(options.propsToIgnore);\n\n return { envDataPropsToIgnoreSet: true };\n }\n\n async setTags(options: { tags: string[] }): Promise<{ tagsSet: boolean }> {\n Gleap.setTags(options.tags);\n\n return { tagsSet: true };\n }\n\n async clearIdentity(): Promise<{ clearIdentity: boolean }> {\n Gleap.clearIdentity();\n\n return { clearIdentity: true };\n }\n\n async getIdentity(): Promise<{\n identity: {\n userId: string;\n name?: string | undefined;\n email?: string | undefined;\n phone?: string | undefined;\n companyId?: string | undefined;\n companyName?: string | undefined;\n avatar?: string | undefined;\n sla?: number | undefined;\n plan?: string | undefined;\n value?: number | undefined;\n };\n }> {\n return { identity: Gleap.getIdentity() };\n }\n\n async isUserIdentified(): Promise<{ isUserIdentified: boolean }> {\n return { isUserIdentified: Gleap.isUserIdentified() };\n }\n\n async attachCustomData(options: {\n data: any;\n }): Promise<{ attachedCustomData: boolean }> {\n Gleap.attachCustomData(options.data);\n\n return { attachedCustomData: true };\n }\n\n async setCustomData(options: {\n key: string;\n value: string;\n }): Promise<{ setCustomData: boolean }> {\n Gleap.setCustomData(options.key, options.value);\n\n return { setCustomData: true };\n }\n\n async removeCustomData(options: {\n key: string;\n }): Promise<{ removedCustomData: boolean }> {\n Gleap.removeCustomData(options.key);\n\n return { removedCustomData: true };\n }\n\n async clearCustomData(): Promise<{ clearedCustomData: boolean }> {\n Gleap.clearCustomData();\n\n return { clearedCustomData: true };\n }\n\n async trackEvent(options: {\n name: string;\n data?: any;\n }): Promise<{ loggedEvent: boolean }> {\n Gleap.trackEvent(options.name, options.data);\n\n return { loggedEvent: true };\n }\n\n async trackPage(options: {\n pageName: string;\n }): Promise<{ trackedPage: boolean }> {\n Gleap.trackEvent('pageView', {\n page: options.pageName,\n });\n\n return { trackedPage: true };\n }\n\n async startFeedbackFlow(options: {\n feedbackFlow?: string | undefined;\n showBackButton?: boolean | undefined;\n }): Promise<{ startedFeedbackFlow: boolean }> {\n if (!options.feedbackFlow) {\n }\n\n Gleap.startFeedbackFlow(\n options.feedbackFlow ?? 'bugreporting',\n options.showBackButton,\n );\n\n return { startedFeedbackFlow: true };\n }\n\n async startBot(options: {\n botId?: string | undefined;\n showBackButton?: boolean | undefined;\n }): Promise<{ startedBot: boolean }> {\n if (!options.botId) {\n }\n\n Gleap.startBot(options.botId ?? '', options.showBackButton);\n\n return { startedBot: true };\n }\n\n async setLanguage(options: {\n languageCode: string;\n }): Promise<{ setLanguage: string }> {\n Gleap.setLanguage(options.languageCode);\n\n return { setLanguage: options.languageCode };\n }\n\n async log(options: {\n message: string;\n logLevel?: 'ERROR' | 'WARNING' | 'INFO' | undefined;\n }): Promise<{ logged: boolean }> {\n Gleap.log(options.message, options.logLevel);\n\n return { logged: true };\n }\n\n async setEventCallback(callback: GleapEventCallback): Promise<string> {\n var callbackId = this.makeid(10);\n GleapWeb.callbacks[callbackId] = callback;\n return callbackId;\n }\n\n async sendSilentCrashReport(options: {\n description: string;\n severity?: 'LOW' | 'MEDIUM' | 'HIGH' | undefined;\n dataExclusion?:\n | {\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 | undefined;\n }): Promise<{ sentSilentBugReport: boolean }> {\n Gleap.sendSilentCrashReport(\n options.description,\n options.severity,\n options.dataExclusion,\n );\n\n return { sentSilentBugReport: true };\n }\n\n async open(): Promise<{ openedWidget: boolean }> {\n Gleap.open();\n\n return { openedWidget: true };\n }\n\n async openChecklists(options: {\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.openChecklists(options.showBackButton);\n\n return { opened: true };\n }\n\n async openChecklist(options: {\n checklistId: string;\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.openChecklist(options.checklistId, options.showBackButton);\n\n return { opened: true };\n }\n\n async startChecklist(options: {\n outboundId: string;\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.startChecklist(options.outboundId, options.showBackButton);\n\n return { opened: true };\n }\n\n async openFeatureRequests(options: {\n showBackButton?: boolean | undefined;\n }): Promise<{ openedFeatureRequests: boolean }> {\n Gleap.openFeatureRequests(options.showBackButton);\n\n return { openedFeatureRequests: true };\n }\n\n async openNews(options: {\n showBackButton?: boolean | undefined;\n }): Promise<{ openedNews: boolean }> {\n Gleap.openNews(options.showBackButton);\n\n return { openedNews: true };\n }\n\n async openNewsArticle(options: {\n articleId: string;\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.openNewsArticle(options.articleId, options.showBackButton);\n\n return { opened: true };\n }\n\n async openHelpCenter(options: {\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.openHelpCenter(options.showBackButton);\n\n return { opened: true };\n }\n\n async openHelpCenterArticle(options: {\n articleId: string;\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.openHelpCenterArticle(options.articleId, options.showBackButton);\n\n return { opened: true };\n }\n\n async askAI(options: {\n question: string;\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.askAI(options.question, options.showBackButton);\n\n return { opened: true };\n }\n\n async openHelpCenterCollection(options: {\n collectionId: string;\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.openHelpCenterCollection(\n options.collectionId,\n options.showBackButton,\n );\n\n return { opened: true };\n }\n\n async searchHelpCenter(options: {\n term: string;\n showBackButton?: boolean | undefined;\n }): Promise<{ opened: boolean }> {\n Gleap.searchHelpCenter(options.term, options.showBackButton);\n\n return { opened: true };\n }\n\n async close(): Promise<{ closedWidget: boolean }> {\n Gleap.close();\n\n return { closedWidget: true };\n }\n\n async isOpened(): Promise<{ isOpened: boolean }> {\n return { isOpened: Gleap.isOpened() };\n }\n\n async disableConsoleLogOverwrite(): Promise<{ consoleLogDisabled: boolean }> {\n Gleap.disableConsoleLogOverwrite();\n\n return { consoleLogDisabled: true };\n }\n\n async enableDebugConsoleLog(): Promise<{ debugConsoleLogEnabled: boolean }> {\n return { debugConsoleLogEnabled: true };\n }\n\n async preFillForm(options: {\n data: any;\n }): Promise<{ preFilledForm: boolean }> {\n Gleap.preFillForm(options.data);\n\n return { preFilledForm: true };\n }\n\n async addAttachment(_options: {\n base64data: string;\n name: string;\n }): Promise<{ attachmentAdded: boolean }> {\n throw this.unavailable('addAttachment not available for browsers');\n }\n\n async removeAllAttachments(): Promise<{ allAttachmentsRemoved: boolean }> {\n throw this.unavailable('removeAllAttachments not available for browsers');\n }\n\n async setNotificationContainerOffset(_options: {\n x: number;\n y: number;\n }): Promise<{ notificationContainerOffsetSet: boolean }> {\n return { notificationContainerOffsetSet: true };\n }\n\n private makeid(length: number): string {\n var result = '';\n var characters =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n var charactersLength = characters.length;\n for (var i = 0; i < length; i++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n return result;\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -1981,6 +1981,7 @@ class WebViewLogCapture {
|
|
|
1981
1981
|
// logs are enabled (like the JavaScript SDK), so nothing is held in memory before that.
|
|
1982
1982
|
this.networkCapture.install();
|
|
1983
1983
|
this.listenForConfig();
|
|
1984
|
+
this.listenForFlush();
|
|
1984
1985
|
}
|
|
1985
1986
|
/**
|
|
1986
1987
|
* Android debug builds (Capacitor's loggingBehavior) write the WebView console to logcat, which the
|
|
@@ -2003,6 +2004,36 @@ class WebViewLogCapture {
|
|
|
2003
2004
|
// The native side predates the event: network logs stay off.
|
|
2004
2005
|
}
|
|
2005
2006
|
}
|
|
2007
|
+
/**
|
|
2008
|
+
* Capture requests: right before the native SDK collects the logs for a request, it asks for what is still
|
|
2009
|
+
* buffered here (pushed at most every PUSH_DELAY_MS otherwise) and waits up to 500 ms for the answer.
|
|
2010
|
+
*/
|
|
2011
|
+
listenForFlush() {
|
|
2012
|
+
try {
|
|
2013
|
+
const handle = this.target.addListener('flushLogs', (data) => {
|
|
2014
|
+
const flushId = data && typeof data.flushId === 'string' ? data.flushId : null;
|
|
2015
|
+
runOutsideZone(() => this.flushNow().then(() => {
|
|
2016
|
+
if (flushId) {
|
|
2017
|
+
this.answerFlush(flushId);
|
|
2018
|
+
}
|
|
2019
|
+
}));
|
|
2020
|
+
});
|
|
2021
|
+
if (handle && typeof handle.catch === 'function') {
|
|
2022
|
+
handle.catch(() => undefined);
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
catch (e) {
|
|
2026
|
+
// The native side predates the event: nothing asks for flushes.
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
answerFlush(flushId) {
|
|
2030
|
+
try {
|
|
2031
|
+
Promise.resolve(this.target.logsFlushed({ flushId })).catch(() => undefined);
|
|
2032
|
+
}
|
|
2033
|
+
catch (e) {
|
|
2034
|
+
// The native side gives up waiting after 500 ms.
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2006
2037
|
applyRemoteConfig(config) {
|
|
2007
2038
|
try {
|
|
2008
2039
|
if (!config || typeof config !== 'object') {
|
|
@@ -2045,15 +2076,20 @@ class WebViewLogCapture {
|
|
|
2045
2076
|
this.markDirty(this.consoleChannel);
|
|
2046
2077
|
this.markDirty(this.networkChannel);
|
|
2047
2078
|
}
|
|
2048
|
-
/**
|
|
2079
|
+
/**
|
|
2080
|
+
* Pushes pending changes now (before a plugin call that can produce a report, or when the native SDK collects the
|
|
2081
|
+
* logs for a capture request). Resolves once the native side took them; never rejects.
|
|
2082
|
+
*/
|
|
2049
2083
|
flushNow() {
|
|
2084
|
+
const pushes = [];
|
|
2050
2085
|
try {
|
|
2051
|
-
this.flushChannel(this.consoleChannel);
|
|
2052
|
-
this.flushChannel(this.networkChannel);
|
|
2086
|
+
pushes.push(this.flushChannel(this.consoleChannel));
|
|
2087
|
+
pushes.push(this.flushChannel(this.networkChannel));
|
|
2053
2088
|
}
|
|
2054
2089
|
catch (e) {
|
|
2055
2090
|
// Ignore.
|
|
2056
2091
|
}
|
|
2092
|
+
return Promise.all(pushes).then(() => undefined, () => undefined);
|
|
2057
2093
|
}
|
|
2058
2094
|
updateRules() {
|
|
2059
2095
|
this.rules = createRedactionRules([...this.remoteProps, ...this.localProps], [...this.remoteBlacklist, ...this.localBlacklist]);
|
|
@@ -2084,20 +2120,21 @@ class WebViewLogCapture {
|
|
|
2084
2120
|
channel.timer = null;
|
|
2085
2121
|
}
|
|
2086
2122
|
}
|
|
2123
|
+
/** Resolves once the push it started (if any) was answered; never rejects. */
|
|
2087
2124
|
flushChannel(channel) {
|
|
2088
2125
|
if (channel.timer !== null) {
|
|
2089
2126
|
clearTimeout(channel.timer);
|
|
2090
2127
|
channel.timer = null;
|
|
2091
2128
|
}
|
|
2092
2129
|
if (!channel.isDirty || !this.canPush(channel)) {
|
|
2093
|
-
return;
|
|
2130
|
+
return Promise.resolve();
|
|
2094
2131
|
}
|
|
2095
2132
|
channel.isDirty = false;
|
|
2096
2133
|
let push;
|
|
2097
2134
|
if (channel.name === 'console') {
|
|
2098
2135
|
const logs = this.consoleCapture ? this.consoleCapture.getEntries() : [];
|
|
2099
2136
|
if (logs.length === 0 && !channel.hasPushedLogs) {
|
|
2100
|
-
return;
|
|
2137
|
+
return Promise.resolve();
|
|
2101
2138
|
}
|
|
2102
2139
|
channel.hasPushedLogs = logs.length > 0;
|
|
2103
2140
|
push = runOutsideZone(() => this.target.attachConsoleLogs({ logs }));
|
|
@@ -2105,18 +2142,19 @@ class WebViewLogCapture {
|
|
|
2105
2142
|
else {
|
|
2106
2143
|
const logs = this.isNetworkEnabled ? this.buildNetworkLogs() : [];
|
|
2107
2144
|
if (logs.length === 0 && !channel.hasPushedLogs) {
|
|
2108
|
-
return;
|
|
2145
|
+
return Promise.resolve();
|
|
2109
2146
|
}
|
|
2110
2147
|
channel.hasPushedLogs = logs.length > 0;
|
|
2111
2148
|
push = runOutsideZone(() => this.target.attachNetworkLogs({ logs }));
|
|
2112
2149
|
}
|
|
2113
2150
|
try {
|
|
2114
|
-
Promise.resolve(push).then(() => {
|
|
2151
|
+
return Promise.resolve(push).then(() => {
|
|
2115
2152
|
channel.failures = 0;
|
|
2116
2153
|
}, () => this.onPushFailed(channel));
|
|
2117
2154
|
}
|
|
2118
2155
|
catch (e) {
|
|
2119
2156
|
this.onPushFailed(channel);
|
|
2157
|
+
return Promise.resolve();
|
|
2120
2158
|
}
|
|
2121
2159
|
}
|
|
2122
2160
|
onPushFailed(channel) {
|
|
@@ -2473,6 +2511,28 @@ class GleapWeb extends core.WebPlugin {
|
|
|
2473
2511
|
});
|
|
2474
2512
|
return { colorScheme: options.colorScheme };
|
|
2475
2513
|
}
|
|
2514
|
+
async setCaptureEnabled(options) {
|
|
2515
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.enabled) !== 'boolean') {
|
|
2516
|
+
throw new Error('No enabled value provided');
|
|
2517
|
+
}
|
|
2518
|
+
// A JavaScript SDK older than capture requests has nothing to switch.
|
|
2519
|
+
const jsSdk = Gleap$1;
|
|
2520
|
+
if (typeof jsSdk.setCaptureEnabled === 'function') {
|
|
2521
|
+
jsSdk.setCaptureEnabled(options.enabled);
|
|
2522
|
+
}
|
|
2523
|
+
return { captureEnabled: options.enabled };
|
|
2524
|
+
}
|
|
2525
|
+
async setRemoteLogCollectionEnabled(options) {
|
|
2526
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.enabled) !== 'boolean') {
|
|
2527
|
+
throw new Error('No enabled value provided');
|
|
2528
|
+
}
|
|
2529
|
+
// A JavaScript SDK older than capture requests has nothing to switch.
|
|
2530
|
+
const jsSdk = Gleap$1;
|
|
2531
|
+
if (typeof jsSdk.setRemoteLogCollectionEnabled === 'function') {
|
|
2532
|
+
jsSdk.setRemoteLogCollectionEnabled(options.enabled);
|
|
2533
|
+
}
|
|
2534
|
+
return { remoteLogCollectionEnabled: options.enabled };
|
|
2535
|
+
}
|
|
2476
2536
|
async identify(options) {
|
|
2477
2537
|
var userData = {
|
|
2478
2538
|
name: options.name,
|
|
@@ -2510,6 +2570,9 @@ class GleapWeb extends core.WebPlugin {
|
|
|
2510
2570
|
// The JavaScript SDK records the page's requests itself on web.
|
|
2511
2571
|
return { networkLogsAttached: false };
|
|
2512
2572
|
}
|
|
2573
|
+
async logsFlushed() {
|
|
2574
|
+
// The JavaScript SDK collects the logs on web itself: nothing is buffered here.
|
|
2575
|
+
}
|
|
2513
2576
|
async attachConsoleLogs() {
|
|
2514
2577
|
// The JavaScript SDK records the page's console itself on web.
|
|
2515
2578
|
return { consoleLogsAttached: false };
|