Package com.shaft.tools.internal
Class FirestoreRestClient
java.lang.Object
com.shaft.tools.internal.FirestoreRestClient
FirestoreRestClient handles anonymous usage telemetry for SHAFT Engine.
This service is designed to be 100% anonymous and only tracks test run counts.
No personal data, machine identifiers, or sensitive information is collected.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
createCounterDocument
(String collectionId, String documentId) Creates a new document with a counter field initialized to 0.static void
incrementCounter
(String collectionId, String documentId) Atomically increments an integer field in a Firestore document.static void
logEventToAnalytics
(String eventName, long durationInMilliseconds) Logs a custom event to Firebase Analytics via the Measurement Protocol.static void
readCounter
(String collectionId, String documentId) Reads a document and prints its content.static void
sendTelemetry
(long executionStartTime, long executionEndTime) Sends anonymous telemetry data if telemetry is enabled.
-
Constructor Details
-
FirestoreRestClient
public FirestoreRestClient()
-
-
Method Details
-
sendTelemetry
public static void sendTelemetry(long executionStartTime, long executionEndTime) Sends anonymous telemetry data if telemetry is enabled. This method executes asynchronously and will not block test execution. Only a simple counter increment is sent to track test run statistics. -
createCounterDocument
public static void createCounterDocument(String collectionId, String documentId) throws IOException, InterruptedException Creates a new document with a counter field initialized to 0.- Parameters:
collectionId
- The collection to create the document in.documentId
- The ID for the new counter document.- Throws:
IOException
- in case of a network or IO issueInterruptedException
- if the operation is interrupted
-
incrementCounter
public static void incrementCounter(String collectionId, String documentId) throws IOException, InterruptedException Atomically increments an integer field in a Firestore document.- Parameters:
collectionId
- The collection containing the counter document.documentId
- The ID of the counter document.- Throws:
IOException
- in case of a network or IO issueInterruptedException
- if the operation is interrupted
-
readCounter
public static void readCounter(String collectionId, String documentId) throws IOException, InterruptedException Reads a document and prints its content.- Parameters:
collectionId
- The collection containing the document.documentId
- The ID of the document to read.- Throws:
IOException
- in case of a network or IO issueInterruptedException
- if the operation is interrupted
-
logEventToAnalytics
public static void logEventToAnalytics(String eventName, long durationInMilliseconds) throws IOException, InterruptedException, URISyntaxException, org.json.JSONException Logs a custom event to Firebase Analytics via the Measurement Protocol. This is the correct way to log events from a desktop application.- Parameters:
eventName
- The name of the event to log (e.g., "test_run").- Throws:
IOException
- in case of a network or IO issueInterruptedException
- if the operation is interruptedURISyntaxException
- if the URI is malformedorg.json.JSONException
-