https://github.com/getsidetrack/vapor-telemetrydeck
📈 Vapor client for posting signals to TelemetryDeck, a privacy-conscious analytics service for apps and websites.
https://github.com/getsidetrack/vapor-telemetrydeck
analytics privacy-protection server-side-swift swift telemetry vapor
Last synced: about 1 year ago
JSON representation
📈 Vapor client for posting signals to TelemetryDeck, a privacy-conscious analytics service for apps and websites.
- Host: GitHub
- URL: https://github.com/getsidetrack/vapor-telemetrydeck
- Owner: getsidetrack
- License: mit
- Created: 2022-02-13T17:05:49.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-12-20T16:06:06.000Z (over 3 years ago)
- Last Synced: 2025-04-15T23:56:06.366Z (about 1 year ago)
- Topics: analytics, privacy-protection, server-side-swift, swift, telemetry, vapor
- Language: Swift
- Homepage:
- Size: 19.5 KB
- Stars: 7
- Watchers: 0
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
TelemetryDeck client for Vapor
## Usage
Once you have added the package to your project, you must initialise the library. This is usually done in `configure.swift`.
```swift
import TelemetryDeck
app.telemetryDeck.initialise(appID: "")
```
### Sending a Signal
There are two ways to send a signal. One method is from the "system", which contains a static user identifier.
```swift
try await app.telemetryDeck.send("applicationStarted")
```
The second option is from a request, this will set the user identifier to be a hashed version of the request IP address.
```swift
try await request.telemetryDeck.send("homePage")
// for example:
app.get("home") { req async throws -> String in
try await req.telemetryDeck.send("homePage")
return "your page content"
}
```
### Properties
You can attach additional payload data with each signal by adding `additionalPayload` to the send functions.
```swift
try await app.telemetryDeck.send("applicationStarted", additionalPayload: [
"host": "gcp"
])
```
You may also configure TelemetryDeck for Vapor with a dictionary of default properties which are sent with every signal.
```swift
app.telemetryDeck.defaultParameters["key"] = "value"
```
## Sessions
With each signal, we send through a session identifier which is a unique UUID generated on initialisation. This is intended
to be different for each running instance of your server, changing each time you reboot the server.
## Test Mode
If you launch Vapor in a non-release environment, signals will be marked as being in test mode. In the Telemetry Viewer app,
actvivate **Test Mode** to see those.
## Signal Batching
This library does not currently support signal batching. This means that signals are sent to TelemetryDeck as you call the functions.
In a future release, we may add the capability to batch signals in memory and post them at regular intervals.