Skip to content
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

merge changes from the original repository #1

Closed
wants to merge 63 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
4f222e4
add new property flushBatchSize for fine tuning the network request
zihejia Nov 10, 2023
a215e52
code review feedback
zihejia Nov 10, 2023
b0fbb6f
add test for the max batch size 50 enforcement
zihejia Nov 10, 2023
a90172f
Fixes so project builds for visionOS
JagCesar Nov 10, 2023
c9ac4c2
Merge pull request #617 from mixpanel/zihe-flush-batch-size
zihejia Nov 13, 2023
0a61bbc
Merge pull request #618 from ambiapps/master
zihejia Nov 13, 2023
f53d469
Version 4.2.0
zihejia Nov 13, 2023
ecd44ed
Update docs
zihejia Nov 13, 2023
c633688
Update CHANGELOG
zihejia Nov 13, 2023
918d3ad
headers and query item capability added to proxy server
mohitanand-cred Dec 12, 2023
91c16b9
added header capability to other network requests
mohitanand-cred Dec 21, 2023
488edd8
automatically collecting common mobile events is a legacy feature so …
zihejia Jan 9, 2024
ec16672
Prevent crashes in unregisterSuperProperty
Jan 16, 2024
618d245
fix CI
zihejia Jan 17, 2024
a8c862f
Merge pull request #624 from mixpanel/zihe-fix-CI-flake
zihejia Jan 17, 2024
ffd0d35
Merge pull request #623 from daleswift/prevent-crash-unregisterSuperP…
zihejia Jan 17, 2024
5b375ea
Automatic Props
ay8s Jan 30, 2024
0f10d84
Import UIKit
ay8s Jan 30, 2024
3750264
Remoev print
ay8s Jan 30, 2024
9438b4a
Merge pull request #627 from ay8s/task/visionos
zihejia Feb 2, 2024
c432bc8
added comment for macos initialize function and separated MixpanelIns…
mohitanand-cred Feb 9, 2024
324d59f
add privacy manifest
jaredmixpanel Mar 14, 2024
e1d64e7
Merge pull request #633 from mixpanel/jared-add-privacy-manifest
jaredmixpanel Mar 14, 2024
5ba0816
Version 4.2.1
jaredmixpanel Mar 14, 2024
60e265a
Update docs
jaredmixpanel Mar 14, 2024
4fa0f5d
Update CHANGELOG
zihejia Mar 14, 2024
8c9b38a
move privacy manifest
jaredmixpanel Mar 18, 2024
6f0a966
Merge pull request #634 from mixpanel/jared-move-privacy-manifest
jaredmixpanel Mar 18, 2024
9f4de4f
Version 4.2.2
jaredmixpanel Mar 18, 2024
e133990
Update docs
jaredmixpanel Mar 18, 2024
09f6555
Update CHANGELOG
zihejia Mar 18, 2024
1aae2cc
make privacy manifest a resource
jaredmixpanel Mar 25, 2024
0f021d9
add to Copy Bundle Resources
jaredmixpanel Mar 25, 2024
6c592db
Merge pull request #636 from mixpanel/jared-privacy-resource
jaredmixpanel Mar 25, 2024
9450536
Version 4.2.3
jaredmixpanel Mar 25, 2024
f9c08fa
Update docs
jaredmixpanel Mar 25, 2024
fe2ed53
Update CHANGELOG
zihejia Mar 25, 2024
aeb303f
use resources_bundle in podspec
jaredmixpanel Mar 27, 2024
bf6c6f7
Merge pull request #638 from mixpanel/jared-pod-resources-bundle
jaredmixpanel Mar 27, 2024
8cc55a6
Version 4.2.4
jaredmixpanel Mar 27, 2024
c3be71e
Update docs
jaredmixpanel Mar 27, 2024
e84dcf7
Update CHANGELOG
zihejia Mar 27, 2024
68ea193
Merge branch 'master' of https://github.com/mixpanel/mixpanel-swift i…
mohitanand-cred Apr 7, 2024
ec92bd9
Merge pull request #628 from CRED-CLUB/feat/proxy_server_header_capab…
jaredmixpanel Apr 8, 2024
0f31799
Version 4.2.5
jaredmixpanel Apr 8, 2024
a7bd485
Update docs
jaredmixpanel Apr 8, 2024
6522fb2
Update CHANGELOG
zihejia Apr 8, 2024
460e1a1
fix the crash for FlushRequest.sendRequest
zihejia Apr 19, 2024
0cbd97e
Merge pull request #642 from mixpanel/zihe-fix-flushrequest-crash
zihejia Apr 19, 2024
b850379
Version 4.2.6
zihejia Apr 19, 2024
2dc2121
Update docs
zihejia Apr 19, 2024
1ae9244
Update CHANGELOG
zihejia Apr 19, 2024
68dc046
Remove all internal tracking
zihejia May 3, 2024
471f69c
temporarily remove the lint
zihejia May 3, 2024
a46229f
Merge pull request #646 from mixpanel/remove-DevX-tracking
zihejia May 4, 2024
6e87451
Version 4.2.7
zihejia May 4, 2024
7f73084
Update docs
zihejia May 4, 2024
e7869c4
Update CHANGELOG
zihejia May 4, 2024
5d1e989
Enable inter-SDK communication for setting super properties.
zihejia Jul 19, 2024
18536ca
Merge pull request #651 from mixpanel/zihe-add-cross-sdks-comm
zihejia Jul 19, 2024
48d6668
Version 4.3.0
zihejia Jul 19, 2024
d99eaa6
Update CHANGELOG
zihejia Jul 19, 2024
61ce9b4
Update CHANGELOG.md
zihejia Jul 19, 2024
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
2 changes: 0 additions & 2 deletions .github/workflows/iOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Swift Lint
run: swiftlint
- name: Run Test
working-directory: MixpanelDemo
run: |
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/macOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Swift Lint
run: swiftlint
- name: Run Test
working-directory: MixpanelDemo
run: |
Expand Down
92 changes: 92 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,79 @@
#


