Git Product home page Git Product logo

mixpanel-swift's Introduction

Mixpanel Swift Library

Average time to resolve an issue Percentage of issues still open CocoaPods Compatible Carthage compatible Swift Package Manager compatible Apache License Documentation

Table of Contents

Overview

Welcome to the official Mixpanel Swift Library

The Mixpanel Swift library for iOS is an open-source project, and we'd love to see your contributions! We'd also love for you to come and work with us! Check out Jobs for details.

If you are using Objective-C, we recommend using our Objective-C Library.

Check out our Advanced iOS Swift Guide for additional advanced configurations and use cases, like setting up your project with European Union data storage.

Quick Start Guide

Our master branch and our releases are on Swift 5. If you wish to use our Swift 4.2 implementation, please point to the v2.6.1 release. For Swift 4/4.1 implementation, please point to the v2.4.5 release. For Swift 3 implementation, please point to the v2.2.3 release.

1. Install Mixpanel

You will need your project token for initializing your library. You can get your project token from project settings.

Installation Option 1: Swift Package Manager (v2.8.0+)

The easiest way to get Mixpanel into your iOS project is to use Swift Package Manager.

  1. In Xcode, select File > Add Packages...
  2. Enter the package URL for this repository Mixpanel Swift library.

Installation Option 2: CocoaPods

  1. If this is your first time using CocoaPods, Install CocoaPods using gem install cocoapods. Otherwise, continue to Step 3.
  2. Run pod setup to create a local CocoaPods spec mirror.
  3. Create a Podfile in your Xcode project directory by running pod init in your terminal, edit the Podfile generated, and add the following line: pod 'Mixpanel-swift'.
  4. Run pod install in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing open *.xcworkspace in your terminal.

Installation Option 3: Carthage

Mixpanel supports Carthage to package your dependencies as a framework. Include the following dependency in your Cartfile:

github "mixpanel/mixpanel-swift"

Check out the Carthage docs for more info.

2. Initialize Mixpanel

Import Mixpanel into AppDelegate.swift, and initialize Mixpanel within application:didFinishLaunchingWithOptions:

import Mixpanel

func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    ...
    Mixpanel.initialize(token: "MIXPANEL_TOKEN", trackAutomaticEvents: false)
    ...
}

See all configuration options

3. Send Data

Let's get started by sending event data. You can send an event from anywhere in your application. Better understand user behavior by storing details that are specific to the event (properties). After initializing the library, Mixpanel will automatically collect common mobile events. You can enable/disable automatic collection through your project settings. Also, Mixpanel automatically tracks some properties by default. learn more

Mixpanel.mainInstance().track(event: "Sign Up", properties: [
   "source": "Pat's affiliate site",
   "Opted out of email": true
])

In addition to event data, you can also send user profile data. We recommend this after completing the quickstart guide.

4. Check for Success

Open up Events in Mixpanel to view incoming events.

Once data hits our API, it generally takes ~60 seconds for it to be processed, stored, and queryable in your project.

👋 👋 Tell us about the Mixpanel developer experience! https://www.mixpanel.com/devnps 👍 👎

Complete Code Example

Here's a runnable code example that covers everything in this quickstart guide.

import Mixpanel

func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    ...
    Mixpanel.initialize(token: "MIXPANEL_TOKEN", trackAutomaticEvents: false)
    Mixpanel.mainInstance().track(event: "Sign Up", properties: [
       "source": "Pat's affiliate site",
       "Opted out of email": true
    ])
    ...
}

FAQ

I want to stop tracking an event/event property in Mixpanel. Is that possible?

Yes, in Lexicon, you can intercept and drop incoming events or properties. Mixpanel won’t store any new data for the event or property you select to drop. See this article for more information.

I have a test user I would like to opt out of tracking. How do I do that?

Mixpanel’s client-side tracking library contains the optOutTracking() method, which will set the user’s local opt-out state to “true” and will prevent data from being sent from a user’s device. More detailed instructions can be found in the section, Opting users out of tracking.

Why aren't my events showing up?

First, make sure your test device has internet access. To preserve battery life and customer bandwidth, the Mixpanel library doesn't send the events you record immediately. Instead, it sends batches to the Mixpanel servers every 60 seconds while your application is running, as well as when the application transitions to the background. You can call flush() manually if you want to force a flush at a particular moment.

Mixpanel.mainInstance().flush()

If your events are still not showing up after 60 seconds, check if you have opted out of tracking. You can also enable Mixpanel debugging and logging, it allows you to see the debug output from the Mixpanel library. To enable it, set loggingEnabled to true.

