# Migration to v3.x

This guide helps you migrate your iOS Fraud Prevention integration to version 3.x.

Important
Version 3.x includes breaking changes that will cause runtime errors if not addressed. Review all changes before upgrading.

## What's new

**Breaking changes**:

- `setUserId()` is renamed to `setAuthenticatedUser()`.
- `baseUrl` is now a mandatory parameter in `initialize()`.
- `claimUserId` in `TSActionEventOptions` is deprecated. Use `claimedUserId` instead.


**New features**:

- `claimedUserId` and `claimedUserIdType` parameters in `TSActionEventOptions` for typed user identification.


## Migrate your integration to v3.x

### Step 1: Update SDK dependency

Update your Swift Package Manager dependency to the latest major version:

Before:


```swift
dependencies: [
    .package(url: "https://github.com/TransmitSecurity/accountprotection-ios-sdk.git", .upToNextMajor(from: "2.0.0"))
]
```

After:


```swift
dependencies: [
    .package(url: "https://github.com/TransmitSecurity/accountprotection-ios-sdk.git", .upToNextMajor(from: "3.0.0"))
]
```

### Step 2: Add baseUrl to initialization

If you initialize the SDK with explicit parameters using `initialize()`, `baseUrl` is now a required parameter. The `baseUrl` value must include the `/risk-collect/` path.

Before:


```swift
TSAccountProtection.initialize(clientId: "[CLIENT_ID]")
```

After:


```swift
TSAccountProtection.initialize(baseUrl: "https://api.transmitsecurity.io/risk-collect/", clientId: "[CLIENT_ID]")
```

If you initialize using `initializeSDK()` with a `TransmitSecurity.plist` file, make sure the plist includes a `baseUrl` key.

### Step 3: Rename setUserId to setAuthenticatedUser

The `setUserId()` method has been renamed to `setAuthenticatedUser()`. Update all occurrences in your code.

Before:


```swift
TSAccountProtection.setUserId("[USER_ID]")
```

After:


```swift
TSAccountProtection.setAuthenticatedUser("[USER_ID]")
```

### Step 4: Update triggerAction options

The `claimUserId` parameter in `TSActionEventOptions` is deprecated. Use `claimedUserId` and `claimedUserIdType` instead.

Before:


```swift
let options = TSActionEventOptions(correlationId: "CORRELATION_ID",
                                  claimUserId: "CLAIM_USER_ID",
                                  referenceUserId: "REFERENCE_USER_ID",
                                  transactionData: nil)
```

After:


```swift
let options = TSActionEventOptions(correlationId: "CORRELATION_ID",
                                  claimedUserId: "91e25bea0c...", // hashed identifier
                                  claimedUserIdType: .email,
                                  referenceUserId: "REFERENCE_USER_ID",
                                  transactionData: nil)
```

### Step 5: Test your integration

- Verify all SDK functionality works as expected.
- Check for any runtime errors related to renamed methods.
- Confirm that `triggerAction()` returns action tokens as expected with the new parameter structure.