https://github.com/edgee-cloud/segment-component
Segment Edgee Component
https://github.com/edgee-cloud/segment-component
edge-computing edgee rust segment wasm wasm-component
Last synced: about 1 year ago
JSON representation
Segment Edgee Component
- Host: GitHub
- URL: https://github.com/edgee-cloud/segment-component
- Owner: edgee-cloud
- License: apache-2.0
- Created: 2024-07-18T05:20:07.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-12T16:07:26.000Z (about 1 year ago)
- Last Synced: 2025-03-29T16:41:26.638Z (about 1 year ago)
- Topics: edge-computing, edgee, rust, segment, wasm, wasm-component
- Language: Rust
- Homepage: https://www.edgee.cloud
- Size: 77.1 KB
- Stars: 1
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
Segment Component for Edgee
[](https://coveralls.io/github/edgee-cloud/segment-component)
[](https://github.com/edgee-cloud/segment-component/issues)
[](https://www.edgee.cloud/edgee/segment)
This component implements the data collection protocol between [Edgee](https://www.edgee.cloud) and [Segment](https://segment.com).
## Quick Start
1. Download the latest component version from our [releases page](../../releases)
2. Place the `segment.wasm` file in your server (e.g., `/var/edgee/components`)
3. Add the following configuration to your `edgee.toml`:
```toml
[[components.data_collection]]
id = "segment"
file = "/var/edgee/components/segment.wasm"
settings.segment_api_key = "..."
```
## Event Handling
### Event Mapping
The component maps Edgee events to Segment events as follows:
| Edgee Event | Segment Event | Description |
|-------------|--------------|-------------|
| Page | `page` | Triggered when a user views a page |
| Track | `track` | Uses the provided event name directly |
| User | `identify` | Used for user identification only |
### User Event Handling
Each time you make a `user` call, Edgee will send an `identify` event to Segment.
But when you make a `user` call using Edgee's JS library or Data Layer, the `user_id`, `anonymous_id` and `properties` are stored in the user's device.
This allows the user's data to be added to any subsequent page or follow-up calls for the user, so that you can correctly attribute these actions.
## Configuration Options
### Basic Configuration
```toml
[[components.data_collection]]
id = "segment"
file = "/var/edgee/components/segment.wasm"
settings.segment_api_key = "..."
# Optional configurations
settings.edgee_anonymization = true # Enable/disable data anonymization in case of pending or denied consent
settings.edgee_default_consent = "pending" # Set default consent status if not specified by the user
```
### Event Controls
Control which events are forwarded to Segment:
```toml
settings.edgee_page_event_enabled = true # Enable/disable page event
settings.edgee_track_event_enabled = true # Enable/disable track event
settings.edgee_user_event_enabled = true # Enable/disable user event
```
### Consent Management
Before sending events to Segment, you can set the user consent using the Edgee SDK:
```javascript
edgee.consent("granted");
```
Or using the Data Layer:
```html
{
"data_collection": {
"consent": "granted"
}
}
```
If the consent is not set, the component will use the default consent status.
| Consent | Anonymization |
|---------|---------------|
| pending | true |
| denied | true |
| granted | false |
## Development
### Building from Source
Prerequisites:
- [Rust](https://www.rust-lang.org/tools/install)
- WASM target: `rustup target add wasm32-wasip2`
- wit-deps: `cargo install wit-deps`
Build command:
```bash
make wit-deps
make build
```
### Contributing
Interested in contributing? Read our [contribution guidelines](./CONTRIBUTING.md)
### Security
Report security vulnerabilities to [security@edgee.cloud](mailto:security@edgee.cloud)