Skip to content

[FME-4222] Events - New Events and InternalEvents with metadata #683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
15a175d
New Events and InternalEvents with metadata
MartinCardozo-SDK Jun 9, 2025
52f912b
ActionTask updated
MartinCardozo-SDK Jun 9, 2025
d58c5d6
Cleanup
MartinCardozo-SDK Jun 9, 2025
4d77b9f
Test added
MartinCardozo-SDK Jun 9, 2025
568d378
Add new channels
MartinCardozo-SDK Jun 10, 2025
2a4c597
Initial commit
MartinCardozo-SDK Jun 10, 2025
d865743
Action handlers unified
MartinCardozo-SDK Jun 10, 2025
2df6b41
Executing with metadata
MartinCardozo-SDK Jun 10, 2025
388ad8f
Event managers adapted to metadata events
MartinCardozo-SDK Jun 10, 2025
d030345
Tests updated. Minimum classes required updated too
MartinCardozo-SDK Jun 10, 2025
0a078f0
Merge branch 'FME-4233-events-managers' into FME-4224-events-defaultC…
MartinCardozo-SDK Jun 10, 2025
e6964ec
Clients updated
MartinCardozo-SDK Jun 10, 2025
a767914
Update Split/Api/FailHelpers.swift
MartinCardozo-SDK Jun 11, 2025
343d473
Merge pull request #685 from splitio/FME-4224-events-defaultClient
MartinCardozo-SDK Jun 11, 2025
0a291cd
Merge pull request #686 from splitio/FME-4233-events-managers
MartinCardozo-SDK Jun 11, 2025
e73495a
Removed unnecessary method
MartinCardozo-SDK Jun 11, 2025
4db5ec7
Removed unnecessary method
MartinCardozo-SDK Jun 11, 2025
493f10a
Merge pull request #684 from splitio/FME-4223-events-actionTask
MartinCardozo-SDK Jun 11, 2025
3455299
Equatables added
MartinCardozo-SDK Jun 12, 2025
e5bd927
Removed unnecessary comparations and methods
MartinCardozo-SDK Jun 12, 2025
cfa37ef
Cleanup
MartinCardozo-SDK Jun 12, 2025
f0bbdb0
Cleanup
MartinCardozo-SDK Jun 12, 2025
c67bcd6
Added logic to show updated flags. Tests pending.
MartinCardozo-SDK Jun 12, 2025
932ac8a
Tests updated
MartinCardozo-SDK Jun 12, 2025
06b39fe
Cleanup
MartinCardozo-SDK Jun 12, 2025
d1a3d93
Initial commit
MartinCardozo-SDK Jun 12, 2025
582192d
Marks
MartinCardozo-SDK Jun 15, 2025
4f8acea
Merge branch 'FME-4228-events-updatedFlag' into FME-4230-events-updat…
MartinCardozo-SDK Jun 15, 2025
f181aeb
Changing branch
MartinCardozo-SDK Jun 16, 2025
2e93d05
Initial commit
MartinCardozo-SDK Jun 17, 2025
b8c44e8
Merge pull request #691 from splitio/FME-4232-events-cleanup
MartinCardozo-SDK Jun 17, 2025
f600d62
Entities made public
MartinCardozo-SDK Jun 17, 2025
d432609
Entities made public
MartinCardozo-SDK Jun 17, 2025
fd76335
Merge branch 'FME-4222-events-withMetadata' into FME-4230-events-upda…
MartinCardozo-SDK Jun 17, 2025
8319054
Properties made public
MartinCardozo-SDK Jun 17, 2025
535196c
Merge branch 'FME-4222-events-withMetadata' into FME-4230-events-upda…
MartinCardozo-SDK Jun 17, 2025
cddd930
Initial Commit
MartinCardozo-SDK Jun 23, 2025
50ceecd
Tests adapted
MartinCardozo-SDK Jun 23, 2025
a21d9ec
Simplified logic of notifications
MartinCardozo-SDK Jun 23, 2025
5cd8a48
Removed methods
MartinCardozo-SDK Jun 23, 2025
ee85972
Initial commit
MartinCardozo-SDK Jun 23, 2025
b9ff6cb
Update Split/Network/Streaming/SyncUpdateWorker.swift
MartinCardozo-SDK Jun 24, 2025
b1c564b
Merge branch 'FME-4229-events-killedFlag' into FME-4230-events-update…
MartinCardozo-SDK Jun 25, 2025
f4b0fb5
New metadata structure
MartinCardozo-SDK Jun 25, 2025
172e28e
Merge pull request #694 from splitio/FME-4222-events-metadataFix
MartinCardozo-SDK Jun 25, 2025
956008d
Merge branch 'FME-4222-events-withMetadata' into withMetadata2
MartinCardozo-SDK Jun 25, 2025
712839a
Adapted to new data type
MartinCardozo-SDK Jun 25, 2025
7d93204
Adapted to the new type structure
MartinCardozo-SDK Jun 25, 2025
0b9851b
Updated to new data structure
MartinCardozo-SDK Jun 25, 2025
cc83434
Initial commit
MartinCardozo-SDK Jun 25, 2025
e41a5ca
Tests and logic updated
MartinCardozo-SDK Jun 25, 2025
b69b901
Code reviews corrections
MartinCardozo-SDK Jun 25, 2025
bc56f40
Update ChangesChecker.swift
MartinCardozo-SDK Jun 25, 2025
11a5fdb
Update ChangesChecker.swift
MartinCardozo-SDK Jun 25, 2025
d7d811c
Code review corrections
MartinCardozo-SDK Jun 25, 2025
c37697c
Method extracted
MartinCardozo-SDK Jun 25, 2025
519f4d0
Changing branch
MartinCardozo-SDK Jun 26, 2025
20b45b4
Logic simplified
MartinCardozo-SDK Jun 26, 2025
b657a92
Logic simplified
MartinCardozo-SDK Jun 26, 2025
3cacbfb
Merge branch 'withMetadata2' into FME-4229-events-killedFlag
MartinCardozo-SDK Jun 26, 2025
745e02b
Merging
MartinCardozo-SDK Jun 26, 2025
7e9295a
New notificator
MartinCardozo-SDK Jun 26, 2025
430bdb9
Simplified logic
MartinCardozo-SDK Jun 26, 2025
6179805
E2E test added
MartinCardozo-SDK Jun 26, 2025
d3e4c7f
Test improved
MartinCardozo-SDK Jun 26, 2025
39353f0
Adding tests
MartinCardozo-SDK Jun 26, 2025
aa8c649
Merging
MartinCardozo-SDK Jun 26, 2025
3175ee2
Merge pull request #692 from splitio/withMetadata2
MartinCardozo-SDK Jun 27, 2025
7e8bbb8
Streaming working
MartinCardozo-SDK Jun 28, 2025
cdfc70e
Merged
MartinCardozo-SDK Jun 28, 2025
2a39839
Tests passing
MartinCardozo-SDK Jun 30, 2025
88d03a8
Change
MartinCardozo-SDK Jun 30, 2025
4c7942e
Removed unused test
MartinCardozo-SDK Jun 30, 2025
06ac5a2
Test fixed
MartinCardozo-SDK Jun 30, 2025
02bc880
Merging
MartinCardozo-SDK Jun 30, 2025
8fd7fef
Changing
MartinCardozo-SDK Jun 30, 2025
e1f7a32
Changing
MartinCardozo-SDK Jun 30, 2025
d1de0fc
Removed file
MartinCardozo-SDK Jun 30, 2025
74f545b
Merged branch
MartinCardozo-SDK Jun 30, 2025
bb4c77d
Merge pull request #693 from splitio/FME-4229-events-killedFlag
MartinCardozo-SDK Jun 30, 2025
6968ebe
Test passing
MartinCardozo-SDK Jun 30, 2025
b2a3985
Added test for built metadata passed to the EventsManager
MartinCardozo-SDK Jun 30, 2025
4a46025
Added test to check correct sending of metadata by key
MartinCardozo-SDK Jun 30, 2025
16c4b23
Merge branch 'FME-4230-events-updatedSegment' into FME-4220-events-RBS
MartinCardozo-SDK Jun 30, 2025
6a1676f
Merge pull request #689 from splitio/FME-4230-events-updatedSegment
MartinCardozo-SDK Jun 30, 2025
191abca
Metadata tested
MartinCardozo-SDK Jul 2, 2025
99cc947
Merge branch 'FME-4220-events-RBS' of github.com:splitio/ios-client i…
MartinCardozo-SDK Jul 2, 2025
1dea4df
Merge pull request #695 from splitio/FME-4220-events-RBS
MartinCardozo-SDK Jul 2, 2025
8cf43be
Merging conflict
MartinCardozo-SDK Jul 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 26 additions & 24 deletions Split/Api/DefaultSplitClient.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
//
// DefaultSplitClient.swift
// Split
//
// Created by Brian Sztamfater on 20/9/17.
// Modified by Natalia Stele on 11/10/17.
//
//

import Foundation

typealias DestroyHandler = () -> Void

public final class DefaultSplitClient: NSObject, SplitClient, TelemetrySplitClient {

Check warning on line 8 in Split/Api/DefaultSplitClient.swift

View workflow job for this annotation

GitHub Actions / test (SplitiOSIntegration) / test

parameter of 'on(event:executeWithMetadata:)' has different optionality than expected by protocol 'SplitClient'

Check warning on line 8 in Split/Api/DefaultSplitClient.swift

View workflow job for this annotation

GitHub Actions / test (SplitiOSIntegration) / test

parameter of 'on(event:executeWithMetadata:)' has different optionality than expected by protocol 'SplitClient'

Check warning on line 8 in Split/Api/DefaultSplitClient.swift

View workflow job for this annotation

GitHub Actions / test (SplitiOSIntegration) / test

parameter of 'on(event:executeWithMetadata:)' has different optionality than expected by protocol 'SplitClient'

Check warning on line 8 in Split/Api/DefaultSplitClient.swift

View workflow job for this annotation

GitHub Actions / test (SplitiOSIntegration) / test

parameter of 'on(event:executeWithMetadata:)' has different optionality than expected by protocol 'SplitClient'

Check warning on line 8 in Split/Api/DefaultSplitClient.swift

View workflow job for this annotation

GitHub Actions / test (SplitStreamingUT) / test

parameter of 'on(event:executeWithMetadata:)' has different optionality than expected by protocol 'SplitClient'

Check warning on line 8 in Split/Api/DefaultSplitClient.swift

View workflow job for this annotation

GitHub Actions / test (SplitStreamingUT) / test

parameter of 'on(event:executeWithMetadata:)' has different optionality than expected by protocol 'SplitClient'

Check warning on line 8 in Split/Api/DefaultSplitClient.swift

View workflow job for this annotation

GitHub Actions / test (SplitStreamingUT) / test

parameter of 'on(event:executeWithMetadata:)' has different optionality than expected by protocol 'SplitClient'

Check warning on line 8 in Split/Api/DefaultSplitClient.swift

View workflow job for this annotation

GitHub Actions / test (SplitStreamingUT) / test

parameter of 'on(event:executeWithMetadata:)' has different optionality than expected by protocol 'SplitClient'

Check warning on line 8 in Split/Api/DefaultSplitClient.swift

View workflow job for this annotation

GitHub Actions / test (SplitiOSStreaming_2) / test

parameter of 'on(event:executeWithMetadata:)' has different optionality than expected by protocol 'SplitClient'

Check warning on line 8 in Split/Api/DefaultSplitClient.swift

View workflow job for this annotation

GitHub Actions / test (SplitiOSStreaming_2) / test

parameter of 'on(event:executeWithMetadata:)' has different optionality than expected by protocol 'SplitClient'

Check warning on line 8 in Split/Api/DefaultSplitClient.swift

View workflow job for this annotation

GitHub Actions / test (SplitiOSStreaming_2) / test

parameter of 'on(event:executeWithMetadata:)' has different optionality than expected by protocol 'SplitClient'

Check warning on line 8 in Split/Api/DefaultSplitClient.swift

View workflow job for this annotation

GitHub Actions / test (SplitiOSStreaming_2) / test

parameter of 'on(event:executeWithMetadata:)' has different optionality than expected by protocol 'SplitClient'

private var storageContainer: SplitStorageContainer
private var key: Key
Expand Down Expand Up @@ -55,7 +49,7 @@
}
}

