Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

The availability of features may depend on your plan type. Contact your Customer Success Manager if you have any questions.

Dev guideRecipesAPI ReferenceChangelog
Dev guideAPI ReferenceRecipesChangelogUser GuideGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev guide

Update from older versions of the Go SDK

Describes how to update from older versions of the Optimizely Full Stack (Legacy) Go SDK to Optimizely Feature Experimentation.

This section provides code examples for how Optimizely recommends leveraging the new Decision and Event Tracking APIs. All existing Full Stack (Legacy) methods and implementation are still supported. See Optimizely Feature Experimentation - application & migration documentation for the latest updates.

Optimizely recommends adopting the new Decide, Decide All, and Track Event methods as a more flexible and easier-to-use replacement where you currently use isFeatureEnabled, getFeatureVariable, getAllFeatures, or Track calls within your implementation.

The following are examples of how to migrate the Full Stack (Legacy) methods to Feature Experimentation methods:

// -------------------------------
// Prereq for new methods: create a user
// ------------------------------
user := optlyClient.CreateUserContext("user_123", map[string]interface{}{"is_logged_in": true})

// -------------------------------
// Is Feature Enabled
// ------------------------------
// old method
enabled, _ := optlyClient.IsFeatureEnabled("flag_1", entities.UserContext{ID: "user_123", Attributes: map[string]interface{}{"is_logged_in": true}})

// new method

decision := user.Decide("flag_1", []decide.OptimizelyDecideOptions{})
enabled = decision.Enabled

// -------------------------------
// Activate & Get Variation
// ------------------------------
// old method
variationKey, _ := optlyClient.Activate("experiment_1", entities.UserContext{ID: "user_123"})
// new method
variationKey = decision.VariationKey



// -------------------------------
// Get All Feature Variables
// ------------------------------
// old method
allVarValues, _ := optlyClient.GetAllFeatureVariables("flag_1", entities.UserContext{ID: "user_123"}) 
// new method
allVarValues = decision.Variables


// -------------------------------
// Get Enabled Features
// ------------------------------
// old method
enabledFlags, _ := optlyClient.GetEnabledFeatures(entities.UserContext{ID: "user_123"})

// new method
decisions := user.DecideAll([]decide.OptimizelyDecideOptions{decide.EnabledFlagsOnly})
enabledFlags = []string{}
for k := range decisions {
  enabledFlags = append(enabledFlags, k)
}


// -------------------------------
// Track
// ------------------------------
// old method
optlyClient.Track("my_purchase_event_key", entities.UserContext{ID: "user_123", Attributes: attributes}, map[string]interface{}{"purchase_count": 2})

// new method
user.TrackEvent("my_purchase_event_key", map[string]interface{}{"purchase_count": 2})

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy