diff --git a/Tests/Global Contexts/TestGlobalContexts.swift b/Tests/Global Contexts/TestGlobalContexts.swift index f50a124c2..1d6c32d18 100644 --- a/Tests/Global Contexts/TestGlobalContexts.swift +++ b/Tests/Global Contexts/TestGlobalContexts.swift @@ -131,7 +131,7 @@ class TestGlobalContexts: XCTestCase { let serviceProvider = getServiceProviderWithGlobalContextGenerators(&globalContexts) let event = Structured(category: "Category", action: "Action") - let trackerEvent = TrackerEvent(event: event, state: nil) + let trackerEvent = TrackerEvent(event: event, eventId: UUID(), state: nil) serviceProvider.tracker.addStateMachineEntities(event: trackerEvent) XCTAssertTrue(trackerEvent.entities.count == 1) @@ -163,7 +163,7 @@ class TestGlobalContexts: XCTestCase { let serviceProvider = getServiceProviderWithGlobalContextGenerators(&globalContexts) let event = Structured(category: stringToMatch, action: "Action") - let trackerEvent = TrackerEvent(event: event, state: nil) + let trackerEvent = TrackerEvent(event: event, eventId: UUID(), state: nil) serviceProvider.tracker.addStateMachineEntities(event: trackerEvent) XCTAssertTrue(trackerEvent.entities.count == 1) @@ -187,21 +187,21 @@ class TestGlobalContexts: XCTestCase { // Not matching primitive event let primitiveEvent = Structured(category: "Category", action: "Action") - var trackerEvent = TrackerEvent(event: primitiveEvent, state: nil) + var trackerEvent = TrackerEvent(event: primitiveEvent, eventId: UUID(), state: nil) serviceProvider.tracker.addStateMachineEntities(event: trackerEvent) XCTAssertTrue(trackerEvent.entities.count == 0) // Not matching self-describing event with mobile schema let screenView = ScreenView(name: "Name", screenId: nil) screenView.type = "Type" - trackerEvent = TrackerEvent(event: screenView, state: nil) + trackerEvent = TrackerEvent(event: screenView, eventId: UUID(), state: nil) serviceProvider.tracker.addStateMachineEntities(event: trackerEvent) XCTAssertTrue(trackerEvent.entities.count == 0) // Matching self-describing event with general schema let timing = Timing(category: "Category", variable: "Variable", timing: 123) timing.label = "Label" - trackerEvent = TrackerEvent(event: timing, state: nil) + trackerEvent = TrackerEvent(event: timing, eventId: UUID(), state: nil) serviceProvider.tracker.addStateMachineEntities(event: trackerEvent) XCTAssertTrue(trackerEvent.entities.count == 1) XCTAssertEqual(trackerEvent.entities[0].schema, "schema") @@ -220,7 +220,7 @@ class TestGlobalContexts: XCTestCase { let serviceProvider = getServiceProviderWithGlobalContextGenerators(&generators) let event = Structured(category: "Category", action: "Action") - let trackerEvent = TrackerEvent(event: event, state: nil) + let trackerEvent = TrackerEvent(event: event, eventId: UUID(), state: nil) serviceProvider.tracker.addStateMachineEntities(event: trackerEvent) XCTAssertTrue(trackerEvent.entities.count == 1) @@ -235,7 +235,7 @@ class TestGlobalContexts: XCTestCase { let serviceProvider = getServiceProviderWithGlobalContextGenerators(&generators) let event = Structured(category: "StringToMatch", action: "Action") - let trackerEvent = TrackerEvent(event: event, state: nil) + let trackerEvent = TrackerEvent(event: event, eventId: UUID(), state: nil) serviceProvider.tracker.addStateMachineEntities(event: trackerEvent) XCTAssertTrue(trackerEvent.entities.count == 1) diff --git a/Tests/Legacy Tests/LegacyTestTracker.swift b/Tests/Legacy Tests/LegacyTestTracker.swift index 695db9db5..6d5d636c1 100644 --- a/Tests/Legacy Tests/LegacyTestTracker.swift +++ b/Tests/Legacy Tests/LegacyTestTracker.swift @@ -114,7 +114,7 @@ class LegacyTestTracker: XCTestCase { } let event = Structured(category: "Category", action: "Action") - let trackerEvent = TrackerEvent(event: event, state: nil) + let trackerEvent = TrackerEvent(event: event, eventId: UUID(), state: nil) var payload = tracker.payload(with: trackerEvent) var payloadDict = payload!.dictionary @@ -135,14 +135,5 @@ class LegacyTestTracker: XCTestCase { XCTAssertEqual(payloadDict[kSPAppId] as? String, "newAppId") XCTAssertEqual(payloadDict[kSPNamespace] as? String, "newNamespace") } - - func testEventIdNotDuplicated() { - let event = Structured(category: "Category", action: "Action") - let eventId = TrackerEvent(event: event, state: nil).eventId - XCTAssertNotNil(eventId) - let newEventId = TrackerEvent(event: event, state: nil).eventId - XCTAssertNotNil(newEventId) - XCTAssertNotEqual(eventId, newEventId) - } } //#pragma clang diagnostic pop diff --git a/Tests/TestStateManager.swift b/Tests/TestStateManager.swift index 83d3690c2..017efdabe 100644 --- a/Tests/TestStateManager.swift +++ b/Tests/TestStateManager.swift @@ -122,7 +122,7 @@ class TestStateManager: XCTestCase { var trackerState = stateManager.trackerState(forProcessedEvent: eventInc) let mockState = trackerState?.state(withStateMachine: stateMachine) as? MockState XCTAssertEqual(1, mockState?.value) - var e = TrackerEvent(event: eventInc, state: trackerState) + var e = TrackerEvent(event: eventInc, eventId: UUID(), state: trackerState) var entities = stateManager.entities(forProcessedEvent: e) XCTAssertEqual(1, ((entities[0].data) as? [String : Int])?["value"]) XCTAssertTrue(stateManager.addPayloadValues(to: e)) @@ -130,7 +130,7 @@ class TestStateManager: XCTestCase { trackerState = stateManager.trackerState(forProcessedEvent: eventInc) XCTAssertEqual(2, (trackerState?.state(withStateMachine: stateMachine) as? MockState)?.value) - e = TrackerEvent(event: eventInc, state: trackerState) + e = TrackerEvent(event: eventInc, eventId: UUID(), state: trackerState) entities = stateManager.entities(forProcessedEvent: e) XCTAssertEqual(2, ((entities[0].data) as? [String : Int])?["value"]) XCTAssertTrue(stateManager.addPayloadValues(to: e)) @@ -138,7 +138,7 @@ class TestStateManager: XCTestCase { trackerState = stateManager.trackerState(forProcessedEvent: eventDec) XCTAssertEqual(1, (trackerState?.state(withStateMachine: stateMachine) as? MockState)?.value) - e = TrackerEvent(event: eventDec, state: trackerState) + e = TrackerEvent(event: eventDec, eventId: UUID(), state: trackerState) entities = stateManager.entities(forProcessedEvent: e) XCTAssertEqual(1, ((entities[0].data) as? [String : Int])?["value"]) XCTAssertTrue(stateManager.addPayloadValues(to: e)) @@ -146,7 +146,7 @@ class TestStateManager: XCTestCase { trackerState = stateManager.trackerState(forProcessedEvent: event) XCTAssertEqual(1, (trackerState?.state(withStateMachine: stateMachine) as? MockState)?.value) - e = TrackerEvent(event: event, state: trackerState) + e = TrackerEvent(event: event, eventId: UUID(), state: trackerState) entities = stateManager.entities(forProcessedEvent: e) XCTAssertEqual(1, ((entities[0].data) as? [String : Int])?["value"]) XCTAssertTrue(stateManager.addPayloadValues(to: e)) @@ -166,7 +166,7 @@ class TestStateManager: XCTestCase { let trackerState = stateManager.trackerState(forProcessedEvent: eventInc) let mockState = trackerState?.state(withIdentifier: "identifier") as? MockState XCTAssertNil(mockState) - let e = TrackerEvent(event: eventInc, state: trackerState) + let e = TrackerEvent(event: eventInc, eventId: UUID(), state: trackerState) let entities = stateManager.entities(forProcessedEvent: e) XCTAssertEqual(0, entities.count) } @@ -181,7 +181,7 @@ class TestStateManager: XCTestCase { ]) let trackerState = stateManager.trackerState(forProcessedEvent: eventInc) - let e = TrackerEvent(event: eventInc, state: trackerState) + let e = TrackerEvent(event: eventInc, eventId: UUID(), state: trackerState) let entities = stateManager.entities(forProcessedEvent: e) XCTAssertEqual(2, entities.count) } @@ -196,7 +196,7 @@ class TestStateManager: XCTestCase { ]) let trackerState = stateManager.trackerState(forProcessedEvent: eventInc) - let e = TrackerEvent(event: eventInc, state: trackerState) + let e = TrackerEvent(event: eventInc, eventId: UUID(), state: trackerState) let entities = stateManager.entities(forProcessedEvent: e) XCTAssertEqual(1, entities.count) } @@ -234,13 +234,13 @@ class TestStateManager: XCTestCase { XCTAssertFalse( stateManager.filter( - event: TrackerEvent(event: SelfDescribing(schema: "s1", payload: [:])) + event: TrackerEvent(event: SelfDescribing(schema: "s1", payload: [:]), eventId: UUID()) ) ) XCTAssertTrue( stateManager.filter( - event: TrackerEvent(event: SelfDescribing(schema: "s2", payload: [:])) + event: TrackerEvent(event: SelfDescribing(schema: "s2", payload: [:]), eventId: UUID()) ) ) }