{"id":19765689,"url":"https://github.com/openhft/chronicle-analytics","last_synced_at":"2026-01-29T01:12:56.416Z","repository":{"id":39511501,"uuid":"312539131","full_name":"OpenHFT/Chronicle-Analytics","owner":"OpenHFT","description":"Support for Analytics","archived":false,"fork":false,"pushed_at":"2024-05-29T07:13:30.000Z","size":441,"stargazers_count":3,"open_issues_count":2,"forks_count":8,"subscribers_count":12,"default_branch":"ea","last_synced_at":"2024-05-29T07:26:46.382Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenHFT.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-13T10:05:13.000Z","updated_at":"2024-05-30T10:00:13.575Z","dependencies_parsed_at":"2023-02-10T17:31:11.120Z","dependency_job_id":"0f8d4a6f-60d9-4f1c-8d59-f30e4fa88e4f","html_url":"https://github.com/OpenHFT/Chronicle-Analytics","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenHFT%2FChronicle-Analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenHFT%2FChronicle-Analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenHFT%2FChronicle-Analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenHFT%2FChronicle-Analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenHFT","download_url":"https://codeload.github.com/OpenHFT/Chronicle-Analytics/tar.gz/refs/heads/ea","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224214789,"owners_count":17274683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T04:19:08.328Z","updated_at":"2026-01-29T01:12:56.355Z","avatar_url":"https://github.com/OpenHFT.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Chronicle-Analytics\nPer Minborg\n\n:toc:\n:toclevels: 4\n:css-signature: demo\n:toc-placement: macro\n:toc-title: Table of contents\n\nimage:https://maven-badges.herokuapp.com/maven-central/net.openhft/chronicle-analytics/badge.svg[Maven Central,link=https://maven-badges.herokuapp.com/maven-central/net.openhft/chronicle-analytics]\nimage:https://javadoc-badge.appspot.com/net.openhft/chronicle-analytics.svg?label=javadoc[JavaDoc, link=https://www.javadoc.io/doc/net.openhft/chronicle-analytics]\nimage:https://img.shields.io/hexpm/l/plug.svg?maxAge=2592000[License, link=https://github.com/OpenHFT/Chronicle-Analytics/blob/master/LICENSE]\nimage:https://img.shields.io/gitter/room/OpenHFT/Lobby.svg?style=popout[link=\"https://gitter.im/OpenHFT/Lobby\"]\n\nThis library provides remote ingress to Google Analytics 4, allowing data, such as usage-statistics, to be collected for Java applications.The data can subsequently be analysed using\na variety of tools available from Google and other providers.\n\nHere is a short Java snippet showing how one could use the library to send a Google Analytics event\nfor the measurement id \"G-TDAZG4CU3G\" using the api secret \"k2hL3x2dQaKq9F2gQ-PNhQ\".\n\n[source,java]\n----\nAnalytics.builder(\"G-TDAZG4CU3G\", \"k2hL3x2dQaKq9F2gQ-PNhQ\") // measurementId, apiSecret\n    .putEventParameter(\"app_version\", \"1.4.2\")\n    .build()\n    .sendEvent(\"started\");\n----\n\nAs can be seen, the event is named \"started\" and is associated with the application's version number under the event parameter name \"app_version`.\n\ntoc::[]\n\n== Disabling the library\n\nUnder `noop` there is a build for an empty jar which when included will ensure this jar does nothing.\nThis jar is redundant but can help ensure this jar does nothing.\n\nTo disable this jar include the following in Maven: \n\n[script,xml]\n----\n\u003cdependency\u003e\n    \u003cgroupId\u003enet.openhft\u003c/groupId\u003e\n    \u003cartifactId\u003echronicle-analytics\u003c/artifactId\u003e\n    \u003cversion\u003e0.20.0\u003c/version\u003e\n----\n\nTo disable this library with Gradle, use: \n\n[script,xml]\n----\nconfigurations {\n    implementation {\n      exclude group: 'net.openhft', module: 'chronicle-analytics'\n    }\n}\n----\n\n== Using the library\n\nThe library and its use is further described hereunder.\n\n=== API overview\n\nApplications will create and use instances of `Analytics`.\nAnalytic instances are created using a builder pattern that optionally allows various custom parameters to be set, after which a new instance is created by invoking a `build()` method:\n\n[source,java]\n----\nString measurementId = \"G-TDAZG4CU3G\";\nString apiSecret = \"k2hL3x2dQaKq9F2gQ-PNhQ\";\nAnalytics.Builder builder = Analytics.builder(measurementId, apiSecret);\n\n// optionally configure the builder, see JavaDocs\n\nAnalytics analytics = builder.build();\nanalytics.sendEvent(\"started\");\n----\n\nNOTE: The `measurementId` and `apiSecret` values can be obtained directly from your Google Analytics account.\n\n=== Builder configuration\n\nConfiguration of the builder may be done using the following methods:\n\n.Builder Methods\n|===\n| Return type | Method | Description\n\n|Analytics |build()|Creates and returns a new Analytics instance for this Builder.\n|Builder   |putEventParameter​(String key, String value)|Associates the provided value with the provided key in this builder's event parameters.\n|Builder   |putUserProperty​(String key, String value)|Associates the provided value with the provided key in this builder's user properties.\n|Builder   |withClientIdFileName​(String clientIdFileName)|Specifies a custom file name to use when storing a persistent client id used to identify returning users.\n|Builder   |withDebugLogger​(Consumer\u003cString\u003e debugLogger)|Specifies a custom logger that will receive debug messages.\n|Builder   |withErrorLogger​(Consumer\u003cString\u003e errorLogger)|Specifies a custom logger that will receive error messages.\n|Builder   |withFrequencyLimit​(long duration, TimeUnit timeUnit)|Limits the frequency by which events can be sent upstream to Google Analytics.\n|Builder   |withReportDespiteJUnit()|Specifies that reporting shall be made even though JUnit test classes are available to the classloader.\n|Builder   |withUrl​(String url)|Specifies a custom URL to use when connecting to Google Analytics.\n|===\n\nNOTE: All parameters and return values are non-null.\n\nNOTE: Invoking `withUrl(\"https://www.google-analytics.com/debug/mp/collect\")` allows debugging of your application reporting on the server side.\n\nNOTE: See the link:https://javadoc.io/doc/net.openhft/chronicle-analytics/latest/index.html[JavaDocs] for more details on the methods above.\n\n=== Analytic methods\n\nOnce we have obtained an Analytic instance, we can send events up stream to Google using the following methods:\n\n.Analytics Methods\n|===\n| Return type | Method | Description\n\n|void|sendEvent​(String name)|Sends an event to Google Analytics as identified by the provided event `name`.\n|void|sendEvent​(String name, Map\u003cString,​String\u003e additionalEventParameters)|Sends an event to Google Analytics as identified by the provided event `name`, including the provided `additionalEventParameters` in the event.\n|===\n\nNOTE: All parameters are non-null.\n\nNOTE: See the link:https://javadoc.io/doc/net.openhft/chronicle-analytics/latest/index.html[JavaDocs] for more details on the methods above.\n\n=== Application example\n\nThe following example sets up an analytics instance with the *event parameter* `app_version = 1.4.2` and perhaps the *user properties*\n`os_name = Linux`, `os_version = 4.18.0.147.2.1.2l8_1.x86_64` and `java_runtime_version = 1.8.0_272-b10` depending on the environment used:\n\n[source, java]\n----\npublic class AnalyticsExampleMain {\n\n    public static void main(String[] args) {\n\n        Analytics analytics = Analytics.builder(\"G-TDAZG4CU3G\", \"k2hL3x2dQaKq9F2gQ-PNhQ\")\n                .putEventParameter(\"app_version\", \"1.4.2\")\n                .putUserProperty(\"os_name\", System.getProperty(\"os.name\"))\n                .putUserProperty(\"os_version\", System.getProperty(\"os.version\"))\n                .putUserProperty(\"java_runtime_version\", System.getProperty(\"java.runtime.version\"))\n                .build();\n\n        analytics.sendEvent(\"started\");\n\n        // do some job\n\n        analytics.sendEvent(\"completed\");\n\n    }\n}\n----\n\nWhen applications like this are run, statistics will be gathered by Google Analytics 4 allowing detailed insights as to how, where and when the application is used.\n\n== Google Analytics 4\n\nGoogle Analytics provides many ways of analysing the uploaded data.\n\n=== Example\n\nHere is an example of how data could be rendered using Google Analytics 4.\n\nimage::docs/images/GA4_example.png[Google Analytics 4 Example]\n\n== Requirements and properties\n\n=== Java versions\n\nThis library requires Java 8 or later.\n\n=== External dependencies\n\nThe library does not have any transitive dependencies and depends directly only on `org.jetbrains:annotations`.\n\n=== JSON compliance\n\nThe library supports basic JSON functionality. Escaping works for the most common characters used in the English language. To keep the dependency graph simple, we did not depend on any external JSON library.\n\n=== Thread safety\n\nAnalytics instances are thread-safe and can be shared across threads.\n\n=== Thread usage\n\nThe library is using a single thread named `\"chronicle-analytics-http-client\"` to send requests. This thread is initially started on demand and will remain dormant throughout the lifespan of the JVM.\n\n=== Special empty version\n\nThere is a special empty artifact available with the version number `0.EMPTY`. This version can be used to remove analytics code from projects that depends on analytics.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenhft%2Fchronicle-analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenhft%2Fchronicle-analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenhft%2Fchronicle-analytics/lists"}