mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Add program opening count to Keen.io analytics
This commit is contained in:
@@ -3,6 +3,10 @@ import Keen from 'keen-tracking';
|
||||
import Window from '../Window';
|
||||
import { getUserUUID } from './UserUUID';
|
||||
import Authentification from '../GDevelopServices/Authentification';
|
||||
import {
|
||||
getProgramOpeningCount,
|
||||
incrementProgramOpeningCount,
|
||||
} from './LocalStats';
|
||||
|
||||
const isDev = Window.isDev();
|
||||
let client = null;
|
||||
@@ -29,6 +33,9 @@ export const installAnalyticsEvents = (authentification: Authentification) => {
|
||||
email: userProfile ? userProfile.email : undefined,
|
||||
emailVerified: userProfile ? userProfile.emailVerified : undefined,
|
||||
},
|
||||
localStats: {
|
||||
programOpeningCount: getProgramOpeningCount(),
|
||||
},
|
||||
page: {
|
||||
title: document.title,
|
||||
url: document.location.href,
|
||||
@@ -91,6 +98,7 @@ export const installAnalyticsEvents = (authentification: Authentification) => {
|
||||
export const sendProgramOpening = () => {
|
||||
if (isDev || !client) return;
|
||||
|
||||
incrementProgramOpeningCount();
|
||||
client.recordEvent('program_opening');
|
||||
};
|
||||
|
||||
@@ -120,7 +128,11 @@ export const sendTutorialOpened = (tutorialName: string) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const sendErrorMessage = (errorMessage: string, type: string, rawError: any) => {
|
||||
export const sendErrorMessage = (
|
||||
errorMessage: string,
|
||||
type: string,
|
||||
rawError: any
|
||||
) => {
|
||||
if (isDev || !client) return;
|
||||
|
||||
client.recordEvent('error_message', {
|
||||
|
23
newIDE/app/src/Utils/Analytics/LocalStats.js
Normal file
23
newIDE/app/src/Utils/Analytics/LocalStats.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// @flow
|
||||
const localStoragePrefix = 'gd-local-stats';
|
||||
|
||||
export const getProgramOpeningCount = (): number => {
|
||||
try {
|
||||
const count = localStorage.getItem(`${localStoragePrefix}-program-opening`);
|
||||
if (count !== null) return parseInt(count, 10);
|
||||
} catch (e) {
|
||||
console.warn('Unable to load stored program opening count', e);
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
export const incrementProgramOpeningCount = () => {
|
||||
const count = getProgramOpeningCount() + 1;
|
||||
|
||||
try {
|
||||
localStorage.setItem(`${localStoragePrefix}-program-opening`, '' + count);
|
||||
} catch (e) {
|
||||
console.warn('Unable to store program opening count', e);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user