еще доразметка событий попыток оплаты на гпт4.1

This commit is contained in:
kazachilo 2025-04-29 10:57:02 +03:00
parent 3c925708ab
commit 8c02d1babb
4 changed files with 1622 additions and 9 deletions

1578
1inch-network.csv Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,13 +2,13 @@ import React, { useState, useEffect } from 'react';
import { Link, useNavigate } from 'react-router-dom'; import { Link, useNavigate } from 'react-router-dom';
import { getUserInfo, isTelegramWebAppAvailable, getCurrentUserId } from '../../constants/user'; import { getUserInfo, isTelegramWebAppAvailable, getCurrentUserId } from '../../constants/user';
import { images } from '../../assets'; import { images } from '../../assets';
import customAnalyticsService from '../../services/customAnalyticsService';
import apiService from '../../services/api'; import apiService from '../../services/api';
import TokenPacksModal from '../tokens/TokenPacksModal'; import TokenPacksModal from '../tokens/TokenPacksModal';
import { paymentService } from '../../services/paymentService'; import { paymentService } from '../../services/paymentService';
import { tokenPacks } from '../../constants/tokenPacks'; import { tokenPacks } from '../../constants/tokenPacks';
import NotificationModal from '../shared/NotificationModal'; import NotificationModal from '../shared/NotificationModal';
import { useBalance } from '../../contexts/BalanceContext'; import { useBalance } from '../../contexts/BalanceContext';
import customAnalyticsService from '../../services/customAnalyticsService';
import { getTranslation } from '../../constants/translations'; import { getTranslation } from '../../constants/translations';
import styles from './Header.module.css'; import styles from './Header.module.css';
@ -79,6 +79,12 @@ const Header: React.FC = () => {
event_category: 'ui_interaction', event_category: 'ui_interaction',
event_name: 'balance_button_click' event_name: 'balance_button_click'
}); });
// Аналитика: открытие модального окна оплаты
customAnalyticsService.trackEvent({
telegram_id: getCurrentUserId(),
event_category: 'payment',
event_name: 'purchase_modal_open'
});
setShowTokensModal(true); setShowTokensModal(true);
}} }}
title={getTranslation('add_balance_title')} title={getTranslation('add_balance_title')}
@ -102,15 +108,22 @@ const Header: React.FC = () => {
onBuyPack={(packId) => { onBuyPack={(packId) => {
const pack = tokenPacks.find(p => p.id === packId); const pack = tokenPacks.find(p => p.id === packId);
if (!pack) return; if (!pack) return;
// Аналитика: попытка оплаты
customAnalyticsService.trackEvent({
telegram_id: getCurrentUserId(),
event_category: 'payment',
event_name: 'purchase_attempt'
});
setShowTokensModal(false); setShowTokensModal(false);
setLastPurchasedPack(pack); setLastPurchasedPack(pack);
paymentService.showBuyTokensPopup(pack, async (userData) => { paymentService.showBuyTokensPopup(pack, async (userData) => {
if (userData) { if (userData) {
// Обновляем баланс через контекст // Обновляем баланс через контекст
updateBalance(); updateBalance();
// Показываем модальное окно с информацией об успешной оплате // Показываем модальное окно с информацией об успешной оплате
setNotificationTitle(getTranslation('payment_success')); setNotificationTitle(getTranslation('payment_success'));
setNotificationMessage(getTranslation('tokens_purchased', pack.tokens + pack.bonusTokens)); setNotificationMessage(getTranslation('tokens_purchased', pack.tokens + pack.bonusTokens));
@ -120,10 +133,10 @@ const Header: React.FC = () => {
try { try {
// Получаем баланс пользователя // Получаем баланс пользователя
const balance = await apiService.getBalance(getCurrentUserId()); const balance = await apiService.getBalance(getCurrentUserId());
// Обновляем баланс через контекст // Обновляем баланс через контекст
updateBalance(); updateBalance();
// Показываем модальное окно с информацией об успешной оплате // Показываем модальное окно с информацией об успешной оплате
setNotificationTitle(getTranslation('payment_success')); setNotificationTitle(getTranslation('payment_success'));
setNotificationMessage(getTranslation('profile_tokens_purchased', pack.tokens + pack.bonusTokens, balance)); setNotificationMessage(getTranslation('profile_tokens_purchased', pack.tokens + pack.bonusTokens, balance));

View File

@ -6,6 +6,7 @@ import { tokenPacks } from '../constants/tokenPacks';
import { paymentService } from '../services/paymentService'; import { paymentService } from '../services/paymentService';
import apiService from '../services/api'; import apiService from '../services/api';
import { getCurrentUserId } from '../constants/user'; import { getCurrentUserId } from '../constants/user';
import customAnalyticsService from '../services/customAnalyticsService';
import NotificationModal from '../components/shared/NotificationModal'; import NotificationModal from '../components/shared/NotificationModal';
import { getTranslation } from '../constants/translations'; import { getTranslation } from '../constants/translations';
@ -27,6 +28,12 @@ const CreateSticker: React.FC = () => {
const userTokens = await apiService.getBalance(getCurrentUserId()); const userTokens = await apiService.getBalance(getCurrentUserId());
if (userTokens < TOKENS_PER_GENERATION) { if (userTokens < TOKENS_PER_GENERATION) {
setMissingTokens(TOKENS_PER_GENERATION - userTokens); setMissingTokens(TOKENS_PER_GENERATION - userTokens);
// Аналитика: открытие модального окна оплаты
customAnalyticsService.trackEvent({
telegram_id: getCurrentUserId(),
event_category: 'payment',
event_name: 'purchase_modal_open'
});
setShowTokensModal(true); setShowTokensModal(true);
return false; return false;
} }
@ -84,10 +91,17 @@ const CreateSticker: React.FC = () => {
onBuyPack={(packId: string) => { onBuyPack={(packId: string) => {
const pack = tokenPacks.find(p => p.id === packId); const pack = tokenPacks.find(p => p.id === packId);
if (!pack) return; if (!pack) return;
// Аналитика: попытка оплаты
customAnalyticsService.trackEvent({
telegram_id: getCurrentUserId(),
event_category: 'payment',
event_name: 'purchase_attempt'
});
setShowTokensModal(false); setShowTokensModal(false);
setLastPurchasedPack(pack); setLastPurchasedPack(pack);
paymentService.showBuyTokensPopup(pack, async (userData) => { paymentService.showBuyTokensPopup(pack, async (userData) => {
if (userData) { if (userData) {
// Обновляем данные на основе полученной информации // Обновляем данные на основе полученной информации
@ -100,7 +114,7 @@ const CreateSticker: React.FC = () => {
try { try {
// Получаем баланс пользователя // Получаем баланс пользователя
const balance = await apiService.getBalance(getCurrentUserId()); const balance = await apiService.getBalance(getCurrentUserId());
// Показываем модальное окно с информацией об успешной оплате // Показываем модальное окно с информацией об успешной оплате
setNotificationTitle(getTranslation('payment_success')); setNotificationTitle(getTranslation('payment_success'));
setNotificationMessage(getTranslation('profile_tokens_purchased', pack.tokens + pack.bonusTokens, balance)); setNotificationMessage(getTranslation('profile_tokens_purchased', pack.tokens + pack.bonusTokens, balance));

View File

@ -3,6 +3,7 @@ import styles from './Profile.module.css';
import { stickerService } from '../services/stickerService'; import { stickerService } from '../services/stickerService';
import apiService from '../services/api'; import apiService from '../services/api';
import { getCurrentUserId } from '../constants/user'; import { getCurrentUserId } from '../constants/user';
import customAnalyticsService from '../services/customAnalyticsService';
import TokenPacksList from '../components/tokens/TokenPacksList'; import TokenPacksList from '../components/tokens/TokenPacksList';
import { tokenPacks, TokenPack } from '../constants/tokenPacks'; import { tokenPacks, TokenPack } from '../constants/tokenPacks';
import { paymentService } from '../services/paymentService'; import { paymentService } from '../services/paymentService';
@ -47,6 +48,13 @@ const Profile: React.FC = () => {
const pack = tokenPacks.find(p => p.id === packId); const pack = tokenPacks.find(p => p.id === packId);
if (!pack) return; if (!pack) return;
// Аналитика: попытка оплаты
customAnalyticsService.trackEvent({
telegram_id: getCurrentUserId(),
event_category: 'payment',
event_name: 'purchase_attempt'
});
setLastPurchasedPack(pack); setLastPurchasedPack(pack);
paymentService.showBuyTokensPopup(pack, async (userData) => { paymentService.showBuyTokensPopup(pack, async (userData) => {