You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: telemetry.go
    path of file: ./repos/octosql/telemetry
    
    the code of the file until where you have to start completion: package telemetry

import (
	"bytes"
	"context"
	"crypto/rand"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
	"path/filepath"
	"runtime"
	"time"

	"github.com/cube2222/octosql/config"
	"github.com/oklog/ulid/v2"
)

var telemetryDir = func() string {
	return filepath.Join(config.OctosqlCacheDir, ".octosql/telemetry")
}()

type event struct {
	DeviceID     string      `json:"device_id"`
	Type         string      `json:"type"`
	Version      string      `json:"version"`
	OS           string      `json:"os"`
	Architecture string      `json:"architecture"`
	NumCPU       int         `json:"num_cpu"`
	Time         time.Time   `json:"time"`
	Data         interface{} `json:"data"`
}

func SendTelemetry(ctx context.Context, version, eventType string, data interface{}) {
	if err := sendTelemetry(ctx, version, eventType, data); err != nil {
		log.Printf("couldn't send telemetry: %s", err)
	}
}

func sendTelemetry(ctx context.Context, version, eventType string, data interface{}) error {
	if o
    
func sendBatch(ctx context.Context) error {
	files, err := filepath.Glob(filepath.Join(telemetryDir, "pending/*.json"))
	if err != nil {
		return err
	}

	if len(files) == 0 {
		return nil
	}

	minimumBatchCount := 10
	if _, err := os.Stat(filepath.Join(telemetryDir, "first_message_sent")); os.IsNotExist(err) {
		minimumBatchCount = 1
	}

	if len(files)%minimumBatchCount != 0 {
		return nil
	}

	var payload []json.RawMessage
	for i := range files {
		data, err := os.ReadFile(files[i])
		if err != nil {
			return err
		}
		payload = append(payload, data)
	}
	data, err := json.Marshal(payload)
	if err != nil {
		return err
	}

	if _, err := http.Post("https://telemetry.octosql.dev/telemetry", "encoding/json", bytes.NewReader(data)); err != nil {
		return err
	}

	if err := os.RemoveAll(filepath.Join(telemetryDir, "recent")); err != nil {
		return err
	}

	if err := os.Rename(filepath.Join(telemetryDir, "pending"), filepath.Join(telemetryDir, "recent")); err != nil {
		return err
	}

	if minimumBatchCount == 1 {
		os.WriteFile(filepath.Join(telemetryDir, "first_message_sent"), []byte{}, 0644)
	}

	return nil
}