Esc
Tracklytic
AnleitungenAPI-ReferenzSDKsChangelogTracklytic öffnen

Insight verändern

View as MarkdownThe page as plain text

Einen numerischen Wert erhöhen oder verringern.

PATCH/v1/insight/mutate

Authentifizierung: API-Token.

Body

project und title sind erforderlich. value ist ein Objekt mit $inc als Zahl; negative Werte verringern den Wert. Optional: icon, notify.

Verhalten

Ein fehlendes Insight wird mit 0 angelegt. Ein bestehender nicht numerischer Wert wird für die Änderung als 0 behandelt. Der Request ist eine relative Änderung: zweimaliges Senden erhöht zweimal. Nicht als generischen MongoDB-Update-Body verwenden; die Integration sollte nur das unterstützte $inc senden.

Antwort

HTTP 200 mit {}. Zum Prüfen des aktuellen Wertes benötigst du einen Benutzer-Access-Token.

Request

curl -X PATCH 'https://api.tracklytic.de/v1/insight/mutate' \
  -H "Authorization: Bearer $TRACKLYTIC_API_TOKEN" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "project": "my-project",
  "title": "Aktive Abonnements",
  "value": {
    "$inc": 1
  }
}'
const response = await fetch("https://api.tracklytic.de/v1/insight/mutate", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.TRACKLYTIC_API_TOKEN}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify(
    {
      "project": "my-project",
      "title": "Aktive Abonnements",
      "value": {
        "$inc": 1
      }
    }
  )
});

if (!response.ok) throw new Error(await response.text());
const result = await response.json();
import json
import os
from urllib.request import Request, urlopen

payload = {
  "project": "my-project",
  "title": "Aktive Abonnements",
  "value": {
    "$inc": 1
  }
}

request = Request(
    "https://api.tracklytic.de/v1/insight/mutate",
    method="PATCH",
    headers={
        "Authorization": "Bearer " + os.environ["TRACKLYTIC_API_TOKEN"],
        "Content-Type": "application/json"
    },
    data=json.dumps(payload).encode("utf-8")
)

with urlopen(request) as response:
    result = json.load(response)

Response

200
{}