Skip to content

merge original mixpanel repo changes into local fork #2

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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'
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*]" = "";
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
Loading