@ansight/capacitor 1.3.0-preview.1 → 1.3.0-preview.11
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/AnsightCapacitor.podspec +1 -1
- package/Package.swift +1 -1
- package/README.md +63 -0
- package/android/build.gradle +2 -2
- package/android/src/main/kotlin/ai/ansight/capacitor/AnsightCapacitorPlugin.kt +79 -4
- package/dist/esm/definitions.d.ts +101 -2
- package/dist/esm/definitions.d.ts.map +1 -1
- package/dist/esm/dom.d.ts.map +1 -1
- package/dist/esm/dom.js +91 -8
- package/dist/esm/dom.js.map +1 -1
- package/dist/esm/index.d.ts +20 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +131 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/network.d.ts +6 -0
- package/dist/esm/network.d.ts.map +1 -0
- package/dist/esm/network.js +742 -0
- package/dist/esm/network.js.map +1 -0
- package/dist/esm/options.d.ts +14 -2
- package/dist/esm/options.d.ts.map +1 -1
- package/dist/esm/options.js +73 -1
- package/dist/esm/options.js.map +1 -1
- package/dist/esm/session-properties.d.ts +16 -0
- package/dist/esm/session-properties.d.ts.map +1 -0
- package/dist/esm/session-properties.js +123 -0
- package/dist/esm/session-properties.js.map +1 -0
- package/dist/plugin.cjs.js +1162 -12
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1162 -12
- package/dist/plugin.js.map +1 -1
- package/dist/standalone.js +1157 -12
- package/dist/standalone.js.map +1 -1
- package/ios/Sources/AnsightCapacitorPlugin/AnsightCapacitorPlugin.swift +81 -3
- package/package.json +1 -1
|
@@ -15,6 +15,8 @@ public final class AnsightCapacitorPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
15
15
|
CAPPluginMethod(name: "registerMetricChannel", returnType: CAPPluginReturnPromise),
|
|
16
16
|
CAPPluginMethod(name: "recordMetric", returnType: CAPPluginReturnPromise),
|
|
17
17
|
CAPPluginMethod(name: "recordEvent", returnType: CAPPluginReturnPromise),
|
|
18
|
+
CAPPluginMethod(name: "recordNetworkRequest", returnType: CAPPluginReturnPromise),
|
|
19
|
+
CAPPluginMethod(name: "recordCrashCandidate", returnType: CAPPluginReturnPromise),
|
|
18
20
|
CAPPluginMethod(name: "screenViewed", returnType: CAPPluginReturnPromise),
|
|
19
21
|
CAPPluginMethod(name: "setAppLifecycleState", returnType: CAPPluginReturnPromise),
|
|
20
22
|
CAPPluginMethod(name: "connect", returnType: CAPPluginReturnPromise),
|
|
@@ -95,13 +97,21 @@ public final class AnsightCapacitorPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
95
97
|
}
|
|
96
98
|
self?.notifyListeners("ansightLog", data: data)
|
|
97
99
|
}
|
|
100
|
+
private var hostConnectionStatusSubscription: HostConnectionStatusSubscription?
|
|
98
101
|
|
|
99
102
|
public override func load() {
|
|
100
103
|
AnsightLogger.registerCallback(logCallback)
|
|
104
|
+
hostConnectionStatusSubscription = AnsightRuntime.shared.addHostConnectionStatusListener { [weak self] status, _ in
|
|
105
|
+
self?.notifyListeners(
|
|
106
|
+
"ansightHostConnectionStatus",
|
|
107
|
+
data: self?.hostConnectionStatusDictionary(status) ?? [:]
|
|
108
|
+
)
|
|
109
|
+
}
|
|
101
110
|
}
|
|
102
111
|
|
|
103
112
|
deinit {
|
|
104
113
|
AnsightLogger.removeCallback(logCallback)
|
|
114
|
+
hostConnectionStatusSubscription?.remove()
|
|
105
115
|
}
|
|
106
116
|
|
|
107
117
|
@objc func initialize(_ call: CAPPluginCall) {
|
|
@@ -194,6 +204,45 @@ public final class AnsightCapacitorPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
194
204
|
}
|
|
195
205
|
}
|
|
196
206
|
|
|
207
|
+
@objc func recordNetworkRequest(_ call: CAPPluginCall) {
|
|
208
|
+
let input = dictionary(call)
|
|
209
|
+
guard JSONSerialization.isValidJSONObject(input),
|
|
210
|
+
let data = try? JSONSerialization.data(withJSONObject: input),
|
|
211
|
+
let request = try? JSONDecoder().decode(AnsightNetworkRequest.self, from: data),
|
|
212
|
+
request.schema == AnsightNetworkRequest.schemaName
|
|
213
|
+
else {
|
|
214
|
+
call.resolve(operationResultDictionary(
|
|
215
|
+
.failure("Network request must use the ansight.network-request.v1 schema.")
|
|
216
|
+
))
|
|
217
|
+
return
|
|
218
|
+
}
|
|
219
|
+
call.keepAlive = true
|
|
220
|
+
Task {
|
|
221
|
+
call.resolve(operationResultDictionary(await AnsightRuntime.shared.recordNetworkRequest(request)))
|
|
222
|
+
call.keepAlive = false
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
@objc func recordCrashCandidate(_ call: CAPPluginCall) {
|
|
227
|
+
let metadata: [String: String]
|
|
228
|
+
if let metadataJson = call.getString("metadata"),
|
|
229
|
+
let data = metadataJson.data(using: .utf8),
|
|
230
|
+
let decoded = try? JSONDecoder().decode([String: String].self, from: data) {
|
|
231
|
+
metadata = decoded
|
|
232
|
+
} else {
|
|
233
|
+
metadata = [:]
|
|
234
|
+
}
|
|
235
|
+
let candidateId = AnsightRuntime.shared.recordCrashCandidate(
|
|
236
|
+
runtime: call.getString("runtime") ?? "capacitor-javascript",
|
|
237
|
+
kind: call.getString("kind") ?? "unhandled_javascript_error",
|
|
238
|
+
message: call.getString("message"),
|
|
239
|
+
stack: call.getString("stack"),
|
|
240
|
+
fatal: call.getBool("fatal") ?? false,
|
|
241
|
+
metadata: metadata
|
|
242
|
+
)
|
|
243
|
+
call.resolve(candidateId.map { ["candidateId": $0] } ?? [:])
|
|
244
|
+
}
|
|
245
|
+
|
|
197
246
|
@objc func screenViewed(_ call: CAPPluginCall) {
|
|
198
247
|
do {
|
|
199
248
|
try AnsightRuntime.shared.screenViewed(
|
|
@@ -567,6 +616,13 @@ public final class AnsightCapacitorPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
567
616
|
dictionary, "enableBatteryLevel", defaultValue: options.enableBatteryLevel
|
|
568
617
|
)
|
|
569
618
|
}
|
|
619
|
+
if hasBool(dictionary, "enableOpenFileHandleTracking") {
|
|
620
|
+
options.enableOpenFileHandleTracking = boolValue(
|
|
621
|
+
dictionary,
|
|
622
|
+
"enableOpenFileHandleTracking",
|
|
623
|
+
defaultValue: options.enableOpenFileHandleTracking
|
|
624
|
+
)
|
|
625
|
+
}
|
|
570
626
|
if let guardName = stringValue(dictionary, "toolGuard") {
|
|
571
627
|
options.toolGuard = toolGuard(guardName)
|
|
572
628
|
} else if useDefaults {
|
|
@@ -618,6 +674,21 @@ public final class AnsightCapacitorPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
618
674
|
)
|
|
619
675
|
}
|
|
620
676
|
}
|
|
677
|
+
if let raw = dictionary?["crashCapture"] {
|
|
678
|
+
if (raw as? Bool) == false {
|
|
679
|
+
options.crashCapture.enabled = false
|
|
680
|
+
} else if let crash = raw as? NSDictionary {
|
|
681
|
+
options.crashCapture = AnsightCrashCaptureOptions(
|
|
682
|
+
enabled: boolValue(crash, "enabled", defaultValue: true),
|
|
683
|
+
studioHandoffEnabled: boolValue(crash, "studioHandoffEnabled", defaultValue: true),
|
|
684
|
+
offlineCaptureAttachmentEnabled: boolValue(crash, "offlineCaptureAttachmentEnabled", defaultValue: true),
|
|
685
|
+
maximumPendingReports: intValue(crash, "maximumPendingReports", defaultValue: 8),
|
|
686
|
+
retentionDays: intValue(crash, "retentionDays", defaultValue: 7),
|
|
687
|
+
maximumBreadcrumbs: intValue(crash, "maximumBreadcrumbs", defaultValue: 64),
|
|
688
|
+
maximumTraceBytes: intValue(crash, "maximumTraceBytes", defaultValue: 1_048_576)
|
|
689
|
+
)
|
|
690
|
+
}
|
|
691
|
+
}
|
|
621
692
|
if let lifecycle = dictionary?["lifecycleCapture"] as? NSDictionary {
|
|
622
693
|
options.lifecycleCapture = AnsightLifecycleCaptureOptions(
|
|
623
694
|
enabled: boolValue(lifecycle, "enabled", defaultValue: options.lifecycleCapture.enabled),
|
|
@@ -841,6 +912,8 @@ public final class AnsightCapacitorPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
841
912
|
"retentionPeriodSeconds": options.retentionPeriodSeconds,
|
|
842
913
|
"enableFramesPerSecond": options.enableFramesPerSecond,
|
|
843
914
|
"enableBatteryLevel": options.enableBatteryLevel,
|
|
915
|
+
"enableOpenFileHandleTracking": options.enableOpenFileHandleTracking,
|
|
916
|
+
"enableJniReferenceCountTracking": false,
|
|
844
917
|
"toolGuard": toolGuardName(options.toolGuard),
|
|
845
918
|
"additionalChannels": options.additionalChannels.map(channelDictionary),
|
|
846
919
|
"customProperties": options.customProperties,
|
|
@@ -881,9 +954,14 @@ public final class AnsightCapacitorPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
881
954
|
"captureGpuBackedSurfaces",
|
|
882
955
|
defaultValue: AnsightSessionJpegCaptureOptions.defaultCaptureGpuBackedSurfaces
|
|
883
956
|
),
|
|
884
|
-
mode:
|
|
885
|
-
|
|
886
|
-
|
|
957
|
+
mode: AnsightSessionJpegCaptureMode(
|
|
958
|
+
rawValue: stringValue(dictionary, "mode") ?? ""
|
|
959
|
+
) ?? .screenshotOnly,
|
|
960
|
+
captureKeyboardPresence: boolValue(
|
|
961
|
+
dictionary,
|
|
962
|
+
"captureKeyboardPresence",
|
|
963
|
+
defaultValue: AnsightSessionJpegCaptureOptions.defaultCaptureKeyboardPresence
|
|
964
|
+
)
|
|
887
965
|
)
|
|
888
966
|
}
|
|
889
967
|
|
package/package.json
CHANGED