Open
Description
Related to:
There was already work done to send events for the LogHandler
and Session
classes in #229, however, adding this feature to the SurveyHandler
requires a lot more of a refactor of the class so that we can easily pass the Analytics
instance to it to send the events
The code block below shows how we are currently initializing the survey handler for tests
analytics = Analytics.test(
tool: DashTool.flutterTool,
homeDirectory: homeDirectory,
measurementId: 'measurementId',
apiSecret: 'apiSecret',
dartVersion: 'dartVersion',
fs: fs,
platform: DevicePlatform.macos,
surveyHandler: FakeSurveyHandler.fromList(
homeDirectory: homeDirectory,
fs: fs,
initializedSurveys: <Survey>[
Survey(
uniqueId: 'uniqueId',
startDate: DateTime(2023, 1, 1),
endDate: DateTime(2023, 12, 31),
description: 'description',
snoozeForMinutes: 10,
samplingRate: 1.0,
excludeDashToolList: [],
conditionList: <Condition>[
Condition('logFileStats.recordCount', '>=', 50),
Condition('logFileStats.toolCount.flutter-tool', '>', 0),
],
buttonList: [],
),
],
),
);
In the above example, we are passing a constructor for the SurveyHandler
to the Analytics.test
constructor. For the LogHandler
and Session
, we initialize these variables within the constructor body making it easy for us to pass this
as a parameter. Example for how we configure LogHandler
below
// This is within the constructor body so we can reference "this"
_logHandler = LogHandler(
fs: fs,
homeDirectory: homeDirectory,
analyticsInstance: this,
);