An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          


TelemetryDeck client for Vapor





Documentation


Team Chat


MIT License


Continuous Integration


Swift 5.2

## 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.