0.6.0 • Published 3 years ago
gavis v0.6.0
Gavis
Declarative analytics logging library for React
See Docs.
Installation
npm i --save gavis
or using yarn,
yarn add gavis
Examples
//App.tsx
import { GavisConfig } from "gavis";
const logger = (category: string, action: string, label: string, data: any) => {
const value = data.viewCount;
ga(category, action, label, value);
};
function App() {
return (
<GavisConfig logger={logger}>
<Page />
</GavisConfig>
);
}
//Page.tsx
import { Gavis } from "gavis";
/*
- Create a log event context with <Gavis/> .
- If 'logOnMount' is true, event
{cateogry: "News", action:"expose", label:"morning",
data: { viewCount, commentCount }} is sent on mount
*/
function Page() {
return (
<div>
<p>hello world</p>
<Gavis
category="News"
action="expose"
label="morning"
data={{ viewCount, commentCount }}
logOnMount
>
<div>message</div>
<Button />
</Gavis>
</div>
);
}
// Button.tsx
import { useGavis } from "gavis";
/*
- The event context can be overriden
by child <Gavis/> or 'log' function
- Event {cateogry: "News", action:"click", label:"evening",
data: { viewCount, commentCount }} is sent on click
*/
function Button() {
const log = useGavis();
return (
<Gavis label="evening">
<button onClick={() => log({ action: "click" })}>LOG</button>;
</Gavis>
);
}
0.4.4-beta.1
3 years ago
0.4.4-beta.2
3 years ago
0.4.4-beta.3
3 years ago
0.4.4-beta.4
3 years ago
0.4.4-beta.0
3 years ago
0.5.0-beta.1
3 years ago
0.5.0-beta.0
3 years ago
0.5.0-beta.4
3 years ago
0.5.0-beta.3
3 years ago
0.5.0-beta.2
3 years ago
0.3.0
3 years ago
0.6.0-beta.0
3 years ago
0.4.4
3 years ago
0.6.0-beta.2
3 years ago
0.6.0-beta.1
3 years ago
0.5.0
3 years ago
0.4.1
3 years ago
0.4.0
3 years ago
0.4.3
3 years ago
0.6.0
3 years ago
0.4.2
3 years ago
0.2.0
3 years ago
0.1.1
3 years ago
0.1.0
3 years ago