Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

jstatistics

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

jstatistics

一个统计系统

unpublished
latest
npmnpm
Version
4.4.4
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

安装

npm install --save jstatistics 

使用

到这个网站http://test-iappweb.jpushoa.com/front-stat/建个统计项目,然后把下面例子的ID "12" 改成你的。

import { StatisticsModule } from 'jstatistics';

const d=new Date();
d.setHours(d.getHours() + 24);

export interface Option {
    useHash?: boolean;
    captureHttp?: boolean;
    captureError?: boolean;
    captureRouteChange?: boolean;
    user_id?: string;
    log?: boolean;
    host: string; 
    data?: Date;
}

const defaultOption = {
    useHash: false, // 默认前端路由是h5 history
    captureError: false, // 自动监听window.onerror,并发送统计
    captureHttp: true, // 拦截http请求
    captureRouteChange: true, // 拦截路由跳转
    log: true, // 是否输出日志
    user_id: 'xxxxx',
    host: 'xxxx' ,// 后台服务器地址
    date: d // 默认1天后cookie过期
};


@NgModule({
    ...
    imports: [
        ...
        StatisticsModule.forRoot('12', { host: '123' })
    ],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule  {

}



import { StatisticsService } from 'jstatistics';
@Component({
    ...
})
export class AppComponent {
  title = 'app';
  constructor(private stat: StatisticsService) {
    console.log(stat);
  }
}

方法

    setUserId(id: string): this; // 设置用户ID
    clearUserId(): this; // 清除用户ID
    error(e: Error): Promise<{}>; // 发送报错信息
    addNetworkListener(cb: Function): void; // 添加网络请求的监听
    events(events: string[], extras?: {
        [propName: string]: string;
    }): Promise<{}>; // 发送事件
    uteReport(data: any): Promise<{}>; // 上报ute报告
    setChangeURL(url: any): Promise<{}>; //再配置中关闭自动url切换上报,手动上报方法
    setCookie(key: string, value: any, expires?: Date): boolean; //expires默认和其他cookie保持一致,通过client_id_expires的cookie拿到
    
    static getCookie(key: string): string;
    static setCookie(key: string, value: any, expires?: Date): boolean;
    static base64:{
        decode(str) // 解码base64
        encode(str) // 编码base64
    }

更新

2.1.0
Statustics 这个单词写错了,改成了 StatisticsService。在2.1.0中修复了

2.8.0
referrer信息放在cookie,默认一天过期

script引入

    从node_modules/jstatistics/build/output/statistics.js 拷出来
    <script src="/assets/js/statistics.js"></script>
    <script>
        window['stat'] = new Statistics('12', { log: false, host: 'http://183.232.42.221:8091/v1' }); // 测试环境sdk后台

        window['stat'] = new Statistics('12', { log: false, host: 'https://stat-srv.jiguang.cn/v1/sdk' });  // 生产环境sdk后台
    </script>

    declare const stat;
    stat.xx //使用

CDN

https://o8ci6tgz8.qnssl.com/jstatistics/{ 版本号 }/statistics.js

FAQs

Package last updated on 11 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts