mirror of
https://github.com/lucasrcsantana/story-generator.git
synced 2025-12-16 21:37: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;
|
||||
|
||||
// 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');
|
||||
console.log('Chamando Edge Function com:', story);
|
||||
|
||||
@ -153,21 +173,14 @@ export function StoryGenerator() {
|
||||
|
||||
if (updateError) throw updateError;
|
||||
|
||||
// Track story generation
|
||||
const selectedTheme = themes?.find(t => t.id === choices.theme_id)?.title || '';
|
||||
const generationTime = Date.now() - startTime.current;
|
||||
// Atualizar a contagem de palavras após a geração
|
||||
const wordCount = updatedStory.content.pages.reduce((acc: number, page: { text: string }) =>
|
||||
acc + page.text.split(/\s+/).length, 0);
|
||||
|
||||
trackStoryGenerated({
|
||||
await supabase.from('story_metrics').insert({
|
||||
story_id: story.id,
|
||||
theme: selectedTheme,
|
||||
prompt: JSON.stringify(choices),
|
||||
generation_time: generationTime,
|
||||
word_count: wordCount,
|
||||
student_id: session.user.id,
|
||||
school_id: session.user.user_metadata?.school_id,
|
||||
class_id: session.user.user_metadata?.class_id
|
||||
generation_time: Date.now() - startTime.current
|
||||
});
|
||||
|
||||
navigate(`/aluno/historias/${story.id}`);
|
||||
|
||||
@ -3,7 +3,11 @@ import { analytics } from '../lib/analytics';
|
||||
interface StoryGeneratedProps {
|
||||
story_id: string;
|
||||
theme: string;
|
||||
prompt: string;
|
||||
subject: string;
|
||||
character: string;
|
||||
setting: string;
|
||||
context?: string;
|
||||
prompt?: string;
|
||||
generation_time: number;
|
||||
word_count: number;
|
||||
student_id: string;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user