
Research
/Security News
60 Malicious Ruby Gems Used in Targeted Credential Theft Campaign
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
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.
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
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.