Skip to content

Commit

Permalink
feat: add download_complete and download_% events
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed Nov 15, 2022
1 parent bbf0825 commit 0ed8022
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ public void notifyDownload(final String id, final int percent) {
this.notifyListeners("download", ret);
if (percent == 100) {
this.notifyListeners("downloadComplete", bundle);
this.implementation.sendStats("download_complete", bundle.getVersionName());
} else if (percent % 10 == 0) {
this.implementation.sendStats("download_" + percent, bundle.getVersionName());
}
} catch (final Exception e) {
Log.e(CapacitorUpdater.TAG, "Could not notify listeners", e);
Expand Down
4 changes: 4 additions & 0 deletions ios/Plugin/CapacitorUpdaterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
self.notifyListeners("download", data: ["percent": percent, "bundle": bundle.toJSON()])
if percent == 100 {
self.notifyListeners("downloadComplete", data: ["bundle": bundle.toJSON()])
self.implementation.sendStats(action: "download_complete", versionName: bundle.getVersionName())
}
else if percent.isMultiple(of: 10) {
self.implementation.sendStats(action: "download_\(percent)", versionName: bundle.getVersionName())
}
}

Expand Down

0 comments on commit 0ed8022

Please sign in to comment.