apptics_flutter 0.0.8 copy "apptics_flutter: ^0.0.8" to clipboard
apptics_flutter: ^0.0.8 copied to clipboard

Flutter plugin for Apptics, wrapper around Apptics Native iOS and Android SDK. Supports features likes in-app updates, in-app events, screens and sessions.

Apptics Flutter #

Flutter library for Apptics, wrapper around Apptics Native iOS and Android SDK. Supports features likes in-app updates, in-app events, screens and sessions.

Android initialization steps #

  1. Register your app and download apptics-config.json from Apptics web console.

  2. Place apptics-config.json file in app/ directory (Root of the Android Studio app module).

  3. Add apptics-plugin classpath and zoho maven url in project level build.gradle

    buildscript {
        repositories {
            maven {
                url "https://maven.zohodl.com/"
            }
        }
        dependencies {
            classpath 'com.zoho.apptics:apptics-plugin:0.2.3'
        }
    }
    allprojects {
     repositories {
         maven {
             url "https://maven.zohodl.com/"
         }
     }
    }
    
  4. In the Android environment, our support begins from a minimum SDK version of 23.

Initialization steps for Apple platforms

  1. Register your app and download apptics-config.plist from Apptics web console.
  2. Once you have created the Project and added your app, download the apptics-config.plist, and move the file into the Xcode project root folder and add the config file to the main target.
  3. Add pre-build scripts.

To add a Run Script via podfile.

source 'https://github.com/CocoaPods/Specs.git'
  target 'MAIN TARGET' do

    # Pre build script will register the app version, upload dSYM file to the server and add apptics specific information to the main info.plist which will be used by the SDK.
    script_phase :name => 'Apptics pre build', :script => 'sh "./Pods/Apptics-SDK/scripts/run" --upload-symbols-for-configurations="Release, Appstore"', :execution_position => :before_compile

  end

Or add a Run Script manually.

  • In the project navigator, select your project.

  • Select the target you want to modify.

  • Click the Build Phases tab. Click the Add button (+), then choose “New Run Script Phase” from the pop-up menu and rename it as 'Apptics pre build.'

  • Click the disclosure triangle for the newly added Run Script phase.

  • In the Shell text field, enter the script below.

    sh "./Pods/Apptics-SDK/scripts/run" --upload-symbols-for-configurations="Release, Appstore"
    

Important:

  • Adding pre-build scripts is mandatory.
  • In the pre-build script, we upload dSYM to the server (optional), register the app with the Apptics server, and add the necessary information of the app version into the apptics-config.plist which is used by the SDK to send the data to the Apptics server.
  • Always make sure 'Copy Bundle Resources' below the 'Compile Sources' and 'Apptics pre build' is above 'Compile Sources'.

Build script usage:

run --upload-symbols-for-configurations="Release, Appstore" --config-file-path="YOUR_PATH/apptics-config.plist" --app-group-identifier="group.com.company.application [Optional]"

  • --config-file-path pass your config file path if it is not added to your project root.
  • --app-group-identifier if you have enabled app group identifier for your app's target.
  • --upload-symbols-for-configurations String, an optional parameter to pass your configuration name debug, release, or add a custom name with comma-separated for which the dSYMs will be uploaded without any prompt during App Store submission process via CI, CT, and CD.

For more details on how to configure for multiple projects please visit iOS user guide

  1. Build the Xcode project and check for any issues and skip to 'Event Tracking'.

Create AppticsFlutter instance

import 'package:apptics_flutter/apptics_flutter.dart';

class _YourClassState extends State<YourClass> {
  // initializes AppticsFlutter
 // _appticsFlutterPlugin can be used to track events, screens, user and control tracking settings.
  final _appticsFlutterPlugin = AppticsFlutter();
}

Event Tracking

  1. Track the configured event with properties using addEvent method.
  _appticsFlutterPlugin.addEvent("eventName", "eventGroupName") // Without Properties
  (or)
  _appticsFlutterPlugin.addEvent("eventName", "eventGroupName", properties: {"propKey": "propValue"}) // With Propeties
  

