Giter Club home page Giter Club logo

analytics-ios-integration-mixpanel's Introduction

Analytics

CircleCI Version License

Mixpanel integration for analytics-ios.

Installation

To install the Segment-Mixpanel integration, simply add this line to your CocoaPods Podfile:

pod "Segment-Mixpanel"

We recommended you specify or pin, at least, the major version of the pod, found in the CHANGELOG.md.

Usage

After adding the dependency, you must register the integration with our SDK. To do this, import the Mixpanel integration in your AppDelegate:

#import <Segment-Mixpanel/SEGMixpanelIntegrationFactory.h>

And add the following lines:

NSString *const SEGMENT_WRITE_KEY = @" ... ";
SEGAnalyticsConfiguration *config = [SEGAnalyticsConfiguration configurationWithWriteKey:SEGMENT_WRITE_KEY];

[config use:[SEGMixpanelIntegrationFactory instance]];

[SEGAnalytics setupWithConfiguration:config];

Developing

To test locally, use the Example implementation.

License

WWWWWW||WWWWWW
 W W W||W W W
      ||
    ( OO )__________
     /  |           \
    /o o|    MIT     \
    \___/||_||__||_|| *
         || ||  || ||
        _||_|| _||_||
       (__|__|(__|__|

The MIT License (MIT)

Copyright (c) 2014 Segment, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

analytics-ios-integration-mixpanel's People

Contributors

alanjcharles avatar brennan avatar briemcnally avatar bsneed avatar f2prateek avatar jaimal avatar ladanazita avatar mericsson avatar ollaashour avatar teresanesteby avatar wcjohnson11 avatar wesleydrobinson avatar

Stargazers

 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

analytics-ios-integration-mixpanel's Issues

Not able to view events in Mixpanel dashboard via analytics-ios-integration-mixpanel

Hi Team,
We have integrated analytics-ios-integration-mixpanel in code via pods. used the following code in swift for setup of analytics.

    let configuration = AnalyticsConfiguration(writeKey: self.segmentKey)
    configuration.use(SEGMixpanelIntegrationFactory.instance())
    Analytics.setup(with: configuration)

===============
After setup we used this following method to send events to segment.

   Analytics.shared().track(action, properties: superDict, options: ["integrations": ["All": true, "Mixpanel": true]])
   Analytics.shared().screen("login launched")

Still we are not able to see any events in Mixpanel in LiveView. Is there anything we are missing at configuration?

Please use instancetype instead of id return type

It would be helpful for your object return types, particularly in the AnalyticsLibraryNameIntegrationFactory methods, to return instancetype instead of id.

There's a longer, better explanation at NSHipster, but the short version is that instancetype is type-safe ("This will only ever be this type of object") and id is not ("What kind of object is this? ¯\_(ツ)_/¯"). This enhancement would be particularly helpful in integrating with Swift code, but it's best practice even in Obj-C.

Note: I've only filed this on this particular integration, but it'd probably be wise to update this across all your integrations.

User's in MixPanel have no userId or id set

We have an iOS app that has a 'create account' flow and a 'sign in' flow.

Create account

analytics.alias("our_user_guid")
analytics.identify("our_user_guid", traits: traitsMap)

Sign in

analytics.identify("our_user_guid", traits: traitsMap)

In the Segment debugger, we see the alias and identify calls with the userId correctly set. We also see track events with the userId attached to them correctly.

In the MixPanel user profiles, we see the users created within the app, they have all the traits (name, email etc.) however they have no userId or id attached to them, only the distinctId (MixPanel anonymous Id). Events from the app also have no userId mentioned.

All users/events from our web app using the JS Segment are working correctly in MixPanel and comparing things in the Segment debugger between iOS and web appear completely identical.

I am starting to wonder if there is an issue in the iOS Segment MixPanel integration, or if we are misunderstanding something in the Segment or MixPanel documentation. I would much appreciate some help with this.

Thanks.

Edit
From further investigation, the events after creating account (identify calls from above) come through with 'user_id' set to the MixPanel distinctId. This is not our user_guid that we provided to the identify call. This means we cannot search for our user ID in any MixPanel events or user profiles.

After sign in, events come through with 'user_id' set to our user_guid (passed to identify call) and so these events can be searched for with our user_guid.

The alias call that is triggered on account creation just before identify call is resulting in some strange behaviour with regards to user IDs.

Please add nullability annotations

It would be very helpful to add nullability annotation support so that the llvm compiler can yell at developers for you when they try to perform something unsupported. This would be particularly helpful with swift, but it also works to a more limited extent with Objective-C.

Again as with #2, I have only filed this on this integration, but it would be helpful to add this across all integrations.

Issues with Main Thread Sanitizer

Our app is reporting that Segment-Mixpanel is accessing UI code from the wrong thread in Xcode 9. Here's the stack trace it gives:

PID: 9001, TID: 6833697, Thread name: (none), Queue name: io.segment.analytics, QoS: 0
Backtrace:
4   Mixpanel                            0x00000001124ad894 -[Mixpanel setupAutomaticPushTracking] + 84
5   Mixpanel                            0x00000001124aa248 -[Mixpanel initWithToken:launchOptions:andFlushInterval:] + 2040
6   Mixpanel                            0x00000001124a9111 +[Mixpanel sharedInstanceWithToken:launchOptions:] + 241
7   Segment_Mixpanel                    0x00000001133bd11c -[SEGMixpanelIntegration initWithSettings:andLaunchOptions:] + 316
8   Segment_Mixpanel                    0x00000001133c01b8 -[SEGMixpanelIntegrationFactory createWithSettings:forAnalytics:] + 168
9   Analytics                           0x000000010fd85733 __57-[SEGIntegrationsManager updateIntegrationsWithSettings:]_block_invoke + 579
10  Analytics                           0x000000010fd7d2f1 __seg_dispatch_specific_block_invoke + 49
11  Analytics                           0x000000010fd7d23e seg_dispatch_specific + 206
12  Analytics                           0x000000010fd7d435 seg_dispatch_specific_sync + 85
13  Analytics                           0x000000010fd854b0 -[SEGIntegrationsManager updateIntegrationsWithSettings:] + 176
14  Analytics                           0x000000010fd853c6 -[SEGIntegrationsManager setCachedSettings:] + 278
15  Analytics                           0x000000010fd85ebd __41-[SEGIntegrationsManager refreshSettings]_block_invoke_3 + 77
16  Analytics                           0x000000010fd7d2f1 __seg_dispatch_specific_block_invoke + 49
17  libdispatch.dylib                   0x000000011adc2273 _dispatch_call_block_and_release + 12
18  libdispatch.dylib                   0x000000011adc32b5 _dispatch_client_callout + 8
19  libdispatch.dylib                   0x000000011adcae3f _dispatch_queue_serial_drain + 654
20  libdispatch.dylib                   0x000000011adcb690 _dispatch_queue_invoke + 329
21  libdispatch.dylib                   0x000000011adcda72 _dispatch_root_queue_drain + 568
22  libdispatch.dylib                   0x000000011adcd7dc _dispatch_worker_thread3 + 119
23  libsystem_pthread.dylib             0x000000011b2821ca _pthread_wqthread + 1387
24  libsystem_pthread.dylib             0x000000011b281c4d start_wqthread + 13

Seems the issue is that SEGIntegrationsManager updateIntegrationsWithSettings is using it's own queue, which eventually hits Mixpanel's initialization code, which accesses UIApplication.shared. delegate.

I'm honestly not sure which project the fix should belong to, but I wanted to raise the issue since we've been seeing it every time the app launches.

Crash

I have installed your pod using : pod "Segment-Mixpanel"

And I am tracking events using:
[[SEGAnalytics sharedAnalytics] track:@"EVENT_NAME"];

Now my app crashes in Mixpanel lbrary (IN CLASS: Mixpanel.m on line number 482) :

  •                      0x0000000100208e24 __38-[Mixpanel setupAutomaticPushTracking]_block_invoke_2 (Mixpanel.m:482) 
    
  •                   0x000000010022de74 mp_swizzledMethod_4 (MPSwizzler.m:75)
    

The reason for crash it gives is:
-[__NSDictionaryI notification]: unrecognized selector sent to instance 0x174e73ec0

Please fix this asap. The crash is appearing in iOS 10 only and not iOS 9

Thanks!

Settings user traits of anonymous user before alias and identify are called

In our app we use install attribution (Branch) which triggers an asynchronous callback shortly after first app launch. In this callback I want to set certain user traits such as installSource and installCampaign. At this point the user isn't logged in yet and I do not have a valid userId yet.

The code looks somewhat like that (note the identify:nil):

// Set user traits so we can segment the user by acquisition channel later
[[SEGAnalytics sharedAnalytics] identify:nil traits:@{
   @"installSource": params[@"~channel"] ? params[@"~channel"] : @"",
   @"installCampaign": params[@"~campaign"] ? params[@"~campaign"] : @"",
   @"installAdGroup": params[@"$marketing_title"] ? params[@"$marketing_title"] : @"",
   @"installAdProvider": @"Branch"
}];

Once the user finally logs in I'm calling alias and identify like this (whereas [self getUserId] return our server-side generated user ID):

[[SEGAnalytics sharedAnalytics] alias:[self getUserId]];
[[SEGAnalytics sharedAnalytics] identify:[self getUserId] traits:@{@"createdAt": [NSDate date], @"userId": [self getUserId]}];

In cases in which the install attribution callback is invoked after identifying the user everything works as expected. However, in most cases the callback is called before the user logs in. In this case none of the traits get set in MixPanel. Events sent either before or after the alias and the identify call are tracked and show up as expected though. Only the traits get lost.

I'm trying to figure out where things are going wrong. From my understanding of the Segment SDK itself it should be possible to set the traits this way even before the user is first identified. So is this a bug in the Mixpanel-Segment-Integration?

The versions used are:

  - Analytics (3.5.5)
  - Mixpanel (3.0.8):
  - Segment-Mixpanel (1.1.0):

segment-mixpanel issue on ios 15

*** -[NSKeyedUnarchiver validateAllowedClass:forKey:]: NSSecureCoding allowed classes list contains [NSObject class], which bypasses security by allowing any Objective-C class to be implicitly decoded. Consider reducing the scope of allowed classes during decoding by listing only the classes you expect to decode, or a more specific base class than NSObject. This will become an error in the future. Allowed class list: {(
"'NSObject' (0x1d9805e30) [/usr/lib]"
)}

Updated to 1.7.2 and seeing this issue in runtime. App is working but it's showing a runtime issue.

Use Mixpanel developer tweaks

Using developer tweaks in Mixpanel as described here doesn't seem to work (Mixpanel never receives the information). Is there any further steps to do?

Support initializing Mixpanel with signal handlers, crash tracking

Currently the Mixpanel shared instance object is created using the function [sharedInstanceWithToken: launchOptions:] which applies default values of YES to trackCrashes and automaticPushTracking but Crashlytics sometimes complains about multiple signal handlers in play at once. Since Mixpanel's library (MixpanelExceptionHandler class) does not support removing a handler after added could a new method be added ?

Current:

-(instancetype)initWithSettings:(NSDictionary *)settings andLaunchOptions:(NSDictionary *)launchOptions
{

    if (self= [super init]) {
        self.settings = settings;
        NSString *token = [self.settings objectForKey:@"token"];
        self.mixpanel = [Mixpanel sharedInstanceWithToken:token launchOptions:launchOptions];
    }
    return self;
}

Proposed:

-(instancetype)initWithSettings:(NSDictionary *)settings andLaunchOptions:(NSDictionary *)launchOptions trackCrashes:(BOOL) trackCrashes automaticPushTracking: (BOOL)automaticPushTracking
{

    if (self= [super init]) {
        self.settings = settings;
        NSString *token = [self.settings objectForKey:@"token"];
        self.mixpanel = [Mixpanel sharedInstanceWithToken:token launchOptions:launchOptions trackCrashes: trackCrashes automaticPushTracking: automaticPushTracking];
    }
    return self;
}

-(instancetype)initWithSettings:(NSDictionary *)settings andLaunchOptions:(NSDictionary *)launchOptions
{
    return [self initWithSettings:settings andLaunchOptions:launchOptions trackCrashes:YES automaticPushTracking:YES];
}

Support Mixpanel-Swift

We use Mixpanel for our internal analytics and Segment with Mixpanel for our customer analytics (in our platform).

And we want to upgrade mixpanel to use their new Mixpanel-Swift pod instead of the old Obj-C one and I was wondering if there is any way to support using the swift library with segment (right now the spec marks the Obj-C one as a dependency)

Thanks

Add compatibility to Mixpanel 3.5

Mixpanel 3.4.x has a knows issue on iOS 13 (mixpanel/mixpanel-iphone#867), which was addressed by version 3.5.0. Unfortunately, your PodSpec references '~> 3.4.7', which means it is not possible to use Mixpanel 3.5.0 with the current version of your library.
Could you please update it?

Not sending call to Mixpanel because it doesn't respond to applicationDidBecomeActive.

Hello,

I'm having trouble getting AB tests running on our iOS segment-mixpanel integration. We're seeing the below line in the logs:

Not sending call to Mixpanel because it doesn't respond to applicationDidBecomeActive.

However, it appears that mixpanel utilizes this function to get the latest AB test data. (quoted from that link: "Mixpanel checks for any new experiments asynchronously on applicationDidBecomeActive")

i don't see how AB tests could be working with the current integration. am i missing something?

Mixpanel-AutoTrack not working on latest version

Currently Mixpanel SDK starting from 5.0+ the autoTrack value should be passed through the code during the initialization of SDK as their docs say
`#import "Mixpanel/Mixpanel.h"

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    ...
    [Mixpanel sharedInstanceWithToken:@"YOUR_API_TOKEN" trackAutomaticEvents:YES];
    ...
    }`
    currently the SEGMixpanelIntegration when call initWithSettings the value of the autoTrack is set false by default and there is no way to pass this value during the init of the factory

Could not build Objective-C module for Mixpanel pod after updating to Swift 3.0

Integration Method: CocoaPods v0.39.0
Xcode Version: 8.0
Library Version: 1.1.0
Platform: iOS
Device: Simulator / iPad
Language: Swift

Description:
After updating my swift app to swift 3.0 / Xcode 8 I have been unable to import Segment_Mixpanel. The pod is integrated, and seems to be built as a framework but when I import I have 3 errors:

  • Mixpanel.h file not found (in MixpanelPrivate.h)
  • Could not build Objective-C module 'Mixpanel' (in SEGMixpanelIntegration.h)
  • Could not build Objective-C module 'Segment_Mixpanel' (shown wherever import is in my code)

I have raised this issue with on the mixpanel-iphone repo as well (mixpanel/mixpanel-iphone#584) as I'm not sure where the best place for a fix is but also listing here in case there is anything that can be done in this repo.

I had hoped a simple fix might be to use the swift mixpanel library from this library but mixpanel doesn't expose anything to objective c for that version

Expected Behavior:
Segment_Mixpanel should be able to be imported in a swift 3 code base and used as it was from the swift 2.2 app

[1.0.2] Crash in identify with analytics 3.0.4

2016-01-07 14:29:39.296 App[50163:5972653] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010697ce65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010a656deb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010697cd9d +[NSException raise:format:] + 205
    3   CoreFoundation                      0x00000001068a9863 -[__NSCFDictionary setObject:forKey:] + 99
    4   CoreFoundation                      0x0000000106898a8d -[NSMutableDictionary addEntriesFromDictionary:] + 301
    5   Analytics                           0x0000000105fa1b7d __35-[SEGSegmentIntegration addTraits:]_block_invoke + 77
    6   Analytics                           0x0000000105f99165 seg_dispatch_specific + 117
    7   Analytics                           0x0000000105f99212 seg_dispatch_specific_async + 82
    8   Analytics                           0x0000000105fa0f6f -[SEGSegmentIntegration dispatchBackground:] + 63
    9   Analytics                           0x0000000105fa1ae5 -[SEGSegmentIntegration addTraits:] + 181
    10  Analytics                           0x0000000105fa2065 __34-[SEGSegmentIntegration identify:]_block_invoke + 165
    11  libdispatch.dylib                   0x000000010b130e5d _dispatch_call_block_and_release + 12
    12  libdispatch.dylib                   0x000000010b15149b _dispatch_client_callout + 8
    13  libdispatch.dylib                   0x000000010b1378ec _dispatch_queue_drain + 2215
    14  libdispatch.dylib                   0x000000010b136e0d _dispatch_queue_invoke + 601
    15  libdispatch.dylib                   0x000000010b139a56 _dispatch_root_queue_drain + 1420
    16  libdispatch.dylib                   0x000000010b1394c5 _dispatch_worker_thread3 + 111
    17  libsystem_pthread.dylib             0x000000010b49f4f2 _pthread_wqthread + 1129
    18  libsystem_pthread.dylib             0x000000010b49d375 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException

image
image

Not seeing 'mixpanel' in events sent by app

Hey there -
I am bundling Segment-mixpanel with my iOS app through a cocoapod:

  pod 'Segment-Mixpanel'

I have enabled Mixpanel integration with this project on the segment dashboard.
We are seeing events show up in segment and those events are propagated through to Mixpanel.

But, according to a conversation I just had with someone at Segment, Mixpanel is not properly bundled with our iOS App because the detailed 'raw' view of events from our app says nothing out Mixpanel integration:

{
  "messageId": "048BB5DD-C275-4076-A036-E720F8D2541A",
  "anonymousId": "145E9A34-7294-4ED0-AC2D-A3F6BDC4B5E0",
  "userId": "gamREsG",
  "context": {
    "screen": {
      "width": 414,
      "height": 736
    },
    "device": {
      "manufacturer": "Apple",
      "model": "x86_64",
      "id": "D0A2B4AA-80BE-4401-ABC2-C160AED0BADC",
      "advertisingId": "D397B299-0969-4808-8604-3AC60DC83AE2",
      "adTrackingEnabled": true,
      "type": "ios"
    },
    "os": {
      "name": "iPhone OS",
      "version": "9.2"
    },
    "app": {
      "build": "63",
      "namespace": "com.zeemee.ZeeMee",
      "name": "",
      "version": "1.5"
    },
    "locale": "en-US",
    "library": {
      "name": "analytics-ios",
      "version": "3.0.7"
    },
    "timezone": "America/Los_Angeles",
    "traits": {
      "email": "[email protected]",
      "typeable_id": "gamREsG",
      "slug": "reggiebarnes",
      "account_type": "Student",
      "name": "3 Doug Barnes"
    },
    "network": {
      "wifi": true,
      "cellular": false,
      "bluetooth": false
    },
    "ip": "24.5.9.198"
  },
  "properties": {
    "applicationDetails": "iOS",
    "applicationType": "native_mobile_app"
  },
  "type": "screen",
  "timestamp": "2016-02-16T23:12:25.171Z",
  "name": "VC_ID_ZMCommunities",
  "integrations": {
    "Segment.io": false
  },
  "writeKey": "PhA2lfToZOHsSZq2p8JgnrfrVC37HcP4",
  "sentAt": "2016-02-16T23:12:24.000Z",
  "receivedAt": "2016-02-16T23:12:25.171Z",
  "originalTimestamp": "2016-02-16T15:12:24-0800"
}

According to person-at-segment, if Mixpanel were properly bundled, I'd see something about Mixpanel in the 'integrations' clause above.

So what else do I need to do to? Is there some kind of extra Mixpanel-specific code I need to add so that my app will send mixpanel-friendly events?

Legacy tags creating confusion for CocoaPods

Some older releases have version number higher than newer releases, creating confusion for CocoaPods, who thinks there is an update to the pod. It would be cool if those could be cleaned up.
screen shot 2017-06-23 at 11 25 10 am

Swift Package Manager support

When using Xcode 11 many developers will inevitably be moving dependencies over to the Swift Package Manager instead of using Cocoapods.

Integrations don't work!

You have cool idea and it looks very nice.

But when I try integrate any tools I have same problem 'Segment-Amplitude/SEGAmplitudeIntegrationFactory.h' file not found same problem for Mixpanel and other services.

I use swift4 and xcode 9.3.1. Do you have any suggestions?

Thanks

Impossible to use mixpanel with swift 3.0

Podfile

# Uncomment this line to define a global platform for your project
swift_version = "3.0"
platform :ios, '9.0'
# Uncomment this line if you're using Swift
use_frameworks!

def libs
    ...
    pod 'Analytics', '~> 3.6.5'
    pod 'Segment-Mixpanel', '1.2.0'
    ...
end

Project-Bridging-Header.h

#import <Segment-Mixpanel/SEGMixpanelIntegrationFactory.h>

error

/Users/xxx/my_project/Panda-Bridging-Header.h:10:9: 'Segment-Mixpanel/SEGMixpanelIntegrationFactory.h' file not found

EXC BAD ACCESS

Hey guys I have an issue on this part of code which is a part of analytics:

- (void)persistQueue
{
[[NSUserDefaults standardUserDefaults] setValue:[self.queue copy] forKey:SEGQueueKey];
[[self.queue copy] writeToURL:self.queueURL atomically:YES];
}

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.