mirror of
https://github.com/lucasrcsantana/story-generator.git
synced 2025-12-18 14:27:51 +00:00
fix: Corrigindo tracking na Geracao de Historia
This commit is contained in:
parent
198cad0047
commit
ce845607f9
@ -130,6 +130,26 @@ export function StoryGenerator() {
|
|||||||
|
|
||||||
if (storyError) throw storyError;
|
if (storyError) throw storyError;
|
||||||
|
|
||||||
|
// Tracking da criação da história
|
||||||
|
const selectedTheme = themes?.find(t => t.id === choices.theme_id)?.title || '';
|
||||||
|
const selectedSubject = subjects?.find(s => s.id === choices.subject_id)?.title || '';
|
||||||
|
const selectedCharacter = characters?.find(c => c.id === choices.character_id)?.title || '';
|
||||||
|
const selectedSetting = settings?.find(s => s.id === choices.setting_id)?.title || '';
|
||||||
|
|
||||||
|
trackStoryGenerated({
|
||||||
|
story_id: story.id,
|
||||||
|
theme: selectedTheme,
|
||||||
|
subject: selectedSubject,
|
||||||
|
character: selectedCharacter,
|
||||||
|
setting: selectedSetting,
|
||||||
|
context: choices.context,
|
||||||
|
generation_time: Date.now() - startTime.current,
|
||||||
|
word_count: 0, // será atualizado após a geração
|
||||||
|
student_id: session.user.id,
|
||||||
|
school_id: session.user.user_metadata?.school_id,
|
||||||
|
class_id: session.user.user_metadata?.class_id
|
||||||
|
});
|
||||||
|
|
||||||
setGenerationStatus('generating-images');
|
setGenerationStatus('generating-images');
|
||||||
console.log('Chamando Edge Function com:', story);
|
console.log('Chamando Edge Function com:', story);
|
||||||
|
|
||||||
@ -153,21 +173,14 @@ export function StoryGenerator() {
|
|||||||
|
|
||||||
if (updateError) throw updateError;
|
if (updateError) throw updateError;
|
||||||
|
|
||||||
// Track story generation
|
// Atualizar a contagem de palavras após a geração
|
||||||
const selectedTheme = themes?.find(t => t.id === choices.theme_id)?.title || '';
|
|
||||||
const generationTime = Date.now() - startTime.current;
|
|
||||||
const wordCount = updatedStory.content.pages.reduce((acc: number, page: { text: string }) =>
|
const wordCount = updatedStory.content.pages.reduce((acc: number, page: { text: string }) =>
|
||||||
acc + page.text.split(/\s+/).length, 0);
|
acc + page.text.split(/\s+/).length, 0);
|
||||||
|
|
||||||
trackStoryGenerated({
|
await supabase.from('story_metrics').insert({
|
||||||
story_id: story.id,
|
story_id: story.id,
|
||||||
theme: selectedTheme,
|
|
||||||
prompt: JSON.stringify(choices),
|
|
||||||
generation_time: generationTime,
|
|
||||||
word_count: wordCount,
|
word_count: wordCount,
|
||||||
student_id: session.user.id,
|
generation_time: Date.now() - startTime.current
|
||||||
school_id: session.user.user_metadata?.school_id,
|
|
||||||
class_id: session.user.user_metadata?.class_id
|
|
||||||
});
|
});
|
||||||
|
|
||||||
navigate(`/aluno/historias/${story.id}`);
|
navigate(`/aluno/historias/${story.id}`);
|
||||||
|
|||||||
@ -3,7 +3,11 @@ import { analytics } from '../lib/analytics';
|
|||||||
interface StoryGeneratedProps {
|
interface StoryGeneratedProps {
|
||||||
story_id: string;
|
story_id: string;
|
||||||
theme: string;
|
theme: string;
|
||||||
prompt: string;
|
subject: string;
|
||||||
|
character: string;
|
||||||
|
setting: string;
|
||||||
|
context?: string;
|
||||||
|
prompt?: string;
|
||||||
generation_time: number;
|
generation_time: number;
|
||||||
word_count: number;
|
word_count: number;
|
||||||
student_id: string;
|
student_id: string;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user