Reporting

Advanced Reporting Capabilities

Stateset One offers a comprehensive set of advanced reporting capabilities to help users analyze and visualize their data effectively. Some of the key features include:

Customizable Reports

Users can create customized reports tailored to their specific needs. The platform provides a user-friendly interface to define report parameters, select relevant data sources, apply filters, and specify the desired output format.

Data Visualization

Stateset One includes & integrates a range of data visualization tools to transform raw data into meaningful visual representations. Users can create charts, graphs, dashboards, and other visual elements to gain insights into their data quickly. The platform supports various visualization types, such as bar charts, pie charts, line graphs, and heatmaps.

Drill-Down Capabilities

With drill-down capabilities, users can dig deeper into their data to uncover more granular details. By interacting with visualizations or reports, users can access underlying data layers, enabling a more comprehensive analysis of trends, patterns, and outliers.

Filtering and Segmentation

Stateset One allows users to apply filters and segment their data for focused analysis. Users can define criteria based on specific dimensions or variables, such as time periods, geographical locations, customer segments, or product categories. This feature enables users to examine data subsets and compare performance across different segments.

Scheduled Exports

Stateset One provides scheduled export functionality, allowing users to automate the generation and delivery of reports at specified intervals. Key features of this capability include:

Flexible Export Formats

Users can choose from a variety of export formats for their reports, such as PDF, Excel, CSV, or HTML. This flexibility ensures compatibility with different systems and caters to the diverse needs of stakeholders who may require specific file formats.

Example Code for Exporting Data

  
  const returnFields = [
    "id",
    "status",
    "order_id",
    "rma",
    "tracking_number",
    "description",
    "customerEmail",
    "zendesk_number",
    "action_needed",
    "reason_category",
    "issue",
    "order_date",
    "shipped_date",
    "requested_date",
    "serial_number",
    "scanned_serial_number",
    "condition",
    "amount",
    "customer_id",
    "tax_refunded",
    "total_refunded",
    "created_date",
    "flat_rate_shipping",
    "warehouse_received_date",
    "warehouse_condition_date",
    "country"
  ];

  const opts = { returnFields };

  // Current Time
  var time = Math.floor(Date.now() / 1000);

  // The ID of your GCS bucket
  const bucketName = 'returns';

  // The path to your file to upload
  const filePath = `../stateset-app/static/data/returns/returns-data-${time}.csv`;

  // The new ID for your GCS file
  const destFileName = `returns-data-${time}.csv`;

  // Upload to Google Cloud Function
  async function uploadFile() {
  
    // Uploads a local file to the bucket
    await storage.bucket(bucketName).upload(filePath, {
      destination: destFileName,
    });

    return res.status(200).json({ status: `${filename}-${time} uploaded to ${bucketName}.` })

  }

  // Get the Return Data
  const return_records = await graphQLClient.request(GET_MY_RETURNS);

  // JSON 2 CSV Parser
  const json2csvParser = new Parser({ returnFields, quote: '', delimiter: ',' });

  // Stateset CSV
  const statesetCSV = json2csvParser.parse(return_records.returns);

  // Parse the Response convert to CSV
  let statesetWriter = createWriteStream(`../stateset-app/static/data/returns/returns-data-${time}.csv`)
  statesetWriter.write(statesetCSV);

  // Upload File
  uploadFile().catch(console.error);


Example for Sending Email with Attachment


import base64
import io
import os
from google.cloud import storage
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import (
    Mail, Attachment, FileContent, FileName,
    FileType, To, Disposition)

sg = SendGridAPIClient(process.env.SENDGRID_API)


def send_mail(data, context):
    message = Mail(
        from_email='',
        to_emails= [To('email@customer.com'), To('partner@customer.com'), To('manager@customer.com')],
        subject='Returns Report',
        html_content='This is the returns report autogenerated via Stateset.'
    )

    storage_client = storage.Client(process.env.STORAGE_CLIENT)
    bucket = storage_client.get_bucket(process.env.STORAGE_BUCKET)
    blob = bucket.blob(data['name'])
    data = blob.download_as_bytes()
    bytes = io.BytesIO(data)
    bytes.seek(0)
    data = bytes.read()
    encoded = base64.b64encode(data)
    csv_file = str(encoded,'utf-8')

    attachment = Attachment()
    attachment.file_content = FileContent(csv_file)
    attachment.file_type = FileType('text/csv')
    attachment.file_name = FileName('returns-export.csv')
    attachment.disposition = Disposition('attachment')
    message.attachment = attachment

    response = sg.send(message)
    print(response.status_code, response.body, response.headers)