feat(analytics) drop defunct Google Analytics integration

We haven't used in years. Those who want to use it can still create
their own custom script and include it, since it wasn't even included by
default.
This commit is contained in:
Saúl Ibarra Corretgé
2025-02-03 20:59:58 +01:00
committed by Saúl Ibarra Corretgé
parent f0d2106c1a
commit b60210d0ad
10 changed files with 0 additions and 182 deletions

View File

@@ -48,8 +48,6 @@ deploy-appbundle:
$(BUILD_DIR)/external_api.min.js.map \
$(BUILD_DIR)/alwaysontop.min.js \
$(BUILD_DIR)/alwaysontop.min.js.map \
$(BUILD_DIR)/analytics-ga.min.js \
$(BUILD_DIR)/analytics-ga.min.js.map \
$(BUILD_DIR)/face-landmarks-worker.min.js \
$(BUILD_DIR)/face-landmarks-worker.min.js.map \
$(BUILD_DIR)/noise-suppressor-worklet.min.js \

View File

@@ -1091,9 +1091,6 @@ var config = {
// True if the analytics should be disabled
// disabled: false,
// The Google Analytics Tracking ID:
// googleAnalyticsTrackingId: 'your-tracking-id-UA-123456-1',
// Matomo configuration:
// matomoEndpoint: 'https://your-matomo-endpoint/',
// matomoSiteID: '42',
@@ -1131,7 +1128,6 @@ var config = {
// Array of script URLs to load as lib-jitsi-meet "analytics handlers".
// scriptURLs: [
// "libs/analytics-ga.min.js", // google-analytics
// "https://example.com/my-custom-analytics.js",
// ],

View File

@@ -87,7 +87,6 @@ export async function createHandlers({ getState }: IStore) {
amplitudeIncludeUTM,
blackListedEvents,
scriptURLs,
googleAnalyticsTrackingId,
matomoEndpoint,
matomoSiteID,
whiteListedEvents
@@ -98,7 +97,6 @@ export async function createHandlers({ getState }: IStore) {
amplitudeIncludeUTM,
blackListedEvents,
envType: deploymentInfo?.envType || 'dev',
googleAnalyticsTrackingId,
matomoEndpoint,
matomoSiteID,
group,

View File

@@ -14,7 +14,6 @@ interface IOptions {
amplitudeIncludeUTM?: boolean;
blackListedEvents?: string[];
envType?: string;
googleAnalyticsTrackingId?: string;
group?: string;
host?: string;
matomoEndpoint?: string;

View File

@@ -1,159 +0,0 @@
/* global ga */
import { getJitsiMeetGlobalNS } from '../../base/util/helpers';
import AbstractHandler, { IEvent } from './AbstractHandler';
/**
* Analytics handler for Google Analytics.
*/
class GoogleAnalyticsHandler extends AbstractHandler {
_userProperties: Object;
_userPropertiesString: string;
/**
* Creates new instance of the GA analytics handler.
*
* @param {Object} options - The Google Analytics options.
* @param {string} options.googleAnalyticsTrackingId - The GA track id
* required by the GA API.
*/
constructor(options: any) {
super(options);
this._userProperties = {};
if (!options.googleAnalyticsTrackingId) {
throw new Error('Failed to initialize Google Analytics handler, no tracking ID');
}
this._enabled = true;
this._initGoogleAnalytics(options);
}
/**
* Initializes the ga object.
*
* @param {Object} options - The Google Analytics options.
* @param {string} options.googleAnalyticsTrackingId - The GA track id
* required by the GA API.
* @returns {void}
*/
_initGoogleAnalytics(options: any) {
/**
* TODO: Keep this local, there's no need to add it to window.
*/
/* eslint-disable */ // @ts-ignore
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
// @ts-ignore
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
/* eslint-enable */
// @ts-ignore
ga('create', options.googleAnalyticsTrackingId, 'auto');
// @ts-ignore
ga('send', 'pageview');
}
/**
* Extracts the integer to use for a Google Analytics event's value field
* from a lib-jitsi-meet analytics event.
*
* @param {Object} event - The lib-jitsi-meet analytics event.
* @returns {number} - The integer to use for the 'value' of a Google
* analytics event, or NaN if the lib-jitsi-meet event doesn't contain a
* suitable value.
* @private
*/
_extractValue(event: IEvent) {
let value: string | number | undefined = event?.attributes?.value;
// Try to extract an integer from the "value" attribute.
value = Math.round(parseFloat(value ?? ''));
return value;
}
/**
* Extracts the string to use for a Google Analytics event's label field
* from a lib-jitsi-meet analytics event.
*
* @param {Object} event - The lib-jitsi-meet analytics event.
* @returns {string} - The string to use for the 'label' of a Google
* analytics event.
* @private
*/
_extractLabel(event: IEvent) {
const { attributes = {} } = event;
const labelsArray
= Object.keys(attributes).map(key => `${key}=${attributes[key]}`);
labelsArray.push(this._userPropertiesString);
return labelsArray.join('&');
}
/**
* Sets the permanent properties for the current session.
*
* @param {Object} userProps - The permanent portperties.
* @returns {void}
*/
setUserProperties(userProps: any = {}) {
if (!this._enabled) {
return;
}
// The label field is limited to 500B. We will concatenate all
// attributes of the event, except the user agent because it may be
// lengthy and is probably included from elsewhere.
const filter = [ 'user_agent', 'callstats_name' ];
this._userPropertiesString
= Object.keys(userProps)
.filter(key => filter.indexOf(key) === -1)
.map(key => `permanent_${key}=${userProps[key]}`)
.join('&');
}
/**
* This is the entry point of the API. The function sends an event to
* google analytics. The format of the event is described in
* analyticsAdapter in lib-jitsi-meet.
*
* @param {Object} event - The event in the format specified by
* lib-jitsi-meet.
* @returns {void}
*/
sendEvent(event: IEvent) {
if (this._shouldIgnore(event)) {
return;
}
const gaEvent: {
eventAction?: string;
eventCategory: string;
eventLabel: string;
eventValue?: number;
} = {
'eventCategory': 'jitsi-meet',
'eventAction': this._extractName(event),
'eventLabel': this._extractLabel(event)
};
const value = this._extractValue(event);
if (!isNaN(value)) {
gaEvent.eventValue = value;
}
// @ts-ignore
ga('send', 'event', gaEvent);
}
}
const globalNS = getJitsiMeetGlobalNS();
globalNS.analyticsHandlers = globalNS.analyticsHandlers || [];
globalNS.analyticsHandlers.push(GoogleAnalyticsHandler);

View File

@@ -237,7 +237,6 @@ export function getConferenceOptions(stateful: IStateful) {
if (options.disableThirdPartyRequests) {
delete config.analytics?.scriptURLs;
delete config.analytics?.amplitudeAPPKey;
delete config.analytics?.googleAnalyticsTrackingId;
}
return options;

View File

@@ -185,7 +185,6 @@ export interface IConfig {
amplitudeIncludeUTM?: boolean;
blackListedEvents?: string[];
disabled?: boolean;
googleAnalyticsTrackingId?: string;
matomoEndpoint?: string;
matomoSiteID?: string;
obfuscateRoomName?: boolean;

View File

@@ -20,7 +20,6 @@ export function _cleanupConfig(config: IConfig) {
if (NativeModules.AppInfo.LIBRE_BUILD) {
delete config.analytics?.amplitudeAPPKey;
delete config.analytics?.googleAnalyticsTrackingId;
delete config.analytics?.rtcstatsEnabled;
delete config.analytics?.rtcstatsEndpoint;
delete config.analytics?.rtcstatsPollInterval;

View File

@@ -17,7 +17,6 @@
"exclude": [
"node_modules",
"react/features/always-on-top",
"react/features/analytics/handlers/GoogleAnalyticsHandler.ts",
"react/features/base/components/participants-pane-list",
"react/features/base/tooltip",
"react/features/connection-stats",

View File

@@ -314,16 +314,6 @@ module.exports = (_env, argv) => {
],
performance: getPerformanceHints(perfHintOptions, 800 * 1024)
}),
Object.assign({}, config, {
entry: {
'analytics-ga': './react/features/analytics/handlers/GoogleAnalyticsHandler.ts'
},
plugins: [
...config.plugins,
...getBundleAnalyzerPlugin(analyzeBundle, 'analytics-ga')
],
performance: getPerformanceHints(perfHintOptions, 35 * 1024)
}),
Object.assign({}, config, {
entry: {
'close3': './static/close3.js'