Mixpanel.mainInstance().loggingEnabled = true

Starting with iOS 14.5, do I need to request the user’s permission through the AppTrackingTransparency framework to use Mixpanel?

No, Mixpanel does not use IDFA so it does not require user permission through the AppTrackingTransparency(ATT) framework.

If I use Mixpanel, how do I answer app privacy questions for the App Store?

Please refer to our Apple App Developer Privacy Guidance

I want to know more!

No worries, here are some links that you will find useful:

Have any questions? Reach out to Mixpanel Support to speak to someone smart, quickly.

mixpanel-swift's People

Contributors

adamf-bluejeans avatar alexandersandberg avatar alvarhansen avatar argenisf avatar asiliuk avatar austinpray-mixpanel avatar ay8s avatar bengottlieb avatar bre7 avatar dneralla avatar froelund avatar jaredmixpanel avatar jbwyme avatar katherineoelsner avatar kevinchau avatar krbarnes avatar ky1ejs avatar madster26 avatar matt-loflin avatar matteinn avatar mazyod avatar mohitanand-cred avatar muukii avatar mxcl avatar ramblinwreck77 avatar rebello95 avatar vikas171999 avatar wgins avatar yarneo avatar zihejia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mixpanel-swift's Issues

Important: Release Versioning and Swift Version Compatibility

The recent release of "v1.0.1" should removed and be named "1.1.0" since Swift 2.2 (in Xcode 7.3.1) and Swift 2.3 (in Xcode 8) are not binary compatible. Anyone using Carthage is in for a big surprise the next time they do an update and find that their project will no longer build, since the current versioning implies the two versions are compatible.

Furthermore, Carthage can't parse the version correctly if specified with the "v" in the Cartfile, so anyone using Carthage will be dead in their tracks until this is resolved. (Release versions should only be numeric anyway as a matter of good practice.)

In the future whoever is dropping releases should keep in mind Swift versions (even point releases) will always be binary incompatible, until Swift 4, and possibly even after 4.0.

Edit: I just discovered that Carthage is smart about removing the "v", so the following spec in the Cartfile will solve this issue:

github "mixpanel/mixpanel-swift" == 1.0.0

Swift 3.01 breaks mix panel (Carthage)

The latest Swift 3.01 included in Xcode 8.1GM breaks mix panel. The framework that Carthage fetches is compiled with Swift 3.0 and cannot be used while trying to force compilation with
carthage update --platform iOS --no-use-binaries
fails with errors and warnings.

Swiftlint not allowing me to build using Carthage

Hey guys!

I'm trying to compile your repo using carthage with the command carthage bootstrap --platform iOS --no-use-binaries --use-ssh.

However Swiftlint tells me the code has errors (breaking coding conventions ofc, so nothing serious :P) and it fails to compile. So the only way for me to build this repo using Carthage is to uninstall Swiftlint before bootstrapping.

Is this something you are aware about?

In-app notifiction openURL throws NSInvalidArguemntException, crashes app

What is wrong?
Seems like there's a few bits wrong with Mixpanel/InAppNotifications.swift with recent change to openURL around line 94.

Error given
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIApplication openURL]: unrecognized selector sent to instance 0x7ff96a602a50'

Details
First, it seems that the selector from string needs to be suffixed with a colon. I was unable to get any links to open until I appended a colon to NSSelectorFromString("openURL:").

After the change, the rest of the line throws EXC_BAD_ACCESS. (Maybe something on our end?)

I'm pretty new to Swift, so I could be a bit wrong? 🤷 Suggestions welcomed!

Full debug output below.