Screen Tracking

Use the methods provided to track screen navigation.


// call when screen appears
_appticsFlutterPlugin.screenAttached("screenName")

// call when screen disappears
_appticsFlutterPlugin.screenDetached("screenName")

Track User

Ties user-id with other stats (events, screens etc)

User Id tracking will happen with respect to Tracking Settings. If the tracking settings is " WithoutPII", stats will not be associated with the user id.


_appticsFlutterPlugin.setUser("userid")

Tracking settings

Apptics offer 7 tracking states to control usage and crash tracking.

  1. UsageAndCrashTrackingWithPII
  2. UsageAndCrashTrackingWithoutPII
  3. OnlyUsageTrackingWithPII
  4. OnlyUsageTrackingWithoutPII
  5. OnlyCrashTrackingWithPII
  6. OnlyCrashTrackingWithoutPII
  7. NoTracking

UsageAndCrashTrackingWithoutPII is the default state out of the box.

Usage Tracking

Usage tracking generally refers to tracking the Events, APIs, Screens, Sessions.

Crash Tracking

Crash tracking is self-explanatory and refers to the tracking of unhandled exceptions.

PII

The term PII is used to denote the value you set using the _appticsFlutterPlugin.setUser method.

You can use setTrackingState method to change the tracking state.


// to change the tracking settings to track only crash and associate user id with crash.
_appticsFlutterPlugin.setTrackingState(TrackingState.OnlyCrashTrackingWithPII);

// to get the current tracking state
_appticsFlutterPlugin.getTrackingState();

In-app Ratings #

Use AppticsInAppRating instance #

  • To check and show new rating alert pop-up, call checkForRatingPop method.
import 'package:apptics_flutter/rateus/apptics_in_app_rating.dart'';

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
// To check and show a new rating alert pop-up, call the checkForRatingPop method.
    AppticsInAppRating.instance.checkForRatingPop(context);

    // return your widget;
  }
}
  • To activate the "Send Feedback" option, set isFeedbackEnabled to true. Future<void> checkForRatingPop(BuildContext context, {bool isFeedbackEnabled = false})
  • This method should be invoked after setting the theme and creating the navigator in a Flutter application.
  • The in-rating pop functionality in Flutter does not currently provide support for Material3.

The in-app rating pop-up will be shown automatically with respect to the configuration in the web console. The default pop-up will have two or three options depending on the availability of Apptics feedback module dependency.

  • 'Rate in Playstore' action will redirect the user to the PlayStore where user can add their ratings and reviews.
  • 'Later' action will dismiss the rating pop-up and the pop-up will be automatically prompted again after a certain period.
  • 'Send Feedback' action will only appear if the Apptics feedback SDK is integrated into the app. This action will direct the user to the Apptics feedback activity. Ensure that you set the Apptics theme; otherwise, app will crash.

If the user chooses 'later' option in the pop-up, the next prompt will be deferred by 10 days ( default). Use the below method to customize the number of days to defer the prompt.

    AppticsInAppRating.instance.daysBeforeShowingPopupAgain = // days as int;

If the user chooses 'Later' option for three consecutive times, the popup will not be shown again until the criteria for that app version is reconfigured in the Apptics web console. Use the below method to customize the max number of prompts.

    AppticsInAppRating.instance.maxTimesToShowPopup = //number as int

Build your own UI #

   import 'package:apptics_flutter/rateus/apptics_in_app_rating.dart'';
   
   await AppticsInAppRating.instance.getCriteriaId();
  • The method above returns the criteriaId, which you can use to construct your UI. If the criteriaId is available, you can display your UI. This method operates asynchronously.

  • You will have to call the sendStats method to send the stats to the server.

