@@ -358,6 +358,7 @@ final class Analytics_Tests: XCTestCase {
358
358
}
359
359
}
360
360
361
+ // Test to ensure bundled and unbundled integrations are populated correctly
361
362
func testDestinationMetadata() {
362
363
let analytics = Analytics(configuration: Configuration(writeKey: "test"))
363
364
let mixpanel = AnyDestination(key: "Mixpanel")
@@ -393,6 +394,45 @@ final class Analytics_Tests: XCTestCase {
393
394
let metadata = trackEvent?._metadata
394
395
395
396
XCTAssertEqual(metadata?.bundled, ["Mixpanel"])
396
- XCTAssertEqual(metadata?.unbundled, ["Customer.io", "Amplitude"])
397
+ XCTAssertEqual(metadata?.unbundled.sorted(), ["Amplitude", "Customer.io"])
398
+ }
399
+
400
+ // Test to ensure bundled and active integrations are populated correctly
401
+ func testDestinationMetadataUnbundled() {
402
+ let analytics = Analytics(configuration: Configuration(writeKey: "test"))
403
+ let mixpanel = AnyDestination(key: "Mixpanel")
404
+ let outputReader = OutputReaderPlugin()
405
+
406
+ // we want the output reader on the segment plugin
407
+ // cuz that's the only place the metadata is getting added.
408
+ let segmentDest = analytics.find(pluginType: SegmentDestination.self)
409
+ segmentDest?.add(plugin: outputReader)
410
+
411
+ analytics.add(plugin: mixpanel)
412
+ var settings = Settings(writeKey: "123")
413
+ let integrations = try? JSON([
414
+ "Segment.io": JSON([
415
+ "unbundledIntegrations":
416
+ [
417
+ "Customer.io"
418
+ ]
419
+ ]),
420
+ "Mixpanel": JSON(["someKey": "someVal"]),
421
+ "Amplitude": JSON(["someKey": "somVal"]),
422
+ "dest1": JSON(["someKey": "someVal"])
423
+ ])
424
+ settings.integrations = integrations
425
+ analytics.store.dispatch(action: System.UpdateSettingsAction(settings: settings))
426
+
427
+ waitUntilStarted(analytics: analytics)
428
+
429
+
430
+ analytics.track(name: "sampleEvent")
431
+
432
+ let trackEvent: TrackEvent? = outputReader.lastEvent as? TrackEvent
433
+ let metadata = trackEvent?._metadata
434
+
435
+ XCTAssertEqual(metadata?.bundled, ["Mixpanel"])
436
+ XCTAssertEqual(metadata?.unbundled.sorted(), ["Amplitude", "Customer.io", "dest1"])
397
437
}
398
438
}
0 commit comments