-
Notifications
You must be signed in to change notification settings - Fork 3
feat(cli_tools): Enable override of analytics API URL #85
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,18 +15,26 @@ abstract interface class Analytics { | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Analytics service for MixPanel. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| class MixPanelAnalytics implements Analytics { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| static const _defaultEndpoint = 'https://api.mixpanel.com/track'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| static const _defaultTimeout = Duration(seconds: 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| final String _uniqueUserId; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| final String _endpoint = 'https://api.mixpanel.com/track'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| final String _endpoint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| final String _projectToken; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| final String _version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| final Duration _timeout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| MixPanelAnalytics({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| required final String uniqueUserId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| required final String projectToken, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| required final String version, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| final String endpoint = _defaultEndpoint, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| final Duration timeout = _defaultTimeout, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) : _uniqueUserId = uniqueUserId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| _projectToken = projectToken, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| _version = version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| _version = version, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| _endpoint = endpoint, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| _timeout = timeout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
27
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Add documentation for the new constructor parameters. The new Apply this diff to add parameter documentation: MixPanelAnalytics({
required final String uniqueUserId,
required final String projectToken,
required final String version,
+ /// The MixPanel API endpoint URL. Defaults to the standard MixPanel track endpoint.
final String endpoint = _defaultEndpoint,
+ /// The timeout duration for analytics API calls. Defaults to 2 seconds.
final Duration timeout = _defaultTimeout,
}) : _uniqueUserId = uniqueUserId,📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| @override | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| void cleanUp() {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -69,7 +77,7 @@ class MixPanelAnalytics implements Analytics { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Accept': 'text/plain', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Content-Type': 'application/x-www-form-urlencoded', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).timeout(const Duration(seconds: 2)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).timeout(_timeout); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify test coverage for the new constructor parameters.
Ensure that the new
endpointandtimeoutparameters are covered by tests, particularly testing with custom values to verify the configuration works as intended.Run the following script to check for existing tests and instantiations:
🏁 Script executed:
Length of output: 710
Now let me search for the test file to check what coverage exists:
is not applicable here as we need the repository files.
🏁 Script executed:
Length of output: 99
🏁 Script executed:
Length of output: 2432
🏁 Script executed:
Length of output: 4911
🏁 Script executed:
Length of output: 939
Add unit tests for MixPanelAnalytics constructor parameters.
The
endpointandtimeoutparameters are used in the HTTP request (lines 74 and 80) but lack dedicated test coverage. Create tests to verify:🤖 Prompt for AI Agents