The value of an action param can be RATE_IN_STORE_CLICKED, SEND_FEEDBACK_CLICKED, or LATER_CLICKED enum depending upon whether the button clicked is to:

  • Rate the app
  • Go to the feedback screen
  • Dismiss the dialog
   import 'package:apptics_flutter/rateus/apptics_in_app_rating.dart'';
   
       AppticsInAppRating.instance.sentStats(criteriaId: criteriaId, popupAction: PopupAction.LATER_CLICKED); 
       

Store in-app review API #

   import 'package:apptics_flutter/rateus/apptics_in_app_rating.dart'';
   
    AppticsInAppRating.instance.setShowStoreAlertOnFulFillingCriteria(true);

If you use checkForRatingPop method. Enabling this will automatically present Google Play's in-app review system once the configured criterion is fulfilled.

Google Play review API doesn't have a callback to know whether the review UI is presented or not.

The Review API quotas are not well defined in the documentation. So, once the configured criterion is fulfilled and the Review API is invoked we will automatically defer the next review API call with respect to the value set in daysBeforeShowingPopupAgain.

Remote Configuration #

Check our user guides to configure Remote config params and conditions.

Use the below snippet to fetch value for a param.

import 'package:apptics_flutter/remoteconfig/apptics_remote_config.dart';

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});
  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  getRemoteConfigData(BuildContext context) async {
    // Use the below method to fetch value for a param.
    String? stringValue = await AppticsRemoteConfig.instance.getStringValue('color'); // params need to config in web console.
    if (stringValue != null) {
      print("stringValue $stringValue");
      showDialog(
        context: context,
        builder: (context) {
          return AlertDialog(
            title: Text(stringValue),
            alignment: Alignment.center,
          );
        },
      );
    } else {
      print("No data available");
    }
  }

  @override
  Widget build(BuildContext context) {
    getRemoteConfigData(context);
    // return your widget;
  }
}

getStringValue accept three params. Future<String?> getStringValue(String key, { bool coldFetch = false, bool fallbackWithOfflineValue = false,})

  • key [String] - the name of the param configured in web console.
  • 'coldFetch' [bool] getStringValue has a cache mechanism, which prevents frequent network calls. If coldFetch is enabled, getStringValue fetches from Network ignoring the cache mechanism. However, we allow only 3 calls to network per minute, if this threshold breaks the method will return null or fallback to offline value.
  • 'fallbackWithOfflineValue' [Boolean] - If enabled, getStringValue will return previously fetched value incase of Network failures.

Set custom condition criteria #

Use the below method to set custom condition criteria for the device.

AppticsRemoteConfig.instance.setCustomConditionValue("ConditionKey", "Criteria")

In-App Update #

Show Popup: #

  • To check and show new version alert pop-up, call checkAndUpdateAlert method.
import 'package:apptics_flutter/appupdate/apptics_in_app_update.dart';

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  

  @override
  Widget build(BuildContext context) {
    // Call the method checkAndUpdateAlert to check for updates and to show the update popup.
    AppticsInAppUpdates.instance.checkAndUpdateAlert(context);
    
    // return your widget;
  }
}
  • This method should be invoked after setting the theme and creating the navigator in a Flutter application.
  • The in-app update functionality in Flutter does not currently provide support for Material3.

Build your own flow #

  • The method below returns a Map<String, dynamic?>, allowing you to obtain data for your pop-up UI.
  • With the data obtained from this method, you have the flexibility to design and implement your own custom pop-up UI to display the in-app update information.
      AppticsInAppUpdates.instance.getInAppUpdateData(context)
  • Returns null, in case of no update availability.
  • You can determine the response type base on the value of the category string, where 1 represents Normal update data and 2 represents Non-Supported OS popup data.
  • After obtaining the map, you can extract the key-value pairs listed below, which can be used to create your custom UI. The action methods available are onClickUpdate, onClickReminder, onClickIgnore, onClickNonSupportAlert, and onSendImpressionStatus.
  • Below are the keys you can use to construct your custom UI.
 For Custom Alerts data (Normal update):
 'updateid': The ID corresponding to a specific update configuration.
 'currentversion': The version of the app installed on the device.
 'featureTitle': The title or heading for the version alert.
 'features': Update features or what's new.
 'remindMeLaterText': Localized text for the "Remind Me Later" action.
 'updateNowText': Localized text for the "Update" action.
 'neverAgainText': Localized text for the "Ignore" action.
 
 The 'option' key determines the type of UI selected for this update in the web console:
 option (1): Flexible update flow.
 option (2): Immediate update flow.
 option (3): Force update flow.
 Read More https://www.zoho.com/apptics/resources/user-guide/in-app-updates.html
 
 'reminderDays': The number of days before showing the popup again if the user chooses "Remind Me Later." These days can be configured from the web console.

 'forceInDays': A custom store URL to redirect when the user taps "Update/Download." This can also be configured from the web console.

 'alertType': The type of the alert - Android in-app updates / ZAnalytics:
 
 0: Apptics Native UI alert
 1: Apptics Custom UI alert
 2: Android in-app updates
 
 'customStoreUrl': You can redirect this URL to another store.

 For the Non-Supported OS popup data:

 'title': The title of the popup.
 'description': The description of the popup.
 'continueBtTxt': Button text for the popup.
 'alertType' in the Non-Supported OS popup determines the action:
  0: Do Nothing
  1: Install Later
  2: Freeze
 'updateid': The ID corresponding to a specific update configuration.

Apptics Crash Tracking #

Fatal Crash #

  • To enable automatic crash tracking, use the following method.
import 'package:apptics_flutter/crash_tracker/apptics_crash_tracker.dart';

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  
  @override
  Widget build(BuildContext context) {
    // Call the method autoCrashTracker to enable crash autoTracking.
    AppticsCrashTracker.instance.autoCrashTracker();
    
    // return your widget;
  }
}

Get last crash info #

  • You can always get the previous crash information as stringified JSONObject.
import 'package:apptics_flutter/crash_tracker/apptics_crash_tracker.dart';

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    // You can reliably obtain the previous crash information as a string.
    String? lastCrash = AppticsCrashTracker.instance.getLastCrashInfo();

    // return your widget;
  }
}
  • Sample JSON structure:
{
  "issuename": "divide by zero",
  "message": "java.lang.ArithmeticException: divide by zero\n\tat com.zoho.apptics.MainActivity.onCreate$lambda$2(MainActivity.kt:42)",
  "networkstatus": 0,
  "serviceprovider": "T-Mobile",
  "orientation": 0,
  "batterystatus": 100,
  "edge": "Unknown",
  "ram": "2.9 GB",
  "rom": "5.8 GB",
  "sessionstarttime": 1711445408267,
  "customproperties": {},
  "screenname": "com.zoho.apptics.MainActivity",
  "happenedat": 1711445420908,
  "happenedcount": 1,
  "listofhappenedtime": 1711445420908,
  "errortype": "native"
}

Showing consent pop-up to send previous session crash info #

  • Presenting a consent pop-up to send crash information from previous sessions.

import 'package:apptics_flutter/crash_tracker/apptics_crash_tracker.dart';

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    // Displaying a consent pop-up to allow the sending of crash information from previous sessions.
    AppticsCrashTracker.instance.showLastSessionCrashedPopup();

    // return your widget;
  }
}

Non-Fatal Crash #

Handle Exception #

  • You can use the following method to record non-fatal exceptions.

import 'package:apptics_flutter/crash_tracker/apptics_crash_tracker.dart';

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    
     try {
      int k = (1 / 0) as int;
    }catch(e,s){
      // Use the below method to record non-fatal.
      AppticsCrashTracker.instance.sendNonFatalException(e, s);
    }

    // return your widget;
  }
}

Set Custom Property #

  • Add custom properties for both fatal and non-fatal events using the method below.
import 'package:apptics_flutter/crash_tracker/apptics_crash_tracker.dart';

 class MyApp extends StatelessWidget {
  const MyApp({super.key});
  
  setCustomProperties() async {
    Map<String, dynamic> _portaInfoMap = {
      "name": "ABCD",
      "domains": ["Data Science", "Mobile", "Web"],
    };

    // Implement the following method to set a Custom Property. You can pass the parameter [map].
    await AppticsCrashTracker.instance.setCrashCustomProperty(_portaInfoMap);
  }
   
  @override
  Widget build(BuildContext context) {
    setCustomProperties();
    // return your widget;
  }
}

Apptics Feedback #

Opening Feedback Screen #

  • The openFeedback() method to directly open the feedback screen where users can submit their feedback.
import 'package:apptics_flutter/feedback/apptics_feedback.dart';

  AppticsFeedback.instance.openFeedback(); // To open the Apptics Feedback screen. 

Reporting a Bug with Screenshot Annotation #

  • The reportBug() method allows users to take a screenshot and annotate it to report bugs easily.
import 'package:apptics_flutter/feedback/apptics_feedback.dart';

  AppticsFeedback.instance.reportBug(); // To open the Apptics Feedback screen. 

Example #

import 'package:apptics_flutter/feedback/apptics_feedback.dart';
import 'package:flutter/material.dart';

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  reportBug() async{
    AppticsFeedback.instance.reportBug(); // To report the bug
  }

  openFeedback() async{
    AppticsFeedback.instance.openFeedback(); // To open the Apptics Feedback screen.
  }

  @override
  Widget build(BuildContext context) {
    // Your application UI
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text("Apptics Feedback Example")),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              ElevatedButton(
                onPressed: () async {
                  // Call the feedback method when the button is pressed
                  openFeedback();
                },
                child: const Text("Send Feedback"),
              ),
              ElevatedButton(
                onPressed: () async {
                  // Call the report bug method when the button is pressed
                  reportBug();
                },
                child: const Text("Report Bug"),
              )
            ]
        ),
      ),
    ));
  }
}

Enabling/Disabling Shake-to-Feedback #

  • Shake-to-Feedback allows users to shake their device to open the feedback screen. You can enable or disable this feature:

Enable Shake for Feedback: #

  • Use the enableShakeForFeedback() method to activate shake for feedback.
  • Note: Shake for feedback is enabled by default.
import 'package:apptics_flutter/feedback/apptics_feedback.dart';
    AppticsFeedback.instance.enableShakeForFeedback();

Disable Shake for Feedback: #

  • Use the disableShakeForFeedback() method to activate shake for feedback.
import 'package:apptics_flutter/feedback/apptics_feedback.dart';
    AppticsFeedback.instance.disableShakeForFeedback();

Check if Shake for Feedback is Enabled: #

  • The isShakeForFeedbackEnabled() method returns whether shake for feedback is enabled.
import 'package:apptics_flutter/feedback/apptics_feedback.dart';
    AppticsFeedback.instance.isShakeForFeedbackEnabled();

Example #

import 'package:apptics_flutter/feedback/apptics_feedback.dart';
import 'package:flutter/material.dart';

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  enableShakeForFeedback() async{
    AppticsFeedback.instance.enableShakeForFeedback(); // To enable share for feedback
  }

  disableShakeForFeedback() async{
    AppticsFeedback.instance.disableShakeForFeedback(); // To disable share for feedback
  }
  
  checkShakeForFeedbackStatus() async{
    bool? isEnabled = await AppticsFeedback.instance.isShakeForFeedbackEnabled(); // To check shake for feedback status
    print("ShakeForFeedback Status: $isEnabled");
  }

  @override
  Widget build(BuildContext context) {
    // Your application UI
    return MaterialApp(
        home: Scaffold(
          appBar: AppBar(title: const Text("Apptics Feedback Example")),
          body: Center(
            child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  ElevatedButton(
                    onPressed: () async {
                      // Call the enable method when the button is pressed
                      enableShakeForFeedback();
                    },
                    child: const Text("Enable Shake To Feedback"),
                  ),
                  ElevatedButton(
                    onPressed: () async {
                      // Call the disable method when the button is pressed
                      enableShakeForFeedback();
                    },
                    child: const Text("Disable Shake To Feedback"),
                  ),
                  ElevatedButton(
                    onPressed: () async {
                      // Call the check method when the button is pressed
                      checkShakeForFeedbackStatus();
                    },
                    child: const Text("Check Shake To Feedback Status"),
                  )
                ]
            ),
          ),
        ));
  }
}

Enabling/Disabling Anonymous User Alerts #

  • Enable or disable anonymous user alerts for collecting feedback without requiring user identification. This is enabled by default.

Enable Anonymous User Alert: #

  • The enableAnonymousUserAlert() method to enable the anonymous user alert.
import 'package:apptics_flutter/feedback/apptics_feedback.dart';
    AppticsFeedback.instance.enableAnonymousUserAlert();

Disable Anonymous User Alert: #

  • The disableAnonymousUserAlert() method to disable the anonymous user alert.
import 'package:apptics_flutter/feedback/apptics_feedback.dart';
    AppticsFeedback.instance.disableAnonymousUserAlert();

Example #

import 'package:apptics_flutter/feedback/apptics_feedback.dart';
import 'package:flutter/material.dart';

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  @override
  void initState() {
    super.initState();
    disableAnonymousUserAlert(); // Disable anonymous user alert during initialization.
  }

  // Method to disable anonymous user alert
  Future<void> disableAnonymousUserAlert() async {
    await AppticsFeedback.instance.disableAnonymousUserAlert();
  }

  // Method to enable anonymous user alert
  Future<void> enableAnonymousUserAlert() async {
    await AppticsFeedback.instance.enableAnonymousUserAlert();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text("Apptics Feedback Example")),
        body: const Center(
          child: ElevatedButton(
            onPressed: () async {
              // Call the enable method when the button is pressed
              enableAnonymousUserAlert();
            },
            child: const Text("Enable Anonymous User Alert"),
          ),
        ),
      ),
    );
  }
}

Check if Anonymous User Alert is Enabled: #

  • The isAnonymousUserAlertEnabled() method returns whether Anonymous User Alert is enabled.
import 'package:apptics_flutter/crash_tracker/apptics_crash_tracker.dart';
    AppticsFeedback.instance.isAnonymousUserAlertEnabled();

Programmatically Sending Feedback #

  • The sendFeedback() method allows you to programmatically send feedback, with options to include logs, diagnostics, and attachments.
import 'package:apptics_flutter/feedback/apptics_feedback.dart';
   
    AppticsFeedback.instance.sendFeedback(
      String feedbackMessage,
      bool includeLogs, bool includeDiagnostics,
      {String? guestMailId,
      bool forceToAnonymous = false,
      List<Uri>? attachmentsUri})

Parameters: feedbackMessage: The feedback content. includeLogs: Whether to include app logs. includeDiagnostics: Whether to include diagnostic data. guestMailId: (Optional) Email of the feedback sender. forceToAnonymous: (Optional) Forces feedback submission as anonymous. attachmentsUri: (Optional) Attachments (e.g., screenshots).

Programmatically Sending a Bug Report #

  • Similar to sending feedback, sendBugReport() lets users send a bug report with logs, diagnostics, and optional attachments.
import 'package:apptics_flutter/feedback/apptics_feedback.dart';
  
    AppticsFeedback.instance.sendBugReport(
      String feedbackMessage, 
      bool includeLogs, 
      bool includeDiagnostics,
      {String? guestMailId,
      bool forceToAnonymous = false,
      List<Uri>? attachmentsUri})

Parameters: feedbackMessage: The feedback content. includeLogs: Whether to include app logs. includeDiagnostics: Whether to include diagnostic data. guestMailId: (Optional) Email of the feedback sender. forceToAnonymous: (Optional) Forces feedback submission as anonymous. attachmentsUri: (Optional) Attachments (e.g., screenshots).

Example #

import 'package:apptics_flutter/feedback/apptics_feedback.dart';
import 'package:flutter/material.dart';

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  sendFeedback() async{
    
    AppticsFeedback.instance.sendFeedback(
        "Great application",
        true, true,
        guestMailId: "user@example.com",
        attachmentsUri: [Uri.parse('file://screenshot.png')]
    );
    
  }
  
  sendBugReport() async{
    
    AppticsFeedback.instance.sendBugReport(
        "Great app, but I found a bug!",
        true, true,
        guestMailId: "user@example.com",
        attachmentsUri: [Uri.parse('file://screenshot.png')]
    );
  }

  @override
  Widget build(BuildContext context) {
    // Your application UI
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text("Apptics Feedback Example")),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              ElevatedButton(
                onPressed: () async {
                  // Call the sendFeedback method when the button is pressed
                  sendFeedback();
                },
                child: const Text("Send Feedback"),
              ),
              ElevatedButton(
                onPressed: () async {
                  // Call the report bug method when the button is pressed
                  sendBugReport();
                },
                child: const Text("Send Report"),
              )
            ]
        ),
      ),
    ));
  }
}

Apptics Feedback Logs #

Apptics Feedback provides the necessary APIs to add logs and diagnostic info detail from anywhere in the app. The files containing these data can be sent by the user while sending feedback.

Use the below method to write a log.

import 'package:apptics_flutter/feedback/apptics_logs.dart';
import 'package:apptics_flutter/feedback/apptics_feedback.dart';

AppticsLogs.instance.writeLog("Some long", Log.DEBUG)

/* logtype is a predefined constant in android.Utils.Log class
* Log.VERBOSE
* Log.INFO
* Log.DEBUG
* Log.WARN
*/
  • Use the below method to attach a log file.
    import 'package:apptics_flutter/feedback/apptics_logs.dart';
    AppticsLogs.instance.addLogFile(file)

Note: If both addLogFile and writeLogs are set by the developer, priority is given to the addlog file. Only one logfile is allowed per feedback and it cannot exceed 1MB in size.

A diagnostic info file is a set of key-value pairs, where each pair can be grouped under the given heading. To add diagnostic info, follow the below.

    import 'package:apptics_flutter/feedback/apptics_logs.dart';
    AppticsLogs.instance.addDiagnosticsInfo("HEADING", "key", "value")

Example #

import 'package:apptics_flutter/feedback/apptics_log_type.dart';
import 'package:apptics_flutter/feedback/apptics_feedback.dart';
import 'package:apptics_flutter/feedback/apptics_logs.dart';
import 'package:flutter/material.dart';

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  sendBugReport() async{
    AppticsFeedback.instance.sendBugReport(
        "Great app, but I found a bug!",
        true, true,
        guestMailId: "user@example.com",
        attachmentsUri: [Uri.parse('file://screenshot.png')]
    );
  }
  addLogInfo() async{
    AppticsLogs.instance.writeLog("Log message", Log.debug); // To write log
                      // or 
    AppticsLogs.instance.addLogFile(File("path")); // To attach a log file.
    
    AppticsLogs.instance.addDiagnosticsInfo("HEADING", "key", "value"); // To add Diagnostics Information.
  }

  @override
  Widget build(BuildContext context) {

   addLogInfo();

    // Your application UI
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text("Apptics Feedback Example")),
        body: Center(
          child: ElevatedButton(
            onPressed: () async {
              // Call the report bug method when the button is pressed
              sendBugReport();
            },
            child: const Text("Send Report"),
          ),
        ),
      ),
    );
  }
}
5
likes
140
points
55
downloads

Publisher

verified publisherzoho.com

Weekly Downloads

Flutter plugin for Apptics, wrapper around Apptics Native iOS and Android SDK. Supports features likes in-app updates, in-app events, screens and sessions.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on apptics_flutter