Skip to content

Commit 813fee5

Browse files
committed
Fixes for migration - Batch 2.3
1 parent f5e64b4 commit 813fee5

18 files changed

+61
-60
lines changed

src/connections/sources/catalog/libraries/mobile/kotlin-android/destination-plugins/mixpanel-kotlin-android.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ title: Analytics Kotlin Mixpanel Plugin
33
strat: kotlin-android
44
---
55

6-
[Mixpanel](https://mixpanel.com/?utm_source=segmentio&utm_medium=docs&utm_campaign=partners){:target="_blank”} is an event-tracking and segmentation platform for your web and mobile apps. By analyzing the actions your users perform, you can gain a better understanding to drive retention, engagement, and conversion. The client-side Mixpanel Destination code is open-source.
6+
[Mixpanel](https://mixpanel.com/?utm_source=segmentio&utm_medium=docs&utm_campaign=partners){:target="\_blank”} is an event-tracking and segmentation platform for your web and mobile apps. By analyzing the actions your users perform, you can gain a better understanding to drive retention, engagement, and conversion. The client-side Mixpanel Destination code is open-source.
77

8-
Segment's Mixpanel destination plugin code is open source and [available on GitHub](https://github.com/segment-integrations/analytics-kotlin-mixpanel){:target="_blank"}.
8+
Segment's Mixpanel destination plugin code is open source and [available on GitHub](https://github.com/segment-integrations/analytics-kotlin-mixpanel){:target="\_blank"}.
99

1010
## Getting Started
1111

12-
13-
1412
1. From the Segment app Destinations page click on **Add Destination**.
1513
2. Search for Mixpanel in the Destinations Catalog and confirm the Source to connect to.
1614
3. Copy your Mixpanel "API Secret" and "Token", and paste them into the Connection Settings in Segment.
@@ -30,11 +28,9 @@ Or the following for Kotlin DSL
3028
implementation('com.segment.analytics.kotlin.destinations:mixpanel:<latest_version>')
3129
```
3230

33-
34-
3531
## Using the Plugin in your App
3632

37-
Open the file where you setup and configure the Analytics-Kotlin library. Add this plugin to the list of imports.
33+
Open the file where you setup and configure the Analytics-Kotlin library. Add this plugin to the list of imports.
3834

3935
```
4036
import com.segment.analytics.kotlin.destinations.mixpanel.MixpanelDestination
@@ -67,12 +63,11 @@ analytics.identify("user-123", buildJsonObject {
6763
The first thing you'll want to do is to identify your users so Mixpanel knows who they are. You'll use the Identify method to accomplish this which takes the unique `userId` of a user and any `traits` you know about them.
6864

6965
> info ""
70-
> **Important:** Mixpanel used to require that you call `alias` in all libraries to connect anonymous visitors to identified users. However, with the release of Mixpanel's new [Identity Merge feature](https://help.mixpanel.com/hc/en-us/articles/360039133851#enable-id-merge){:target="_blank"} this is no longer necessary. To enable ID Merge, go to your Mixpanel Settings Dashboard, navigate to **Project Settings > Identity Merge** and enable the setting from that screen. If you are _not_ using this setting, use the instructions below.
71-
66+
> **Important:** Mixpanel used to require that you call `alias` in all libraries to connect anonymous visitors to identified users. However, with the release of Mixpanel's new [Identity Merge feature](https://help.mixpanel.com/hc/en-us/articles/360039133851#enable-id-merge){:target="_blank"} this is no longer necessary. To enable ID Merge, go to your Mixpanel Settings Dashboard, navigate to **Project Settings > Identity Merge** and enable the setting from that screen. If you are \_not_ using this setting, use the instructions below.
7267
7368
As soon as you have a `userId` for a visitor that was previously anonymous you'll need to [`alias`](/docs/connections/spec/alias/) their old anonymous `id` to the new `userId`. In Mixpanel only **one** anonymous user history can be merged to **one** identified user. For that reason you should only call `alias` once, right after a user registered, but before the first `identify`.
7469

75-
When you call the Identify method from the client in either a browser using Analytics.js or one a mobile SDKs, several things occur: Segment recognizes and translates the [special traits](/docs/connections/spec/identify/#traits) so that they fit the expectations of Mixpanel's API. The table below shows the mappings. Pass the key on the left and Segment transforms it to the key on the right before sending to Mixpanel.
70+
When you call the Identify method from the client in either a browser using Analytics.js or one a mobile SDKs, several things occur: Segment recognizes and translates the [special traits](/docs/connections/spec/identify/#traits) so that they fit the expectations of Mixpanel's API. The table below shows the mappings. Pass the key on the left and Segment transforms it to the key on the right before sending to Mixpanel.
7671

7772
<table>
7873
<tr>
@@ -117,7 +112,7 @@ Group calls are sent to Mixpanel if, **and only if**,
117112

118113
1. The Group Identifier Traits setting has one or more traits saved in the destination settings for Mixpanel.
119114
![Group ID Traits](/docs/connections/destinations/catalog/mixpanel/images/mixpanel-group-id-traits.png)
120-
2. You have created a group key of the same name in your Mixpanel [project settings](https://help.mixpanel.com/hc/en-us/articles/360025333632-Group-Analytics#implementation){:target="_blank"}.
115+
2. You have created a group key of the same name in your Mixpanel [project settings](https://help.mixpanel.com/hc/en-us/articles/360025333632-Group-Analytics#implementation){:target="\_blank"}.
121116
3. A Group trait with the same name as one of the configured Group Identifier Traits is sent with the group call.
122117

123118
```swift
@@ -128,7 +123,7 @@ analytics.group("user-123", buildJsonObject {
128123
});
129124
```
130125

131-
Mixpanel supports multiple definitions of groups. For more information see [Mixpanel's Group Analytics documentation](https://help.mixpanel.com/hc/en-us/articles/360025333632-Group-Analytics){:target="_blank"}.
126+
Mixpanel supports multiple definitions of groups. For more information see [Mixpanel's Group Analytics documentation](https://help.mixpanel.com/hc/en-us/articles/360025333632-Group-Analytics){:target="\_blank"}.
132127

133128
If the group call **does not** have a group trait that matches the Group Identifier Traits setting, then the event will be ignored.
134129

@@ -157,6 +152,7 @@ analytics.track("View Product", buildJsonObject {
157152
put("productName" "Striped trousers")
158153
});
159154
```
155+
160156
Because Mixpanel is an event tracking analytics tool, you'll want to [`track`](/docs/connections/spec/track/) your user's actions. The more useful events you [`track`](/docs/connections/spec/track/), the better Mixpanel becomes.
161157

162158
You should use the [`track`](/docs/connections/spec/track/) method to accomplish this. The Segment [`track`](/docs/connections/spec/track/) method maps events and event properties directly to Mixpanel events and event properties.
@@ -173,22 +169,21 @@ There are two strings to avoid when naming event properties that will be sent to
173169

174170
Previously, Segment set all traits and properties as both Super Properties and People Properties (If you had Mixpanel People enabled). Now Mixpanel allows you to segment your reports by both People Properties and Super Properties. To give you better precision and control over what property or trait gets set as a Super Property or People Property, you can disable **Set All Traits as Super Properties or People Properties By Default** and pass in the properties or traits that you want to send to Mixpanel as People or Super Properties as shown below. Segment passes through all of Mixpanel's special traits as People Properties so you only need to add the ones that aren't on [this list](#group-using-device-mode).
175171

176-
177-
![mixpanel people properties list](images/mixpanelpeoplesuperprops.png)
172+
![mixpanel people properties list](/docs/connections/destinations/catalog/mixpanel/images/mixpanelpeoplesuperprops.png)
178173

179174
### Incrementing events
180175

181176
You don't need to add extra code to increment event counts for Mixpanel people, as long as they are "known users". Supply the events that should be incremented.
182177

183-
![mixpanel increment events list](images/mixpanelincrementinpeople.png)
178+
![mixpanel increment events list](/docs/connections/destinations/catalog/mixpanel/images/mixpanelincrementinpeople.png)
184179

185180
You can find this in the **Advanced Options** of your Mixpanel settings on your Segment Destinations page.
186181

187182
For each event name listed, Segment calls Mixpanel `increment`, and set a user trait of `Last + {{ event.name }}`.
188183

189184
For example, if you add **Logged In** to the list of increment events, Segment increments a user trait called **Logged In** and set a trait called **Last Logged In** with the current date and time.
190185

191-
If you'd like to add an increment for viewing a specific page or screen, ensure you have the setting "Track Named Pages" selected and use the dynamically generated event name under "Events to Increment in People." For example, `.page('Signup')` would translate to "*Viewed* Signup *Page*" and `.screen('Listing')` would translate to "*Viewed* Listing *Screen*".
186+
If you'd like to add an increment for viewing a specific page or screen, ensure you have the setting "Track Named Pages" selected and use the dynamically generated event name under "Events to Increment in People." For example, `.page('Signup')` would translate to "_Viewed_ Signup _Page_" and `.screen('Listing')` would translate to "_Viewed_ Listing _Screen_".
192187

193188
Remember, Segment sends one event per `page` call.
194189

@@ -232,4 +227,4 @@ If you're testing in Xcode remember you must first background the app, then the
232227
Push notifications are only available for projects bundling the Segment-Mixpanel SDK.
233228

234229
> info ""
235-
> Set up your push notification handlers by calling into native Mixpanel methods. You can read more about how to approach this in [Android] (/docs/connections/sources/catalog/libraries/mobile/android/android-faqs/#how-can-i-use-a-destination-specific-feature)
230+
> Set up your push notification handlers by calling into native Mixpanel methods. You can read more about how to approach this in [Android] (/docs/connections/sources/catalog/libraries/mobile/android/android-faqs/#how-can-i-use-a-destination-specific-feature)

src/connections/sources/catalog/libraries/mobile/kotlin-android/kotlin-android-faq.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ The core Segment SDK is extremely lightweight. The JAR weighs in at 12.3KB.
3030
## How should I configure Proguard?
3131

3232
For the Segment SDKs, you can add the following snippet to your Proguard configuration:
33+
3334
```
3435
- keep class com.segment.analytics.** { *; }
3536
- keep class androidx.lifecycle.DefaultLifecycleObserver
@@ -49,42 +50,45 @@ Yes. Please refer to the [Java Compatibility](https://github.com/segmentio/analy
4950

5051
If you're on a version prior to `1.10.4`, the SDK internally uses a number of Java 8 language APIs through desugaring (see [Java 8+ API](https://developer.android.com/studio/write/java8-support#library-desugaring) desugaring support). Please make sure your project either uses Android Gradle plugin 4.0.0 or higher, has a minimum API level of 26, or is upgraded to the latest SDK.
5152

52-
5353
## My deeplinks are not tracked?
5454

55-
5655
While Analytics Kotlin will automatically track deep links that open your app when the `trackDeepLinks` Configuration property is set to `true`. There are some situations when the app is already open that could cause a deep link open event to be missed.
5756

5857
The `openUrl` function allows you to manually track that a deep link has opened your app while your app was already open:
5958

59+
```
60+
override fun onNewIntent(intent: Intent?) {
61+
super.onNewIntent(intent)
62+
63+
// Add a deep-link opened event manually.
64+
// This is necessary when your Activity has a android:launchMode of
65+
// 'singleInstance', 'singleInstancePerTask', 'singleTop', or any other mode
66+
// that will re-use an existing Activity instead of creating a new instance.
67+
// The Analytics SDK automatically identifies when you app is started from
68+
// a deep link if the Activity is created, but not if it is re-used. Therefore
69+
// we have to add this code to manually capture the Deep Link info.
70+
71+
val referrer = "unknown"
72+
analytics.trackDeepLinkOpen(referrer, intent)
73+
}
74+
```
6075

61-
override fun onNewIntent(intent: Intent?) {
62-
super.onNewIntent(intent)
63-
64-
// Add a deep-link opened event manually.
65-
// This is necessary when your Activity has a android:launchMode of
66-
// 'singleInstance', 'singleInstancePerTask', 'singleTop', or any other mode
67-
// that will re-use an existing Activity instead of creating a new instance.
68-
// The Analytics SDK automatically identifies when you app is started from
69-
// a deep link if the Activity is created, but not if it is re-used. Therefore
70-
// we have to add this code to manually capture the Deep Link info.
71-
72-
val referrer = "unknown"
73-
analytics.trackDeepLinkOpen(referrer, intent)
74-
}
75-
76-
Note: Due to the way deep links are handled in Android, we can not know the referrer when a deep link causes `onNewIntent()` to be fired instead of `onCreate()`.
76+
Note: Due to the way deep links are handled in Android, we can not know the referrer when a deep link causes `onNewIntent()` to be fired instead of `onCreate()`.
7777

7878
For a sample implementation see our [Kotlin Sample App](https://github.com/segmentio/analytics-kotlin/tree/main/samples/kotlin-android-app).
7979

8080
## Will I still see device-mode integrations listed as `false` in the integrations object?
81+
8182
When you successfully package a plugin in device-mode, you will no longer see the integration listed as `false` in the integrations object for a Segment event. This logic is now packaged in the event metadata, and is not surfaced in the Segment debugger.
8283

8384
## What is the instanceId set in context?
84-
The instanceId was introduced in [V 1.10.1](https://github.com/segmentio/analytics-kotlin/releases/tag/1.10.1){:target="_blank"} and correlates events to a particular instance of the client in a scenario when you might have multiple instances on a single app.
85+
86+
The instanceId was introduced in [V 1.10.1](https://github.com/segmentio/analytics-kotlin/releases/tag/1.10.1){:target="\_blank"} and correlates events to a particular instance of the client in a scenario when you might have multiple instances on a single app.
8587

8688
## How should I configure my proxy URL?
89+
8790
To proxy events to Segment's API, you can configure your proxy URL via the `requestFactory` setting:
91+
8892
```
8993
Analytics(BuildConfig.SEGMENT_WRITE_KEY, androidContext()) {
9094
trackApplicationLifecycleEvents = true
@@ -104,4 +108,4 @@ Analytics(BuildConfig.SEGMENT_WRITE_KEY, androidContext()) {
104108
}
105109
```
106110

107-
When proxying your events, you must forward the batched events to `https://api.segment.io/v1/b`. The `https://api.segment.io/v1/batch` endpoint is reserved for events arriving from server side sending, and proxying to that endpoint for your mobile events may result in unexpected behavior.
111+
When proxying your events, you must forward the batched events to `https://api.segment.io/v1/b`. The `https://api.segment.io/v1/batch` endpoint is reserved for events arriving from server side sending, and proxying to that endpoint for your mobile events may result in unexpected behavior.

0 commit comments

Comments
 (0)