|
|
|
@ -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<Decision> 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<GameEvent>().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<GameEvent>().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<GameEvent>().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<GameEvent>().Insert(gameEvent);
|