Skip to content

Commit

Permalink
fix(stats): Remove stats
Browse files Browse the repository at this point in the history
Remove stats added by #934

Ref #964
  • Loading branch information
netil authored Jul 3, 2019
1 parent 142fb3f commit 29d6edc
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 58 deletions.
16 changes: 0 additions & 16 deletions src/config/Options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/internals/ChartInternal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -40,7 +40,6 @@ export default class ChartInternal {
beforeInit() {
const $$ = this;

$$.config.stats && sendStats();
$$.callPluginHook("$beforeInit");

// can do something
Expand Down
31 changes: 0 additions & 31 deletions src/internals/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: (() => {
Expand Down Expand Up @@ -466,7 +436,6 @@ export {
mergeObj,
notEmpty,
sanitise,
sendStats,
setTextValue,
sortValue,
toArray,
Expand Down
9 changes: 0 additions & 9 deletions types/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 29d6edc

Please sign in to comment.