diff --git a/Assets/Scenes/Demo.unity b/Assets/Scenes/Demo.unity index 735ab88..c64123a 100644 --- a/Assets/Scenes/Demo.unity +++ b/Assets/Scenes/Demo.unity @@ -154170,6 +154170,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 50b27839ecef84443a10112beb860a7a, type: 3} m_Name: m_EditorClassIdentifier: + supabaseUrl: https://vihjspljbslozbjzxutl.supabase.co + supabaseAnonKey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZpaGpzcGxqYnNsb3pianp4dXRsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDk1NDc4OTMsImV4cCI6MjA2NTEyMzg5M30.IYPvShgu5j3NnE5PHn-aFLCBJl1QQaVQvAjzxFt8tlA --- !u!114 &2143540274 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/BodyLinkHandler.cs b/Assets/Scripts/BodyLinkHandler.cs index e991f59..0e5fe69 100644 --- a/Assets/Scripts/BodyLinkHandler.cs +++ b/Assets/Scripts/BodyLinkHandler.cs @@ -41,6 +41,8 @@ public class BodyLinkHandler : MonoBehaviour, IPointerClickHandler, IPointerExit Debug.Log("🔗 Clicked link: " + linkID); EmailPopupManager.Instance?.ShowPopup(linkID); + SupabaseEventLogger.Instance.LogScoreEvent(0); // Wrong action: clicked link + var emailPanelGO = WorldTimelineManager.Instance?.OpenedEmailPanel; if (emailPanelGO != null && emailPanelGO.TryGetComponent(out var emailPanel)) { diff --git a/Assets/CreateScrollableText.cs b/Assets/Scripts/CreateScrollableText.cs similarity index 100% rename from Assets/CreateScrollableText.cs rename to Assets/Scripts/CreateScrollableText.cs diff --git a/Assets/CreateScrollableText.cs.meta b/Assets/Scripts/CreateScrollableText.cs.meta similarity index 100% rename from Assets/CreateScrollableText.cs.meta rename to Assets/Scripts/CreateScrollableText.cs.meta diff --git a/Assets/Scripts/EmailOpenPanel.cs b/Assets/Scripts/EmailOpenPanel.cs index 6b9b4aa..b346215 100644 --- a/Assets/Scripts/EmailOpenPanel.cs +++ b/Assets/Scripts/EmailOpenPanel.cs @@ -114,7 +114,8 @@ public class EmailOpenPanel : MonoBehaviour bool isCorrect = (action == "report" && emailData.isPhishing) || (action == "ignore" && !emailData.isPhishing); - + int score = isCorrect ? 10 : 0; + SupabaseEventLogger.Instance.LogScoreEvent(score); if (isCorrect) { InstructionManager.Instance?.ShowScreenInstruction("correct_choice", 3f); diff --git a/Assets/ForcedArabic.cs b/Assets/Scripts/ForcedArabic.cs similarity index 100% rename from Assets/ForcedArabic.cs rename to Assets/Scripts/ForcedArabic.cs diff --git a/Assets/ForcedArabic.cs.meta b/Assets/Scripts/ForcedArabic.cs.meta similarity index 100% rename from Assets/ForcedArabic.cs.meta rename to Assets/Scripts/ForcedArabic.cs.meta diff --git a/Assets/Scripts/Scripts.zip b/Assets/Scripts/Scripts.zip new file mode 100644 index 0000000..ad2b2d6 Binary files /dev/null and b/Assets/Scripts/Scripts.zip differ diff --git a/Assets/Scripts/Scripts.zip.meta b/Assets/Scripts/Scripts.zip.meta new file mode 100644 index 0000000..a05772e --- /dev/null +++ b/Assets/Scripts/Scripts.zip.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: bde532f7bcac08f459962af7046c06b8 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/SupabaseEventLogger.cs b/Assets/Scripts/SupabaseEventLogger.cs similarity index 93% rename from Assets/SupabaseEventLogger.cs rename to Assets/Scripts/SupabaseEventLogger.cs index 603d21d..6873682 100644 --- a/Assets/SupabaseEventLogger.cs +++ b/Assets/Scripts/SupabaseEventLogger.cs @@ -10,7 +10,7 @@ public class SupabaseEventLogger : MonoBehaviour [Header("Supabase")] public string supabaseUrl = "https://vihjspljbslozbjzxutl.supabase.co"; - public string supabaseAnonKey = "YOUR_ANON_KEY_HERE"; + public string supabaseAnonKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZpaGpzcGxqYnNsb3pianp4dXRsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDk1NDc4OTMsImV4cCI6MjA2NTEyMzg5M30.IYPvShgu5j3NnE5PHn-aFLCBJl1QQaVQvAjzxFt8tlA"; private DateTime sessionStartTime; @@ -69,7 +69,7 @@ public class SupabaseEventLogger : MonoBehaviour { event_key = "game_session_started", timestamp = sessionStartTime.ToString("o"), - user_id = "user123" + user_id = SystemInfo.deviceUniqueIdentifier }; StartCoroutine(PostToSupabase("game_events", JsonUtility.ToJson(payload))); @@ -83,12 +83,33 @@ public class SupabaseEventLogger : MonoBehaviour { event_key = eventKey, timestamp = DateTime.UtcNow.ToString("o"), - user_id = "user123" + user_id = SystemInfo.deviceUniqueIdentifier }; StartCoroutine(PostToSupabase("game_events", JsonUtility.ToJson(payload))); } + [Serializable] + public class ScoreLogPayload + { + public string user_id; + public string timestamp; + public int score; + } + + public void LogScoreEvent(int score) + { + ScoreLogPayload payload = new ScoreLogPayload + { + user_id = SystemInfo.deviceUniqueIdentifier, + timestamp = DateTime.UtcNow.ToString("o"), + score = score + }; + + StartCoroutine(PostToSupabase("game_score_log", JsonUtility.ToJson(payload))); + } + + public void CompleteSessionAndSubmitResult(string userId, bool passed, int optimal, int suboptimal, string scenarioId, List decisionLog = null) { var endTime = DateTime.UtcNow; @@ -267,7 +288,7 @@ public class SupabaseEventLogger : MonoBehaviour // Id = Guid.NewGuid(), // EventKey = "game_session_started", // Timestamp = sessionStartTime, -// UserId = "user123" +// UserId = SystemInfo.deviceUniqueIdentifier // }; // await Client.Instance.From().Insert(gameEvent); @@ -298,7 +319,7 @@ public class SupabaseEventLogger : MonoBehaviour // Id = Guid.NewGuid(), // EventKey = eventKey, // Timestamp = DateTime.UtcNow, -// UserId = "user123" +// UserId = SystemInfo.deviceUniqueIdentifier // }; // await Client.Instance.From().Insert(gameEvent); @@ -412,7 +433,7 @@ public class SupabaseEventLogger : MonoBehaviour //// Id = Guid.NewGuid(), // <== Ensure this is explicitly set //// EventKey = "game_session_started", //// Timestamp = sessionStartTime, -//// UserId = "user123" +//// UserId = SystemInfo.deviceUniqueIdentifier //// }; //// await Client.Instance.From().Insert(gameEvent); //// Debug.Log("✅ Supabase Event: game_session_started"); @@ -430,7 +451,7 @@ public class SupabaseEventLogger : MonoBehaviour //// Id = Guid.NewGuid(), //// EventKey = eventKey, //// Timestamp = DateTime.UtcNow, -//// UserId = "user123" +//// UserId = SystemInfo.deviceUniqueIdentifier //// }; //// await Client.Instance.From().Insert(gameEvent); diff --git a/Assets/SupabaseEventLogger.cs.meta b/Assets/Scripts/SupabaseEventLogger.cs.meta similarity index 100% rename from Assets/SupabaseEventLogger.cs.meta rename to Assets/Scripts/SupabaseEventLogger.cs.meta diff --git a/Assets/SupabaseManager.cs b/Assets/Scripts/SupabaseManager.cs similarity index 100% rename from Assets/SupabaseManager.cs rename to Assets/Scripts/SupabaseManager.cs diff --git a/Assets/SupabaseManager.cs.meta b/Assets/Scripts/SupabaseManager.cs.meta similarity index 100% rename from Assets/SupabaseManager.cs.meta rename to Assets/Scripts/SupabaseManager.cs.meta diff --git a/Assets/SupabaseTestInsert.cs b/Assets/Scripts/SupabaseTestInsert.cs similarity index 100% rename from Assets/SupabaseTestInsert.cs rename to Assets/Scripts/SupabaseTestInsert.cs diff --git a/Assets/SupabaseTestInsert.cs.meta b/Assets/Scripts/SupabaseTestInsert.cs.meta similarity index 100% rename from Assets/SupabaseTestInsert.cs.meta rename to Assets/Scripts/SupabaseTestInsert.cs.meta diff --git a/Assets/ZoomTween.cs b/Assets/Scripts/ZoomTween.cs similarity index 100% rename from Assets/ZoomTween.cs rename to Assets/Scripts/ZoomTween.cs diff --git a/Assets/ZoomTween.cs.meta b/Assets/Scripts/ZoomTween.cs.meta similarity index 100% rename from Assets/ZoomTween.cs.meta rename to Assets/Scripts/ZoomTween.cs.meta