Skip to content

Commit

Permalink
fix: sendStats in android and updateFailed position
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed May 20, 2022
1 parent 719d2f5 commit fd3e744
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public void sendStats(final String action, final VersionInfo version) {
url = new URL(this.getStatsUrl());
json.put("platform", "android");
json.put("action", action);
json.put("version_name", version);
json.put("version_name", version.getName());

This comment has been minimized.

Copy link
@lincolnthree

lincolnthree May 20, 2022

Collaborator

😱 Good catch.

json.put("device_id", this.getDeviceID());
json.put("version_build", this.versionBuild);
json.put("version_code", this.versionCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,10 @@ public void onActivityStopped(@NonNull final Activity activity) {
Log.i(CapacitorUpdater.TAG, "Version: " + current + ", is in error state.");
Log.i(CapacitorUpdater.TAG, "Will fallback to: " + fallback + " on application restart.");
Log.i(CapacitorUpdater.TAG, "Did you forget to call 'notifyAppReady()' in your Capacitor App code?");

final JSObject ret = new JSObject();
ret.put("version", current);
this.notifyListeners("updateFailed", ret);
this.implementation.sendStats("revert", current)
if (!fallback.isBuiltin() && !fallback.equals(current)) {
final Boolean res = this.implementation.set(fallback);
if (res && this._reload()) {
Expand All @@ -544,9 +547,6 @@ public void onActivityStopped(@NonNull final Activity activity) {
}

if (this.autoDeleteFailed) {
final JSObject ret = new JSObject();
ret.put("version", current);
this.notifyListeners("updateFailed", ret);
Log.i(CapacitorUpdater.TAG, "Deleting failing version: " + current);
try {
final Boolean res = this.implementation.delete(current.getVersion());
Expand Down
2 changes: 1 addition & 1 deletion ios/Plugin/CapacitorUpdaterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
print("\(self.implementation.TAG) Version: \(curVersionName), is considered broken")
print("\(self.implementation.TAG) Will downgraded to version: \(pastVersionName == "" ? "builtin" : pastVersionName) for next start")
print("\(self.implementation.TAG) Don't forget to trigger 'notifyAppReady()' in js code to validate a version.")
self.notifyListeners("updateFailed", data: ["version": curVersionName])
implementation.sendStats(action: "revert", version: curVersionName)
if (pastVersion != "" && pastVersionName != "") {
let res = implementation.set(version: pastVersion, versionName: pastVersionName)
Expand All @@ -364,7 +365,6 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
UserDefaults.standard.set(curVersionName, forKey: "failingVersion")
let res = implementation.delete(version: curVersion, versionName: curVersionName)
if (res) {
self.notifyListeners("updateFailed", data: ["version": curVersionName])
print("\(self.implementation.TAG) Delete failing version: \(curVersionName)")
}
} else if (pastVersion != "") {
Expand Down

1 comment on commit fd3e744

@lincolnthree
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Please sign in to comment.