2017-06-20 19:58:36.606 Poncho[54484:4571230] -[UIApplication openURL]: unrecognized selector sent to instance 0x7f867ac026d0
2017-06-20 19:58:36.638 Poncho[54484:4571230] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIApplication openURL]: unrecognized selector sent to instance 0x7f867ac026d0'
*** First throw call stack:
(
	0   CoreFoundation                      0x0000000107311b0b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x000000010695c141 objc_exception_throw + 48
	2   CoreFoundation                      0x0000000107381134 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
	3   CoreFoundation                      0x0000000107298840 ___forwarding___ + 1024
	4   CoreFoundation                      0x00000001072983b8 _CF_forwarding_prep_0 + 120
	5   Mixpanel                            0x00000001059fcea1 _TFFC8Mixpanel18InAppNotifications25notificationShouldDismissFT10controllerCS_30BaseNotificationViewController15callToActionURLGSqV10Foundation3URL__SbU0_FT_T_ + 561
	6   Mixpanel                            0x0000000105a12acc _TFFC8Mixpanel30MiniNotificationViewController4hideFT8animatedSb10completionFT_T__T_U0_FSbT_ + 492
	7   Mixpanel                            0x0000000105a120e3 _TTRXFo_dSb__XFdCb_dSb__ + 51
	8   UIKit                               0x0000000108523cd4 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 527
	9   UIKit                               0x00000001084f6f07 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 222
	10  UIKit                               0x00000001084f7446 -[UIViewAnimationState animationDidStop:finished:] + 136
	11  QuartzCore                          0x000000010818368e _ZN2CA5Layer23run_animation_callbacksEPv + 306
	12  libdispatch.dylib                   0x000000010b63605c _dispatch_client_callout + 8
	13  libdispatch.dylib                   0x000000010b61740b _dispatch_main_queue_callback_4CF + 411
	14  CoreFoundation                      0x00000001072d6909 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
	15  CoreFoundation                      0x000000010729cae4 __CFRunLoopRun + 2164
	16  CoreFoundation                      0x000000010729c016 CFRunLoopRunSpecific + 406
	17  GraphicsServices                    0x000000010f3f9a24 GSEventRunModal + 62
	18  UIKit                               0x000000010846b0d4 UIApplicationMain + 159
	19  Poncho                              0x0000000104e13de7 main + 55
	20  libdyld.dylib                       0x000000010b68265d start + 1
	21  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

AB Testing with Tweaks

Hi,
i actually want to use Mixpanel to do a simple AB Testing and a little tracking on my login form :

  • 25% of users get the new login modal
  • 75% of users stay with the old one

To do so i just created a MixpanelTweak called showNewLogin of type Bool with a default value set to false.
Following the tutorial, i want to set up an experiment where 25% of users showNewLogin = true but can't figure it out how to do so in the Mixpanel A/B test designer.

My experiment is not base on a visual element so why do i need to connect my device and display the UI to set an experiment ?
Where do i set the Tweak value associated to a % of users ?

Thanks a lot !

Pod install not working

This is what I get when I try to do a pod install =>
[!] Unable to find a specification for 'Mixpanel-swift'

I've been using cocoa pods a lot in my project and it works perfectly.

Data race

Hey guys,

I ran my app with Thread Sanitizer enabled and it just reported a data race inside mixpanel-swift library.

Can you check it out, please?

Change back to Swift 3.0

Xcode 8.2 released and does not accept 3.0.1 version. Tried to build with carthage --no-use-binaries

The following build commands failed:
	Check dependencies
(1 failure)
=== BUILD TARGET Mixpanel OF PROJECT Mixpanel WITH CONFIGURATION Release ===

Check dependencies
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.

** BUILD FAILED **

Support for Swift 4 / Xcode 9

Hello,

I wanted to know if Mixpanel is working on supporting the SDK for Xcode 9 Beta 1 / Swift 4 and if there is existing code that I could use with my Swift 4 project.
(I've tried looking at the branches in the mixpanel-swift project and I couldn't find one that indicated support for these environments)

Xcode 8.3 Compatibility

It seems the MixPanel SDK wasn't properly prepared for Xcode 8.3, despite the fact there were 5 betas before release.

image

If you accept PRs I don't mind fixing it real quick. I've already fixed locally for the time being to clean up the warnings.

Thanks :)
Shai

Compiler warnings with 3.0.8

The most recent release introduced some compiler warnings due to deprecations. We do not use these classes in our application and would very much love to not get these warnings from the compiler as well.

image

Inconsistent distinct_id handling with the mixpanel obj-c sdk

It seems like here, you're trying to read the distinct_id from the unarchived properties - and in case they are not retrievable, you set it to "" (empty string)
https://github.com/mixpanel/mixpanel-swift/blob/master/Mixpanel/Persistence.swift#L179
This seems like a good opportunity to set it to nil so that you can properly handle that issue somewhere

In your objc sdk on the other hand, you try to retrieve the distinct_id and then "generate" a new one (or use ifa/ifv if available) in case you couldn't read it from the archive.

Of course this is just a handling of an issue that should never occur anyway - but for us it did - the archive files were somehow corrupted and distinct_ids were reset - but at least they were just reset.
It looks like in this swift SDK, all users would end up getting an empty distinct_id --> all events would be attributed to the same "Mixpanel-user" with id ""

App extension target

Have just spotted you have a Swift project now so thought I'd check it out.

The project wont link with an app extension because the "App extension API only" build setting isn't set. In your ObjC project you have a separate target for this - I'm not sure why but I'm sure you have your reasons. It would be good to sort this in the Swift project.