// MARK: Events
// MARK: Customers Listeners
extension DefaultSplitClient {

public func on(event: SplitEvent, execute action: @escaping SplitAction) {
Expand Down Expand Up @@ -89,14 +83,23 @@
on(event: event, executeTask: task)
}

private func on(event: SplitEvent, executeTask task: SplitEventTask) {
if event != .sdkReadyFromCache,
eventsManager.eventAlreadyTriggered(event: event) {
Logger.w("A handler was added for \(event.toString()) on the SDK, " +
"which has already fired and won’t be emitted again. The callback won’t be executed.")
private func onWithMetadata(event: SplitEventWithMetadata, runInBackground: Bool, queue: DispatchQueue?, execute actionWithMetadata: @escaping SplitActionWithMetadata) {
guard let factory = clientManager?.splitFactory else { return }
let task = SplitEventActionTask(action: actionWithMetadata, event: event.type, runInBackground: runInBackground, factory: factory, queue: queue)
on(event: event.type, executeTask: task)
}

public func on(event: SplitEvent, executeWithMetadata action: SplitActionWithMetadata?) {
guard let action = action else { return }
onWithMetadata(event: SplitEventWithMetadata(type: event, metadata: nil), runInBackground: true, queue: nil, execute: action)
}

private func on(event: SplitEvent, executeTask task: SplitEventActionTask) {
if event != .sdkReadyFromCache, eventsManager.eventAlreadyTriggered(event: event) {
Logger.w("A handler was added for \(event.toString()) on the SDK, which has already fired and won’t be emitted again. The callback won’t be executed.")
return
}
eventsManager.register(event: event, task: task)
eventsManager.register(event: SplitEventWithMetadata(type: event, metadata: nil), task: task)
}
}

Expand Down Expand Up @@ -164,7 +167,7 @@
}
}