## [v4.3.0](https://github.com/mixpanel/mixpanel-swift/tree/v4.3.0) (2024-07-19)

### Enhancements

- Enable cross SDK communication for registering super properties. [\#628](https://github.com/mixpanel/mixpanel-swift/pull/651)

#

## [v4.2.7](https://github.com/mixpanel/mixpanel-swift/tree/v4.2.7) (2024-05-04)

### Fixes

- Remove all internal tracking and fix crashes caused by it [\#646](https://github.com/mixpanel/mixpanel-swift/pull/646)

#

## [v4.2.6](https://github.com/mixpanel/mixpanel-swift/tree/v4.2.6) (2024-04-19)

### Fixes

- Fix the crash for FlushRequest.sendRequest [\#642](https://github.com/mixpanel/mixpanel-swift/pull/642)

#

## [v4.2.5](https://github.com/mixpanel/mixpanel-swift/tree/v4.2.5) (2024-04-08)

### Enhancements

- feat: Proxy server header capability [\#628](https://github.com/mixpanel/mixpanel-swift/pull/628)

#

## [v4.2.4](https://github.com/mixpanel/mixpanel-swift/tree/v4.2.4) (2024-03-27)

#

## [v4.2.3](https://github.com/mixpanel/mixpanel-swift/tree/v4.2.3) (2024-03-25)

### Fixes

- Make privacy manifest a resource [\#636](https://github.com/mixpanel/mixpanel-swift/pull/636)

#

## [v4.2.2](https://github.com/mixpanel/mixpanel-swift/tree/v4.2.2) (2024-03-18)

#

## [v4.2.1](https://github.com/mixpanel/mixpanel-swift/tree/v4.2.1) (2024-03-14)

### Enhancements

- Add privacy manifest [\#633](https://github.com/mixpanel/mixpanel-swift/pull/633)
- visionOS Operating System & Version along with Automatic Events [\#627](https://github.com/mixpanel/mixpanel-swift/pull/627)

### Fixes

- Prevent crashes in unregisterSuperProperty [\#623](https://github.com/mixpanel/mixpanel-swift/pull/623)

#

## [v4.2.0](https://github.com/mixpanel/mixpanel-swift/tree/v4.2.0) (2023-11-13)

### Enhancements

- add a new property 'flushBatchSize' for fine tuning the network request [\#617](https://github.com/mixpanel/mixpanel-swift/pull/617)

### Fixes

- Fixes so project builds for visionOS [\#618](https://github.com/mixpanel/mixpanel-swift/pull/618)

#

## [v4.1.4](https://github.com/mixpanel/mixpanel-swift/tree/v4.1.4) (2023-07-19)

### Fixes
Expand Down Expand Up @@ -370,6 +444,24 @@ When you call the API `createAlias`, there is an implicit `identify` call inside
























Expand Down
2 changes: 1 addition & 1 deletion Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>4.1.4</string>
<string>4.3.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
3 changes: 2 additions & 1 deletion Mixpanel-swift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Mixpanel-swift'
s.version = '4.1.4'
s.version = '4.3.0'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Version bump introduces NSScreen/NSApplication usage that may affect DuetDaemon

The version update from 4.1.4 to 4.3.0 has reintroduced NSScreen and NSApplication usage that was previously commented out for daemon mode compatibility:

  • Uncommented import Cocoa in both files
  • Reintroduced NSScreen usage for screen size detection in AutomaticProperties.swift
  • Enabled NSApplication notifications in MixpanelInstance.swift

These changes could cause issues with DuetDaemon during user logout as previously noted. Consider:

  • Re-commenting the Cocoa imports and NSScreen/NSApplication usage
  • Or implementing runtime checks to disable these features when running in daemon mode
🔗 Analysis chain

Verify version bump compatibility with DuetDaemon

Given the significant version jump from 4.1.4 to 4.3.0 and the concerns about NSScreen/NSApplication affecting DuetDaemon during user logout, we should carefully verify the macOS-specific changes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for NSScreen/NSApplication related changes in the version diff

# Check changelog for breaking changes
echo "Checking CHANGELOG.md for breaking changes..."
rg -A 5 "4\.3\.0" CHANGELOG.md

# Look for NSScreen/NSApplication usage in source files
echo "Checking for NSScreen/NSApplication usage..."
rg -l "NSScreen|NSApplication" Sources/

Length of output: 569


Script:

#!/bin/bash
# Let's examine the specific NSScreen/NSApplication usage in the identified files
echo "Checking NSScreen/NSApplication usage in MixpanelInstance.swift..."
rg -B 2 -A 2 "NSScreen|NSApplication" Sources/MixpanelInstance.swift

echo "\nChecking NSScreen/NSApplication usage in AutomaticProperties.swift..."
rg -B 2 -A 2 "NSScreen|NSApplication" Sources/AutomaticProperties.swift

# Let's also check the git diff for these files to see if there were any changes
echo "\nChecking git diff for these files..."
git diff origin/main..HEAD -- Sources/MixpanelInstance.swift Sources/AutomaticProperties.swift

Length of output: 1460


Script:

#!/bin/bash
# Let's try with master branch instead of main
echo "Checking git diff for NSScreen/NSApplication related files..."
git diff origin/master..HEAD -- Sources/MixpanelInstance.swift Sources/AutomaticProperties.swift

# Let's also check the commit history for these files
echo "\nChecking recent commits affecting these files..."
git log -n 5 --oneline -- Sources/MixpanelInstance.swift Sources/AutomaticProperties.swift

# Let's verify if there are any changes in the version being merged
echo "\nChecking version-specific changes..."
git show v4.3.0 -- Sources/MixpanelInstance.swift Sources/AutomaticProperties.swift 2>/dev/null || echo "Tag v4.3.0 not found"

Length of output: 24761

s.module_name = 'Mixpanel'
s.license = 'Apache License, Version 2.0'
s.summary = 'Mixpanel tracking library for iOS (Swift)'
Expand All @@ -9,6 +9,7 @@ Pod::Spec.new do |s|
s.author = { 'Mixpanel, Inc' => 'support@mixpanel.com' }
s.source = { :git => 'https://github.com/mixpanel/mixpanel-swift.git',
:tag => "v#{s.version}" }
s.resource_bundles = {'Mixpanel' => ['Sources/Mixpanel/PrivacyInfo.xcprivacy']}
s.ios.deployment_target = '11.0'
s.ios.frameworks = 'UIKit', 'Foundation', 'CoreTelephony'
s.ios.pod_target_xcconfig = {
Expand Down
18 changes: 18 additions & 0 deletions Mixpanel.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
17C6547A2BB1F15C00C8A126 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 1728208D2BA8BDE4002CD973 /* PrivacyInfo.xcprivacy */; };
17C6547B2BB1F16000C8A126 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 1728208D2BA8BDE4002CD973 /* PrivacyInfo.xcprivacy */; };
17C6547C2BB1F16400C8A126 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 1728208D2BA8BDE4002CD973 /* PrivacyInfo.xcprivacy */; };
17C6547D2BB1F16800C8A126 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 1728208D2BA8BDE4002CD973 /* PrivacyInfo.xcprivacy */; };
51DD567C1D306B740045D3DB /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51DD56791D306B740045D3DB /* Logger.swift */; };
51DD56831D306B7B0045D3DB /* PrintLogging.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51DD56801D306B7B0045D3DB /* PrintLogging.swift */; };
51DD56841D306B7B0045D3DB /* FileLogging.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51DD56811D306B7B0045D3DB /* FileLogging.swift */; };
Expand Down Expand Up @@ -95,6 +99,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
1728208D2BA8BDE4002CD973 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = Sources/Mixpanel/PrivacyInfo.xcprivacy; sourceTree = SOURCE_ROOT; };
51DD56791D306B740045D3DB /* Logger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
51DD56801D306B7B0045D3DB /* PrintLogging.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PrintLogging.swift; sourceTree = "<group>"; };
51DD56811D306B7B0045D3DB /* FileLogging.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileLogging.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -157,6 +162,14 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
17C654792BB1EF6700C8A126 /* Mixpanel */ = {
isa = PBXGroup;
children = (
1728208D2BA8BDE4002CD973 /* PrivacyInfo.xcprivacy */,
);
path = Mixpanel;
sourceTree = "<group>";
};
51DD56771D306B620045D3DB /* Log */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -208,6 +221,7 @@
E11594881CFF14D3007F8B4F /* Source */ = {
isa = PBXGroup;
children = (
17C654792BB1EF6700C8A126 /* Mixpanel */,
E189D8FB1D5A6943007F3F29 /* Networking */,
51DD56771D306B620045D3DB /* Log */,
E189D8FA1D5A692A007F3F29 /* Utilities */,
Expand Down Expand Up @@ -427,27 +441,31 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
17C6547D2BB1F16800C8A126 /* PrivacyInfo.xcprivacy in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
E115947B1CFF1491007F8B4F /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
17C6547A2BB1F15C00C8A126 /* PrivacyInfo.xcprivacy in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
E12782B11D4AB4B30025FB05 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
17C6547B2BB1F16000C8A126 /* PrivacyInfo.xcprivacy in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
E1F15FC71E64A10700391AE3 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
17C6547C2BB1F16400C8A126 /* PrivacyInfo.xcprivacy in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
14 changes: 10 additions & 4 deletions MixpanelDemo/MixpanelDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -851,7 +851,6 @@
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeamName = "Mixpanel, Inc.";
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.ApplePay = {
enabled = 0;
Expand Down Expand Up @@ -1841,10 +1840,10 @@
CODE_SIGN_ENTITLEMENTS = MixpanelDemo/MixpanelDemo.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 6;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = E8FVX7QLET;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = MixpanelDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -1899,8 +1898,12 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = AXVA7A4XGX;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = "";
Comment on lines +1901 to +1906
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Build configuration inconsistency detected across targets

There are inconsistent DEVELOPMENT_TEAM settings across different targets:

  • One target still has DEVELOPMENT_TEAM = E8FVX7QLET (appears twice)
  • Another target has DEVELOPMENT_TEAM = AXVA7A4XGX with platform-specific overrides set to empty
  • Some targets already have empty DEVELOPMENT_TEAM settings

This partially aligns with the PR's objective, but the configuration needs to be consistent across all targets.

🔗 Analysis chain

Confirm build configuration for all platforms.

Development team settings have been cleared for both iOS and macOS targets. This change:

  1. Aligns with the PR objective regarding DuetDaemon
  2. May require manual team configuration for each developer

Let me gather more context about the build configurations to understand the complete picture.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for platform-specific build configurations
# Look for any remaining team IDs that might need to be cleared
rg "DEVELOPMENT_TEAM\s*=\s*[A-Z0-9]+" 

Length of output: 300


Script:

#!/bin/bash
# Get more context around the DEVELOPMENT_TEAM settings to understand which targets they belong to
rg "DEVELOPMENT_TEAM.*=.*" -B 5 -A 1 MixpanelDemo/MixpanelDemo.xcodeproj/project.pbxproj

Length of output: 1815

GCC_PREPROCESSOR_DEFINITIONS = (
"$(inherited)",
"COCOAPODS=1",
Expand Down Expand Up @@ -1928,6 +1931,8 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = MixpanelDemoTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -1937,6 +1942,7 @@
LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../Mixpanel";
PRODUCT_BUNDLE_IDENTIFIER = com.mixpanel.MixpanelDemoTests;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-O";
Expand Down
43 changes: 30 additions & 13 deletions MixpanelDemo/MixpanelDemoTests/MixpanelDemoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MixpanelDemoTests: MixpanelBaseTests {
XCTAssert(waitTime >= 110, "Network backoff time is less than 2 minutes.")
XCTAssert(testMixpanel.flushInstance.flushRequest.networkConsecutiveFailures == 2,
"Network failures did not equal 2")

XCTAssert(eventQueue(token: testMixpanel.apiToken).count == 2,
"Removed an event from the queue that was not sent")
removeDBfile(testMixpanel.apiToken)
Expand All @@ -51,6 +51,18 @@ class MixpanelDemoTests: MixpanelBaseTests {
"events should have been flushed")
removeDBfile(testMixpanel.apiToken)
}

func testFlushProperties() {
let testMixpanel = Mixpanel.initialize(token: randomId(), trackAutomaticEvents: true, flushInterval: 60)
XCTAssertTrue(testMixpanel.flushBatchSize == 50, "the default flush batch size is set to 50")
XCTAssertTrue(testMixpanel.flushInterval == 60, "flush interval is set correctly")
testMixpanel.flushBatchSize = 10
XCTAssertTrue(testMixpanel.flushBatchSize == 10, "flush batch size is set correctly")
testMixpanel.flushBatchSize = 60
XCTAssertTrue(testMixpanel.flushBatchSize == 50, "flush batch size is max at 50")
testMixpanel.flushInterval = 30
XCTAssertTrue(testMixpanel.flushInterval == 30, "flush interval is set correctly")
}

func testFlushPeople() {
let testMixpanel = Mixpanel.initialize(token: randomId(), trackAutomaticEvents: true, flushInterval: 60)
Expand Down Expand Up @@ -957,25 +969,28 @@ class MixpanelDemoTests: MixpanelBaseTests {

func testMultipleInstancesWithSameTokenButDifferentInstanceName() {
let testToken = randomId()
let instance1 = Mixpanel.initialize(token: testToken, trackAutomaticEvents: true, flushInterval: 60, instanceName: "instance1")
let instance2 = Mixpanel.initialize(token: testToken, trackAutomaticEvents: true, flushInterval: 60, instanceName: "instance2")
let instanceName1 = randomId()
let instanceName2 = randomId()
let instance1 = Mixpanel.initialize(token: testToken, trackAutomaticEvents: true, flushInterval: 60, instanceName: instanceName1)
let instance2 = Mixpanel.initialize(token: testToken, trackAutomaticEvents: true, flushInterval: 60, instanceName: instanceName2)

XCTAssertNotEqual(instance1.distinctId, instance2.distinctId)
instance1.identify(distinctId: "user1")
instance1.track(event: "test")
waitForTrackingQueue(instance1)
waitForTrackingQueue(instance2)

XCTAssertEqual(instance1.distinctId, "user1")
XCTAssertEqual(instance1.userId, "user1")
let events = eventQueue(token: "instance1")
let events = eventQueue(token: instanceName1)
let properties = events.last?["properties"] as? InternalProperties
// TODO: Need to figure out why this test is flaky
// event property should have the current distinct id
//XCTAssertEqual(properties?["distinct_id"] as? String, "user1")
XCTAssertEqual(properties?["distinct_id"] as? String, "user1")

instance1.people.set(property: "p1", to: "a")
waitForTrackingQueue(instance1)

let peopleQueue_value = peopleQueue(token: "instance1")
waitForTrackingQueue(instance2)

let peopleQueue_value = peopleQueue(token: instanceName1)
let setValue = peopleQueue_value.last!["$set"] as! InternalProperties
XCTAssertEqual(setValue["p1"] as? String, "a", "custom people property not queued")

Expand All @@ -984,26 +999,28 @@ class MixpanelDemoTests: MixpanelBaseTests {

instance2.identify(distinctId: "user2")
instance2.track(event: "test2")
waitForTrackingQueue(instance1)
waitForTrackingQueue(instance2)
XCTAssertEqual(instance2.distinctId, "user2")
XCTAssertEqual(instance2.userId, "user2")
let events2 = eventQueue(token: "instance2")
let events2 = eventQueue(token: instanceName2)
let properties2 = events2.last?["properties"] as? InternalProperties
// event property should have the current distinct id
XCTAssertEqual(properties2?["distinct_id"] as? String, "user2")

instance2.people.set(property: "p2", to: "b")
waitForTrackingQueue(instance1)
waitForTrackingQueue(instance2)

let peopleQueue2_value = peopleQueue(token: "instance2")
let peopleQueue2_value = peopleQueue(token: instanceName2)
XCTAssertEqual(peopleQueue2_value.last?["$distinct_id"] as? String,
"user2", "distinct id not set properly on the people record")

let setValue2 = peopleQueue2_value.last!["$set"] as! InternalProperties
XCTAssertEqual(setValue2["p2"] as? String, "b", "custom people property not queued")

removeDBfile("instance1")
removeDBfile("instance2")
removeDBfile(instanceName1)
removeDBfile(instanceName2)
}

func testReadWriteMultiThreadShouldNotCrash() {
Expand Down
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ let package = Package(
targets: [
.target(
name: "Mixpanel",
path: "Sources"
path: "Sources",
resources: [
.copy("Mixpanel/PrivacyInfo.xcprivacy")
]
)
]
)
Loading