From 29d6edc4f3267006ae1f97a91691982e1db65f46 Mon Sep 17 00:00:00 2001 From: Jae Sung Park Date: Wed, 3 Jul 2019 10:50:04 +0900 Subject: [PATCH] fix(stats): Remove stats Remove stats added by #934 Ref #964 --- src/config/Options.js | 16 ---------------- src/internals/ChartInternal.js | 3 +-- src/internals/util.js | 31 ------------------------------- types/options.d.ts | 9 --------- 4 files changed, 1 insertion(+), 58 deletions(-) diff --git a/src/config/Options.js b/src/config/Options.js index b631d68e6..6281236ef 100644 --- a/src/config/Options.js +++ b/src/config/Options.js @@ -86,22 +86,6 @@ export default class Options { size_width: undefined, size_height: undefined, - /** - * Allow usage stats collection. - * - **NOTE:** - * - The usage stats collection is used for reference purpose only. - * - The stats data will be sent in a period of once in every 2 weeks. - * - Help us to make a better chart library! :) - * @name stats - * @memberof Options - * @type {Boolean} - * @default true - * @example - * // turn off stats sending - * stats: false - */ - stats: true, - /** * The padding of the chart element. * @name padding diff --git a/src/internals/ChartInternal.js b/src/internals/ChartInternal.js index c6b575d7f..b864c3c92 100644 --- a/src/internals/ChartInternal.js +++ b/src/internals/ChartInternal.js @@ -17,7 +17,7 @@ import {transition as d3Transition} from "d3-transition"; import Axis from "../axis/Axis"; import CLASS from "../config/classes"; import {document, window} from "../internals/browser"; -import {notEmpty, asHalfPixel, getOption, isValue, isArray, isFunction, isString, isNumber, isObject, callFn, sendStats, sortValue} from "./util"; +import {notEmpty, asHalfPixel, getOption, isValue, isArray, isFunction, isString, isNumber, isObject, callFn, sortValue} from "./util"; /** * Internal chart class. @@ -40,7 +40,6 @@ export default class ChartInternal { beforeInit() { const $$ = this; - $$.config.stats && sendStats(); $$.callPluginHook("$beforeInit"); // can do something diff --git a/src/internals/util.js b/src/internals/util.js index d4185423f..8d407790a 100644 --- a/src/internals/util.js +++ b/src/internals/util.js @@ -329,36 +329,6 @@ const getRange = (start, end) => { return res; }; -/** - * Send stats - * @private - */ -const sendStats = () => { - if (navigator && localStorage) { - const key = "$bb.stats"; - const url = `https://www.google-analytics.com/collect?v=1&tid=UA-141911582-1&cid=555&t=pageview&dp=%2F${location ? location.hostname : ""}`; - const t = +new Date(); - const last = +localStorage.getItem(key); - const expire = 1000 * 60 * 60 * 24 * 14; - - if (!last || (last + expire) < t) { - localStorage.setItem(key, t + expire); - - if (navigator.sendBeacon) { - navigator.sendBeacon(url); - } else { - const i = new Image(); - - i.src = url; - i.style.display = "none"; - - document.body.appendChild(i); - document.body.removeChild(i); - } - } - } -}; - // emulate event const emulateEvent = { mouse: (() => { @@ -466,7 +436,6 @@ export { mergeObj, notEmpty, sanitise, - sendStats, setTextValue, sortValue, toArray, diff --git a/types/options.d.ts b/types/options.d.ts index 2d47714db..1a6f6d0d8 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -40,15 +40,6 @@ export interface ChartOptions { height?: number; }; - /** - * Allow usage stats collection. - * - **NOTE:** - * - The usage stats collection is used for reference purpose only. - * - The stats data will be sent in a period of once in every 2 weeks. - * - Help us to make a better chart library! :) - */ - stats?: boolean; - padding?: { /** * The padding on the top of the chart.