Skip to content
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

Add Support for Custom Shareable Options #744

Open
1 of 2 tasks
handstandsam opened this issue Dec 19, 2021 · 3 comments
Open
1 of 2 tasks

Add Support for Custom Shareable Options #744

handstandsam opened this issue Dec 19, 2021 · 3 comments
Labels
feature request Request a new feature to be developed

Comments

@handstandsam
Copy link
Contributor

⚠️ Is your feature request related to a problem? Please describe

I would like to add an additional shareable item when I configure Chucker. I would like to be able to export to a custom format that wouldn't make sense to add to the chucker library itself as it's not a standard. In this case it's exporting a Kotlin file that is generated from HTTP data.

💡 Describe the solution you'd like

I'd like to be able to give a "Sharable" format option via the ChuckerInterceptor.Builder that would be shown on

override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
R.id.share_text -> shareTransactionAsText { transaction ->
val encodeUrls = viewModel.encodeUrl.value!!
TransactionDetailsSharable(transaction, encodeUrls)
}
R.id.share_curl -> shareTransactionAsText { transaction ->
TransactionCurlCommandSharable(transaction)
}
R.id.share_file -> shareTransactionAsFile(EXPORT_TXT_FILE_NAME) { transaction ->
val encodeUrls = viewModel.encodeUrl.value!!
TransactionDetailsSharable(transaction, encodeUrls)
}
R.id.share_har -> shareTransactionAsFile(EXPORT_HAR_FILE_NAME) { transaction ->
TransactionDetailsHarSharable(
HarUtils.harStringFromTransactions(
listOf(transaction),
getString(R.string.chucker_name),
getString(R.string.chucker_version)
)
)
}
else -> super.onOptionsItemSelected(item)
}

Example Code

data class SharableOption(
  val name: String,
  val sharable: Sharable
)
val chuckerInterceptor = ChuckerInterceptor.Builder(context)
        .addSharableOption(sharableOption)
        .build()

📊 Describe alternatives you've considered

I am already doing this manually myself in my own library, but it would be nice to have a UI to do it, and yours is nice.

📄 Additional context

I could create a fork, but it seems like this would be fairly trivial to add to Chucker with the way your existing Sharables work today, and would allow this to be more extensible.

🙋 Do you want to develop this feature yourself?

  • Yes
  • No
@MiSikora
Copy link
Contributor

MiSikora commented Dec 20, 2021

Hey, thanks for creating this ticket. I agree that it would be a great addition, and it is something that I strive for. Unfortunately, I don't think it is as straightforward as it appears. Our Sharable implementations are internal and rely on the internal data model. Exposing them is tracked by #579, which is additionally "blocked" by #259.

It is something that I plan to prioritize in early 2022 when I have more free time on my hands. But if you (or anyone) would like to tackle this, it would be much appreciated for sure. :)

Unless you envisioned some other mechanism of sharing that doesn't rely on the internal data model?

@handstandsam
Copy link
Contributor Author

That all makes sense. This would rely on the internal data model which would require a fork at this time if it wanted to get done. The benefit of chucker is that it has what I need as far as UI and persistence, just not the ability to export in my format.

I'll keep brainstorming, but might have to do it after those other changes happen. Thank you!

@MiSikora MiSikora added the feature request Request a new feature to be developed label Dec 23, 2021
@cortinico
Copy link
Member

Thanks for raising this point @handstandsam

Further sharing options were on our table for a while, as @MiSikora mentioned. Some months ago we merged HAR support #696. Ideally we would like to follow the approach already mentioned (i.e. #579 and #259) and allow users to plug in their "exporter" plugin.

HAR could be one of that and refactored outside the core of chucker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request a new feature to be developed
Projects
None yet
Development

No branches or pull requests

3 participants