4.4.4 • Published 6 years ago

jstatistics v4.4.4

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

安装

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
4.4.4

6 years ago

4.4.3

6 years ago

4.4.2

6 years ago

4.4.1

6 years ago

4.4.0

6 years ago

4.3.5

6 years ago

4.3.4

6 years ago

4.3.3

6 years ago

4.1.1

6 years ago

4.1.0

6 years ago

4.0.16

6 years ago

4.0.13

6 years ago

4.0.12

6 years ago

4.0.11

6 years ago

4.0.9

6 years ago

4.0.8

6 years ago

4.0.7

6 years ago

4.0.4

6 years ago

4.0.3

6 years ago

4.0.2

6 years ago

4.0.1

6 years ago

4.0.0

6 years ago

3.6.0

6 years ago

3.5.0

6 years ago

3.4.0

6 years ago

3.3.0

6 years ago

3.2.0

6 years ago

3.0.0

6 years ago

2.9.0

6 years ago

2.8.0

6 years ago

2.7.0

6 years ago

2.6.0

6 years ago

2.5.0

6 years ago

2.4.0

6 years ago

2.3.0

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago