Skip to main content
AdvancedTelemetry and diagnostics in Slate

Darkgrade Slate records diagnostics about the camera exchanges it makes, and on Node.js it shares them with Darkgrade unless you turn that off. This page shows how to control that from an application you ship: the switches, what Slate does on its own, and the benchmark you can run yourself.

This page covers behaviour and controls only. What is collected and why is in the privacy policy. The same defaults apply to any product built on Slate, so read it before you ship.

Turn sharing off

Sharing is on by default. Any one of these turns it off:

HowLasts
Set DARKGRADE_CONTRIBUTIONS=0 or DO_NOT_TRACK=1 in the environmentWhile the variable is set
Run darkgrade telemetry opt-outSaved for this computer's user, across Studio, the CLI and Slate
Call setConsent(false) in your codeSaved the same way
import { nodeDiagnostics } from '@darkgrade/slate/telemetry/settings'

const diagnostics = await nodeDiagnostics()
await diagnostics.setConsent(false)
console.log(diagnostics.status())
// { enabled: false, sharingEnabled: false,
//   installationId: …, queuedEntries: 0, … }

setConsent(false) stops uploads and clears what was waiting to be sent. setConsent(true) turns sharing back on. withdraw() turns it off and also asks the collector to delete what this installation shared; darkgrade telemetry delete does the same.

Slate never shares under a test runner: with NODE_ENV=test, the automatic client is disabled.

What Slate does on its own

  • Nothing at import. Installing or importing Slate opens no camera, writes no settings and contacts no server.
  • One queue per process. When a Camera connects over USB or PTP/IP on Node.js, Slate attaches its diagnostics to that connection. It opens no second session.
  • Real cameras only. A custom or simulated transport is not observed, unless you configure a client yourself.
  • Batched uploads. Entries are sent every 30 seconds from a bounded queue, off the camera's path: an upload never delays or fails a camera operation. When the queue is full, new entries are dropped and counted.
  • One entry per call. Each public Camera call is recorded as a call entry with a callId, its outcome (ok, unsupported, refused, outcome-unknown, invalid-input or error) and the surface that made it. The protocol commands sent during the call carry the same callId.
  • Settings on disk. The sharing preference and a random installation id are kept in ~/.darkgrade/settings.json, which Studio and the CLI share.
  • A log on disk. Diagnostics are also written to ~/.darkgrade/diagnostics/<process id>.jsonl, for debugging. Each file rotates at 2 MiB and keeps one previous file. This continues when sharing is off.
  • Three more files. In ~/.darkgrade Slate also keeps reported-facts.json (hashes of what it already shared, so each connection doesn't upload the same inventory again), known-cameras.json (the make and model each USB device last reported) and profiles/ (saved camera profiles).

Environment variables

VariableEffect
DARKGRADE_CONTRIBUTIONS=0Turns sharing off.
DO_NOT_TRACK=1Turns sharing off.
DARKGRADE_LOCAL_DIAGNOSTICS=0Stops the log on disk.
DARKGRADE_HOMEThe folder to use in place of ~/.darkgrade.
DARKGRADE_TELEMETRY_URLAn HTTPS origin to send to, in place of Darkgrade's collector.

First contact

The first time Slate connects to a model that is not one of its tested models, it reads that camera's inventory once: its identity, the descriptors of the properties it advertises, and its storage ids.

  • It only reads. It takes no photo, starts no live view and changes no setting.
  • It runs once per model and firmware version on each installation, inside connect(), and is limited to 30 seconds and 512 properties.
  • It saves the profile to ~/.darkgrade/profiles/ and shares the inventory like any other diagnostics.
  • It does not run when sharing is off, under NODE_ENV=test, outside Node.js, or on a simulated transport.
  • It never throws: a failed inventory does not fail connect().

Turn it off for one camera with the constructor option:

import { Camera } from '@darkgrade/slate'

const camera = new Camera({ firstContact: false })

Benchmark a camera

runBenchmark is the same inventory on demand, with two optional transfers: it reads the camera's identity, the operations and events it advertises, its property descriptors and its storage ids, and times each check. Use it to see what a camera you haven't worked with supports. The CLI runs it as darkgrade telemetry benchmark.

import { Camera, runBenchmark } from '@darkgrade/slate'

const camera = new Camera()
await camera.connect()
try {
    const { passed, checks, profile } = await runBenchmark(camera, {
        photo: true,
        liveView: true,
        onProgress: ({ name, passed }) => console.log(name, passed),
    })
    console.log(passed, checks.length, profile.status)
    console.log(profile.identity?.model)
} finally {
    await camera.disconnect()
}

The camera must be connected, idle and yours for the duration: don't run other operations on it meanwhile. On a Sony, the storage check switches the camera to its file-transfer mode and back.

OptionDescription
photoTake one photo, without autofocus, and transfer it. It is saved to the card too. Default false.
liveViewTransfer one live-view frame. Default false.
timeoutMillisecondsThe whole benchmark's deadline. Default 180000, at most 300000. A check that would start after it is recorded as 'deadline'.
maximumPropertiesHow many property descriptors to read. Default 128, at most 512.
signalAn AbortSignal. Cancellation takes effect between checks.
onProgressCalled with each BenchmarkCheck as it finishes.
flushEvidenceCalled between phases, for hosts that manage their own upload queue.
purpose'first-contact' runs the read-only inventory above: no photo, no live view. Default 'benchmark'.

The result:

FieldMeaning
checksOne BenchmarkCheck per step: name, passed, durationMilliseconds, and error ('operation-failed', 'deadline' or 'cancelled') when it did not pass.
passedEvery check passed, nothing was cut short.
profileA darkgrade.camera-profile/v1 document: the camera's identity, vendorId, transport, status ('complete', 'partial' or 'cancelled'), and the datasets that were read.
mediaDecodedAlways false: a returned photo proves the transfer, not that the image decodes.

A passing benchmark shows what this camera answered today. profile.hardwarePass is always false: an inventory is not proof that each advertised feature works. For that, see Checks before a shoot.

Use your own store or collector

nodeDiagnostics() is the client Slate uses on Node.js. In a browser, or when you want the preference kept somewhere other than ~/.darkgrade, create a client yourself and hand it to Slate:

import { configureSlateTelemetry } from '@darkgrade/slate'
import {
    createApplicationDiagnostics,
    type InstallationState,
    type InstallationStore,
} from '@darkgrade/slate/telemetry'

let saved: InstallationState | null = null
const store: InstallationStore = {
    read: async () => saved,
    write: async state => {
        saved = state // keep it somewhere durable; it holds a credential
    },
}

const diagnostics = await createApplicationDiagnostics({
    endpoint: 'https://collector.example.com',
    store,
})
configureSlateTelemetry(diagnostics)

endpoint and store are required.

OptionDescription
endpointThe collector's HTTPS origin: no path, query or credentials.
storeReads and writes the InstallationState: the preference and this installation's credential.
disabledA function; return true to pause sharing, for example behind your own setting.
presentNoticeCalled once per notice version with { text, version }. Return false to start with sharing off.
localRecordReceives every entry, for your own log.
flushIntervalMillisecondsDefault 30000. From 1000 to 3600000.
requestTimeoutMillisecondsDefault 10000. At most 60000.
fetchA fetch to use for requests.

The client has status(), setConsent(value), withdraw(), flush() and close(). Create it once per process and reuse it for every camera. configureSlateTelemetry(undefined) puts back Slate's default. Everything else the two entries export is listed under @darkgrade/slate/telemetry and @darkgrade/slate/telemetry/settings.

⌘I