feat: add TeleCartPulse telemetry system and ETL endpoints
- Add TeleCartPulse service for event tracking and analytics - Implement PayloadSigner for secure payload signing/verification - Add StartParamSerializer for campaign parameter handling - Create TeleCartPulseServiceProvider for dependency injection - Add PulseEvents constants and exception classes - Add TelemetryHandler for ingesting client-side events - Implement /ingest endpoint for receiving webapp events - Support WEBAPP_OPEN event tracking with campaign metadata - Add ETLHandler for customer data export - Implement /customers endpoint for ETL processes - Add /customers/meta endpoint for pagination metadata - Support filtering by updated_at timestamp - Include customer metrics: orders count, total spent, etc. - Add InvalidApiTokenException for API key validation - Update Request class to support API key extraction - Add Utils helper methods for domain extraction - Integrate telemetry in frontend SPA (webapp open event) - Add TeleCartPulseView in admin panel for API key configuration - Update routes to include new telemetry and ETL endpoints
This commit is contained in:
3
frontend/spa/src/constants/tPulseEvents.js
Normal file
3
frontend/spa/src/constants/tPulseEvents.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export const TC_PULSE_EVENTS = {
|
||||
WEBAPP_OPEN: 'WEBAPP_OPEN',
|
||||
};
|
||||
@@ -8,18 +8,18 @@ import {useSettingsStore} from "@/stores/SettingsStore.js";
|
||||
import ApplicationError from "@/ApplicationError.vue";
|
||||
import AppMetaInitializer from "@/utils/AppMetaInitializer.ts";
|
||||
import {injectYaMetrika} from "@/utils/yaMetrika.js";
|
||||
import {checkIsUserPrivacyConsented, saveTelegramCustomer} from "@/utils/ftch.js";
|
||||
import {checkIsUserPrivacyConsented, ingest, saveTelegramCustomer} from "@/utils/ftch.js";
|
||||
|
||||
import {register} from 'swiper/element/bundle';
|
||||
import 'swiper/element/bundle';
|
||||
import 'swiper/css/bundle';
|
||||
import AppLoading from "@/AppLoading.vue";
|
||||
import {useProductFiltersStore} from "@/stores/ProductFiltersStore.js";
|
||||
import {useBlocksStore} from "@/stores/BlocksStore.js";
|
||||
import {getCssVarOklchRgb} from "@/helpers.js";
|
||||
|
||||
import {defaultConfig, plugin} from '@formkit/vue';
|
||||
import config from './formkit.config.js';
|
||||
import {TC_PULSE_EVENTS} from "@/constants/tPulseEvents.js";
|
||||
|
||||
register();
|
||||
|
||||
@@ -51,18 +51,22 @@ settings.load()
|
||||
throw new Error('App disabled (maintenance mode)');
|
||||
}
|
||||
})
|
||||
.then(async () => {
|
||||
.then(() => {
|
||||
const webapp = window.Telegram.WebApp;
|
||||
ingest({
|
||||
event: TC_PULSE_EVENTS.WEBAPP_OPEN,
|
||||
webapp,
|
||||
})
|
||||
.catch(err => console.error('Ingest failed:', err));
|
||||
})
|
||||
.then(() => {
|
||||
// Сохраняем данные Telegram-пользователя в базу данных
|
||||
const userData = window.Telegram?.WebApp?.initDataUnsafe?.user;
|
||||
if (userData) {
|
||||
try {
|
||||
console.debug('[Init] Saving Telegram customer data');
|
||||
await saveTelegramCustomer(userData);
|
||||
console.debug('[Init] Telegram customer data saved successfully');
|
||||
} catch (error) {
|
||||
// Не прерываем загрузку приложения, если не удалось сохранить пользователя
|
||||
console.warn('[Init] Failed to save Telegram customer data:', error);
|
||||
}
|
||||
console.debug('[Init] Saving Telegram customer data');
|
||||
saveTelegramCustomer(userData)
|
||||
.then(() => console.debug('[Init] Telegram customer data saved successfully'))
|
||||
.catch(() => console.warn('[Init] Failed to save Telegram customer data:', error));
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
@@ -82,11 +86,11 @@ settings.load()
|
||||
})();
|
||||
})
|
||||
.then(() => blocks.processBlocks(settings.mainpage_blocks))
|
||||
.then(async () => {
|
||||
console.debug('Load default filters for the main page');
|
||||
const filtersStore = useProductFiltersStore();
|
||||
filtersStore.applied = await filtersStore.fetchFiltersForMainPage();
|
||||
})
|
||||
// .then(async () => {
|
||||
// console.debug('Load default filters for the main page');
|
||||
// const filtersStore = useProductFiltersStore();
|
||||
// filtersStore.applied = await filtersStore.fetchFiltersForMainPage();
|
||||
// })
|
||||
.then(() => {
|
||||
console.debug('[Init] Set theme attributes');
|
||||
document.documentElement.setAttribute('data-theme', settings.theme[window.Telegram.WebApp.colorScheme]);
|
||||
|
||||
Reference in New Issue
Block a user