add growing-io (#39163)

* feat: add growing-io

* fix: for non-npm package
This commit is contained in:
Forzoom 2019-10-17 04:54:07 +08:00 committed by Andrew Branch
parent 5c97ace92d
commit f4d8af8660
4 changed files with 106 additions and 0 deletions

View File

@ -0,0 +1,40 @@
// No npm package for wx-js-sdk, source location is: http://assets.giocdn.com/2.1/gio.js
gio('clearUserId');
gio('sendPage');
gio('setUserId', '1');
gio('app.set', 'key', 'value');
gio('people.set', 'key', 'value');
gio('page.set', 'key', 'value');
gio('visit.set', 'key', 'value');
gio('evar.set', 'key', 'value');
gio('app.set', {
key: 'value',
});
gio('people.set', {
key: 'value',
});
gio('page.set', {
key: 'value',
});
gio('visit.set', {
key: 'value',
});
gio('evar.set', {
key: 'value',
});
gio('track', 'eventId');
gio('track', 'eventId', 1);
gio('track', 'eventId', {
key: 'value',
});
gio('track', 'eventId', 1, {
key: 'value',
});
gio('init', 'projectId', {});
gio('init', 'projectId');
gio('config', {});

42
types/growing-io/index.d.ts vendored Normal file
View File

@ -0,0 +1,42 @@
// Type definitions for non-npm package growing-io-browser 2.1
// Project: https://docs.growingio.com/docs/dashboard/homepage
// Definitions by: Forzoom <https://github.com/Forzoom>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// growingIO
interface GIOObjectVariables {
[key: string]: string;
}
interface GIOInitOptions {
/** 配置imp类型的数据关闭发送 */
imp?: boolean;
}
interface GIOConfigOptions {
/** 是否采集数据 */
dataCollect?: 'true' | 'false' | boolean;
/** 是否检测hash变化 */
hashtag?: 'true' | 'false' | boolean;
}
interface GrowingIO {
/** clearUserId: 清空用户信息, sendPage: 上报页面数据 */
(action: 'clearUserId' | 'sendPage'): void;
/** 设置用户登录id */
(action: 'setUserId', userId: string): void;
/** app.set: 对于应用级变量,也就是 1.x 版本中的 CS2 - CS10, people.set: 用户级变量, page.set: 页面级变量 visit.set: 访问用户级变量, evar.set: 转化变量 */
(action: 'app.set' | 'people.set' | 'page.set' | 'visit.set' | 'evar.set', variables: GIOObjectVariables): void;
/** app.set: 对于应用级变量,也就是 1.x 版本中的 CS2 - CS10, people.set: 用户级变量, page.set: 页面级变量 visit.set: 访问用户级变量, evar.set: 转化变量 */
(action: 'app.set' | 'people.set' | 'page.set' | 'visit.set' | 'evar.set', key: string, value: string): void;
/** 自定义埋点 */
(action: 'track', eventId: string, numberOrVariables?: number | GIOObjectVariables): void;
/** 自定义埋点 */
(action: 'track', eventId: string, number: number, eventLevelVariables: GIOObjectVariables): void;
/** 初始化 */
(action: 'init', projectId: string, options?: GIOInitOptions): void;
/** 配置 */
(action: 'config', options: GIOConfigOptions): void;
}
declare const gio: GrowingIO;

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"growing-io-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }