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

[Backport release-3_0] Refine manual log submission #4714

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/appinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ void AppInterface::logRuntimeProfiler()
#endif
}

void AppInterface::sendLog( const QString &message )
void AppInterface::sendLog( const QString &message, const QString &cloudUser )
{
#if WITH_SENTRY
sentry_wrapper::capture_event( message.toUtf8().constData() );
sentry_wrapper::capture_event( message.toUtf8().constData(), cloudUser.toUtf8().constData() );
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/appinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class AppInterface : public QObject
/**
* Sends a logs reporting through to sentry when enabled.
*/
Q_INVOKABLE void sendLog( const QString &message );
Q_INVOKABLE void sendLog( const QString &message, const QString &cloudUser );

/**
* Initalizes sentry connection.
Expand Down
2 changes: 1 addition & 1 deletion src/core/layerobserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void LayerObserver::onEditingStopped()

if ( vl->source().contains( QStringLiteral( "data.gpkg" ) ) && mLocalAndSourcePkAttrAreEqual )
{
AppInterface::instance()->sendLog( QStringLiteral( "Called LayerObserver::onEditingStopped!" ) );
AppInterface::instance()->sendLog( QStringLiteral( "Called LayerObserver::onEditingStopped!" ), QString() );
mLocalAndSourcePkAttrAreEqual = false;
}

Expand Down
68 changes: 65 additions & 3 deletions src/qml/MessageLog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,78 @@ Page {
QfButton {
id: submitLog
Layout.fillWidth: true
text: qsTr( 'Send application log' )
text: qsTr("Send application log")
visible: qfieldSettings.enableInfoCollection && platformUtilities.capabilities & PlatformUtilities.SentryFramework

onClicked: {
iface.sendLog("Manual log submission")
displayToast(qsTr("Your application log is being sent"))
applicationLogDialog.open()
}
}
}

Dialog {
id: applicationLogDialog
title: qsTr("Send application log")
focus: true
font: Theme.defaultFont

x: ( mainWindow.width - width ) / 2
y: ( mainWindow.height - height - 80 ) / 2

onAboutToShow: {
appliationLogInput.text = ''
}

Column {
width: childrenRect.width
height: childrenRect.height
spacing: 10

TextMetrics {
id: applicationLogLabelMetrics
font: applicationLogLabel.font
text: applicationLogLabel.text
}

Label {
id: applicationLogLabel
width: mainWindow.width - 60 < applicationLogLabelMetrics.width ? mainWindow.width - 60 : applicationLogLabelMetrics.width
text: qsTr("This will send a log of your current session to the development team. You only need to do this when you are asked for it.")
wrapMode: Text.WordWrap
font: Theme.defaultFont
color: Theme.mainTextColor
}

QfTextField {
id: appliationLogInput
width: applicationLogLabel.width
placeholderText: qsTr("Type optional details")
}

CheckBox {
id: includeCloudInformationCheckBox
width: applicationLogLabel.width
topPadding: 5
bottomPadding: 5
text: qsTr('Include cloud user details')
font: Theme.defaultFont
visible: cloudConnection.status === QFieldCloudConnection.LoggedIn
checked: cloudConnection.status === QFieldCloudConnection.LoggedIn
indicator.height: 16
indicator.width: 16
indicator.implicitHeight: 24
indicator.implicitWidth: 24
}
}

standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: {
var applicationLogMessage = appliationLogInput.text.trim()
iface.sendLog(applicationLogMessage != '' ? applicationLogMessage : 'Manual log submission', includeCloudInformationCheckBox.checked ? cloudConnection.username : '')
displayToast(qsTr("Your application log is being sent"))
nirvn marked this conversation as resolved.
Show resolved Hide resolved
}
}

Connections {
target: model

Expand Down
14 changes: 11 additions & 3 deletions src/sentry/sentry_classic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,19 @@ namespace sentry_wrapper
sentry_close();
}

void capture_event( const char *message )
void capture_event( const char *message, const char *cloudUser )
{
sentry_capture_event( sentry_value_new_message_event(
sentry_value_t event = sentry_value_new_message_event(
SENTRY_LEVEL_INFO,
"custom",
message ) );
message );

sentry_value_t cloud = sentry_value_new_object();
sentry_value_set_by_key( cloud, "user", sentry_value_new_string( cloudUser ) );
sentry_value_t contexts = sentry_value_new_object();
sentry_value_set_by_key( contexts, "cloud", cloud );
sentry_value_set_by_key( event, "contexts", contexts );

sentry_capture_event( event );
}
} // namespace sentry_wrapper
2 changes: 1 addition & 1 deletion src/sentry/sentry_cocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void install_message_handler() {
originalMessageHandler = qInstallMessageHandler(qfMessageHandler);
}

void capture_event(const char *message) {
void capture_event(const char *message, const char *cloudUser) {
SentryId *eventId =
[SentrySDK captureMessage:[NSString stringWithUTF8String:message]];
#if 0
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/sentry_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ namespace sentry_wrapper
void init();
void close();
void install_message_handler();
void capture_event( const char *message );
void capture_event( const char *message, const char *cloudUser );
} // namespace sentry_wrapper
Loading