
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
react-loggly-jslogger
Advanced tools
Wrapper of loggly-jslogger for use in React apps.
Provides a LogglyTracker
instance with helper functions for logging various levels of messages.
Data provider callbacks can be used to append properties to the data sent to Loggly as new information becomes available (e.g. authenticated user information).
Install the package using NPM or Yarn:
npm install --save react-loggly-jslogger
# or
# yarn add react-loggly-jslogger
Add your Loggly token and any environment-specific tags to ./.env
:
REACT_APP_LOGGLY_CUSTOMER_TOKEN=<token>
REACT_APP_LOGGLY_TAG=mytagone,mytagtwo
LogglyProvider
Componentimport React from 'react';
import { LogglyProvider } from 'react-loggly-jslogger';
// Custom LogglyTracker initialization options
// Sensible React defaults (including your customer token) are automatically applied
const options = {};
// Custom data can be appended using provider callbacks
// Additional providers can be added later down the component tree (see examples below)
const providers = {
// Custom "foo" data added to error messages only
foo: (instance, key, level, data) => {
if ('error' === level) {
return {
[key]: 'bar',
};
}
},
};
const App = (props) => (
<LogglyProvider options={options} providers={providers}>
...
</LogglyProvider>
);
export default App;
useLoggly
Hookimport React from 'react';
import { useLoggly } from 'react-loggly-jslogger';
import { useUser } from 'some-authed-user-provider';
const AccountDashboard = (props) => {
const { error, providers } = useLoggly();
const { user } = useUser();
// Append authenticated user information to logged messages
providers.user = (instance, key, level, data) => ({
[key]: user.id,
)},
try {
somethingThatBangs();
} catch (err) {
error(err);
}
return (
<>
...
</>
);
};
export default AccountDashboard;
withLoggly
High-Order Componentimport React, { Component } from 'react';
import { withLoggly } from 'react-loggly-jslogger';
import { withUser } from 'some-authed-user-provider';
class AccountDashboard extends Component {
render() {
const { loggly: { error, providers }, user } = this.props;
// Append authenticated user information to logged messages
providers.user = (instance, key, level, data) => ({
[key]: user.id,
)},
try {
somethingThatBangs();
} catch (err) {
error(err);
}
return (
<>
...
</>
);
}
}
export default withLoggly(withUser(AccountDashboard));
FAQs
React providers for loggly-jslogger using the Context API.
The npm package react-loggly-jslogger receives a total of 65 weekly downloads. As such, react-loggly-jslogger popularity was classified as not popular.
We found that react-loggly-jslogger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.