forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create unstable API for event logging (facebook#39091)
Summary: Pull Request resolved: facebook#39091 Changelog: [Internal] Adds a simple typed logging hook to `react-native/dev-middleware`. This is intended to allow integrators to receive events from the dev server, apply any relevant sampling/processing, and log them to a backend. (To be clear, the open source version of React Native does not and will not collect any data.) WARNING: The API will evolve over the coming weeks/months and is *not guaranteed to be stable* - it might even break between patch releases. Reviewed By: huntie Differential Revision: D48466760 fbshipit-source-id: ed1e21fb0dac5d6199ff1ee26017a1d33d9b7d92
- Loading branch information
1 parent
910a956
commit f4f1894
Showing
6 changed files
with
108 additions
and
4 deletions.
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
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,48 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
*/ | ||
|
||
type SuccessResult<Props: {...} | void = {}> = { | ||
status: 'success', | ||
...Props, | ||
}; | ||
|
||
type ErrorResult<ErrorT = mixed> = { | ||
status: 'error', | ||
error: ErrorT, | ||
}; | ||
|
||
type CodedErrorResult<ErrorCode: string> = { | ||
status: 'coded_error', | ||
errorCode: ErrorCode, | ||
errorDetails?: string, | ||
}; | ||
|
||
export type ReportableEvent = | ||
| { | ||
type: 'launch_debugger_frontend', | ||
... | ||
| SuccessResult<{appId: string}> | ||
| ErrorResult<mixed> | ||
| CodedErrorResult<'MISSING_APP_ID' | 'NO_APPS_FOUND'>, | ||
} | ||
| { | ||
type: 'connect_debugger_frontend', | ||
...SuccessResult<void> | ErrorResult<mixed>, | ||
}; | ||
|
||
/** | ||
* A simple interface for logging events, to be implemented by integrators of | ||
* `dev-middleware`. | ||
* | ||
* This is an unstable API with no semver guarantees. | ||
*/ | ||
export interface EventReporter { | ||
logEvent(event: ReportableEvent): void; | ||
} |