@@ -115,16 +115,22 @@ class DocumentViewController: UIViewController, DocumentDelegate {
115115 }
116116
117117 if doc. hasUnsavedChanges {
118- let alert = UIAlertController ( title: " You have unsaved changes " , message: " Save it ? " , preferredStyle: . alert)
118+ let alert = UIAlertController ( title: " You have unsaved changes " , message: " Save them now ? " , preferredStyle: . alert)
119119 alert. addAction ( UIAlertAction ( title: " No " , style: . destructive, handler: { ( _) in
120+ Analytics . logEvent ( " alert_unsaved_changes_no " , parameters: nil )
121+
120122 self . discardChanges ( )
121123 self . closeCurrentDocument ( )
122124 } ) )
123125 alert. addAction ( UIAlertAction ( title: " Yes " , style: . default, handler: { ( _) in
126+ Analytics . logEvent ( " alert_unsaved_changes_yes " , parameters: nil )
127+
124128 self . closeCurrentDocument ( ) //doc.close calls autosave
125129 } ) )
126130
127131 self . present ( alert, animated: true , completion: nil )
132+
133+ Analytics . logEvent ( " show_alert_unsaved_changes " , parameters: nil )
128134 } else {
129135 closeCurrentDocument ( )
130136 }
@@ -139,7 +145,7 @@ class DocumentViewController: UIViewController, DocumentDelegate {
139145
140146 doc. close { ( success) in
141147 if ( !success) {
142- self . showToast ( controller: self , message: " Error while saving " , seconds: 1 , color: . red) {
148+ self . showToast ( controller: self , message: " Error while saving " , seconds: 1.5 , color: . red) {
143149 self . dismiss ( animated: true , completion: nil )
144150 }
145151 } else {
@@ -183,6 +189,8 @@ class DocumentViewController: UIViewController, DocumentDelegate {
183189 }
184190
185191 func discardChanges( ) {
192+ Analytics . logEvent ( " menu_discard_changes " , parameters: nil )
193+
186194 guard let doc = document else {
187195 Crashlytics . sharedInstance ( ) . throwException ( )
188196
@@ -193,6 +201,8 @@ class DocumentViewController: UIViewController, DocumentDelegate {
193201 }
194202
195203 func saveContent( ) {
204+ Analytics . logEvent ( " menu_save_content " , parameters: nil )
205+
196206 guard let doc = document else {
197207 Crashlytics . sharedInstance ( ) . throwException ( )
198208
@@ -201,9 +211,9 @@ class DocumentViewController: UIViewController, DocumentDelegate {
201211
202212 doc. save ( to: doc. fileURL, for: . forOverwriting) { success in
203213 if success {
204- self . showToast ( controller: self , message: " Successfully saved " , seconds: 1 , color: . green)
214+ self . showToast ( controller: self , message: " Successfully saved " , seconds: 1.5 , color: . green)
205215 } else {
206- self . showToast ( controller: self , message: " Error while saving " , seconds: 1 , color: . red)
216+ self . showToast ( controller: self , message: " Error while saving " , seconds: 1.5 , color: . red)
207217 }
208218 }
209219 }
0 commit comments