Spaces:
Running
Running
init GTM
Browse files- app/api/bulk-create/data.json +151 -1
- app/api/start/route.ts +19 -5
- app/layout.tsx +5 -1
- components/gtm/index.tsx +48 -0
- components/quizz/hooks/useQuizz.ts +1 -1
- utils/gtm.ts +22 -0
app/api/bulk-create/data.json
CHANGED
@@ -438,5 +438,155 @@
|
|
438 |
"Iron Man in a sleek, futuristic suit, standing on a rooftop overlooking a neon-lit cityscape at sunset. (Style: Cyberpunk, Mood: Heroic)",
|
439 |
"Tony Stark, aka Iron Man, relaxing in his home workshop, surrounded by gadgets and tools, with a friendly AI assistant hovering nearby. (Style: Toon Monster, Mood: Casual)",
|
440 |
"Iron Man in a dark, gritty, post-apocalyptic wasteland, battling against a horde of robotic enemies. (Style: Punky, Mood: Dramatic)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
441 |
]
|
442 |
-
]
|
|
|
438 |
"Iron Man in a sleek, futuristic suit, standing on a rooftop overlooking a neon-lit cityscape at sunset. (Style: Cyberpunk, Mood: Heroic)",
|
439 |
"Tony Stark, aka Iron Man, relaxing in his home workshop, surrounded by gadgets and tools, with a friendly AI assistant hovering nearby. (Style: Toon Monster, Mood: Casual)",
|
440 |
"Iron Man in a dark, gritty, post-apocalyptic wasteland, battling against a horde of robotic enemies. (Style: Punky, Mood: Dramatic)"
|
441 |
+
],
|
442 |
+
[
|
443 |
+
"A dramatic digital portrait of Saruman, with a dark and moody color palette, highlighting his piercing eyes and menacing demeanor.",
|
444 |
+
"An adorable 3D character of Saruman, with a playful expression and a vibrant color scheme, standing in front of a beautiful, lush forest.",
|
445 |
+
"A stylized anime portrait of Saruman, with exaggerated facial features and a bold, colorful background, showcasing his powerful magic abilities."
|
446 |
+
],
|
447 |
+
[
|
448 |
+
"Create a 3D CGI portrait of Sauron, the dark lord of Mordor, with a dramatic, ominous atmosphere.",
|
449 |
+
"Illustrate Sauron as an adorable, chibi character, with a cute, playful expression, surrounded by colorful, whimsical background elements.",
|
450 |
+
"Envision Sauron as a cyberpunk robot, with glowing red eyes and metallic armor, standing in a dystopian, neon-lit cityscape."
|
451 |
+
],
|
452 |
+
[
|
453 |
+
"A dark, moody portrait of Count Dracula, rendered in a gothic, mystical style, with intricate details and textures that evoke the feeling of an ancient, haunted castle.",
|
454 |
+
"An adorable, chibi-style Count Dracula, with a playful, mischievous expression and a colorful, whimsical background that clashes with his dark reputation.",
|
455 |
+
"A futuristic, cyberpunk interpretation of Count Dracula, with glowing red eyes, cybernetic enhancements, and a dystopian cityscape in the background, evoking a sense of technological horror and unease."
|
456 |
+
],
|
457 |
+
[
|
458 |
+
"A dark and moody illustration of Sherlock Holmes sitting in his armchair, surrounded by smoke and shadows, with a magnifying glass in hand and a thoughtful expression on his face.",
|
459 |
+
"A stylized, comic book-inspired illustration of Sherlock Holmes, standing heroically with his trenchcoat flowing behind him, a deerstalker hat on his head, and a confident smile on his face.",
|
460 |
+
"A whimsical, almost fantastical illustration of Sherlock Holmes, depicted as a tiny, mouse-like creature in a giant, steam-powered laboratory, surrounded by gears, levers, and brass fixtures, with a magnifying glass in hand and a look of curiosity on his face."
|
461 |
+
],
|
462 |
+
[
|
463 |
+
"Sherlock Holmes' trusty sidekick, Dr. Watson, sits in a dimly lit room, surrounded by stacks of books and papers, deep in thought as he helps Holmes solve a mystery. (Realistic, Dramatic)",
|
464 |
+
"Dr. Watson, reimagined as a cute, anime-style girl, blushes as she helps Sherlock Holmes solve a case, her heart racing with excitement. (Cute Kawaii, Anime Portrait)",
|
465 |
+
"In a steampunk world, Dr. Watson, a rugged, cybernetically-enhanced man, assists Sherlock Holmes in unraveling a complex conspiracy, their advanced gadgets and gizmos at the ready. (Cyberpunk, Digital Art)"
|
466 |
+
],
|
467 |
+
[
|
468 |
+
"A cute, pastel-colored Frankenstein's monster, surrounded by flowers and trees, with a friendly expression. (Cute Kawaii, Pastel Colors, Friendly)",
|
469 |
+
"A dark and moody Frankenstein's monster, standing in a stormy night, with lightning striking in the background. (Dark, Moody, Stormy)",
|
470 |
+
"A futuristic Frankenstein's monster, with glowing blue eyes and cybernetic parts, standing in a neon-lit cityscape. (Cyberpunk, Glowing Blue Eyes, Neon Lights)"
|
471 |
+
],
|
472 |
+
[
|
473 |
+
"A dark and moody portrait of the Wolfman, with a focus on his sharp teeth and glowing eyes, set against a eerie forest background. (Style: Digital Portrait, Mood: Dramatic, Colors: Dark blues and greys)",
|
474 |
+
"An adorable, stylized Wolfman character, with a playful expression and a colorful, whimsical background. (Style: Cute Creature, Mood: Playful, Colors: Bright pastels)",
|
475 |
+
"A cyberpunk reimagining of the Wolfman, with a sleek, futuristic suit and glowing cybernetic eyes, standing in a dystopian cityscape. (Style: Cyberpunk, Mood: Edgy, Colors: Neon pink and blue)"
|
476 |
+
],
|
477 |
+
[
|
478 |
+
"A sleek black cat with a mischievous grin, sitting on a pile of colorful balls, in a playful, vibrant atmosphere.",
|
479 |
+
"A fluffy white cat with big, round eyes, surrounded by a soft, pastel-colored background, exuding a sense of innocence and cuteness.",
|
480 |
+
"A tough-looking grey cat with a scar above its eye, standing on a gritty, urban rooftop, surrounded by a dark, moody atmosphere."
|
481 |
+
],
|
482 |
+
[
|
483 |
+
"A clumsy dog with a goofy smile, standing on its hind legs while wearing a superhero cape, in a bright and colorful comic book style.",
|
484 |
+
"A drooling dog with a sideways glance, sitting on a pile of its favorite toys, surrounded by a soft, pastel-colored background.",
|
485 |
+
"A snarling dog with sharp teeth, standing on a desolate, post-apocalyptic wasteland, with a dark and gritty cyberpunk atmosphere."
|
486 |
+
],
|
487 |
+
[
|
488 |
+
"Superman in a dramatic pose, standing on a skyscraper, looking out over the city. (Style: Digital Art, Mood: Heroic, Colors: Blue, Red, Yellow, Gray)",
|
489 |
+
"Superman in a cute, cartoonish style, flying through the air with a big smile on his face. (Style: Comic Art, Mood: Playful, Colors: Bright, Pastel)",
|
490 |
+
"Superman in a dark, gritty style, standing in a dark alleyway, looking intense and brooding. (Style: Digital Art, Mood: Moody, Colors: Dark, Muted)"
|
491 |
+
],
|
492 |
+
[
|
493 |
+
"A dark and gritty Batman portrait with a spotlight shining down on his face, highlighting his intense expression and dramatic shadows. Style: Digital Art, Dramatic, Low Poly.",
|
494 |
+
"A stylized Batman illustration with a bold, angular design and vibrant colors, showcasing his sleek suit and confident pose. Style: Comic Art, Pixar, Toon Monster.",
|
495 |
+
"A haunting Batman scene with a twisted, nightmarish atmosphere, featuring twisted, elongated shadows and a sense of impending danger. Style: Horror, Digital Art, Isometric.Please let me know if you want me to generate more prompts or if you have any specific theme or style in mind."
|
496 |
+
],
|
497 |
+
[
|
498 |
+
"A 3D CGI rendering of Green Lantern in a dramatic pose, with a glowing green energy aura surrounding his body and a powerful expression on his face.",
|
499 |
+
"An adorable, cartoon-style Green Lantern, with a cute, rounded design and a playful expression on his face, surrounded by a bright and colorful background.",
|
500 |
+
"A dark and moody depiction of Green Lantern, with a gritty, realistic style and a menacing expression on his face, surrounded by a dark and ominous cityscape."
|
501 |
+
],
|
502 |
+
[
|
503 |
+
"Anime Captain America portrait with a dynamic pose and vibrant colors, showcasing his iconic shield and costume.",
|
504 |
+
"3D Captain America standing on a ruined building, looking out towards the horizon with a sense of determination, in a dark and gritty style inspired by video games.",
|
505 |
+
"Cute Kawaii Captain America in a chibi style, holding a miniature shield and wearing a adorable costume, surrounded by colorful balloons and confetti in a joyful atmosphere."
|
506 |
+
],
|
507 |
+
[
|
508 |
+
"CyberPunk Darth VaderGenerate a cybernetic version of Darth Vader with neon lights and glowing red eyes, standing in front of a futuristic cityscape.",
|
509 |
+
"Adorable Darth VaderCreate a cute and endearing version of Darth Vader, with a childlike appearance and a playful expression, holding a lightsaber and standing in front of a colorful background.",
|
510 |
+
"Dark Darth VaderIllustrate a dark and ominous version of Darth Vader, with a menacing expression and a dark aura surrounding him, standing in front of a stormy sky or a dark cave."
|
511 |
+
],
|
512 |
+
[
|
513 |
+
"Luke Skywalker in a dramatic pose, surrounded by a glowing aura, with a starry night sky background. (Style: Digital Art, Mood: Dramatic, Color: Blue and gold, Details: Lightsaber, Jedi robes)",
|
514 |
+
"Luke Skywalker as a cute anime-style character, holding a lightsaber and wearing a mini Jedi robe, standing on a planetary surface with a bright and colorful sunset background. (Style: Anime Portrait, Mood: Adorable, Color: Pastel, Details: Big eyes, exaggerated facial expression)",
|
515 |
+
"Luke Skywalker as a gritty, realistic character, standing in a dark and grungy alleyway, with a broken lightsaber hilt at his feet and a stormtrooper helmet on the ground nearby. (Style: Digital Art, Mood: Dark, Color: Grungy, Details: Broken lightsaber, Stormtrooper helmet)"
|
516 |
+
],
|
517 |
+
[
|
518 |
+
"A 3D rendering of Han Solo standing in front of the Millennium Falcon, with a swaggering pose and a confident smile. The lighting should be dramatic, with a strong contrast between light and dark.",
|
519 |
+
"An adorable, cartoon-style Han Solo, dressed in his signature outfit, holding a blaster and standing in front of a colorful, stylized version of the Death Star. The mood should be playful and light-hearted.",
|
520 |
+
"A stylized digital portrait of Han Solo, with a focus on his rugged, weathered appearance. The color palette should be muted and gritty, with a focus on earth tones. The pose should be relaxed, with Han leaning against a wall or sitting on a crate, looking tired but still confident."
|
521 |
+
],
|
522 |
+
[
|
523 |
+
"A 3D rendered image of Hogwarts School of Witchcraft and Wizardry, with a warm and inviting lighting, showcasing the castle's grand architecture and snow-covered grounds.",
|
524 |
+
"An adorable illustration of a young Harry Potter, sitting on a stack of books, surrounded by owls, with a curious expression on his face, and a warm color palette.",
|
525 |
+
"A dark and moody illustration of a wand choosing a wizard, with a spotlight shining down on the wand, and a dark, mysterious background, showcasing the wand's power and destiny."
|
526 |
+
],
|
527 |
+
[
|
528 |
+
"Create a 3D character model of Hermione Granger in a dynamic pose, with a vibrant and colorful background that reflects her personality.",
|
529 |
+
"Draw an adorable illustration of Hermione Granger in a cute outfit, surrounded by books and magic sparkles, with a soft and pastel color palette.",
|
530 |
+
"Imagine a dark and edgy version of Hermione Granger, with a gothic-inspired outfit and a fierce expression, standing in a dimly lit library with shelves of ancient tomes and mysterious artifacts."
|
531 |
+
],
|
532 |
+
[
|
533 |
+
"Anime-style Ron Weasley portrait with a mischievous grin and a hint of movement in the background, as if he's just apparated into the scene.",
|
534 |
+
"3D CGI Ron Weasley character model with a detailed, realistic texture and a dynamic pose, as if he's about to cast a spell.",
|
535 |
+
"Cute, stylized Ron Weasley illustration with bold lines and vibrant colors, surrounded by floating objects and patterns that reflect his playful and mischievous personality."
|
536 |
+
],
|
537 |
+
[
|
538 |
+
"A 3D rendered Gandalf, standing on a rocky cliff overlooking a vast landscape, with a staff in hand and a wise expression on his face.",
|
539 |
+
"An adorable Gandalf, sitting on a mushroom in a whimsical forest, surrounded by friendly woodland creatures, with a book in hand and a kind smile.",
|
540 |
+
"A cyberpunk Gandalf, standing in a dark alleyway, surrounded by neon lights and holographic advertisements, with a cybernetic staff and a determined expression."
|
541 |
+
],
|
542 |
+
[
|
543 |
+
"Anime Frodo Baggins in a beautiful, serene landscape, surrounded by lush greenery and a warm, soft light.",
|
544 |
+
"Frodo Baggins as a cute, cartoonish character, standing on a rocky cliffside, with a playful expression and a vibrant, colorful background.",
|
545 |
+
"Frodo Baggins as a gritty, realistic digital portrait, with a strong, determined expression and a dark, dramatic atmosphere."
|
546 |
+
],
|
547 |
+
[
|
548 |
+
"A 3D rendered Samwise Gamgee, standing on a green hill under a bright blue sky, with a friendly smile and a trusty sword by his side.",
|
549 |
+
"An adorable Samwise Gamgee, drawn in a cute Kawaii style, sitting on a mushroom in a whimsical forest, surrounded by colorful flowers and birds.",
|
550 |
+
"A dark and moody Samwise Gamgee, illustrated in a punky style, standing in a dystopian urban landscape, with a determined look on his face and a rebellious spirit in his eyes."
|
551 |
+
],
|
552 |
+
[
|
553 |
+
"A 3D rendered image of Bilbo Baggins sitting in his cozy hobbit hole, surrounded by books and pipes, with a warm and inviting lighting.",
|
554 |
+
"A stylized Bilbo Baggins portrait with an anime-inspired style, featuring vibrant colors and bold lines, showcasing his bravery and determination.",
|
555 |
+
"A dark and moody illustration of Bilbo Baggins navigating through a mysterious and eerie forest, with glowing eyes and misty atmosphere, highlighting the sense of danger and uncertainty."
|
556 |
+
],
|
557 |
+
[
|
558 |
+
"Epic Aragorn in a dramatic pose, surrounded by a glowing aura, with a mystical sword in hand and a regal crown on his head, standing on a rocky cliff overlooking a vast kingdom.",
|
559 |
+
"Adorable Aragorn as a chibi character, with a playful expression, holding a tiny sword and wearing a miniature crown, sitting on a cute little cushion surrounded by fluffy clouds and rainbows.",
|
560 |
+
"Dark Aragorn as a brooding, menacing figure, with a dark sword and a black crown, standing in a dimly lit throne room with stone walls and flickering torches, casting a sinister shadow on the ground."
|
561 |
+
],
|
562 |
+
[
|
563 |
+
"A dark, moody portrait of Gollum, emphasizing his gaunt, emaciated features and obsessive gaze, surrounded by a faint glow of preciousness.",
|
564 |
+
"An adorable, stylized Gollum, with large, round eyes and a playful expression, perched atop a pile of treasure, surrounded by a bright, colorful aura.",
|
565 |
+
"A dramatic, 3D rendering of Gollum, posed atop a rocky outcropping, with a stormy, threatening sky in the background, and a sense of tension and unease in his posture and facial expression."
|
566 |
+
],
|
567 |
+
[
|
568 |
+
"Anime-style Boromir with a determined expression, standing on a rocky cliff overlooking a vast landscape.",
|
569 |
+
"3D CGI Boromir with a rugged, battle-worn appearance, holding a sword and shield in a dark, dystopian environment.",
|
570 |
+
"Cute, chibi Boromir with a playful expression, sitting on a mushroom in a whimsical forest surrounded by friendly creatures."
|
571 |
+
],
|
572 |
+
[
|
573 |
+
"A 3D rendered image of Legolas from The Lord of the Rings, standing on a rocky cliff overlooking a vast landscape.",
|
574 |
+
"An adorable, chibi-style Legolas, sitting on a mushroom in a whimsical forest, surrounded by animals and plants.",
|
575 |
+
"A dark and moody Legolas, standing in a dimly lit forest, his eyes glowing in the shadows, with a mysterious atmosphere."
|
576 |
+
],
|
577 |
+
[
|
578 |
+
"A 3D rendered Gimli, standing proudly with his axe, in a dramatic pose, with a stormy background.",
|
579 |
+
"An adorable Gimli, with a cute expression, sitting on a pile of gold coins, surrounded by jewels and treasure, in a colorful, whimsical style.",
|
580 |
+
"A cyberpunk Gimli, with glowing red eyes, standing in a dark alleyway, surrounded by neon lights and futuristic technology, in a moody, dystopian atmosphere."
|
581 |
+
],
|
582 |
+
[
|
583 |
+
"A dramatic portrait of Thorin Oakenshield, with a stern expression and a battle-worn armor, standing in front of a snowy mountain. Style: Digital Portrait, Color: Cold colors, Mood: Serious, Details: Snow, armor, sword.",
|
584 |
+
"An adorable 3D character of Thorin Oakenshield, with a cute and playful expression, standing in front of a colorful background with a rainbow. Style: 3D Character, Color: Bright colors, Mood: Happy, Details: Rainbow, clouds, flowers.",
|
585 |
+
"A cyberpunk version of Thorin Oakenshield, with glowing blue eyes and a futuristic armor, standing in front of a neon-lit cityscape. Style: Cyberpunk, Color: Neon colors, Mood: Mysterious, Details: Glowing eyes, neon lights, futuristic city."
|
586 |
+
],
|
587 |
+
[
|
588 |
+
"A cyberpunk-inspired illustration of Bard the Bowman, with a sleek, futuristic bow and arrow, standing on a neon-lit rooftop overlooking a dystopian cityscape.",
|
589 |
+
"An adorable, chibi-style Bard the Bowman, holding a tiny bow and arrow, standing on a grassy hill with a cute, cartoonish castle in the background.",
|
590 |
+
"A dark, gritty illustration of Bard the Bowman, with a weathered, worn bow and arrow, standing in a dimly-lit alleyway surrounded by looming shadows and mysterious figures."
|
591 |
]
|
592 |
+
]
|
app/api/start/route.ts
CHANGED
@@ -3,12 +3,12 @@ import { PrismaClient } from '@prisma/client'
|
|
3 |
|
4 |
const prisma = new PrismaClient()
|
5 |
|
6 |
-
export async function POST(request: NextRequest
|
7 |
-
|
8 |
|
9 |
const results: Array<Record<string, any>> = await prisma.$queryRawUnsafe(
|
10 |
-
|
11 |
-
|
12 |
`SELECT * FROM "Prompt" ORDER BY RANDOM() DESC LIMIT 1;`,
|
13 |
)
|
14 |
|
@@ -20,11 +20,25 @@ export async function POST(request: NextRequest,) {
|
|
20 |
const prompts = await prisma.promptImage.findMany({
|
21 |
where: {
|
22 |
promptId: results[0].id
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
})
|
25 |
|
26 |
const correct_prompt = prompts[is_correct]
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
if (!correct_prompt) {
|
29 |
return Response.json({
|
30 |
message: "Not enough prompts. Try again."
|
@@ -41,7 +55,7 @@ export async function POST(request: NextRequest,) {
|
|
41 |
{
|
42 |
data: {
|
43 |
prompts,
|
44 |
-
question:
|
45 |
quest_id: quest.id
|
46 |
},
|
47 |
ok: true,
|
|
|
3 |
|
4 |
const prisma = new PrismaClient()
|
5 |
|
6 |
+
export async function POST(request: NextRequest) {
|
7 |
+
const { old_id } = await request?.json()
|
8 |
|
9 |
const results: Array<Record<string, any>> = await prisma.$queryRawUnsafe(
|
10 |
+
old_id ?
|
11 |
+
`SELECT * FROM "Prompt" WHERE id != '${old_id}' ORDER BY RANDOM() LIMIT 1` :
|
12 |
`SELECT * FROM "Prompt" ORDER BY RANDOM() DESC LIMIT 1;`,
|
13 |
)
|
14 |
|
|
|
20 |
const prompts = await prisma.promptImage.findMany({
|
21 |
where: {
|
22 |
promptId: results[0].id
|
23 |
+
},
|
24 |
+
select: {
|
25 |
+
id: true,
|
26 |
+
file_name: true,
|
27 |
+
promptId: true,
|
28 |
}
|
29 |
})
|
30 |
|
31 |
const correct_prompt = prompts[is_correct]
|
32 |
|
33 |
+
const prompt_image = await prisma.promptImage.findUnique({
|
34 |
+
where: {
|
35 |
+
id: correct_prompt.id
|
36 |
+
},
|
37 |
+
select: {
|
38 |
+
text: true
|
39 |
+
}
|
40 |
+
})
|
41 |
+
|
42 |
if (!correct_prompt) {
|
43 |
return Response.json({
|
44 |
message: "Not enough prompts. Try again."
|
|
|
55 |
{
|
56 |
data: {
|
57 |
prompts,
|
58 |
+
question: prompt_image?.text,
|
59 |
quest_id: quest.id
|
60 |
},
|
61 |
ok: true,
|
app/layout.tsx
CHANGED
@@ -1,10 +1,11 @@
|
|
1 |
-
import { cache } from "react";
|
2 |
import type { Metadata } from "next";
|
3 |
import { Inter } from "next/font/google";
|
4 |
import { QueryClient } from "@tanstack/react-query";
|
5 |
|
6 |
import Providers from "@/components/react-query/providers";
|
7 |
import "@/assets/css/globals.css";
|
|
|
8 |
|
9 |
export const metadata: Metadata = {
|
10 |
title: "Guess the Image: which one is the good one?",
|
@@ -52,6 +53,9 @@ export default function RootLayout({
|
|
52 |
<Providers>{children}</Providers>
|
53 |
</div>
|
54 |
<div id="background__noisy" />
|
|
|
|
|
|
|
55 |
</body>
|
56 |
</html>
|
57 |
);
|
|
|
1 |
+
import { cache, Suspense } from "react";
|
2 |
import type { Metadata } from "next";
|
3 |
import { Inter } from "next/font/google";
|
4 |
import { QueryClient } from "@tanstack/react-query";
|
5 |
|
6 |
import Providers from "@/components/react-query/providers";
|
7 |
import "@/assets/css/globals.css";
|
8 |
+
import Analytics from "@/components/gtm";
|
9 |
|
10 |
export const metadata: Metadata = {
|
11 |
title: "Guess the Image: which one is the good one?",
|
|
|
53 |
<Providers>{children}</Providers>
|
54 |
</div>
|
55 |
<div id="background__noisy" />
|
56 |
+
<Suspense>
|
57 |
+
<Analytics />
|
58 |
+
</Suspense>
|
59 |
</body>
|
60 |
</html>
|
61 |
);
|
components/gtm/index.tsx
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use client";
|
2 |
+
import { useEffect } from "react";
|
3 |
+
import { usePathname, useSearchParams } from "next/navigation";
|
4 |
+
import Script from "next/script";
|
5 |
+
|
6 |
+
import { pageview } from "@/utils/gtm";
|
7 |
+
|
8 |
+
export default function Analytics() {
|
9 |
+
const pathname = usePathname();
|
10 |
+
const searchParams = useSearchParams();
|
11 |
+
const isDeveloper = process.env.NEXT_PUBLIC_APP_DOMAIN === "developpeur.bio";
|
12 |
+
|
13 |
+
useEffect(() => {
|
14 |
+
if (pathname) {
|
15 |
+
pageview(pathname);
|
16 |
+
}
|
17 |
+
}, [pathname, searchParams]);
|
18 |
+
|
19 |
+
if (process.env.NEXT_PUBLIC_ENV !== "production") {
|
20 |
+
return null;
|
21 |
+
}
|
22 |
+
|
23 |
+
return (
|
24 |
+
<>
|
25 |
+
<noscript>
|
26 |
+
<iframe
|
27 |
+
src="https://www.googletagmanager.com/ns.html?id=P6WGPCC4"
|
28 |
+
height="0"
|
29 |
+
width="0"
|
30 |
+
style={{ display: "none", visibility: "hidden" }}
|
31 |
+
/>
|
32 |
+
</noscript>
|
33 |
+
<Script
|
34 |
+
id="gtm-script"
|
35 |
+
strategy="afterInteractive"
|
36 |
+
dangerouslySetInnerHTML={{
|
37 |
+
__html: `
|
38 |
+
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
39 |
+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
40 |
+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
41 |
+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
42 |
+
})(window,document,'script','dataLayer', 'GTM-P6WGPCC4');
|
43 |
+
`,
|
44 |
+
}}
|
45 |
+
/>
|
46 |
+
</>
|
47 |
+
);
|
48 |
+
}
|
components/quizz/hooks/useQuizz.ts
CHANGED
@@ -59,7 +59,7 @@ export const useQuizz = () => {
|
|
59 |
};
|
60 |
|
61 |
const { data, isFetching: loading, error, refetch } = useQuery<{ prompts: PromptType[], quest_id: string, question: string }>(['quizz'], async () => {
|
62 |
-
const request = await fetch(`/api/start`, { method: 'POST' });
|
63 |
const response = await request.clone().json().catch(() => ({}));
|
64 |
return response.data;
|
65 |
}, {
|
|
|
59 |
};
|
60 |
|
61 |
const { data, isFetching: loading, error, refetch } = useQuery<{ prompts: PromptType[], quest_id: string, question: string }>(['quizz'], async () => {
|
62 |
+
const request = await fetch(`/api/start`, { method: 'POST', body: JSON.stringify({}) });
|
63 |
const response = await request.clone().json().catch(() => ({}));
|
64 |
return response.data;
|
65 |
}, {
|
utils/gtm.ts
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// lib/gtm.ts
|
2 |
+
type WindowWithDataLayer = Window & {
|
3 |
+
dataLayer: Record<string, any>[]
|
4 |
+
}
|
5 |
+
|
6 |
+
declare const window: WindowWithDataLayer
|
7 |
+
|
8 |
+
export const GTM_ID = "GTM-P6WGPCC4"
|
9 |
+
|
10 |
+
export const pageview = (url: string) => {
|
11 |
+
if (typeof window.dataLayer !== "undefined") {
|
12 |
+
window.dataLayer.push({
|
13 |
+
event: "pageview",
|
14 |
+
page: url,
|
15 |
+
})
|
16 |
+
} else {
|
17 |
+
console.log({
|
18 |
+
event: "pageview",
|
19 |
+
page: url,
|
20 |
+
})
|
21 |
+
}
|
22 |
+
}
|