mixgather
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Mixgather

NPM NPM GitHub Workflow Status

"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

  1. git clone git@github.com:rct-ai/mixgather.git
  2. cd mixgather
  3. yarn
  4. 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 and d.ts files in the build/ directory
  • clean: removes the build/ directory
  • type:dts: only generates d.ts
  • type:check: only run typechecking
  • type: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 runner
  • test: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 fixing
  • format:check: runs prettier without automatic fixing (used in CI)
  • lint: runs eslint with automatic fixing
  • lint: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 commitizen
  • semantic-release: triggers a release (used in CI)

Package Sidebar

Install

npm i mixgather

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

139 kB

Total Files

46

Last publish

Collaborators

  • sunebear