{"id":27954517,"url":"https://github.com/ebu/peach-collector-android","last_synced_at":"2025-05-07T17:34:16.117Z","repository":{"id":53557155,"uuid":"221211442","full_name":"ebu/peach-collector-android","owner":"ebu","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-12T11:44:39.000Z","size":7578,"stargazers_count":5,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-13T17:55:45.227Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ebu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2019-11-12T12:21:37.000Z","updated_at":"2024-05-08T10:32:07.302Z","dependencies_parsed_at":"2024-05-08T10:42:11.326Z","dependency_job_id":null,"html_url":"https://github.com/ebu/peach-collector-android","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebu%2Fpeach-collector-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebu%2Fpeach-collector-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebu%2Fpeach-collector-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebu%2Fpeach-collector-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ebu","download_url":"https://codeload.github.com/ebu/peach-collector-android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252926481,"owners_count":21826322,"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":"2025-05-07T17:30:41.260Z","updated_at":"2025-05-07T17:34:16.099Z","avatar_url":"https://github.com/ebu.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![](https://jitpack.io/v/ebu/peach-collector-android.svg)](https://jitpack.io/#ebu/peach-collector-android)\n# About\n\nThe **Peach Collector** module provides simple functionalities to facilitate the collect of events. `PeachCollector` helps you by managing a queue of events serialized until they are successfully published.\n\n# Compatibility\n\nThe library is suitable for applications running on Android API 16 and above. The framework is built using the build tools version 29.0.2\n\n# Setup\n## 1. Provide the gradle dependency\nAdd it in your root build.gradle at the end of repositories:\n```gradle\nallprojects {\n  repositories {\n    ...\n    maven { url \"https://jitpack.io\" }\n  }\n}\n```\nAdd the dependency:\n```gradle\ndependencies {\n  implementation 'com.github.ebu:peach-collector-android:1.0.0'\n}\n```\n\n## 2. Initialize the collector\nIn your main activity, provide the application to the PeachCollector init function\n```java\nPeachCollector.init(getApplication());\n```\n\n## 3. Add a publisher\nYou need to add a `Publisher` to start sending the queued events.\nYou can either provide a __SiteKey__ or set a __URL address__ in order to configure the publisher.\n```java\nPublisher publisher = new Publisher(\"zzebu00000000017\");\nPeachCollector.addPublisher(publisher, \"My Publisher\");\n```\n\n## Configuring the collector\n\n- A user ID can be defined using the **`userID`** PeachCollector property.\n- A device ID can be defined using the **`setUserID`** function in PeachCollector. If set before initialization, PeachCollector will not try to retrieve an Advertising ID.\n- If userIDs are generated automatically for anonymous user. You can use the `setUserIsLoggedIn()` function to define if the user is logged in or not\n- For debugging purpose, a **`isUnitTesting`** flag is available. If true, notifications will be sent by the collector (see `PEACH_LOG_NOTIFICATION` constants)\n- The collector retrieves the *Advertising ID* to set as the *device ID* in order to track users that do not have user IDs. People can choose to limit tracking on their devices and the Advertising ID will not be available anymore. In this case, if there is no **`userID`** defined, no events will be recorder or sent. Unless you set the **`shouldCollectAnonymousEvents`** flag to *true*. Default is *false*.\n- Optionally, you can define an **`implementationVersion`** (that will be added to the request's payload).\n- `inactivityInterval` is the minimum duration (in milliseconds) of inactivity that will cause the `sessionStartTimestamp` to be reset when app becomes active (default is 1800000 milliseconds, half an hour)\n- `maximumStorageDays` is the maximum number of days an event should be kept in the queue (if it could not be sent).\n- `maximumStoredEvents` is the maximum number of events that should be kept in the queue. \n`maximumStorageDays` and `maximumStoredEvents` should be set before the initialisation of the framework as it will be used to clean the queue during the initialisation.\n- An `appID` can be defined if you don't want to use the default value (which is the bundle ID of the app).\n```java\nPeachCollector.isUnitTesting = true;\nPeachCollector.setDeviceID(UUID.randomUUID().toString());\nPeachCollector.shouldCollectAnonymousEvents = true;\nPeachCollector.userID = \"123e4567-e89b-12d3-a456-426655440000\";\nPeachCollector.implementationVersion = \"1\";\nPeachCollector.inactivityInterval = 3600000;\nPeachCollector.maximumStorageDays = 5;\nPeachCollector.maximumStoredEvents = 1000;\nPeachCollector.appID = \"my.test.app\";\n```\n\n### Configuring a Publisher\nA publisher needs to be initialized with a __SiteKey__ or a full __URL address__ as seen previously.\nBut it has 4 others properties that are worth mentioning :\n\n**`interval`**: The interval in seconds at which events are sent to the server (interval starts after the first event is queued). Default is 20 seconds.\n\n**`maxEventsPerBatch`**: Number of events queued that triggers the publishing process even if the desired interval hasn't been reached. Default is 20 events.\n\n**`maxEventsPerBatchAfterOfflineSession`**: Maximum number of events that can be sent in a single batch. Especially useful after a long offline session. Default is 1000 events.\n\n**`gotBackPolicy`**: How the publisher should behave after an offline period. Available options are `SendAll` (sends requests with **`maxEventsPerBatchAfterOfflineSession`** continuously), `SendBatchesRandomly` (separates requests by a random delay between 0 and 60 seconds).\n\n```java\npublisher.serviceURL = \"http://newEndPoint.com\";\npublisher.interval = 30;  \npublisher.maxEventsPerBatch = 50;\npublisher.maxEventsPerBatchAfterOfflineSession = 500;\n```\n\n### Adding custom data to a Publisher's client information\nEverytime events are sent to the defined __SiteKey__ or server, the payload (containing the JSON description of the events) has a single description of the client used. You can add any custom fields to this client description and it will be sent in every request.\n```java\npublisher.addClientField(\"country\", \"Germany\");\npublisher.addClientField(\"isGeolocalized\", true);\n```\n\n\n## Setting up a remote configuration\n`PeachCollector` allows you to set up a remote configuration URL. Remote configurations are simple JSON files with different fields to configure the publisher. For that, you need to provide the URL at the initialisation stage of the publisher.\n\n```java\nPublisher publisher = new Publisher(\"zzebu00000000017\", \"https://peach-bucket.ebu.io/zzebu/config-test.json\");\nPeachCollector.addPublisher(publisher, \"MyRemoteConfiguredPublisher\");\n```\n\nIn this remote configuration, you can for example define the interval (at which events are sent), the batch size (number of events per request) or the type of events that should be sent by the publisher.\n\n\n### Flushing and Cleaning\n\n**`Flush`** is called when the application is about to go to background, or if a special type of event is sent while in background (events that will potentially push the application into an inactive state). It will try to send all the queued events (even if the maximum number of events hasn't been reached)\n\n**`Clean`** will simply remove all current queued events. It is never called in the life cycle of the framework.\n\n`Flush` and `Clean` can be called manually.\n\n\n### Recording an Event\n\n```java\n// page view event\n\nEvent.sendPageView(\"page00\"+i, null, \"reco00\");\n\n\n// recommendation displayed event\n\nEventContextComponent carouselComponent = new EventContextComponent();  \ncarouselComponent.type = \"Carousel\";  \ncarouselComponent.name = \"recoCarousel\";  \ncarouselComponent.version = \"1.0\";  \n\nArrayList\u003cString\u003e items = new ArrayList\u003c\u003e();  \nitems.add(\"media00\");  \nitems.add(\"media01\");  \nitems.add(\"media02\");  \nitems.add(\"media03\");  \n\nEvent.sendRecommendationDisplayed(\"reco00\", items , null, null, carouselComponent);\n\n```\n\n### Setting up a player tracker\n\nTo track a player automatically, you just need to provide the ExoPlayer instance and information about the item that is being played.\nYou can provide information about the item or leave empty. The tracker will only update (or create if not provided) the `props` part of the events with data from the player\nYou can start and stop tracking an item manually.\n\n```java\nPeachPlayerTracker.setPlayer(exoPlayer);\nPeachPlayerTracker.trackMedia(\"video0001\", null, null, null);\nPeachPlayerTracker.clearCurrentItem(); \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Febu%2Fpeach-collector-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Febu%2Fpeach-collector-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Febu%2Fpeach-collector-android/lists"}