// MARK: Track Events
// MARK: Tracking
extension DefaultSplitClient {

public func track(trafficType: String, eventType: String) -> Bool {
Expand Down Expand Up @@ -214,7 +217,7 @@
}
}

// MARK: Persistent attributes feature
// MARK: Persistence
extension DefaultSplitClient {

public func setAttribute(name: String, value: Any) -> Bool {
Expand Down Expand Up @@ -256,8 +259,7 @@
}

private func isValidAttribute(_ value: Any) -> Bool {
return anyValueValidator.isPrimitiveValue(value: value) ||
anyValueValidator.isList(value: value)
return anyValueValidator.isPrimitiveValue(value: value) || anyValueValidator.isList(value: value)
}

private func logInvalidAttribute(name: String) {
Expand All @@ -266,31 +268,31 @@
}

private func attributesStorage() -> AttributesStorage {
return storageContainer.attributesStorage
storageContainer.attributesStorage
}
}

// MARK: By Sets evaluation
// MARK: By Flagsets
extension DefaultSplitClient {
public func getTreatmentsByFlagSet(_ flagSet: String, attributes: [String: Any]?) -> [String: String] {
return treatmentManager.getTreatmentsByFlagSet(flagSet: flagSet, attributes: attributes, evaluationOptions: nil)
treatmentManager.getTreatmentsByFlagSet(flagSet: flagSet, attributes: attributes, evaluationOptions: nil)
}

public func getTreatmentsByFlagSets(_ flagSets: [String], attributes: [String: Any]?) -> [String: String] {
return treatmentManager.getTreatmentsByFlagSets(flagSets: flagSets, attributes: attributes, evaluationOptions: nil)
treatmentManager.getTreatmentsByFlagSets(flagSets: flagSets, attributes: attributes, evaluationOptions: nil)
}

public func getTreatmentsWithConfigByFlagSet(_ flagSet: String, attributes: [String: Any]?) -> [String: SplitResult] {
return treatmentManager.getTreatmentsWithConfigByFlagSet(flagSet: flagSet, attributes: attributes, evaluationOptions: nil)
treatmentManager.getTreatmentsWithConfigByFlagSet(flagSet: flagSet, attributes: attributes, evaluationOptions: nil)
}

public func getTreatmentsWithConfigByFlagSets(_ flagSets: [String],
attributes: [String: Any]?) -> [String: SplitResult] {
return treatmentManager.getTreatmentsWithConfigByFlagSets(flagSets: flagSets, attributes: attributes, evaluationOptions: nil)
treatmentManager.getTreatmentsWithConfigByFlagSets(flagSets: flagSets, attributes: attributes, evaluationOptions: nil)
}
}

