Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fathom-client

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fathom-client - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

2

package.json
{
"name": "fathom-client",
"version": "2.0.2",
"version": "2.0.3",
"description": "A simple wrapper around the Fathom Analytics library",

@@ -5,0 +5,0 @@ "keywords": [

@@ -50,53 +50,25 @@ # Fathom Client [![CircleCI](https://circleci.com/gh/unstacked/fathom-client.svg?style=svg)](https://circleci.com/gh/unstacked/fathom-client)

```jsx
import React from 'react';
import App from 'next/app';
import React, { useEffect } from 'react';
import Router from 'next/router';
import * as Fathom from 'fathom-client';
class MyApp extends App {
render() {
const { Component, pageProps } = this.props;
return <Component {...pageProps} />;
}
}
// Record a pageview when route changes
Router.events.on('routeChangeComplete', () => {
Fathom.trackPageview();
});
export default MyApp;
```
function App({ Component, pageProps }) {
// Initialize Fathom when the app loads
useEffect(() => {
if (process.env.NODE_ENV === 'production') {
Fathom.load();
Fathom.setSiteId('ZFEWBXJZ');
Fathom.trackPageview();
}
}, []);
Then, add a wrapper component with an effect to load Fathom on page load:
return <Component {...pageProps} />;
}
```diff
- import React from 'react'
+ import React, { useEffect } from 'react'
+ import * as Fathom from 'fathom-client'
+ import Router from 'next/router'
import App from 'next/app'
+ Router.events.on('routeChangeComplete', () => {
+ Fathom.trackPageview();
+ });
+ function Layout(props) {
+ useEffect(() => {
+ if (process.env.NODE_ENV === 'production') {
+ Fathom.load();
+ Fathom.setSiteId('<your-site-id>');
+ Fathom.trackPageview();
+ }
+ }, []);
+
+ return <div {...props} />;
+ }
class MyApp extends App {
render() {
const { Component, pageProps } = this.props
- return <Component {...pageProps} />
+ return (
+ <Layout>
+ <Component {...pageProps}></Component>
+ </Layout>
+ )
}
}
export default MyApp
export default App;
```

@@ -103,0 +75,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc