New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@goodhood/helpers

Package Overview
Dependencies
Maintainers
6
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@goodhood/helpers - npm Package Compare versions

Comparing version 1.0.0-beta.0 to 1.0.0

5

lib/index.esm.js

@@ -51,4 +51,7 @@ const dumpValue = item => {

const getNullLogger = () => () => {};
const defaultLogger = getLogger('nebenan', {
collapsed: true
});
export { getLogger, getNullLogger };
export { defaultLogger, getLogger, getNullLogger };
//# sourceMappingURL=index.esm.js.map

4

lib/index.js

@@ -55,5 +55,9 @@ 'use strict';

const getNullLogger = () => () => {};
const defaultLogger = getLogger('nebenan', {
collapsed: true
});
exports.defaultLogger = defaultLogger;
exports.getLogger = getLogger;
exports.getNullLogger = getNullLogger;
//# sourceMappingURL=index.js.map

@@ -6,2 +6,3 @@ type LoggerOptions = {

export declare const getNullLogger: typeof getLogger;
export declare const defaultLogger: (...args: unknown[]) => void;
export {};

@@ -9,3 +9,3 @@ {

"bugs": "https://github.com/goodhood-eu/goodhood/issues",
"version": "1.0.0-beta.0",
"version": "1.0.0",
"module": "lib/index.esm.js",

@@ -12,0 +12,0 @@ "main": "lib/index.js",

@@ -1,119 +0,15 @@

# `@goodhood/tracking`
# `@goodhood/helpers`
> Declarative tracking for react apps
Split up tracking payload setup from the actual tracking call. Avoids leaking data across the whole app.
- [Preview](https://goodhood-eu.github.io/goodhood/packages/tracking/preview/)
## Install
```
npm i @goodhood/tracking
npm i @goodhood/helpers
```
```js
import { TrackingProvider } from '@goodhood/tracking';
const handleEvent = (payload) => {
sendAnalyticsEvent(payload);
};
<TrackingProvider onEvent={handleEvent}>
...
</TrackingProvider>
import { getLogger } from '@goodhood/helpers';
const log = getLogger('@goodhood/tracking', { collapsed: true });
log('tracking without dataLayer', event, payload);
```
## Preview
- `npm run start`
- Visit http://localhost:3000
## Usage
### Track an event with hooks
`trackingProvider.track(payload)`
- sends the payload to the parent provider
- expects an object
- with at least the `event` key
- can have any kind of other keys
`useTrack` returns a function that forwards to `trackingProvider.track(payload)`
```jsx
import { useTrack } from '@goodhood/tracking';
export default {
const track = useTrack();
return (
<button
type="button"
onClick={() => { track({ event: 'button-clicked' }); }}
>
track now
</button>
);
}
```
### Track an event via class components
```jsx
class ClassComponent extends PureComponent {
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
this.provider.track({ event: 'button-clicked' });
}
render() {
return (
<>
<Provider ref={(provider) => { this.provider = provider; }} />
<button type="button" onClick={this.handleClick} className="ui-button ui-button-primary">
press me to track (check console)
</button>
</>
);
}
}
```
### Track on mount
`TrackingTrigger` accepts any kind of props. All props will be forwarded as payload to `track(payload)`.
```jsx
import { TrackingTrigger } from '@goodhood/tracking';
<TrackingTrigger event="pageload" additional-data={123} />
```
### Setting up tracking data
```jsx
<Provider email="fun@mail.at">
<Provider funnel="Post creation" any-kind-of-prop="oh yes">
<TrackButton />
</Provider>
</Provider>
```
### `TrackingProvider`
`TrackingProvider` accepts the following props:
- `onEvent`: Called whenever the provider receives a `track(payload)` call. Either directly or coming from a `TrackingProvider` inside children.
- `transform`: Allows to change payloads before they are sent to the parent `TrackingProvider` (or to `onEvent`) (check stories for detailed examples)
- all other props will be merged to the payload
`TrackingProvider` allows imperative access to:
- `track(payload)` as described above

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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