-
Notifications
You must be signed in to change notification settings - Fork 29
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
New event added for sending analytics within package on errors #229
Merged
eliasyishak
merged 21 commits into
dart-lang:main
from
eliasyishak:167-new-event-for-internal-usage-within-package-for-logging-errors-unifiedanalyticserror
Feb 13, 2024
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
f87a22f
Added new event + refactoring sentEvent on impl
eliasyishak 116b710
Merge remote-tracking branch 'upstream/main' into 167-new-event-for-i…
eliasyishak 421df72
Fix tests + limiting one error event for logFileStats
eliasyishak 6f0e8a4
Make `Analytics` required for `LogHandler`
eliasyishak ac0f3ad
Make error sent a field in class
eliasyishak 42161bc
Events added for error handling in session handler
eliasyishak 5ec6a99
Remove unnecessary `io` import
eliasyishak 2bee9cc
Refactoring `legacyOptOut` to use loop
eliasyishak e313828
Only expose `sentEvents` on the `FakeAnalytics` instance
eliasyishak b0960ea
Bump version
eliasyishak 5307fde
Misc
eliasyishak 48abbd8
Convert to wip
eliasyishak 6079595
Pass send method instead of `Analytics` + nits
eliasyishak 0120151
`ErrorHandler` class created + used in session
eliasyishak ef19bb6
Use `ErrorHandler` with `LogHandler`
eliasyishak 103980a
Check telemetry status in `Session`
eliasyishak 74e7f8b
Tests added for the survey handler
eliasyishak b67ce4b
Fix error
eliasyishak 1bd099f
Tests added for log handler exceptions
eliasyishak 369147b
Use set for sent error messages
eliasyishak 39cb809
Test added to check for 2 unique error events
eliasyishak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'analytics.dart'; | ||
import 'enums.dart'; | ||
import 'event.dart'; | ||
|
||
class ErrorHandler { | ||
/// Stores each of the events that have been sent to GA4 so that the | ||
/// same error doesn't get sent twice. | ||
final Set<Event> _sentErrorEvents = {}; | ||
final SendFunction _sendFunction; | ||
|
||
/// Handles any errors encountered within package:unified_analytics. | ||
ErrorHandler({required SendFunction sendFunction}) | ||
: _sendFunction = sendFunction; | ||
|
||
/// Sends the encountered error [Event.analyticsException] to GA4 backend. | ||
/// | ||
/// This method will not send the event to GA4 if it has already been | ||
/// sent before during the current process. | ||
void log(Event event) { | ||
if (event.eventName != DashEvent.analyticsException || | ||
_sentErrorEvents.contains(event)) { | ||
return; | ||
} | ||
|
||
_sendFunction(event); | ||
_sentErrorEvents.add(event); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@christopherfujino thoughts?