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

Refactor SurveyHandler to use Event.analyticsException event for logging errors #232

Open
eliasyishak opened this issue Feb 1, 2024 · 0 comments

Comments

@eliasyishak
Copy link
Contributor

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,
    );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant