capacitor-gleap-plugin 19.0.1 → 19.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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
package/dist/plugin.js
CHANGED
|
@@ -1979,6 +1979,7 @@ var capacitorGleap = (function (exports, core, Gleap$1) {
|
|
|
1979
1979
|
// logs are enabled (like the JavaScript SDK), so nothing is held in memory before that.
|
|
1980
1980
|
this.networkCapture.install();
|
|
1981
1981
|
this.listenForConfig();
|
|
1982
|
+
this.listenForFlush();
|
|
1982
1983
|
}
|
|
1983
1984
|
/**
|
|
1984
1985
|
* Android debug builds (Capacitor's loggingBehavior) write the WebView console to logcat, which the
|
|
@@ -2001,6 +2002,36 @@ var capacitorGleap = (function (exports, core, Gleap$1) {
|
|
|
2001
2002
|
// The native side predates the event: network logs stay off.
|
|
2002
2003
|
}
|
|
2003
2004
|
}
|
|
2005
|
+
/**
|
|
2006
|
+
* Capture requests: right before the native SDK collects the logs for a request, it asks for what is still
|
|
2007
|
+
* buffered here (pushed at most every PUSH_DELAY_MS otherwise) and waits up to 500 ms for the answer.
|
|
2008
|
+
*/
|
|
2009
|
+
listenForFlush() {
|
|
2010
|
+
try {
|
|
2011
|
+
const handle = this.target.addListener('flushLogs', (data) => {
|
|
2012
|
+
const flushId = data && typeof data.flushId === 'string' ? data.flushId : null;
|
|
2013
|
+
runOutsideZone(() => this.flushNow().then(() => {
|
|
2014
|
+
if (flushId) {
|
|
2015
|
+
this.answerFlush(flushId);
|
|
2016
|
+
}
|
|
2017
|
+
}));
|
|
2018
|
+
});
|
|
2019
|
+
if (handle && typeof handle.catch === 'function') {
|
|
2020
|
+
handle.catch(() => undefined);
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
catch (e) {
|
|
2024
|
+
// The native side predates the event: nothing asks for flushes.
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
answerFlush(flushId) {
|
|
2028
|
+
try {
|
|
2029
|
+
Promise.resolve(this.target.logsFlushed({ flushId })).catch(() => undefined);
|
|
2030
|
+
}
|
|
2031
|
+
catch (e) {
|
|
2032
|
+
// The native side gives up waiting after 500 ms.
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2004
2035
|
applyRemoteConfig(config) {
|
|
2005
2036
|
try {
|
|
2006
2037
|
if (!config || typeof config !== 'object') {
|
|
@@ -2043,15 +2074,20 @@ var capacitorGleap = (function (exports, core, Gleap$1) {
|
|
|
2043
2074
|
this.markDirty(this.consoleChannel);
|
|
2044
2075
|
this.markDirty(this.networkChannel);
|
|
2045
2076
|
}
|
|
2046
|
-
/**
|
|
2077
|
+
/**
|
|
2078
|
+
* Pushes pending changes now (before a plugin call that can produce a report, or when the native SDK collects the
|
|
2079
|
+
* logs for a capture request). Resolves once the native side took them; never rejects.
|
|
2080
|
+
*/
|
|
2047
2081
|
flushNow() {
|
|
2082
|
+
const pushes = [];
|
|
2048
2083
|
try {
|
|
2049
|
-
this.flushChannel(this.consoleChannel);
|
|
2050
|
-
this.flushChannel(this.networkChannel);
|
|
2084
|
+
pushes.push(this.flushChannel(this.consoleChannel));
|
|
2085
|
+
pushes.push(this.flushChannel(this.networkChannel));
|
|
2051
2086
|
}
|
|
2052
2087
|
catch (e) {
|
|
2053
2088
|
// Ignore.
|
|
2054
2089
|
}
|
|
2090
|
+
return Promise.all(pushes).then(() => undefined, () => undefined);
|
|
2055
2091
|
}
|
|
2056
2092
|
updateRules() {
|
|
2057
2093
|
this.rules = createRedactionRules([...this.remoteProps, ...this.localProps], [...this.remoteBlacklist, ...this.localBlacklist]);
|
|
@@ -2082,20 +2118,21 @@ var capacitorGleap = (function (exports, core, Gleap$1) {
|
|
|
2082
2118
|
channel.timer = null;
|
|
2083
2119
|
}
|
|
2084
2120
|
}
|
|
2121
|
+
/** Resolves once the push it started (if any) was answered; never rejects. */
|
|
2085
2122
|
flushChannel(channel) {
|
|
2086
2123
|
if (channel.timer !== null) {
|
|
2087
2124
|
clearTimeout(channel.timer);
|
|
2088
2125
|
channel.timer = null;
|
|
2089
2126
|
}
|
|
2090
2127
|
if (!channel.isDirty || !this.canPush(channel)) {
|
|
2091
|
-
return;
|
|
2128
|
+
return Promise.resolve();
|
|
2092
2129
|
}
|
|
2093
2130
|
channel.isDirty = false;
|
|
2094
2131
|
let push;
|
|
2095
2132
|
if (channel.name === 'console') {
|
|
2096
2133
|
const logs = this.consoleCapture ? this.consoleCapture.getEntries() : [];
|
|
2097
2134
|
if (logs.length === 0 && !channel.hasPushedLogs) {
|
|
2098
|
-
return;
|
|
2135
|
+
return Promise.resolve();
|
|
2099
2136
|
}
|
|
2100
2137
|
channel.hasPushedLogs = logs.length > 0;
|
|
2101
2138
|
push = runOutsideZone(() => this.target.attachConsoleLogs({ logs }));
|
|
@@ -2103,18 +2140,19 @@ var capacitorGleap = (function (exports, core, Gleap$1) {
|
|
|
2103
2140
|
else {
|
|
2104
2141
|
const logs = this.isNetworkEnabled ? this.buildNetworkLogs() : [];
|
|
2105
2142
|
if (logs.length === 0 && !channel.hasPushedLogs) {
|
|
2106
|
-
return;
|
|
2143
|
+
return Promise.resolve();
|
|
2107
2144
|
}
|
|
2108
2145
|
channel.hasPushedLogs = logs.length > 0;
|
|
2109
2146
|
push = runOutsideZone(() => this.target.attachNetworkLogs({ logs }));
|
|
2110
2147
|
}
|
|
2111
2148
|
try {
|
|
2112
|
-
Promise.resolve(push).then(() => {
|
|
2149
|
+
return Promise.resolve(push).then(() => {
|
|
2113
2150
|
channel.failures = 0;
|
|
2114
2151
|
}, () => this.onPushFailed(channel));
|
|
2115
2152
|
}
|
|
2116
2153
|
catch (e) {
|
|
2117
2154
|
this.onPushFailed(channel);
|
|
2155
|
+
return Promise.resolve();
|
|
2118
2156
|
}
|
|
2119
2157
|
}
|
|
2120
2158
|
onPushFailed(channel) {
|
|
@@ -2471,6 +2509,28 @@ var capacitorGleap = (function (exports, core, Gleap$1) {
|
|
|
2471
2509
|
});
|
|
2472
2510
|
return { colorScheme: options.colorScheme };
|
|
2473
2511
|
}
|
|
2512
|
+
async setCaptureEnabled(options) {
|
|
2513
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.enabled) !== 'boolean') {
|
|
2514
|
+
throw new Error('No enabled value provided');
|
|
2515
|
+
}
|
|
2516
|
+
// A JavaScript SDK older than capture requests has nothing to switch.
|
|
2517
|
+
const jsSdk = Gleap$1;
|
|
2518
|
+
if (typeof jsSdk.setCaptureEnabled === 'function') {
|
|
2519
|
+
jsSdk.setCaptureEnabled(options.enabled);
|
|
2520
|
+
}
|
|
2521
|
+
return { captureEnabled: options.enabled };
|
|
2522
|
+
}
|
|
2523
|
+
async setRemoteLogCollectionEnabled(options) {
|
|
2524
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.enabled) !== 'boolean') {
|
|
2525
|
+
throw new Error('No enabled value provided');
|
|
2526
|
+
}
|
|
2527
|
+
// A JavaScript SDK older than capture requests has nothing to switch.
|
|
2528
|
+
const jsSdk = Gleap$1;
|
|
2529
|
+
if (typeof jsSdk.setRemoteLogCollectionEnabled === 'function') {
|
|
2530
|
+
jsSdk.setRemoteLogCollectionEnabled(options.enabled);
|
|
2531
|
+
}
|
|
2532
|
+
return { remoteLogCollectionEnabled: options.enabled };
|
|
2533
|
+
}
|
|
2474
2534
|
async identify(options) {
|
|
2475
2535
|
var userData = {
|
|
2476
2536
|
name: options.name,
|
|
@@ -2508,6 +2568,9 @@ var capacitorGleap = (function (exports, core, Gleap$1) {
|
|
|
2508
2568
|
// The JavaScript SDK records the page's requests itself on web.
|
|
2509
2569
|
return { networkLogsAttached: false };
|
|
2510
2570
|
}
|
|
2571
|
+
async logsFlushed() {
|
|
2572
|
+
// The JavaScript SDK collects the logs on web itself: nothing is buffered here.
|
|
2573
|
+
}
|
|
2511
2574
|
async attachConsoleLogs() {
|
|
2512
2575
|
// The JavaScript SDK records the page's console itself on web.
|
|
2513
2576
|
return { consoleLogsAttached: false };
|