I'm using Carthage to build.

Not necessary to split into two pods

I have examined why you split the framework into two and it isn't necessary.

It is certainly quite inconvenient, not to mention inefficient for my apps that you do. So it seems more ideal that it would not be done.

The various hooks that the Mixpanel-swift does that Mixpanel-swift-appex doesn't could all be decided by examining the runtime and not with compile-time #ifdefs.

Then the extension can be marked app-extension-safe and you only need one framework.

TakeoverNotificationViewController crash line 87

Crash when TakeoverNotificationViewController displayed, line 87: window.isHidden = false throws SIGABRT, seems it can't find the nib file. Installed via cocoapods using. Full stack trace:

2016-09-27 11:11:09.515611 LuckyTrip[1629:311525] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/containers/Bundle/Application/4CB1773C-4169-4081-9CD6-6BAC6296B515/LuckyTrip.app> (loaded)' with name 'TakeoverNotificationViewController~iphoneportrait''
*** First throw call stack:
(0x18d64c1c0 0x18c08455c 0x18d64c108 0x19399683c 0x1937f7648 0x1935c9868 0x193495074 0x193494fa4 0x19349b750 0x193498bf0 0x101121268 0x1010f1f10 0x1010f291c 0x1010f19e0 0x1019a925c 0x1019a921c 0x1019ae284 0x18d5f9f2c 0x18d5f7b18 0x18d526048 0x18efa9198 0x193500628 0x1934fb360 0x10007a148 0x18c5085b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

screen shot 2016-09-27 at 11 12 18

Make default distinct_id IDFA when available.

This would bring distinct_id convention in line with the older, more common Obj-C library, and accommodate existing 3rd party attribution integrations that expect this behavior.

Swift 3 Support?

Currently I'm using Xcode 8, Swift 3, Cocoapods (version 1.1.0.rc.2) and Mixpanel-swift (1.0.1). In my podfile..

pod 'Mixpanel-swift'

But apparently it's not compatible with Swift 3?

screen shot 2016-09-20 at 1 57 19 pm

Can't update a user until the app is reinstalled

Hello,

I am using Carthage 0.20 and the Mixpanel SDK v2.1.4.
In my app, I am updating a user after I have identified him.

var mixpanelAttributes: Properties = ["$name": "Axel"]
Mixpanel.mainInstance().people.set(properties: mixpanelAttributes)

However, this does not seem to work: on the dashboard, I don't see the user (either created or updated). If I enable the logging in the Mixpanel SDK, I see that in the console.

screenshot 2017-03-07 20 36 48

I also tried, without success (same messages in the logs)

Mixpanel.mainInstance().people.set(property: "$name", to: "Axel")

If I remove my app from the device and reinstall it, I don't have the issue. I fear that if I update my app on the App Store, I can't track anymore the users.

Thanks,
Axel

Xcode 9 - Main Thread Sanitizer

Seems like Mixpanel is updating the isNetworkActivityIndicatorVisible variable in a background thread. This is being reported by Xcode 9's Main Thread Sanitizer.

Main Thread Checker: UI API called on a background thread: -[UIApplication setNetworkActivityIndicatorVisible:]
PID: 740, TID: 51960, Thread name: (none), Queue name: com.mixpanel.b63c85c3ad9426aa86cdecacb8825329, QoS: 0
Backtrace:
4   Mixpanel                            0x0000000102958478 _T08Mixpanel0A8InstanceC30updateNetworkActivityIndicatorySbF + 148
5   Mixpanel                            0x00000001029591e4 _T08Mixpanel0A8InstanceCAA13FlushDelegateA2aDP30updateNetworkActivityIndicatorySbFTW + 68
6   Mixpanel                            0x0000000102927894 _T08Mixpanel5FlushC19flushQueueInBatchesySays10DictionaryVySSypGGz_AA0B4TypeO4typetF + 1092
7   Mixpanel                            0x0000000102926b68 _T08Mixpanel5FlushC10flushQueueyAA0B4TypeO4type_Says10DictionaryVySSypGGz5queuetF + 136
8   Mixpanel                            0x000000010292610c _T08Mixpanel5FlushC16flushEventsQueueySays10DictionaryVySSypGGz_SbSg09automaticD7EnabledtF + 92
9   Mixpanel                            0x000000010295bf78 _T08Mixpanel0A8InstanceC5flushyyycSg10completion_tFyycfU_ + 512
10  Mixpanel                            0x0000000102902634 _T0Ix_IyB_TR + 48
11  libdispatch.dylib                   0x0000000104751654 _dispatch_call_block_and_release + 24
12  libdispatch.dylib                   0x0000000104751614 _dispatch_client_callout + 16
13  libdispatch.dylib                   0x0000000104761008 _dispatch_queue_serial_drain + 716
14  libdispatch.dylib                   0x0000000104754e58 _dispatch_queue_invoke + 340
15  libdispatch.dylib                   0x00000001047621c4 _dispatch_root_queue_drain_deferred_wlh + 412
16  libdispatch.dylib                   0x00000001047697fc _dispatch_workloop_worker_thread + 868
17  libsystem_pthread.dylib             0x00000001aa6e71e8 _pthread_wqthread + 924
18  libsystem_pthread.dylib             0x00000001aa6e6e40 start_wqthread + 4

Mysterious Crashes in SDK

I'm seeing two crashes in the latest MixPanel SDK. I've seen at least one of them before.

  1. Something goes wrong with GCD in the setCurrentRadio method of the MixpanelInstance class. This is the one I've seen before. Previously I forked the repo and just commented out this method entirely because current radio information doesn't seem particularly important. In our latest release I switched back to see if it had been fixed by other changes - apparently not.
EXC_BREAKPOINT 0x000000000000defe

Crashed: com.mixpanel.c39eea2c9ad72a79d1688ca82c50cb94
0  libsystem_platform.dylib       0x1e18cdbc _os_unfair_lock_unowned_abort + 59
1  libsystem_platform.dylib       0x1e18c639 _os_unfair_lock_unlock_slow + 130
2  libcoretls_cfhelpers.dylib     0x3bb98a00 (Missing)
3  libsystem_malloc.dylib         0x1e126739 free_tiny_botch + 86
4  CoreFoundation                 0x1e8f2033 _CFRelease + 1198
5  Mixpanel                       0x1769108 _TTSf4g___TFFC8Mixpanel16MixpanelInstance15setCurrentRadioFT_T_U_FT_T_ + 316
6  Mixpanel                       0x1768cf4 _TPA__TFFC8Mixpanel16MixpanelInstance15setCurrentRadioFT_T_U_FT_T_ + 80
7  libdispatch.dylib              0x1dfda097 _dispatch_call_block_and_release + 10
8  libdispatch.dylib              0x1dfe6e5d _dispatch_queue_serial_drain + 840
9  libdispatch.dylib              0x1dfdd379 _dispatch_queue_invoke + 566
10 libdispatch.dylib              0x1dfe8a5d _dispatch_root_queue_drain + 378
11 libdispatch.dylib              0x1dfe8883 _dispatch_worker_thread3 + 106
12 libsystem_pthread.dylib        0x1e18f937 _pthread_wqthread + 1168
13 libsystem_pthread.dylib        0x1e18f490 start_wqthread + 8
  1. Something goes wrong with GCD in the flushQueueInBatches method of Flush. This seems more vital and not something I can just excise.
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000011693c52

Crashed: com.mixpanel.Wc39eea2c9ad72a79d1688ca82c50cb94
0  libswiftCore.dylib             0x1f8aab0 swift_unknownRelease + 7
1  libswiftCore.dylib             0x1f87b87 swift::metadataimpl::ValueWitnesses<swift::metadataimpl::OpaqueExistentialBox<0u> >::destroyArray(swift::OpaqueValue*, unsigned long, swift::TargetMetadata<swift::InProcess> const*) + 26
2  libswiftCore.dylib             0x1d94280 _TFSp12deinitializefT5countSi_Sv + 44
3  libswiftCore.dylib             0x1e061b4 _TFCs28_NativeDictionaryStorageImpld + 444
4  libswiftCore.dylib             0x1e05fe8 _TFCs28_NativeDictionaryStorageImplD + 12
5  libswiftCore.dylib             0x1e096d0 _TFCs29_NativeDictionaryStorageOwnerD + 28
6  libswiftCore.dylib             0x1f87b87 swift::metadataimpl::ValueWitnesses<swift::metadataimpl::OpaqueExistentialBox<0u> >::destroyArray(swift::OpaqueValue*, unsigned long, swift::TargetMetadata<swift::InProcess> const*) + 26
7  libswiftCore.dylib             0x1d94280 _TFSp12deinitializefT5countSi_Sv + 44
8  libswiftCore.dylib             0x1e061b4 _TFCs28_NativeDictionaryStorageImpld + 444
9  libswiftCore.dylib             0x1e05fe8 _TFCs28_NativeDictionaryStorageImplD + 12
10 libswiftCore.dylib             0x1e096d0 _TFCs29_NativeDictionaryStorageOwnerD + 28
11 libswiftCore.dylib             0x1f3b6d8 _TwXxOs18_VariantSetStorage + 40
12 libswiftCore.dylib             0x1d94280 _TFSp12deinitializefT5countSi_Sv + 44
13 libswiftCore.dylib             0x1dc9560 _TFCs23_ContiguousArrayStoraged + 172
14 libswiftCore.dylib             0x1dc94a4 _TFCs23_ContiguousArrayStorageD + 12
15 Mixpanel                       0x170cd48 _TFC8Mixpanel5Flush19flushQueueInBatchesfTRGSaGVs10DictionarySSP___4typeOS_9FlushType_T_ + 1552
16 Mixpanel                       0x1744d90 _TTSf4g_g___TFFC8Mixpanel16MixpanelInstance5flushFT10completionGSqFT_T___T_U_FT_T_ + 452
17 Mixpanel                       0x1743794 _TPA__TFFC8Mixpanel16MixpanelInstance5flushFT10completionGSqFT_T___T_U_FT_T_ + 112
18 libdispatch.dylib              0x1ba4e097 _dispatch_call_block_and_release + 10
19 libdispatch.dylib              0x1ba5ae5d _dispatch_queue_serial_drain + 840
20 libdispatch.dylib              0x1ba51379 _dispatch_queue_invoke + 566
21 libdispatch.dylib              0x1ba5b2f5 _dispatch_queue_override_invoke + 286
22 libdispatch.dylib              0x1ba5ca5d _dispatch_root_queue_drain + 378
23 libdispatch.dylib              0x1ba5c883 _dispatch_worker_thread3 + 106
24 libsystem_pthread.dylib        0x1bc03937 _pthread_wqthread + 1168
25 libsystem_pthread.dylib        0x1bc03490 start_wqthread + 8

The first one is a very high-frequency crash - top crash on Crashlytics, severity of about .7% of all users. The second one, less so but still concerning. Any advice on a fix would be nice - I'm happy to push out some test code to our userbase if anyone has a theoretical fix.

A/B developer tweaks not working

Hello

After connect my iPhone to mixpanle it will update the tweaks variables value instant in same phone but its not updating in other device even after kill the application.

Thanks

Crashes on iOS four finger Autotrack connection

Looking at the stack trace, it looks like it start executing in a random part of my code, after running the mixpanel code. I'm not sure if it's a compiler issue or something else.

Particularly, it looks like it's failing in getPropertyValue in ObjectSerializer.swift. selectorDescription.selectorName is "preferredContentSize", which starts execution of UINavigationController.preferredContentSize, which eventually executes my code HomeownerViewController.viewDidLoad() which causes the crash.

screen shot 2016-12-14 at 2 24 47 pm

Documentation not clear for use in app extensions

I have an iOS app, a watchOS extension, a message extension, a today extension and a notification extension.

Should I be specifying just:

pod 'Mixpanel-swift-appex', '~> 2.0'

or:

pod 'Mixpanel-swift', '~> 2.0'

For the app and the Mixpanel-swift-appex variant for the extension targets?

Will the distinct-id for my integration be the same across all the apps and extensions? Or is extra work required to achieve that. Thanks.

Stronger Type-safety and/or leniency for Properties

This one tripped me for a long while, because the crash it caused was only happening in production:

I was sending launchOptions as? [String: AnyObject] as properties in my app's didFinishLaunchingWithOptions, having read that Properties was just a typealias for [String: AnyObject].

For some possible values of launchOptions (say a UIApplicationShortcutItem), this is going to crash.

The library should either be more specific in its typing, or at least be lenient and not crash on unexpected input.

IMHO the number one goal of a library like this, is to never, ever trip the developers into unexpected crashes.

Thanks!

PS: would you say the library is production-ready yet? Have you heard of large-scale apps that have switched to it from the Obj-C one?

App Release ($app_release) and version ($app_version) not populated

We migrated from the objc library to this MixpanelSwift library as our project is moving to swift. With the 'old' mixpanel library, the $app_release and $app_version were populated automatically on each event (as documented here: https://mixpanel.com/help/questions/articles/what-properties-do-mixpanels-libraries-store-by-default

However, in this MixPanel-Swift library, they do not get populated anymore. They now always have the value 'undefined'.

Module compiled with Swift 3.0 cannot be imported in Swift 3.0.1

I've just updated to latest version of Xcode (8.0 => 8.1). Previously I had installed mixpanel-swift package with CocoaPods. It worked fine.

When I now build my project in Xcode 8.1, I get the following error :

Module compiled with Swift 3.0 cannot be imported in Swift 3.0.1: 

I tried to rerun both pod install and pod update. It didn't solve the issue. What should I do ? Thanks !

Cannot run project after upgrading to 2.1.4

I upgraded the framework to 2.1.4 and received the new MixpanelAppex framework, but as I don't need to use it in my iOS project, I have not integrated that framework into my project.

I have cleaned, and deleted build and derived data folder, but I receive the following error when running my project:
Found bundle at

Found bundle at 
/Users/<redacted>/Library/Developer/CoreSimulator/Devices/
<redacted>/data/Library/Caches/com.apple.mobile.installd.staging/temp.mCZKl6/extracted/
<redacted>.app/Frameworks/MixpanelAppex.framework 
with the same identifier (com.mixpanel.Mixpanel) as bundle at
/Users/<redacted>/Library/Developer/CoreSimulator/Devices/
<redacted>/data/Library/Caches/com.apple.mobile.installd.staging/temp.mCZKl6/extracted/
<redacted>.app/Frameworks/Mixpanel.framework

Add Swift 3.1 binray framework support in Carthage

*** Skipped installing mixpanel-swift.framework binary due to the error:
"Incompatible Swift version - framework was built with 3.0.2 and the local version is 3.1."

this warning raise when I run carthage update, I could build it by myself use the latest SDK, but it would be better for me download the binary framework directly.

Carthage doesn't build mixpanel-swift for the tvOS platform

Running carthage build --platform tvOS gives the following warning.
*** Skipped building mixpanel-swift due to the error: Dependency "mixpanel-swift" has no shared framework schemes for any of the platforms: tvOS

Solution:
Share the Mixpanel_tvOS target and check in Mixpanel_tvOS.xcscheme

Mixpanel.initialize breaks my UI

When I initialize Mixpanel in my AppDelegate, I find that I am unable to drag one of my UI elements. Mixpanel breaks the UI. Since Mixpanel has nothing to do with UI, this shouldn't happen. Right now, I'm forced to disable Mixpanel on iOS.

I've narrowed down the issue to this line:

        let mp = Mixpanel.initialize(token: "FOO")

This is an example project that reproduces the issue: https://github.com/btc/MixpanelLNPopupController/tree/master

Error while migrating to Swift 3

I am calling Mixpanel.mainInstance().track(event: name.rawValue, properties: dictionary), here error is dictionary as it is of type [String: AnyObject].
So should i forcefully make it to Properties?
Also that gives me error like cannot convert value of type [String: AnyObject] to type Properties? in coercion.

I am able to get rid of error if i change to [String: String]

Improve compile times

patch.txt

Compile times on this repo could be better. You can locate the slow spots using the following build command and checking the output on culprits.txt.

xcodebuild -scheme Mixpanel clean build OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies" | grep .[0-9]ms | grep -v ^0.[0-9]ms | sort -nr > culprits.txt

Here is the before:

1942.0ms    /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/SHA256.swift:132:10   final func calculate32() -> Array<UInt8>
1844.8ms    /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/SHA256.swift:132:10   final func calculate32() -> Array<UInt8>
1769.4ms    /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/MD5.swift:120:10  final func update<T : Sequence where T.Iterator.Element == UInt8>(withBytes bytes: T, isLast: Bool = default) throws -> Array<UInt8>
1697.9ms    /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/MD5.swift:120:10  final func update<T : Sequence where T.Iterator.Element == UInt8>(withBytes bytes: T, isLast: Bool = default) throws -> Array<UInt8>
1692.9ms    /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/SHA256.swift:207:44   (closure)
1598.3ms    /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/SHA256.swift:207:44   (closure)
594.8ms /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/UIViewSelectors.swift:80:10   @objc dynamic func mp_imageFingerprint() -> String?
568.3ms /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/UIViewSelectors.swift:80:10   @objc dynamic func mp_imageFingerprint() -> String?
211.6ms /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/ObjectSerializer.swift:31:10  func visitObject(_ object: AnyObject?, context: ObjectSerializerContext)
210.5ms /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/ObjectSerializer.swift:31:10  func visitObject(_ object: AnyObject?, context: ObjectSerializerContext)

Here is the after:

559.0ms /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/UIViewSelectors.swift:80:10   @objc dynamic func mp_imageFingerprint() -> String?
553.2ms /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/UIViewSelectors.swift:80:10   @objc dynamic func mp_imageFingerprint() -> String?
253.3ms /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/SHA256.swift:132:10   final func calculate32() -> Array<UInt8>
250.2ms /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/SHA256.swift:132:10   final func calculate32() -> Array<UInt8>
210.9ms /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/ObjectSerializer.swift:31:10  func visitObject(_ object: AnyObject?, context: ObjectSerializerContext)
203.0ms /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/ObjectSerializer.swift:31:10  func visitObject(_ object: AnyObject?, context: ObjectSerializerContext)
139.3ms /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/SHA256.swift:215:10   final func calculate64() -> Array<UInt8>
129.5ms /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/SHA256.swift:215:10   final func calculate64() -> Array<UInt8>
78.0ms  /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/Track.swift:24:10 func track(event: String?, properties: Properties? = default, eventsQueue: inout Queue, timedEvents: inout InternalProperties, superProperties: InternalProperties, distinctId: String, epochInterval: Double)
77.3ms  /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/MD5.swift:65:22   fileprivate final func process<C : Collection where C.Iterator.Element == UInt8, C.Index == Int>(block chunk: C, currentHash: inout Array<UInt32>)
76.8ms  /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/UIColorToNSString.swift:22:19 @objc override func transformedValue(_ value: Any?) -> Any?
75.0ms  /Users/kbarnes/GitHub/mixpanel-swift/Mixpanel/MD5.swift:65:22   fileprivate final func process<C : Collection where C.Iterator.Element == UInt8, C.Index == Int>(block chunk: C, currentHash: inout Array<UInt32>)

The attached patch is simple. It initializes a [UInt8] and appends that rather than doing in in one line. The additional type information given to the compiler allows it to run faster.

Cache files location for non-sandboxed macOS apps.

I've found out that Mixpanel stores its cache files to the ~/Library/Caches folder which is not the best location. It suits sandboxed apps because of their Containers, but I suggest to change the path to ~/Library/Caches/<bundle_id>/ to avoid possible issues.

312

What do you think? I can submit a PR once you agree.

Module compiled with Swift 3.0.2 cannot be imported in Swift 3.1

I use Carthage (0.20.1):
github "mixpanel/mixpanel-swift" ~> 2.1.5

and run
carthage update --platform iOS --no-use-binaries
(no error/warning message to run this command)

and clean folder of /Users/ouou/Library/Developer/Xcode/DerivedData
and clean project in Xcode

Then I got following compiling error on Xcode 8.3

:0: error: module compiled with Swift 3.0.2 cannot be imported in Swift 3.1: /Users/ouou/Documents/Project/epc-ios/Carthage/Build/iOS/Mixpanel.framework/Modules/Mixpanel.swiftmodule/x86_64.swiftmodule

[!] Unable to find a specification for `Mixpanel-swift-appex`

While attempting to migrate from Objective-C to Swift version of the library, I've faced the following issue.

My project uses Mixapanel for the App and the Appex, so my Podfile has this:

target 'Application' do
    pod 'Mixpanel-swift'
end

target 'Keyboard' do
    pod 'Mixpanel-swift-appex'
end

Running pod install, gives the error:

[!] Unable to find a specification for `Mixpanel-swift-appex`

Thanks to this SO answer, I did the workaround:

target 'Application' do
    pod 'Mixpanel-swift'
end

target 'Keyboard' do
    pod 'Mixpanel-swift-appex', :git => 'https://github.com/mixpanel/mixpanel-swift'
end

This works.

CocoaPods v1.1.0

Xcode 8.2: Legacy Code Settings

Issue to build with Xcode 8.2 because "Use legacy Swift Language Version" is undefined on the project build settings. I fixed by setting to "No"

exec_bad_access in mp_controllerVariable in UIViewSelectors.swift

I am getting exec_bad_access in UIViewSelectors.swift in this method

 func mp_controllerVariable() -> String? {
        if self is UIControl {
            var responder = self.next
            while responder != nil && !(responder is UIViewController) {
                responder = responder?.next
            }
            if let responder = responder {
                let mirrored_object = Mirror(reflecting: responder)

                for (_, attr) in mirrored_object.children.enumerated() {   ****  exec_bad_access


                    if let property_name = attr.label {
                        if let value = attr.value as? UIView, value == self {
                            return property_name
                        }
                    }
                }
            }
        }

mixpanel_error

Distinct id and email

Hi,

I am using the Swift SDK in an OSX app. I am setting the distinct Id to a user email address, and I can see the distinct ID being set correctly to this in the SDK, but this email doesnt come through in the live view when viewing the data.

Curiously enough when I set the distinct id to something like "1111" and not an email address, it seems to come through fine.

Is there some sort of restriction on the distinctID being an email address?

Even better, do you have a reference for what the format of the distinct ID should be?

Thanks

Tony

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.