Skip to content

Commit a69bda1

Browse files
committed
- added ContentType to load_success and load_error Analytics parameters
1 parent 08d03cf commit a69bda1

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

OpenDocumentReader/Document.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,11 @@ class Document: UIDocument {
104104
parse()
105105
}
106106
}
107+
108+
extension Document {
109+
110+
var shortenedDocumentUrl: String {
111+
return fileURL.absoluteString.prefix(49) + ".." + fileURL.absoluteString.suffix(49)
112+
}
113+
114+
}

OpenDocumentReader/DocumentViewController.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,12 @@ class DocumentViewController: UIViewController, DocumentDelegate {
214214

215215
self.webview.loadHTMLString("<html><h1>Error</h1>Failed to load given document. Please try another one while we are working hard to support as many documents as possible. Feel free to contact us via support@opendocument.app for further questions.</html>", baseURL: nil)
216216

217-
Analytics.logEvent("load_error", parameters: nil)
217+
Analytics.logEvent(
218+
"load_error",
219+
parameters: [
220+
AnalyticsParameterItemName: doc.shortenedDocumentUrl,
221+
AnalyticsParameterContentType: fileType
222+
])
218223
}
219224

220225
func documentLoadingStarted(_ doc: Document) {
@@ -225,7 +230,14 @@ class DocumentViewController: UIViewController, DocumentDelegate {
225230
func documentLoadingCompleted(_ doc: Document) {
226231
progressBar.isHidden = true
227232

228-
Analytics.logEvent("load_success", parameters: nil)
233+
let fileType = doc.fileURL.pathExtension.lowercased()
234+
235+
Analytics.logEvent(
236+
"load_success",
237+
parameters: [
238+
AnalyticsParameterItemName: doc.shortenedDocumentUrl,
239+
AnalyticsParameterContentType: fileType
240+
])
229241
}
230242

231243
func documentPagesChanged(_ doc: Document) {

0 commit comments

Comments
 (0)