npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

james-sensor

v0.0.8

Published

james-sensor

Downloads

12

Readme

项目

james-sensor

项目本地开发

项目本身使用: rollupV2 工具库打出的 esm 包

1. 项目初始化

    npm install

2. 库暴露出来的方法

    创建并初始化
        /*
            __DEV__: 是否是开发环境
            options: 用于覆盖默认配置
         */
        const createAndInitSA = (__DEV__ = true, options = {})

    用户登录
        const login = (id) => {
            //  默认情况下,是把 cookie_id 作为 Distinct ID 的
            sensors.login(id)
        }

    设置用户属性
        const setProfile = (params) => {
            sensors.setProfile(params)
        }

    设置事件静态公共属性
        const registerPage = (params) => {
            sensors.registerPage(params)
        }

    手动埋点方法
        const track = (name, params) => {
            sensors.track(name, params)
        }

    为React项目的使用导出了方法:
        SensorContext
        SensorProvider

    为Vue2项目的使用导出了方法:
        provide
        inject

4. sensorsdata.es6.min.js 从哪里来?

github上搜索sa-sdk-javascript

5. 项目打包

    npm run build

6. 发布 npm 包

    npm run patch
    npm login
    npm publish

npm 包使用

    下载包:
        nexus -------- https://nexus.eeo-inc.com/repository/eeo-npm/
        nrm use nexus
        npm i -D james-sensor


    React项目使用:
        入口文件:
            import { SensorProvider } from 'james-sensor'
            <SensorProvider __DEV__={true} options={{ show_log: true }}>
              <App />
            </SensorProvider>

        hooks文件:
            import { useContext } from 'react'
            import { SensorContext } from 'james-sensor'

            export const useSensor = () => {
                const { track } = useContext(SensorContext)
                // 埋点
                const sensor = function (eventName, name) {
                    track(eventName, {
                        tab_name: name,
                    })
                }

                return {
                    sensor,
                }
            }


    Vue2项目使用:
        入口文件:
            import { createAndInitSA, provide } from 'james-sensor'
            new Vue({
                beforeCreate(){
                    createAndInitSA()
                },
                provide
            })

        打点文件:
            import { inject } from 'james-sensor'
            export default {
                inject,
                methods: {
                    sensors(card) {
                        track("HelpCenter", {
                            tab_name: card.tabName
                        });
                    },
                }
            }

神策数据文档地址

地址

注意

1. 使用.npmrc配置registry之后就不需要切换镜像源发布npm包了
2. 注意package.json中的main字段和files字段