Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1008 B
Raw Blame
import ExpoModulesCore
import WidgetKit

// The suite, keys and widget kind must match targets/HedgehogWidget and modules/hedgehog-widget/README.md.
// app.config.ts names the App Group "group." plus the bundle id, so each app variant (dev, preview, store) has its own.
private let suiteName = "group.\(Bundle.main.bundleIdentifier ?? "com.posthog.code.mobile")"
private let choreographyKey = "choreography"
private let widgetKind = "HedgehogWidget"

public class HedgehogWidgetModule: Module {
    public func definition() -> ModuleDefinition {
        Name("HedgehogWidget")

        Function("setChoreography") { (json: String) in
            UserDefaults(suiteName: suiteName)?.set(json, forKey: choreographyKey)
            WidgetCenter.shared.reloadTimelines(ofKind: widgetKind)
        }

        Function("clearChoreography") {
            UserDefaults(suiteName: suiteName)?.removeObject(forKey: choreographyKey)
            WidgetCenter.shared.reloadTimelines(ofKind: widgetKind)
        }
    }
}