-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(packages/sui-logger): Migrate sui-logger from inner source
- Loading branch information
Showing
22 changed files
with
3,674 additions
and
3,198 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,43 @@ | ||
{ | ||
"name": "@s-ui/logger", | ||
"version": "1.0.0-beta0", | ||
"description": "Web app logger for both client and server side", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"lib": "babel --presets sui ./src --out-dir ./lib", | ||
"lint": "sui-lint js", | ||
"prepublishOnly": "rm -rf ./lib && npm run lib", | ||
"test": "npm run test:server && npm run test:browser", | ||
"test:browser": "NODE_ENV=test sui-test browser -P './test/browser/*Spec.js' -H", | ||
"test:server": "NODE_ENV=test sui-test server -P './test/server/*Spec.js'" | ||
}, | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"react": "16 || 17" | ||
}, | ||
"dependencies": { | ||
"@s-ui/react-router": "1", | ||
"bunyan": "1.8.12", | ||
"bunyan-middleware": "1.0.0", | ||
"hot-shots": "7.7.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "7.15.7", | ||
"@s-ui/bundler": "9", | ||
"@s-ui/lint": "4", | ||
"@s-ui/mono": "2", | ||
"@s-ui/test": "8", | ||
"babel-preset-sui": "3", | ||
"chai": "4.3.4", | ||
"react": "17", | ||
"sinon": "11.1.2" | ||
}, | ||
"config": { | ||
"sui-test": { | ||
"server": { | ||
"esmOverride": true, | ||
"useLibDir": true | ||
} | ||
} | ||
} | ||
} |
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,19 @@ | ||
import createLogger from './logger' | ||
|
||
export const createClientLogger = ({userId, trackerName} = {}) => | ||
createLogger({ | ||
listenUnhandled: logError => { | ||
const handleWindowError = e => { | ||
const error = e.reason || e.error | ||
|
||
logError(error) | ||
} | ||
|
||
window.addEventListener('error', handleWindowError) | ||
window.addEventListener('unhandledrejection', handleWindowError) | ||
}, | ||
userAgent: window.navigator.userAgent, | ||
trackerName, | ||
userId, | ||
getUrlFactory: () => window.location.href | ||
}) |
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,15 @@ | ||
const {NODE_ENV} = process.env | ||
const isServer = typeof window === 'undefined' ? 'true' : 'false' | ||
|
||
export {createClientLogger} from './client.js' | ||
export {createServerLogger, logErrorsMiddleware} from './server.js' | ||
export {traceInitialProps} from './traceInitialProps.js' | ||
|
||
export const initTracker = ({Mushroom, appName, environment, version, tenant, ...config}) => { | ||
const context = {environment: environment || NODE_ENV, isServer, version, tenant} | ||
|
||
Mushroom.start(appName, { | ||
...config, | ||
context | ||
}) | ||
} |
Oops, something went wrong.