Summary

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

API Stability Preview

Syntax

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

For the input, you'll have to give information for the timestamp, the action, user's browser, and several other parameters. See the Input Parameters section for more.

For the results, you'll receive confirmation if successful.

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

For the input, you'll have to give information for logging (e.g., the timestamp, the action, user's browser, etc.). The table below provides more information on this and links to sub-parameters:

Table: AnalyticsLogWithTimestamp Input Datatype

ParameterTypeRequiredDefaultStabilityDescription
Some input parameters may be required, as indicated in the Required column. For return values, this indicates that you are assured a value if the field is requested for the results.
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.