-
Notifications
You must be signed in to change notification settings - Fork 146
[WOOMOB-1896] Attach full application logs as a file to Zendesk support tickets #16263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from 1 commit
0328c27
4d20ad7
5a4f2fa
5740e33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import android.os.Parcelable | |
| import com.woocommerce.android.applicationpasswords.IsAppPasswordsSupportedForJetpackSite | ||
| import com.woocommerce.android.extensions.formatResult | ||
| import com.woocommerce.android.support.help.HelpOrigin | ||
| import com.woocommerce.android.support.zendesk.RequestConstants.APPLICATION_LOG_FILENAME | ||
| import com.woocommerce.android.support.zendesk.RequestConstants.DIAGNOSTIC_LOG_FILENAME | ||
| import com.woocommerce.android.support.zendesk.RequestConstants.requestCreationIdentityNotSetErrorMessage | ||
| import com.woocommerce.android.support.zendesk.RequestConstants.requestCreationTimeoutErrorMessage | ||
|
|
@@ -70,11 +71,10 @@ class ZendeskTicketRepository @Inject constructor( | |
|
|
||
| val ssr: String? = selectedSite?.let { fetchSSR(it) } | ||
|
|
||
| val attachmentTokens = if (diagnosticLog != null) { | ||
| listOfNotNull(uploadDiagnosticLog(diagnosticLog)) | ||
| } else { | ||
| emptyList() | ||
| } | ||
| val attachmentTokens = listOfNotNull( | ||
| diagnosticLog?.let { uploadTextAttachment(DIAGNOSTIC_LOG_FILENAME, it) }, | ||
| uploadTextAttachment(APPLICATION_LOG_FILENAME, envDataSource.getFullDeviceLogs()) | ||
| ) | ||
|
|
||
| val requestCallback = object : ZendeskCallback<Request>() { | ||
| override fun onSuccess(result: Request?) { | ||
|
|
@@ -130,19 +130,20 @@ class ZendeskTicketRepository @Inject constructor( | |
| return result.model?.formatResult() | ||
| } | ||
|
|
||
| private suspend fun uploadDiagnosticLog( | ||
| diagnosticLog: String | ||
| private suspend fun uploadTextAttachment( | ||
| fileName: String, | ||
| content: String | ||
| ): String? { | ||
| val tempFile = withContext(dispatchers.io) { | ||
| File.createTempFile(DIAGNOSTIC_LOG_FILENAME, null).also { | ||
| it.writeText(diagnosticLog) | ||
| File.createTempFile(fileName, null).also { | ||
| it.writeText(content) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we also make the local file preparation best-effort? |
||
| } | ||
| } | ||
|
|
||
| return try { | ||
| suspendCancellableCoroutine { continuation -> | ||
| zendeskSettings.uploadProvider?.uploadAttachment( | ||
| DIAGNOSTIC_LOG_FILENAME, | ||
| fileName, | ||
| tempFile, | ||
| "text/plain", | ||
|
AdamGrzybkowski marked this conversation as resolved.
Outdated
|
||
| object : ZendeskCallback<UploadResponse>() { | ||
|
|
@@ -153,7 +154,7 @@ class ZendeskTicketRepository @Inject constructor( | |
| } | ||
|
|
||
| override fun onError(error: ErrorResponse?) { | ||
| wooLog.e(WooLog.T.SUPPORT, "Failed to upload diagnostic log") | ||
| wooLog.e(WooLog.T.SUPPORT, "Failed to upload attachment: $fileName") | ||
| if (continuation.isActive) { | ||
| continuation.resume(null) | ||
| } | ||
|
|
@@ -362,6 +363,7 @@ private object RequestConstants { | |
| const val requestCreationTimeoutErrorMessage = "Request creation timed out" | ||
| const val requestCreationIdentityNotSetErrorMessage = "Request creation failed: identity not set" | ||
| const val DIAGNOSTIC_LOG_FILENAME = "connectivitytest_log.txt" | ||
| const val APPLICATION_LOG_FILENAME = "application_log.txt" | ||
| } | ||
|
|
||
| private data class ZendeskCustomFieldsParams( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.