Skip to content

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 you want to attach to a feedback. Wiredash will call this callback when appropriate, i.e. when the user takes a screenshot.

return Wiredash(
  // ...
  feedbackOptions: WiredashFeedbackOptions(
    collectMetaData: (metaData) => metaData
      // user information
      ..userEmail = 'dash@wiredash.io'
      ..userId = '0242ac120002',

      // information about your app build
      ..buildVersion = '1.2.1',
      ..buildNumber = '42',
      ..buildCommit = '74a54cc',

      // custom metadata
      ..custom['isPremium'] = false
      ..custom['nested'] = {'wire': 'dash'},
  )
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

Note, that Wiredash prepopulates the metaData Object before handling it to the collectMetaData callback. Properties like the buildNumber may be already set, as well as properties from a previous call to collectMetaData or when Wiredash.of(context).setUserProperties() was called beforehand.

You're responsible to set properties that will be sent to the console, as well as removing properties you don't want to send to the console.

INFO

Make sure to set userEmail and userId to null when a user logs out

Custom metadata

You can go completely custom by adding custom properties to the custom Map. The data structures (List, Map) can be deeply nested.

return Wiredash(
  // ...
  feedbackOptions: WiredashFeedbackOptions(
    collectMetaData: (metaData) => metaData
      // custom metadata
      ..custom['customKey'] = 'customValue'
      ..custom['nested'] = {
        'emails_read_today': 13, 
        {
          'items': 24,
        },
      },
  )
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14

The only restriction is that the data structures must be serializable.

WARNING

DateTime is not serializable! Use dateTime.toIso8601String()

If Wiredash can't serializable your 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 your console during development.

Your custom metadata will be visible in the console afterwards. Congrats!

Prefill email address

To prefill the email address, use the setUserProperties method before opening Wiredash.

Wiredash.of(context).setUserProperties(
  userEmail: 'mail@example.com',
  userId: 'custom-id',
);
1
2
3
4

Or use the collectMetaData callback as described above

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.

Set Build properties

During run-time

A quick way to set the build properties is calling this.

Wiredash.of(context).setBuildProperties(
  buildNumber: '42',
  buildVersion: '1.42.0',
  buildCommit: '74a54cc'
);
1
2
3
4
5

This is the same as implementing collectMetaData

You can also define them during compile-time instead.

During compile-time

Available only when using Flutter 1.17 or newer

If you want to receive information about build number, build version or specific commit related to the feedback you can pass additional parameters to your flutter build or flutter run command.

To receive the build information along with your feedback you must pass --dart-define flags to your flutter build command as follows:

flutter build --dart-define=BUILD_NUMBER=$BUILD_NUMBER --dart-define=BUILD_VERSION=$BUILD_VERSION --dart-define=BUILD_COMMIT=$FCI_COMMIT
1

Supported keys are:

  • BUILD_NUMBER
  • BUILD_VERSION
  • BUILD_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 current build number and SHA of commit used to build the app. For instance, on Codemagic these are BUILD_NUMBER and FCI_COMMIT respectively.

Be aware that this feature was added in Flutter 1.17 and won't work in previous versions.