EventMonitorTile Documentation
Overview
The EventMonitorTile is a component designed to monitor specific events based on user-defined queries. It allows users to initiate monitoring of real-time events occurring across various domains and retrieves relevant event data based on selected timespans. This component continuously polls for new events, alerts users of any changes, and provides an interface for easy visualization and interaction with event data.
Purpose
The primary purpose of the EventMonitorTile is to provide a mechanism for users to:
- Monitor live updates of events related to specific topics of interest.
- Fetch and display a limited number of recent events in a user-friendly format.
- Easily start and stop monitoring processes based on user interactions.
How It Works
When the user inputs a query and selects a timespan, the EventMonitorTile makes API calls to fetch events that match the criteria. The monitoring can be started and stopped via dedicated buttons, and the data is displayed in a clean list format. The component handles loading states, errors, and indicates when data is last checked. It utilizes JavaScript's asynchronous capabilities to retrieve data without blocking the user interface.
Data Expectations
The EventMonitorTile expects:
- Query Parameter: A string input representing the topic to monitor for events.
- Timespan Parameter: A selection from predefined options ('15min', '30min', '1h', '3h') to determine the monitoring interval.
- API Response Structure: The API must return a JSON object containing an array of event objects, each of which should include properties such as
url,title, andseendate.
Settings
1. Query
- Input Type: String
- Description: This setting allows users to specify the event topic they want to monitor. Changing this value dynamically alters the events returned by the API.
- Default Value: An empty string (
'').
2. Timespan
- Input Type: Dropdown (with predefined options)
- Options:
'15min''30min''1h''3h'
- Description: This setting defines the frequency of event polling. The available timespans affect how often the system checks for new events:
- 15min: Polls every 1 minute.
- 30min: Polls every 2 minutes.
- 1h: Polls every 5 minutes.
- Default Value:
'15min'.
3. Loading State
- Input Type: Boolean
- Description: Indicates whether the data is currently being fetched. It controls the display of loading animations.
- Default Value:
false.
4. Error State
- Input Type: String
- Description: Holds error messages if the API call fails for any reason. This state allows specific feedback to be shown to the user.
- Default Value:
null.
5. Event List
- Input Type: Array
- Description: Stores the array of events fetched from the API. This list is updated every time a new successful fetch occurs.
- Default Value: An empty array (
[]).
6. Monitoring State
- Input Type: Boolean
- Description: Indicates whether the system is currently monitoring events. This state toggles the active state of the monitoring button.
- Default Value:
false.
7. Last Checked
- Input Type: Date Object
- Description: Stores the timestamp of the last successful fetch of events, used for display.
- Default Value:
null.
Use Cases & Examples
Use Cases
-
Real-Time News Monitoring: A media company may use the EventMonitorTile to monitor breaking news events related to specific keywords (e.g., "elections", "COVID-19").
-
Market Event Alerts: Financial institutions can utilize the tile to track specific market events or regulatory changes by monitoring relevant sectors.
-
Social Media Event Tracking: Businesses can track significant social media events or trends based on user-set keywords that are relevant to their marketing strategies.
Example Configuration
Use Case: A marketing team wants to monitor recent events related to "product launch".
Configuration Data
{
"tile": {
"config": {
"defaultQuery": "product launch",
"defaultTimespan": "30min"
}
}
}Explanation:
- defaultQuery: Set to "product launch", meaning the monitoring will target events regarding product launches in real-time.
- defaultTimespan: Set to "30min", which will check for new events every 2 minutes, ensuring they stay up-to-date with the latest news.
This configuration enables the marketing team to react promptly to market developments and competitive activities.