Class FirestoreRestClient
java.lang.Object
com.shaft.tools.internal.FirestoreRestClient
FirestoreRestClient handles anonymous usage telemetry for SHAFT Engine.
Each test run sends one test_run event to Google Analytics (GA4) via the
Measurement Protocol. The event captures per-test-method outcome counts
(passed, failed, skipped, total), engine version, target platform, OS name,
and anonymous geographic region — derived automatically by GA4 from the
ip_override field, so no separate geo-lookup call is required.
Privacy: no personal data is collected. Only the client IP is
forwarded to GA4 (via ip_override) to enable anonymous country-level
reporting; the raw IP is not stored by SHAFT. Telemetry can be disabled by
setting telemetry.enabled=false in custom.properties.
Identity model:
client_id/user_id— a static, persistent UUID stored on disk atsrc/test/resources/META-INF/services/uuid. It identifies the installation across test runs.session_id(event param) — a dynamic value derived from the epoch-second timestamp at which the current test run started. It uniquely identifies a single test-run session and changes with every execution.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcreateCounterDocument(String collectionId, String documentId) Deprecated, for removal: This API element is subject to removal in a future version.Firestore counters are no longer used for telemetry; GA4 counts events natively.static voidincrementCounter(String collectionId, String documentId) Deprecated, for removal: This API element is subject to removal in a future version.Firestore counters are no longer used for telemetry; GA4 counts events natively.static voidlogEventToAnalytics(String eventName, long executionStartTime, long durationInMilliseconds, int passedTests, int failedTests, int skippedTests, int flakyTests) Sends onetest_runevent to the GA4 Measurement Protocol endpoint.static voidreadCounter(String collectionId, String documentId) Deprecated, for removal: This API element is subject to removal in a future version.Firestore counters are no longer used for telemetry; GA4 counts events natively.static voidsendTelemetry(long executionStartTime, long executionEndTime, int passedTests, int failedTests, int skippedTests, int flakyTests) Sends anonymous telemetry data if telemetry is enabled.
-
Constructor Details
-
FirestoreRestClient
public FirestoreRestClient()
-
-
Method Details
-
sendTelemetry
public static void sendTelemetry(long executionStartTime, long executionEndTime, int passedTests, int failedTests, int skippedTests, int flakyTests) Sends anonymous telemetry data if telemetry is enabled. This method executes asynchronously and will not block test execution. One GA4 analytics event (test_run) is sent, carrying deduplicated per-method outcome counts and key environment dimensions. Network overhead is minimal: only two HTTP calls are made (one to resolve the client IP for geographic attribution, one to the GA4 Measurement Protocol endpoint).- Parameters:
executionStartTime- the epoch-millisecond timestamp when the test run beganexecutionEndTime- the epoch-millisecond timestamp when the test run finishedpassedTests- the number of unique test methods that passedfailedTests- the number of unique test methods that failed (never passed)skippedTests- the number of unique test methods that were skippedflakyTests- the number of test methods that failed on at least one attempt but eventually passed (i.e. retried to success); 0 if none
-
createCounterDocument
@Deprecated(since="10.2.20260422", forRemoval=true) public static void createCounterDocument(String collectionId, String documentId) throws IOException, InterruptedException Deprecated, for removal: This API element is subject to removal in a future version.Firestore counters are no longer used for telemetry; GA4 counts events natively.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
@Deprecated(since="10.2.20260422", forRemoval=true) public static void incrementCounter(String collectionId, String documentId) throws IOException, InterruptedException Deprecated, for removal: This API element is subject to removal in a future version.Firestore counters are no longer used for telemetry; GA4 counts events natively.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
@Deprecated(since="10.2.20260422", forRemoval=true) public static void readCounter(String collectionId, String documentId) throws IOException, InterruptedException Deprecated, for removal: This API element is subject to removal in a future version.Firestore counters are no longer used for telemetry; GA4 counts events natively.Reads a document and returns 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 executionStartTime, long durationInMilliseconds, int passedTests, int failedTests, int skippedTests, int flakyTests) throws IOException, InterruptedException, org.json.JSONException Sends onetest_runevent to the GA4 Measurement Protocol endpoint.Network calls made (two total):
checkip.amazonaws.com— resolves the outbound IP so GA4 can attribute the event to the correct country viaip_override.- GA4 Measurement Protocol — posts the event payload.
ip_override.Identity fields:
client_id/user_id— the static installation UUID (persisted on disk). Stable across runs; used for unique-user counting.session_id(event param) — the dynamic epoch-second timestamp of the test-run start. Unique per execution; used for session-scoped analysis.
- Parameters:
eventName- the name of the event to log (e.g.,"test_run")executionStartTime- the epoch-millisecond timestamp when the test run began; divided by 1000 to produce thesession_iddurationInMilliseconds- the total execution duration in millisecondspassedTests- the number of unique test methods that passedfailedTests- the number of unique test methods that failed (never passed)skippedTests- the number of unique test methods that were skippedflakyTests- the number of test methods that failed then passed on retry; 0 if none- Throws:
IOException- in case of a network or IO issueInterruptedException- if the operation is interruptedorg.json.JSONException- if the JSON payload cannot be constructed
-