
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
plausible-client
Advanced tools
Plausible client to collect analytics in browser with no hassle.
There are official plausible-tracker
package, it have quite few code, but have a lot of bugs like
Current package is lightweight too, but written and maintained by those who use a plausible analytics on production. See dogfooding.
Install package with npm i plausible-client
Create instance and play
import { Plausible } from 'plausible-client';
const plausible = new Plausible({
apiHost: 'https://plausible.io',
domain: 'example.org',
});
plausible.sendEvent('test', {
props: {
foo: 1,
bar: 'string',
baz: null,
},
revenue: {
currency: 'USD',
amount: 5,
},
});
To track page views automatically, call enableAutoPageviews
:
import { Plausible, enableAutoPageviews } from 'plausible-client';
const plausible = new Plausible({
apiHost: 'https://plausible.io',
domain: 'example.org',
});
// Function returns cleanup callback and starts track pageviews
enableAutoPageviews(plausible);
To track outbound clicks automatically, call enableAutoOutboundTracking
:
import { Plausible, enableAutoOutboundTracking } from 'plausible-client';
const plausible = new Plausible({
apiHost: 'https://plausible.io',
domain: 'example.org',
});
// Function returns cleanup callback and starts track outbound clicks
enableAutoOutboundTracking(plausible);
You may filter out specific events.
It may be useful to skip events of users who should not be tracked, ignore irrelevant events by its props, and for development purposes.
Just define predicate filter
in config:
true
to send request and false
to skipimport { Plausible, enableAutoOutboundTracking } from 'plausible-client';
const plausible = new Plausible({
apiHost: 'https://plausible.io',
domain: 'example.org',
filter(event, eventName) {
// Skip all events while development
if (location.hostname === 'localhost') {
console.warn('Analytics event is skipped, since run on localhost', event);
return false;
}
// Skip all events for users who don't want to be tracked
if (window.localStorage.plausible_ignore === 'true') return false;
// Skip events by event props
if (event.props.group === 'no-track') return false;
// Skip events by its name, for users who does not participate in preview program
if (!event.props.previewEnabled && eventName.startsWith('preview:')) return false;
// Pass all events otherwise
return true;
}
});
You may transform events.
It may be useful to enrich events data or redact some collected data.
Just define option transform
in config
import { Plausible, enableAutoOutboundTracking } from 'plausible-client';
const plausible = new Plausible({
apiHost: 'https://plausible.io',
domain: 'example.org',
transform(event, eventName) {
event.props = {
...event.props,
group: 'clients',
userId: event.props.uid ? "uuid:" + event.props.uid : undefined,
isPreferDarkTheme: window.matchMedia("(prefers-color-scheme: dark)").matches,
};
return event;
}
});
Transformation hook is runs after filter.
plausible-client
is an truth open source project, so you are welcome on project github repository to contribute a code, make issues with feature requests and bug reports.
You may contribute to a project if you tell about plausible-client
to your friends.
FAQs
Plausible analytics client with no hassle
The npm package plausible-client receives a total of 62 weekly downloads. As such, plausible-client popularity was classified as not popular.
We found that plausible-client demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.