@clutter/wt
Advanced tools
Comparing version 2.0.0-rc.2 to 2.0.0
{ | ||
"name": "@clutter/wt", | ||
"version": "2.0.0-rc.2", | ||
"version": "2.0.0", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "test": "jest", |
@@ -18,10 +18,14 @@ # What is wt | ||
Events can be tracked with the function `wt.track(kind: string, params: Record<string, any>)`. | ||
For a single event, set `kind` to `'event'` and pass any parameters you want to track in `params`. | ||
For instance: | ||
Events can be tracked with the function `wt.track(params: WTEventParams & Record<string, any>)`. | ||
```js | ||
wt.track("event", { action: "hover" }); | ||
wt.track({ action: "hover" }); | ||
``` | ||
All events have a `kind` property that defaults to `"event"`. For events that don't require any additional data (e.g. pageview events), there is a simplified syntax to set _only_ the `kind` property: | ||
```js | ||
wt.track("pageview"); | ||
``` | ||
### Multiple events | ||
@@ -32,5 +36,5 @@ | ||
```js | ||
wt.track("event", { action: "hover" }); | ||
wt.track({ action: "hover" }); | ||
// after 0.2 seconds | ||
wt.track("event", { action: "click" }); | ||
wt.track({ action: "click" }); | ||
``` | ||
@@ -44,10 +48,6 @@ | ||
### Pageviews | ||
### Data | ||
Events can be tracked without explicit parameters: | ||
`wt` includes a list of recognized properties, detailed in `WTEventParams` (also see [Server Implementation](#server-implementation) below). Custom properties can also be tracked and will be grouped under a single `metadata` property. | ||
```js | ||
wt.track("pageview"); | ||
``` | ||
# React Integration | ||
@@ -73,4 +73,3 @@ | ||
If | ||
additional customization is desired, there is also a `createProvider` utility which allows for custom typing and added | ||
If additional customization is desired, there is also a `createProvider` utility which allows for custom typing and added | ||
event control. Each call to `createProvider` creates a new, distinct React context meaning that the returned hooks _will not work_ with the default `WTProvider`. | ||
@@ -86,3 +85,3 @@ | ||
const { WTProvider, useTrack, useWT } = createProvider((params: EventParams) => | ||
wt.track("event", params) | ||
wt.track(params) | ||
); | ||
@@ -164,3 +163,3 @@ ``` | ||
const { WTProvider } = createProvider((params) => wt.track("event", params), { | ||
const { WTProvider } = createProvider((params) => wt.track(params), { | ||
validateEvent, | ||
@@ -261,4 +260,2 @@ }); | ||
{ | ||
// The first parameter passed to wt.track() | ||
kind: 'event', | ||
// The url of the page triggering the event | ||
@@ -273,3 +270,4 @@ url: 'https://www.clutter.com/', | ||
ts: '1634596872864' | ||
// The second parameter passed to wt.track is merged into the event | ||
// Known parameters passed to wt.track are converted to snake case and merged with the event | ||
kind: 'event', | ||
category: 'user_interaction', | ||
@@ -285,3 +283,3 @@ action: 'click', | ||
// Parameters not included in the above list will be grouped under | ||
// a single metadata key | ||
// a single metadata key (without any transformation). | ||
metadata: { | ||
@@ -288,0 +286,0 @@ variant: 'jungle', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
46288
2
287