Score Log Events Added
This commit is contained in:
parent
ec8726cf94
commit
f5413dce9e
@ -154170,6 +154170,8 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 50b27839ecef84443a10112beb860a7a, type: 3}
|
m_Script: {fileID: 11500000, guid: 50b27839ecef84443a10112beb860a7a, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
supabaseUrl: https://vihjspljbslozbjzxutl.supabase.co
|
||||||
|
supabaseAnonKey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZpaGpzcGxqYnNsb3pianp4dXRsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDk1NDc4OTMsImV4cCI6MjA2NTEyMzg5M30.IYPvShgu5j3NnE5PHn-aFLCBJl1QQaVQvAjzxFt8tlA
|
||||||
--- !u!114 &2143540274
|
--- !u!114 &2143540274
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -41,6 +41,8 @@ public class BodyLinkHandler : MonoBehaviour, IPointerClickHandler, IPointerExit
|
|||||||
Debug.Log("🔗 Clicked link: " + linkID);
|
Debug.Log("🔗 Clicked link: " + linkID);
|
||||||
EmailPopupManager.Instance?.ShowPopup(linkID);
|
EmailPopupManager.Instance?.ShowPopup(linkID);
|
||||||
|
|
||||||
|
SupabaseEventLogger.Instance.LogScoreEvent(0); // Wrong action: clicked link
|
||||||
|
|
||||||
var emailPanelGO = WorldTimelineManager.Instance?.OpenedEmailPanel;
|
var emailPanelGO = WorldTimelineManager.Instance?.OpenedEmailPanel;
|
||||||
if (emailPanelGO != null && emailPanelGO.TryGetComponent<EmailOpenPanel>(out var emailPanel))
|
if (emailPanelGO != null && emailPanelGO.TryGetComponent<EmailOpenPanel>(out var emailPanel))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -114,7 +114,8 @@ public class EmailOpenPanel : MonoBehaviour
|
|||||||
bool isCorrect =
|
bool isCorrect =
|
||||||
(action == "report" && emailData.isPhishing) ||
|
(action == "report" && emailData.isPhishing) ||
|
||||||
(action == "ignore" && !emailData.isPhishing);
|
(action == "ignore" && !emailData.isPhishing);
|
||||||
|
int score = isCorrect ? 10 : 0;
|
||||||
|
SupabaseEventLogger.Instance.LogScoreEvent(score);
|
||||||
if (isCorrect)
|
if (isCorrect)
|
||||||
{
|
{
|
||||||
InstructionManager.Instance?.ShowScreenInstruction("correct_choice", 3f);
|
InstructionManager.Instance?.ShowScreenInstruction("correct_choice", 3f);
|
||||||
|
|||||||
BIN
Assets/Scripts/Scripts.zip
Normal file
BIN
Assets/Scripts/Scripts.zip
Normal file
Binary file not shown.
7
Assets/Scripts/Scripts.zip.meta
Normal file
7
Assets/Scripts/Scripts.zip.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bde532f7bcac08f459962af7046c06b8
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -10,7 +10,7 @@ public class SupabaseEventLogger : MonoBehaviour
|
|||||||
|
|
||||||
[Header("Supabase")]
|
[Header("Supabase")]
|
||||||
public string supabaseUrl = "https://vihjspljbslozbjzxutl.supabase.co";
|
public string supabaseUrl = "https://vihjspljbslozbjzxutl.supabase.co";
|
||||||
public string supabaseAnonKey = "YOUR_ANON_KEY_HERE";
|
public string supabaseAnonKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZpaGpzcGxqYnNsb3pianp4dXRsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDk1NDc4OTMsImV4cCI6MjA2NTEyMzg5M30.IYPvShgu5j3NnE5PHn-aFLCBJl1QQaVQvAjzxFt8tlA";
|
||||||
|
|
||||||
private DateTime sessionStartTime;
|
private DateTime sessionStartTime;
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ public class SupabaseEventLogger : MonoBehaviour
|
|||||||
{
|
{
|
||||||
event_key = "game_session_started",
|
event_key = "game_session_started",
|
||||||
timestamp = sessionStartTime.ToString("o"),
|
timestamp = sessionStartTime.ToString("o"),
|
||||||
user_id = "user123"
|
user_id = SystemInfo.deviceUniqueIdentifier
|
||||||
};
|
};
|
||||||
|
|
||||||
StartCoroutine(PostToSupabase("game_events", JsonUtility.ToJson(payload)));
|
StartCoroutine(PostToSupabase("game_events", JsonUtility.ToJson(payload)));
|
||||||
@ -83,12 +83,33 @@ public class SupabaseEventLogger : MonoBehaviour
|
|||||||
{
|
{
|
||||||
event_key = eventKey,
|
event_key = eventKey,
|
||||||
timestamp = DateTime.UtcNow.ToString("o"),
|
timestamp = DateTime.UtcNow.ToString("o"),
|
||||||
user_id = "user123"
|
user_id = SystemInfo.deviceUniqueIdentifier
|
||||||
};
|
};
|
||||||
|
|
||||||
StartCoroutine(PostToSupabase("game_events", JsonUtility.ToJson(payload)));
|
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<Decision> decisionLog = null)
|
public void CompleteSessionAndSubmitResult(string userId, bool passed, int optimal, int suboptimal, string scenarioId, List<Decision> decisionLog = null)
|
||||||
{
|
{
|
||||||
var endTime = DateTime.UtcNow;
|
var endTime = DateTime.UtcNow;
|
||||||
@ -267,7 +288,7 @@ public class SupabaseEventLogger : MonoBehaviour
|
|||||||
// Id = Guid.NewGuid(),
|
// Id = Guid.NewGuid(),
|
||||||
// EventKey = "game_session_started",
|
// EventKey = "game_session_started",
|
||||||
// Timestamp = sessionStartTime,
|
// Timestamp = sessionStartTime,
|
||||||
// UserId = "user123"
|
// UserId = SystemInfo.deviceUniqueIdentifier
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// await Client.Instance.From<GameEvent>().Insert(gameEvent);
|
// await Client.Instance.From<GameEvent>().Insert(gameEvent);
|
||||||
@ -298,7 +319,7 @@ public class SupabaseEventLogger : MonoBehaviour
|
|||||||
// Id = Guid.NewGuid(),
|
// Id = Guid.NewGuid(),
|
||||||
// EventKey = eventKey,
|
// EventKey = eventKey,
|
||||||
// Timestamp = DateTime.UtcNow,
|
// Timestamp = DateTime.UtcNow,
|
||||||
// UserId = "user123"
|
// UserId = SystemInfo.deviceUniqueIdentifier
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// await Client.Instance.From<GameEvent>().Insert(gameEvent);
|
// await Client.Instance.From<GameEvent>().Insert(gameEvent);
|
||||||
@ -412,7 +433,7 @@ public class SupabaseEventLogger : MonoBehaviour
|
|||||||
//// Id = Guid.NewGuid(), // <== Ensure this is explicitly set
|
//// Id = Guid.NewGuid(), // <== Ensure this is explicitly set
|
||||||
//// EventKey = "game_session_started",
|
//// EventKey = "game_session_started",
|
||||||
//// Timestamp = sessionStartTime,
|
//// Timestamp = sessionStartTime,
|
||||||
//// UserId = "user123"
|
//// UserId = SystemInfo.deviceUniqueIdentifier
|
||||||
//// };
|
//// };
|
||||||
//// await Client.Instance.From<GameEvent>().Insert(gameEvent);
|
//// await Client.Instance.From<GameEvent>().Insert(gameEvent);
|
||||||
//// Debug.Log("✅ Supabase Event: game_session_started");
|
//// Debug.Log("✅ Supabase Event: game_session_started");
|
||||||
@ -430,7 +451,7 @@ public class SupabaseEventLogger : MonoBehaviour
|
|||||||
//// Id = Guid.NewGuid(),
|
//// Id = Guid.NewGuid(),
|
||||||
//// EventKey = eventKey,
|
//// EventKey = eventKey,
|
||||||
//// Timestamp = DateTime.UtcNow,
|
//// Timestamp = DateTime.UtcNow,
|
||||||
//// UserId = "user123"
|
//// UserId = SystemInfo.deviceUniqueIdentifier
|
||||||
//// };
|
//// };
|
||||||
|
|
||||||
//// await Client.Instance.From<GameEvent>().Insert(gameEvent);
|
//// await Client.Instance.From<GameEvent>().Insert(gameEvent);
|
||||||
Loading…
x
Reference in New Issue
Block a user