Understanding analysis results
First of all, let's prepare our next query in order to fetch the Analysis results.
By using the id
returned in the response body, we can retrieve the Analysis
's entry that we've just created. We're also asking the GraphQL API to return us some extra information accessible in this document such as the Analysis
's Status
or the listing of the violations that the crawler could have identified.
As retrieving an entry in GraphQL is associated to a simple query
, the following payload should be used:
Query
query {
analysis(id: "YW5hbHlzaXN8YThiYzk0M2ItNTY3ZS00NzA5LWIwOWItMTI1YmMzNGMxMjUwfDIwMTgtMDktMDI=") {
id
content
status
violation
violations
}
}
Response
{
"data": {
"analysis": {
"id": "YW5hbHlzaXN8YThiYzk0M2ItNTY3ZS00NzA5LWIwOWItMTI1YmMzNGMxMjUwfDIwMTgtMDktMDI=",
"content": "https://examples.adsecure.com/simple",
"status": "DONE",
"violation": false,
"violations": []
}
}
}
The response's body returns a result that mirrors the shape of the requested query. Let's review them one by one:
id
: This field is theAnalysis
's identifier. Unique, it's the one that we got in the response's body of our first query.content
: The content that we asked the AdSecure's crawler to analyse.status
: TheAnalysis
'sStatus
. This field has its value set asDONE
which mean that the analysis was already completed at the time of your query. If you try to get theAnalysis
before its full completion you might see this field set asINITIAL
. In the same way if an error happens, it will be reflected here by usingERROR
as value.violation
: If set totrue
, theviolation
field report that the crawler identified one or more violations. In our example, this field's value isfalse
, meaning that the AdSecure's crawler didn't found any violation on thehttps://examples.adsecure.com/simple
web page.violations
: This field lists the violations found during an analysis. As mentioned previously, no violations were found during the analysis and so this array is empty.
Positive case
Let's now make a new analysis, but this time on a content that we know is going to contain some violations. In this next example, we're going to analyse a web content that is positive for the Landing Page Error detection:
https://examples.adsecure.com/404
We're here going to use the same query as the one used previously but updating the input.content
field with this new content URL.
Query
mutation {
createAnalysis(input: {
content: "https://examples.adsecure.com/404"
}) {
id
}
}
Response
{
"data": {
"createAnalysis": {
"id": "YW5hbHlzaXN8YThiYzI0M2ItNTY3ZS13ZjA5LWIwOWItMTI1YmMzNGMxMzRyfDIwMTgtMDktMDI="
}
}
}
Our new analysis is now created and we can retrieve it by using the same query as in our first example but replacing the previous id
by the one generated for this new Analysis
:
Query
query {
analysis(id: "YW5hbHlzaXN8YThiYzI0M2ItNTY3ZS13ZjA5LWIwOWItMTI1YmMzNGMxMzRyfDIwMTgtMDktMDI=") {
id
content
status
violation
violations
}
}
Response
{
"data": {
"analysis": {
"id": "YW5hbHlzaXN8YThiYzk0M2ItNTY3ZS00NzA5LWIwOWItMTI1YmMzNGMxMjUwfDIwMTgtMDktMDI=",
"content": "https://examples.adsecure.com/404",
"status": "DONE",
"violation": true,
"violations": ["landing-page-error"]
}
}
}
As you can see here, the field violation
is now set to true
meaning that at least one violations was found by the crawler. In order to have more information about it we need to check the field violations
. Here we see that the array is now containing the landing-page-error
value which is the identifier of the Landing Page Error detection.
Having a detection's identifier listed in this violations
array means that the AdSecure crawler found some positive results for the corresponding detection during its analysis.