Summary

The logAnalyticsBatch() mutation records multiple user interface actions in LogScale in a single API call. Use this mutation to capture telemetry for several UI interactions — such as feature usage, navigation events, or user actions — without issuing a separate request for each event. For a single event, use logAnalytics() instead.

Syntax

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

The required input argument accepts a non-null list of AnalyticsLogWithTimestamp objects. Each object represents one recorded UI event, identified by a unique eventId and a Unix epoch millisecond timestamp, along with event data including action name, route, system context, and browser information. The full set of fields is described in the Input Parameters section following.

The mutation returns a non-null Boolean! confirming whether all events in the batch were recorded successfully.

Example

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',
  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
  }
}

Input Parameters

The input argument accepts a list of AnalyticsLogWithTimestamp objects. Each object represents one recorded UI event, with fields for the event identifier, timestamp, action, route, system context, and browser information. The following table describes the available fields.

Table: AnalyticsLogWithTimestamp Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
actionStringyes    
argumentsStringyes    
contextStringyes    
eventIdStringyes    
featureString     
featuresAnalyticsFeatureyes    
metricsAnalyticsMetricsyes    
routeStringyes    
systemStringyes    
timestampLongyes    
userAgentAnalyticsUserAgentyes   Â