From 2ad84f28110b523a0fc0a98a7675c5fcbb5c49f7 Mon Sep 17 00:00:00 2001 From: J Blackman Date: Sat, 22 Jun 2024 09:20:31 +1000 Subject: [PATCH] 10.10-maintenance: Move analytics to its own domain and capture host (#4036) --- src/js/Analytics.js | 19 +++++++++++++------ src/js/BuildApi.js | 11 ----------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/js/Analytics.js b/src/js/Analytics.js index 9e5115eab3..df8fa5a522 100644 --- a/src/js/Analytics.js +++ b/src/js/Analytics.js @@ -1,5 +1,4 @@ import ShortUniqueId from 'short-unique-id'; -import BuildApi from './BuildApi'; import { set as setConfig, get as getConfig } from './ConfigStorage'; import GUI from './gui'; import CONFIGURATOR from './data_storage'; @@ -74,7 +73,7 @@ class Analytics { this.setOptOut(settings.optOut); this._settings = settings; - this._api = new BuildApi(); + this._url = 'https://analytics.betaflight.com'; this.EVENT_CATEGORIES = { APPLICATION: 'Application', @@ -90,11 +89,19 @@ class Analytics { return; } - this._api.sendAnalytics(name, { - sessionId: this._settings.sessionId, - userId: this._settings.userId, - [name]: properties, + const url = `${this._url}/analytics/${name}`; + $.ajax({ + url: url, + type: "POST", + data: JSON.stringify({ + sessionId: this._settings.sessionId, + userId: this._settings.userId, + [name]: properties, + }), + contentType: "application/json", + dataType: "json", }); + } sendSettings() { diff --git a/src/js/BuildApi.js b/src/js/BuildApi.js index 5f6a88f799..af94f8ee67 100644 --- a/src/js/BuildApi.js +++ b/src/js/BuildApi.js @@ -182,15 +182,4 @@ export default class BuildApi { } }); } - - sendAnalytics(type, parcel) { - const url = `${this._url}/analytics/${type}`; - $.ajax({ - url: url, - type: "POST", - data: JSON.stringify(parcel), - contentType: "application/json", - dataType: "json", - }); - } }