Skip to content
Feralin

Developers

Go: quickstart

Install and first-use steps for sending events to Feralin with Go. Code samples come from the SDK's own README and statuses from the capability record.

Install

github.com/feralincom/sdk/sdks/go 0.1.0 is published on Go modules; install it with your package manager using the command below.

go get github.com/feralincom/sdk/sdks/go@v0.1.0
// go.mod
require github.com/feralincom/sdk/sdks/go v0.1.0
replace github.com/feralincom/sdk/sdks/go => ../../sdks/go

First use

import feralin "github.com/feralincom/sdk/sdks/go"

client, err := feralin.NewClient("pk_live_…", "https://collect.example.com",
    feralin.WithConsent(feralin.Consent{Analytics: true}), // consent-first: varsayılan analytics=false
    feralin.WithFlushInterval(2*time.Second),              // 0 → arka plan gönderici kapalı
    feralin.WithBatchSize(100),                            // ≤ 500
    feralin.WithQueueLimit(1000),                          // aşılırsa en eski olay atılır
    feralin.WithHTTPClient(&http.Client{Timeout: 10 * time.Second}),
    feralin.WithLogger(slog.Default()),
)
if err != nil { /* ErrSecretKey, ErrInvalidProjectKey, ErrInvalidCollectURL */ }
defer client.Close() // kalan olayları en fazla 5 sn içinde gönderir

ev, err := client.Track(ctx, feralin.Event{
    Name:       "order_completed",                  // snake_case, ≤100
    UserID:     "user_42",                          // müşteri uygulamasının kimliği; PII değil
    Properties: map[string]any{"order_id": "ord_1", "amount": 249.9}, // ≤100 anahtar, ^[a-zA-Z][a-zA-Z0-9_]{0,63}$
    Context:    &feralin.Context{Locale: "tr-TR", Timezone: "Europe/Istanbul"},
})
// consent.analytics=false → ev == nil && err == nil (olay üretilmez; Web SDK ile tutarlı)
// doğrulama hatası     → errors.Is(err, feralin.ErrInvalidEventName | ErrInvalidPropertyKey | ErrTooManyProperties | ErrInvalidIdentifier)

res, err := client.Flush(ctx)
// 202              → err == nil; res.Accepted/Rejected/BatchID
// 4xx (429 hariç)  → errors.Is(err, feralin.ErrRejected); olaylar atıldı
// 5xx / 429 / ağ   → errors.Is(err, feralin.ErrTemporary); olaylar kuyrukta, backoff 1 sn → 30 sn (Retry-After'a uyar)
client.SetGlobalProperties(map[string]any{"app_release": "2.4.0"}) // adı fr_ ile başlamayan her olaya eklenir; nil anahtarı siler
who := feralin.Identity{UserID: "user_42"}
client.SetUserProperties(ctx, map[string]any{"plan": "pro"}, who)   // fr_user_properties; geçerli özellik yoksa (nil, nil)
client.Group(ctx, "acme-team", map[string]any{"plan": "team"}, who) // fr_group; geçersiz group_id → (nil, nil)
client.ClearGlobalProperties()
client, _ := feralin.NewClient(key, url, feralin.WithAppVersion("2.4.0"), feralin.WithErrorSampleRate(1))
if err := charge(ctx); err != nil {
    client.CaptureError(ctx, err, feralin.ErrorOptions{Identity: who}) // varsayılan origin "handled"
}
defer func() {
    if r := recover(); r != nil {
        client.CaptureError(ctx, fmt.Errorf("%v", r), feralin.ErrorOptions{Origin: feralin.ErrorOriginUncaught, Fatal: true})
        panic(r)
    }
}()

Code samples are taken as they are from sdks/go/README.md; comments inside may be in Turkish. You create the project key in the dashboard.

Capabilities

Go capability status
CapabilityStatus
Event sendingSupported
Batch sendingPartial
Consent handlingSupported
IdentitySupported
AttributionNot applicable
Deep linksNot applicable
RevenuePartial
Error capturePartial
Session replayNot applicable
TracingPlanned

Verification chain

Go verification chain
LinkStatus
SourcePassed
BuildPassed
TestPassed
Registry publicationPassed
Clean installPassed
Event receiptPassed
DocumentationPassed
Super Admin proofNot started

Passed means local evidence: source, build and tests ran. Registry publication and Super Admin proof are separate links; the SDK is not called ready until each has passed.