// MARK: Flush / Destroy
// MARK: Lifecycle
extension DefaultSplitClient {

private func syncFlush() {
Expand Down
52 changes: 21 additions & 31 deletions Split/Api/FailHelpers.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
//
// FailHelpers.swift
// Split
//
// Created by Javier Avrudsky on 24-Apr-2022.
// Copyright © 2022 Split. All rights reserved.
//

import Foundation

Expand Down Expand Up @@ -57,52 +52,50 @@ class FailedClient: SplitClient {
func on(event: SplitEvent, execute action: @escaping SplitAction) {
}

func on(event: SplitEvent, runInBackground: Bool,
execute action: @escaping SplitAction) {
}
func on(event: SplitEvent, runInBackground: Bool, execute action: @escaping SplitAction) {}

func on(event: SplitEvent,
queue: DispatchQueue, execute action: @escaping SplitAction) {
}
func on(event: SplitEvent, queue: DispatchQueue, execute action: @escaping SplitAction) {}

func on(event: SplitEvent, executeWithMetadata: @escaping SplitActionWithMetadata) {}

func track(trafficType: String, eventType: String) -> Bool {
return false
false
}

func track(trafficType: String, eventType: String, value: Double) -> Bool {
return false
false
}

func track(eventType: String) -> Bool {
return false
false
}

func track(eventType: String, value: Double) -> Bool {
return false
false
}

func setAttribute(name: String, value: Any) -> Bool {
return false
false
}

func getAttribute(name: String) -> Any? {
return false
false
}

func setAttributes(_ values: [String: Any]) -> Bool {
return false
false
}

func getAttributes() -> [String: Any]? {
return [:]
}

func removeAttribute(name: String) -> Bool {
return false
false
}

func clearAttributes() -> Bool {
return false
false
}

func getTreatmentsByFlagSet(_ flagSet: String, attributes: [String: Any]?) -> [String: String] {
Expand Down Expand Up @@ -137,33 +130,30 @@ class FailedClient: SplitClient {
return [:]
}

func setUserConsent(enabled: Bool) {
}
func setUserConsent(enabled: Bool) {}

func flush() {
}
func flush() {}

func destroy() {
}
func destroy() {}

func destroy(completion: (() -> Void)?) {
completion?()
}

func track(trafficType: String, eventType: String, properties: [String: Any]?) -> Bool {
return false
false
}

func track(trafficType: String, eventType: String, value: Double, properties: [String: Any]?) -> Bool {
return false
false
}

func track(eventType: String, properties: [String: Any]?) -> Bool {
return false
false
}

func track(eventType: String, value: Double, properties: [String: Any]?) -> Bool {
return false
false
}
}

Expand All @@ -173,6 +163,6 @@ class FailedManager: SplitManager {
var splitNames: [String] = []

func split(featureName: String) -> SplitView? {
return nil
nil
}
}
Loading
Loading