Metadata
Wiredash collects metadata from the app, platform and the user to provide context for the feedback.
Custom properties
Wiredash can be initialized with custom properties such as the user email
that will be sent to the console together with the feedback.
Wiredash collects metadata when appropriate
Implement collectMetaData
callback and provide all information to attach to a feedback. Wiredash will call this callback when appropriate, i.e. when the user takes a screenshot.
return Wiredash(
// ...
collectMetaData: (metaData) => metaData
// user information
..userEmail = 'dash@wiredash.com'
..userId = 'player-12345',
// custom metadata
..custom['subscription'] = 'premium-3'
..custom['nested'] = {
'wire': 'dash',
},
);
The metaData
Object is mutable by design. It contains the values set the last time collectMetaData
was called as well as the properties set via Wiredash.of(context).setUserProperties()
or Wiredash.of(context).modifyMetaData()
.
You're responsible to set properties that will be sent to the console, as well as removing properties when necessary.
INFO
WiredashFeedbackOptions(collectMetaData: )
and PsOptions(collectMetaData: )
are deprecated and will not be called when Wiredash(collectMetaData: )
is set
Reset metadata
When a user logs out, make sure to reset the metadata to avoid leaking information to the next user.
Resetting all metadata is as easy as
Wiredash.of(context).resetMetaData();
Removing partial metadata is also possible
Wiredash.of(context).modifyMetaData((metadata) => metadata
..userEmail= null
..userId= null
..custom.remove('subscription'),
);
Custom metadata
Metadata are completely customizable by adding custom properties to the custom
Map
. The data structures (List
, Map
) can be deeply nested.
return Wiredash(
// ...
collectMetaData: (metaData) => metaData
// custom metadata
..custom['customKey'] = 'customValue'
..custom['nested'] = {
'emails_read_today': 13,
{
'items': [5, 7, 8, 9],
},
'doubleValue': 1.0,
'intValue': 1,
'stringValue': 'string',
'boolValue': true,
'lastLogin': _lastLogin.toIso8601String(),
},
);
The only restriction is that the data structures must be serializable.
WARNING
DateTime
is not serializable! Use dateTime.toIso8601String()
If Wiredash can't serializable custom meta-data with jsonEncode
they will be removed before sending them to the Wiredash Console. An error will be printed, so watch out for the console during development.
Custom metadata will be visible in the console, attached to every feedback. Congrats!
Prefill email address
To prefill the email address and userId
, use the setUserProperties
method before opening Wiredash.
Wiredash.of(context).setUserProperties(
userEmail: 'mail@example.com',
userId: 'custom-id',
);
INFO
For privacy reasons the userEmail
won't be attached automatically but it will be used to populate the input field so the user does not have to fill it in manually.
Or use the Wiredash.of(context).modifyMetaData()
to attach custom metadata
Wiredash.of(context).modifyMetaData((metadata) => metadata
..userEmail= 'mail@example.com'
..userId= 'custom-id'
..custom = {
'subscription': 'premium-3',
},
);
Set Build properties
Automatically collected
Wiredash automatically collects build properties from your app with native APIs. This usually works out of the box.
However, some platforms like Flutter Web or linux may not return the correct values. In this case you can set the build properties manually with --dart-define
during compile time
During compile-time
You can override the build properties Wiredash will attach to feedback by passing --dart-define
flags to your flutter build
command.
Supported keys are:
BUILD_NUMBER
BUILD_VERSION
BUILD_COMMIT
flutter build \
--dart-define=BUILD_NUMBER=$BUILD_NUMBER \
--dart-define=BUILD_VERSION=$BUILD_VERSION \
--dart-define=BUILD_COMMIT=$FCI_COMMIT
In the example above $BUILD_NUMBER
is an environment variable defined in CI. Of course, you can also use any other value or variable like --dart-define=BUILD_NUMBER="1.0.42"
.
Most of the CI platforms define some common environment variables containing the current build number and SHA of the commit used to build the app. For instance, on Codemagic these are BUILD_NUMBER
and FCI_COMMIT
respectively.
During run-time (deprecated)
Previous versions of Wiredash (<1.8.0) supported setting build properties during run-time. This method is now deprecated and not operational anymore.
Please remove this code!
// deprecated
Wiredash.of(context).setBuildProperties(
buildNumber: '42', // does not work anymore
buildVersion: '1.42.0', // does not work anymore
buildCommit: '74a54cc' // does not work anymore
);
Build properties are now collected automatically. To override, set the values at compile-time instead.