@capgo/capacitor-updater 5.8.11 → 5.9.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/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +18 -2
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +1 -1
- package/ios/Plugin/CapacitorUpdater.swift +9 -4
- package/ios/Plugin/CapacitorUpdaterPlugin.swift +1 -1
- package/package.json +1 -1
|
@@ -687,9 +687,10 @@ public class CapacitorUpdater {
|
|
|
687
687
|
final File bundle = this.getBundleDirectory(id);
|
|
688
688
|
Log.i(TAG, "Setting next active bundle: " + id);
|
|
689
689
|
if (this.bundleExists(id)) {
|
|
690
|
+
var currentBundleName = this.getCurrentBundle().getVersionName();
|
|
690
691
|
this.setCurrentBundle(bundle);
|
|
691
692
|
this.setBundleStatus(id, BundleStatus.PENDING);
|
|
692
|
-
this.sendStats("set", newBundle.getVersionName());
|
|
693
|
+
this.sendStats("set", newBundle.getVersionName(), currentBundleName);
|
|
693
694
|
return true;
|
|
694
695
|
}
|
|
695
696
|
this.setBundleStatus(id, BundleStatus.ERROR);
|
|
@@ -745,11 +746,16 @@ public class CapacitorUpdater {
|
|
|
745
746
|
|
|
746
747
|
public void reset(final boolean internal) {
|
|
747
748
|
Log.d(CapacitorUpdater.TAG, "reset: " + internal);
|
|
749
|
+
var currentBundleName = this.getCurrentBundle().getVersionName();
|
|
748
750
|
this.setCurrentBundle(new File("public"));
|
|
749
751
|
this.setFallbackBundle(null);
|
|
750
752
|
this.setNextBundle(null);
|
|
751
753
|
if (!internal) {
|
|
752
|
-
this.sendStats(
|
|
754
|
+
this.sendStats(
|
|
755
|
+
"reset",
|
|
756
|
+
this.getCurrentBundle().getVersionName(),
|
|
757
|
+
currentBundleName
|
|
758
|
+
);
|
|
753
759
|
}
|
|
754
760
|
}
|
|
755
761
|
|
|
@@ -1020,6 +1026,14 @@ public class CapacitorUpdater {
|
|
|
1020
1026
|
}
|
|
1021
1027
|
|
|
1022
1028
|
public void sendStats(final String action, final String versionName) {
|
|
1029
|
+
this.sendStats(action, versionName, "");
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
public void sendStats(
|
|
1033
|
+
final String action,
|
|
1034
|
+
final String versionName,
|
|
1035
|
+
final String oldVersionName
|
|
1036
|
+
) {
|
|
1023
1037
|
String statsUrl = this.statsUrl;
|
|
1024
1038
|
if (statsUrl == null || statsUrl.isEmpty()) {
|
|
1025
1039
|
return;
|
|
@@ -1027,6 +1041,8 @@ public class CapacitorUpdater {
|
|
|
1027
1041
|
JSONObject json;
|
|
1028
1042
|
try {
|
|
1029
1043
|
json = this.createInfoObject();
|
|
1044
|
+
json.put("version_name", versionName);
|
|
1045
|
+
json.put("old_version_name", oldVersionName);
|
|
1030
1046
|
json.put("action", action);
|
|
1031
1047
|
} catch (JSONException e) {
|
|
1032
1048
|
Log.e(TAG, "Error sendStats JSONException", e);
|
|
@@ -55,7 +55,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
55
55
|
private static final String channelUrlDefault =
|
|
56
56
|
"https://api.capgo.app/channel_self";
|
|
57
57
|
|
|
58
|
-
private final String PLUGIN_VERSION = "5.
|
|
58
|
+
private final String PLUGIN_VERSION = "5.9.0";
|
|
59
59
|
private static final String DELAY_CONDITION_PREFERENCES = "";
|
|
60
60
|
|
|
61
61
|
private SharedPreferences.Editor editor;
|
|
@@ -73,7 +73,8 @@ struct InfoObject: Codable {
|
|
|
73
73
|
let version_build: String?
|
|
74
74
|
let version_code: String?
|
|
75
75
|
let version_os: String?
|
|
76
|
-
|
|
76
|
+
var version_name: String?
|
|
77
|
+
var old_version_name: String?
|
|
77
78
|
let plugin_version: String?
|
|
78
79
|
let is_emulator: Bool?
|
|
79
80
|
let is_prod: Bool?
|
|
@@ -716,9 +717,10 @@ extension CustomError: LocalizedError {
|
|
|
716
717
|
return true
|
|
717
718
|
}
|
|
718
719
|
if bundleExists(id: id) {
|
|
720
|
+
let currentBundleName = self.getCurrentBundle().getVersionName()
|
|
719
721
|
self.setCurrentBundle(bundle: self.getBundleDirectory(id: id).path)
|
|
720
722
|
self.setBundleStatus(id: id, status: BundleStatus.PENDING)
|
|
721
|
-
self.sendStats(action: "set", versionName: newBundle.getVersionName())
|
|
723
|
+
self.sendStats(action: "set", versionName: newBundle.getVersionName(), oldVersionName: currentBundleName)
|
|
722
724
|
return true
|
|
723
725
|
}
|
|
724
726
|
self.setBundleStatus(id: id, status: BundleStatus.ERROR)
|
|
@@ -740,11 +742,12 @@ extension CustomError: LocalizedError {
|
|
|
740
742
|
|
|
741
743
|
public func reset(isInternal: Bool) {
|
|
742
744
|
print("\(self.TAG) reset: \(isInternal)")
|
|
745
|
+
let currentBundleName = self.getCurrentBundle().getVersionName()
|
|
743
746
|
self.setCurrentBundle(bundle: "")
|
|
744
747
|
self.setFallbackBundle(fallback: Optional<BundleInfo>.none)
|
|
745
748
|
_ = self.setNextBundle(next: Optional<String>.none)
|
|
746
749
|
if !isInternal {
|
|
747
|
-
self.sendStats(action: "reset")
|
|
750
|
+
self.sendStats(action: "reset", versionName: self.getCurrentBundle().getVersionName(), oldVersionName: currentBundleName)
|
|
748
751
|
}
|
|
749
752
|
}
|
|
750
753
|
|
|
@@ -882,7 +885,7 @@ extension CustomError: LocalizedError {
|
|
|
882
885
|
return getChannel
|
|
883
886
|
}
|
|
884
887
|
|
|
885
|
-
func sendStats(action: String, versionName: String? = nil) {
|
|
888
|
+
func sendStats(action: String, versionName: String? = nil, oldVersionName: String? = "") {
|
|
886
889
|
guard !statsUrl.isEmpty else {
|
|
887
890
|
return
|
|
888
891
|
}
|
|
@@ -891,6 +894,8 @@ extension CustomError: LocalizedError {
|
|
|
891
894
|
|
|
892
895
|
var parameters = createInfoObject()
|
|
893
896
|
parameters.action = action
|
|
897
|
+
parameters.version_name = versionName
|
|
898
|
+
parameters.old_version_name = oldVersionName
|
|
894
899
|
|
|
895
900
|
DispatchQueue.global(qos: .background).async {
|
|
896
901
|
let request = AF.request(
|
|
@@ -15,7 +15,7 @@ import Version
|
|
|
15
15
|
@objc(CapacitorUpdaterPlugin)
|
|
16
16
|
public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
17
17
|
public var implementation = CapacitorUpdater()
|
|
18
|
-
private let PLUGIN_VERSION: String = "5.
|
|
18
|
+
private let PLUGIN_VERSION: String = "5.9.0"
|
|
19
19
|
static let updateUrlDefault = "https://api.capgo.app/updates"
|
|
20
20
|
static let statsUrlDefault = "https://api.capgo.app/stats"
|
|
21
21
|
static let channelUrlDefault = "https://api.capgo.app/channel_self"
|