-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
An export and combination of our assorted IDS client implementations, combined.
- Loading branch information
Showing
27 changed files
with
2,390 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file, utf-8 charset | ||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
charset = utf-8 | ||
|
||
# Rust | ||
[*.rs] | ||
indent_style = space | ||
|
||
# Misc | ||
[*.{yaml,yml,nix,json,sh,service,socket,toml,te}] | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.md] | ||
insert_final_newline = true | ||
indent_style = space | ||
|
||
[*.plist] | ||
indent_style = tab | ||
|
||
[*.ps1] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[Cargo.lock] | ||
indent_style = space | ||
indent_size = 1 | ||
|
||
# selinux | ||
[*.pp] | ||
charset = unset | ||
end_of_line = unset | ||
indent_size = unset | ||
indent_style = unset | ||
insert_final_newline = unset | ||
trim_trailing_whitespace = unset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
groups: | ||
actions-deps: | ||
patterns: | ||
- "*" | ||
|
||
- package-ecosystem: "cargo" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
groups: | ||
cargo-deps: | ||
patterns: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
tags: | ||
- "v?[0-9]+.[0-9]+.[0-9]+*" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
Lints: | ||
runs-on: UbuntuLatest32Cores128G | ||
permissions: | ||
contents: read | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: DeterminateSystems/nix-installer-action@main | ||
- uses: DeterminateSystems/flakehub-cache-action@main | ||
- name: Check Nixpkgs input | ||
uses: DeterminateSystems/flake-checker-action@main | ||
|
||
- name: Check EditorConfig conformance | ||
if: always() | ||
run: nix develop --command check-editorconfig | ||
|
||
- name: Check Spelling | ||
if: always() | ||
run: nix develop --command check-spelling | ||
|
||
- name: Check nixpkgs-fmt formatting | ||
if: always() | ||
run: nix develop --command check-nixpkgs-fmt | ||
|
||
- name: Check rustfmt | ||
if: always() | ||
run: nix develop --command check-rustfmt | ||
|
||
- name: Check Clippy | ||
if: always() | ||
run: nix develop --command check-clippy | ||
|
||
DeterminateCI: | ||
needs: | ||
- Lints | ||
uses: DeterminateSystems/ci/.github/workflows/workflow.yml@main | ||
permissions: | ||
id-token: "write" | ||
contents: "read" | ||
with: | ||
visibility: private | ||
runner-map: | | ||
{ | ||
"aarch64-darwin": "macos-latest-xlarge", | ||
"aarch64-linux": "UbuntuLatest32Cores128GArm", | ||
"i686-linux": "UbuntuLatest32Cores128G", | ||
"x86_64-darwin": "macos-latest-xlarge", | ||
"x86_64-linux": "UbuntuLatest32Cores128G" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/target | ||
Cargo.lock | ||
.direnv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[package] | ||
name = "detsys-ids-client" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[features] | ||
default = [] | ||
|
||
# See: https://github.com/tokio-rs/tracing/issues/3207 | ||
tracing-instrument = [] | ||
|
||
|
||
[dependencies] | ||
chrono = { version = "0.4.38", features = ["serde"] } | ||
reqwest = { version = "0.12.12", default-features = false, features = [ | ||
"json", | ||
"rustls-tls-native-roots", | ||
] } | ||
serde = { version = "1.0.217", features = ["derive", "rc"] } | ||
serde_json = "1.0.137" | ||
sysinfo = { version = "0.33.1", default-features = false, features = [ "system", "disk" ] } | ||
tracing = { version = "0.1" } | ||
tokio = { version = "1", features = ["full", "tracing"] } | ||
uuid = { version = "1.12.1", features = [ "v4", "v7", "serde"] } | ||
thiserror = "2.0.11" | ||
url = "2.5.4" | ||
|
||
detsys-srv = "0.3" | ||
http = "1.2.0" | ||
trust-dns-resolver = "0.23.2" | ||
target-lexicon = "0.13.1" | ||
is_ci = "1.2.0" | ||
sys-locale = "0.3.2" | ||
iana-time-zone = "0.1.61" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# detsys-ids-client | ||
|
||
A client for `install.determinate.systems`, in particular the feature flagging/configuration and event collection. | ||
The event collection data is explicitly PostHog compatible. | ||
|
||
The collected properties are not identifying. | ||
You can see our privacy policy at https://determinate.systems/policies/privacy/. | ||
|
||
### Architecture | ||
|
||
```mermaid | ||
flowchart TD | ||
Recorder --> Collator | ||
ConfigurationProxy --> Recorder | ||
subgraph Worker | ||
Collator --> Submitter | ||
SystemSnapshotter --> Collator | ||
Submitter --> Transport | ||
Transport --> ConfigurationProxy | ||
end | ||
Transport --> Backend["File / HTTP Backend"] | ||
``` | ||
|
||
Components: | ||
|
||
- **Recorder** is the user-interface and cheap to clone, doing all the work over channels. | ||
- **ConfigurationProxy** reads configuration and feature properties from the **Transport**. | ||
- **Collator** fetches a recent **SystemSnapshot** from the **SystemSnapshotter** and agggregates the total sum of facts and event data to enrich the basic event data from the **Recorder**. Those events are then sent to the **Submitter**. | ||
- **SystemSnapshotter** produces a fresh **SystemSnapshot** of the host. This may include properties that change frequently, like thermal state, so a SystemSnapshot must not be reused. | ||
- **Submitter** batches and sends events over the **Transport** on a schedule, or when the **Recorder** explicitly requests an immediate flush. | ||
- **Transport** handles the actual reading of configuration and writing of event data. | ||
|
||
### Transports | ||
|
||
- **SrvHttp**: The default if no endpoint is specified (ie: None is passed). | ||
The provided endpoint record will be queried for SRV records. | ||
Each server in the record will be used in rotation, and for fallback if the backend is not behaving. | ||
Beyond that, it behaves like the HTTP transport. | ||
|
||
- **File**: Will try to parse the endpoint as-is, or with `file://` prefixed on it. | ||
With the File endpoint, the `DETSYS_IDS_CHECKIN_FILE` environment variable can point to a check-in configuration document to read. | ||
**Note:** You can pass an endpoint of `file:///dev/stdout` for interactive debugging. | ||
|
||
- **HTTP**: takes the configured `endpoint` and sets the URL path to `/check-in` for the checkin process, and `/events` for event submission. | ||
|
||
### Environment Variables | ||
|
||
- `DETSYS_IDS_CHECKIN_FILE` -- When using the File transport, this environment variable can point to a Checkin-compatible JSON file to specify features and options. | ||
- `DETSYS_IDS_IN_CI` -- Set to `1` to explicitly indicate this run is in CI. | ||
- `DETSYS_CORRELATION` -- A JSON blob that is set by `detsys-ts` and passes down some anonymized context about the GitHub Actions run. It can also contain an arbitrary set of event properties. | ||
|
||
The correlation data is mixed in to the event data by the Collator, and: | ||
|
||
- `$session_id` is preferred over generating a new one. | ||
- `$anon_distinct_id` is preferred over generating a new one. | ||
- `distinct_id` is used if the user of the library doesn't explicitly pass a distinct ID. | ||
- `$device_id` is used instead of generating a new one if the user doesn't explicitly pass a device ID. | ||
- `$groups` is merged in to the user-provided groups. | ||
- Any additional property is appended to the user-provided facts. | ||
|
||
### To-do | ||
|
||
- Rotate sessions after inactivity: https://github.com/PostHog/posthog-ios/blob/35d7b9306ae932da869a8c1fcadf2232494a5e71/PostHog/PostHogSessionManager.swift#L57-L69 | ||
- send-receive ZSTD data |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.