API Stability Preview

The logAnalyticsBatch() GraphQL mutation is used to log actions in the LogScale user interface in batches.

For information on auditing logs of user actions, see the Audit Logging documentation page.

Syntax

Below is the syntax for the logAnalyticsBatch() mutation field:

graphql
logAnalyticsBatch(
     input: [AnalyticsLogWithTimestamp]!
   ): boolean

There are no special returned datatypes for this mutation field. Below is an example of how it might be used:

Raw
graphql
mutation {
  logAnalyticsBatch ( input: 
    { eventId: "string",
      timestamp: 123,
      route: "string",
      action: "string",
      system: "string",
      arguments: ["string"],
      features: [ {name: "string", value: true} ],
      context: "string",
      metrics: {fps: 10},
      userAgent: {browser{info {}, isChrome: true, isChromeHeadless: false,
                          isEdge: false, isFirefox: true, isIE: true, isSafari: true},
                  device{info {},
                         isConsole: true, isDesktop: true, 
                         isMobile: false, isTablet: false }, 
                  engine{info {name: "string", version: "1"}, isWebkit: false }, 
                  os {info {name: "string", version: "1"}, 
                      isAndroid: false, isIOS: false, 
                      isLinux: true, isMacOS: true, isWindows: true} } 
    }
  )
}
Mac OS or Linux (curl)
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "mutation {
  logAnalyticsBatch ( input: 
    { eventId: \"string\",
      timestamp: 123,
      route: \"string\",
      action: \"string\",
      system: \"string\",
      arguments: [\"string\"],
      features: [ {name: \"string\", value: true} ],
      context: \"string\",
      metrics: {fps: 10},
      userAgent: {browser{info {}, isChrome: true, isChromeHeadless: false,
                          isEdge: false, isFirefox: true, isIE: true, isSafari: true},
                  device{info {},
                         isConsole: true, isDesktop: true, 
                         isMobile: false, isTablet: false }, 
                  engine{info {name: \"string\", version: \"1\"}, isWebkit: false }, 
                  os {info {name: \"string\", version: \"1\"}, 
                      isAndroid: false, isIOS: false, 
                      isLinux: true, isMacOS: true, isWindows: true} } 
    }
  )
}"
}
EOF
Mac OS or Linux (curl) One-line
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "mutation {
  logAnalyticsBatch ( input: 
    { eventId: \"string\",
      timestamp: 123,
      route: \"string\",
      action: \"string\",
      system: \"string\",
      arguments: [\"string\"],
      features: [ {name: \"string\", value: true} ],
      context: \"string\",
      metrics: {fps: 10},
      userAgent: {browser{info {}, isChrome: true, isChromeHeadless: false,
                          isEdge: false, isFirefox: true, isIE: true, isSafari: true},
                  device{info {},
                         isConsole: true, isDesktop: true, 
                         isMobile: false, isTablet: false }, 
                  engine{info {name: \"string\", version: \"1\"}, isWebkit: false }, 
                  os {info {name: \"string\", version: \"1\"}, 
                      isAndroid: false, isIOS: false, 
                      isLinux: true, isMacOS: true, isWindows: true} } 
    }
  )
}"
}
EOF
Windows Cmd and curl
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql ^
    -H "Authorization: Bearer $TOKEN" ^
    -H "Content-Type: application/json" ^
    -d @'{"query" : "mutation { ^
  logAnalyticsBatch ( input:  ^
    { eventId: \"string\", ^
      timestamp: 123, ^
      route: \"string\", ^
      action: \"string\", ^
      system: \"string\", ^
      arguments: [\"string\"], ^
      features: [ {name: \"string\", value: true} ], ^
      context: \"string\", ^
      metrics: {fps: 10}, ^
      userAgent: {browser{info {}, isChrome: true, isChromeHeadless: false, ^
                          isEdge: false, isFirefox: true, isIE: true, isSafari: true}, ^
                  device{info {}, ^
                         isConsole: true, isDesktop: true,  ^
                         isMobile: false, isTablet: false },  ^
                  engine{info {name: \"string\", version: \"1\"}, isWebkit: false },  ^
                  os {info {name: \"string\", version: \"1\"},  ^
                      isAndroid: false, isIOS: false,  ^
                      isLinux: true, isMacOS: true, isWindows: true} }  ^
    } ^
  ) ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  logAnalyticsBatch ( input: 
    { eventId: \"string\",
      timestamp: 123,
      route: \"string\",
      action: \"string\",
      system: \"string\",
      arguments: [\"string\"],
      features: [ {name: \"string\", value: true} ],
      context: \"string\",
      metrics: {fps: 10},
      userAgent: {browser{info {}, isChrome: true, isChromeHeadless: false,
                          isEdge: false, isFirefox: true, isIE: true, isSafari: true},
                  device{info {},
                         isConsole: true, isDesktop: true, 
                         isMobile: false, isTablet: false }, 
                  engine{info {name: \"string\", version: \"1\"}, isWebkit: false }, 
                  os {info {name: \"string\", version: \"1\"}, 
                      isAndroid: false, isIOS: false, 
                      isLinux: true, isMacOS: true, isWindows: true} } 
    }
  )
}"
}'
    "$YOUR_LOGSCALE_URL/graphql"
Perl
perl
#!/usr/bin/perl

use HTTP::Request;
use LWP;

my $TOKEN = "TOKEN";

my $uri = '$YOUR_LOGSCALE_URL/graphql';

my $query = "mutation {
  logAnalyticsBatch ( input: 
    { eventId: \"string\",
      timestamp: 123,
      route: \"string\",
      action: \"string\",
      system: \"string\",
      arguments: [\"string\"],
      features: [ {name: \"string\", value: true} ],
      context: \"string\",
      metrics: {fps: 10},
      userAgent: {browser{info {}, isChrome: true, isChromeHeadless: false,
                          isEdge: false, isFirefox: true, isIE: true, isSafari: true},
                  device{info {},
                         isConsole: true, isDesktop: true, 
                         isMobile: false, isTablet: false }, 
                  engine{info {name: \"string\", version: \"1\"}, isWebkit: false }, 
                  os {info {name: \"string\", version: \"1\"}, 
                      isAndroid: false, isIOS: false, 
                      isLinux: true, isMacOS: true, isWindows: true} } 
    }
  )
}";
$query =~ s/\n/ /g;
my $json = sprintf('{"query" : "%s"}',$query);
my $req = HTTP::Request->new("POST", $uri );

$req->header("Authorization" => "Bearer $TOKEN");
$req->header("Content-Type" => "application/json");

$req->content( $json );

my $lwp = LWP::UserAgent->new;

my $result = $lwp->request( $req );

print $result->{"_content"},"\n";
Python
python
#! /usr/local/bin/python3

import requests

url = '$YOUR_LOGSCALE_URL/graphql'
mydata = r'''{"query" : "mutation {
  logAnalyticsBatch ( input: 
    { eventId: \"string\",
      timestamp: 123,
      route: \"string\",
      action: \"string\",
      system: \"string\",
      arguments: [\"string\"],
      features: [ {name: \"string\", value: true} ],
      context: \"string\",
      metrics: {fps: 10},
      userAgent: {browser{info {}, isChrome: true, isChromeHeadless: false,
                          isEdge: false, isFirefox: true, isIE: true, isSafari: true},
                  device{info {},
                         isConsole: true, isDesktop: true, 
                         isMobile: false, isTablet: false }, 
                  engine{info {name: \"string\", version: \"1\"}, isWebkit: false }, 
                  os {info {name: \"string\", version: \"1\"}, 
                      isAndroid: false, isIOS: false, 
                      isLinux: true, isMacOS: true, isWindows: true} } 
    }
  )
}"
}'''

resp = requests.post(url,
                     data = mydata,
                     headers = {
   "Authorization" : "Bearer $TOKEN",
   "Content-Type" : "application/json"
}
)

print(resp.text)
Node.js
javascript
const https = require('https');

const data = JSON.stringify(
    {"query" : "mutation {
  logAnalyticsBatch ( input: 
    { eventId: \"string\",
      timestamp: 123,
      route: \"string\",
      action: \"string\",
      system: \"string\",
      arguments: [\"string\"],
      features: [ {name: \"string\", value: true} ],
      context: \"string\",
      metrics: {fps: 10},
      userAgent: {browser{info {}, isChrome: true, isChromeHeadless: false,
                          isEdge: false, isFirefox: true, isIE: true, isSafari: true},
                  device{info {},
                         isConsole: true, isDesktop: true, 
                         isMobile: false, isTablet: false }, 
                  engine{info {name: \"string\", version: \"1\"}, isWebkit: false }, 
                  os {info {name: \"string\", version: \"1\"}, 
                      isAndroid: false, isIOS: false, 
                      isLinux: true, isMacOS: true, isWindows: true} } 
    }
  )
}"
}
);


const options = {
  hostname: '$YOUR_LOGSCALE_URL/graphql',
  path: '/graphql',
  port: 443,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length,
    Authorization: 'BEARER ' + process.env.TOKEN,
    'User-Agent': 'Node',
  },
};

const req = https.request(options, (res) => {
  let data = '';
  console.log(`statusCode: ${res.statusCode}`);

  res.on('data', (d) => {
    data += d;
  });
  res.on('end', () => {
    console.log(JSON.parse(data).data);
  });
});

req.on('error', (error) => {
  console.error(error);
});

req.write(data);
req.end();
Example Responses
Success (HTTP Response Code 200 OK)
json
{
  "data": {
    "logAnalyticsBatch": true
  }
}

Given Datatypes

For AnalyticsLogWithTimestamp, there are several parameters that may be given in a comma-separated list. Below is a list of them along with a description of each:

Table: AnalyticsLogWithTimestamp

ParameterTypeRequiredDefaultStabilityDescription
Some arguments may be required, as indicated in the Required column. For some fields, this column indicates that a result will always be returned for this column.
Table last updated: Sep 17, 2024
actionstringyes PreviewThe action to take related to the event.
arguments[string]yes PreviewAny arguments passed for the analytics.
contextstringyes PreviewThe context of the analytics.
eventIdstringyes PreviewThe unique identifier of the event.
featurestring  PreviewOur GraphQL pages are currently under development. This description will be added or changed soon.
features[AnalyticsFeature]yes PreviewOur GraphQL pages are currently under development. This description will be added or changed soon. See AnalyticsFeature.
metricsAnalyticsMetricsyes PreviewThe frames per second to use for the analytics metrics. See AnalyticsMetrics.
routestringyes PreviewOur GraphQL pages are currently under development. This description will be added or changed soon.
systemstringyes PreviewOur GraphQL pages are currently under development. This description will be added or changed soon.
timestamplongyes PreviewThe date and time stamp of the event.
userAgentAnalyticsUserAgentyes PreviewThe browser, device type, and other information for the analytics. See AnalyticsUserAgent.