mixgather
v1.0.1
Published
I am a product log maker, so I write logs day by day.
Downloads
45
Maintainers
Readme
Mixgather
"I am a product log maker, so I write logs day by day."
Installation
$ yarn add mixgather
Usage
1. Init - Required
import mixgather from 'mixgather'
async inSomeSetupHook() {
// ...other setup
await mixgather.init({
debug: process.env.NODE_ENV !== 'production',
google: {
id: 'G-XXXX'
},
mixpanel: {
token: 'xxxxxx'
}
})
// ...integrate track with router hooks
}
The init step is async, we should track after finishing it.
2. Track - Core
// Pages
mixgather.page('/path')
mixgather.page('/profile', 'User Home')
// Events
mixgather.event('some_action')
mixgather.event('el_clicked', {
property: 'value'
})
// Screens
mixgather.screen('screen_name')
mixgather.screen('modal_name')
3. User - Optional
Set the userMeta
on the gathers:
mixgather.setUser({ id: 'xxxxx', ...otherProps })
if id is null
, will remove the current user.
4. Global Property - Optional
mixgather.setProperty({ appName: 'xxxxx', ...others })
if property value is null
, will remove the property.
Get Vendors
Sometimes, we need to run vendor-spec APIs, getting $vendor sdk is necessary.
const gatherName = 'mixpanel' // 'google'
mixgather.getGather(gatherName).$vendor
Development
Run Example in Local
$ yarn dev
It starts a server at http://localhost:1234.
Reset Package Name
git clone [email protected]:rct-ai/mixgather.git
cd mixgather
yarn
yarn setup
Node.js, npm and/or yarn version
The lib relies on volta to ensure node version to be consistent across developers. It's also used in the GitHub workflow file.
Typescript
Leverages esbuild for blazing fast builds, but keeps tsc
to generate .d.ts
files.
Generates two builds to support both ESM and CJS.
Commands:
build
: runs typechecking then generates CJS, ESM andd.ts
files in thebuild/
directoryclean
: removes thebuild/
directorytype:dts
: only generatesd.ts
type:check
: only run typecheckingtype:build
: only generates CJS and ESM
Tests
Mixgather uses ava and esbuild-register so that there is no need to compile before the tests start running. The coverage is done through nyc.
Commands:
test
: runs ava test runnertest:coverage
: runs ava test runner and generates coverage reports
Format & lint
This template relies on the combination of eslint — through typescript-eslint for linting and prettier for formatting. It also uses cspell to ensure spelling
Commands:
format
: runs prettier with automatic fixingformat:check
: runs prettier without automatic fixing (used in CI)lint
: runs eslint with automatic fixinglint:check
: runs eslint without automatic fixing (used in CI)spell:check
: runs spellchecking
Releasing
Under the hood, this library uses semantic-release and commitizen.
The goal is to avoid manual release process. Using semantic-release
will automatically create a github release (hence tags) as well as an npm release.
Based on your commit history, semantic-release
will automatically create a patch, feature or breaking release.
Commands:
cz
: interactive CLI that helps you generate a proper git commit message, using commitizensemantic-release
: triggers a release (used in CI)