---
title: Update from older versions of the Swift SDK
slug: feature-experimentation/docs/migrate-from-older-versions-swift
docTags: 
createdAt: 2026-08-05T20:39:54.000Z
---

This section provides code examples for how You should leveraging the new [Decision](docId\:m4P0yMbtf7fA3weCgyLGn) and [Event Tracking](docId\:I9jAN0zACRv-CVA3e-jS2) APIs. All existing [Full Stack (Legacy)](docId:6_ik6SSz-WyJLWuCQw7BT) methods and implementation are still supported. See [Optimizely Feature Experimentation - application & migration](docId\:bykQnE4aGRkC5WXhU6Yi5) documentation for the latest updates.

You should 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:

```swift
// -------------------------------
// Prereq for new methods: create a user
// ------------------------------
let attributes: [String: Any] = ["is_logged_in": true]
let user = optimizely.createUserContext(userId: "user_123", attributes: attributes)

// -------------------------------
// Is Feature Enabled 
// ------------------------------
// old method
let enabled = optimizely.isFeatureEnabled(featureKey: "flag_1", userId: "user_123", attributes: attributes)

// new method
let decision = user.decide(key: "flag_1")
let enabled = decision.enabled

// -------------------------------
// Activate & Get Variation 
// ------------------------------
// old method
let variationKey = try? optimizely.activate(experimentKey:"experiment_1",
                                            userId: "user_123",
                                            attributes: attributes)
// new method
let variationKey = decision.variationKey



// -------------------------------
// Get All Feature Variables 
// ------------------------------
// old method
let allVarValues = try? optimizelyClient.getAllFeatureVariables(featureKey: "flag_1",
                                                            userId: "user_123",) 
// new method
let allVarValues = decision.variables


// -------------------------------
// Get Enabled Features 
// ------------------------------
// old method
let enabledFlags = optimizely.getEnabledFeatures(userId: "user_123")

// new method
let decisions = user.decideAll(options: [.enabledFlagsOnly])
let enabledFlags = decisions.keys


// -------------------------------
// Track 
// ------------------------------
// old method
try? optimizely.track(eventKey: "my_purchase_event_key", 
											userId: "user_123", 
                      attributes: attributes, 
                      eventTags: ["purchase_count": 2])

// new method
try? user.trackEvent(eventKey: 'my_purchase_event_key', 
                     eventTags: ["purchase_count": 2])
```
