Hypertune
  • Introduction
  • Getting Started
    • Set up Hypertune
    • Next.js (App Router) quickstart
    • Next.js (Pages Router) quickstart
    • React quickstart
    • Remix quickstart
    • Gatsby quickstart
    • Vue quickstart
    • Nuxt quickstart
    • Node.js quickstart
    • React Native quickstart
    • JavaScript quickstart
    • Python quickstart
    • Rust quickstart
    • Go quickstart
    • Web quickstart
    • GraphQL quickstart
  • Example apps
    • Next.js and Vercel example app
  • Concepts
    • Architecture
    • Project
    • Schema
    • Flag lifecycle
    • Logic
    • Variables
    • Splits
    • A/B tests
    • Staged rollouts
    • Multivariate tests
    • Machine learning loops
    • Events
    • Funnels
    • Hypertune Edge
    • Reduction
    • SDKs
    • GraphQL API
    • Git-style version control
    • App configuration
  • Use Cases
    • Feature flags and A/B testing
    • Landing page optimization
    • In-app content management
    • Pricing plan management
    • Permissions, rules and limits
    • Optimizing magic numbers
    • Backend configuration
    • Product analytics
  • Integrations
    • Vercel Edge Config integration
    • Google Analytics integration
    • Segment integration
    • Webhooks
      • Creating webhooks
      • Handling webhooks
  • SDK Reference
    • Installation
    • Type-safe client generation
    • Initialization
    • Build-time logic snapshot
    • Hard-coded fallbacks
    • Local-only, offline mode
    • Hydrate from your own server
    • Wait for server initialization
    • Provide targeting attributes
    • Local, synchronous evaluation
    • Remote logging
    • Getting flag updates
    • Serverless environments
    • Vercel Edge Config
    • Custom logging
    • Shutting down
Powered by GitBook
On this page
  • Manually flush logs
  • Configuring log flushing
  • Flush interval
  • Logging mode
  1. SDK Reference

Remote logging

PreviousLocal, synchronous evaluationNextGetting flag updates

Last updated 2 months ago

SDKs send logs to in the background. This allows you to:

  • See how often different parts of your flag logic are evaluated, e.g. to see how often different targeting rules are evaluated and passed in realtime

  • Log

  • Log exposures, e.g. for , and

  • See any SDK errors from the Hypertune UI

Manually flush logs

You can manually trigger and wait for logs to be flushed with the flushLogs method:

import { NextFetchEvent, NextRequest } from "next/server";
import getHypertune from "./lib/getHypertune";

export async function middleware(
  req: NextRequest,
  context: NextFetchEvent
): Promise<void> {
  const hypertune = await getHypertune();

  const exampleFlag = hypertune.exampleFlag({ fallback: false });
  console.log("Middleware Example Flag:", exampleFlag);

  context.waitUntil(hypertune.flushLogs());
}

Configuring log flushing

Flush interval

Logging mode

The logging mode determines which SDK log messages, expression evaluations, A/B test exposures, and analytics events are sent to the remote server. You can control this behaviour using the remoteLogging.mode initialization option:

Mode
Behaviour

Normal

All data is sent to the remote server.

Session

SDK log messages, expression evaluations, and A/B test exposures are deduplicated per session, based on the provided context. However, all analytics events are still sent to the remote server.

Off

No data is sent, making this mode ideal for local development or testing environments.

Custom logging endpoint

This is a requirement in like Vercel deployments, Cloudflare Workers, AWS Lambdas, etc, where background SDK tasks like flushing logs aren't guaranteed to execute.

By default, SDKs flush logs to every 2 seconds. You can adjust this interval by setting the remoteLogging.flushIntervalMs option. For example, to flush logs every 10 seconds, set this option to 10_000. Setting the value to null disables automatic log flushing.

By default, SDKs send all log data to Hypertune servers via the https://gcp.fasthorse.workers.dev/logs endpoint. If you're experiencing issues with ad blockers and want to ensure reliable data transmission, you can proxy these requests through your own server. To do this, set the remoteLogging.endpointUrl option to an endpoint in your backend and then forward the requests to the default Hypertune endpoint from there using tools like or a tool like .

If you'd rather store and process Hypertune data within your own system, you can implement this behaviour in your custom remote logging endpoint. To help you do this we've published the OpenAPI contract for the logging endpoint . You can use the contract to better understand the payload format the endpoint uses and to generate types in your language of choice.

Hypertune Edge
analytics events
split
A/B tests
multivariate tests
machine learning loops
serverless and edge environments
Hypertune Edge
Next.js redirects
http-proxy-middleware
here