@@ -51,6 +51,7 @@ SOFTWARE.
51
51
@Serializable
52
52
data class MixpanelSettings (
53
53
var token : String ,
54
+ var enableEuropeanUnionEndpoint : Boolean = false ,
54
55
@SerialName(" people" )
55
56
var isPeopleEnabled : Boolean = false ,
56
57
var setAllTraitsByDefault : Boolean = true ,
@@ -71,7 +72,7 @@ class MixpanelDestination(
71
72
private val context : Context
72
73
) : DestinationPlugin(), AndroidLifecycle, VersionedPlugin {
73
74
74
- internal var settings : MixpanelSettings ? = null
75
+ internal var mixpanelSettings : MixpanelSettings ? = null
75
76
internal var mixpanel: MixpanelAPI ? = null
76
77
77
78
override val key: String = " Mixpanel"
@@ -80,13 +81,18 @@ class MixpanelDestination(
80
81
super .update(settings, type)
81
82
if (settings.hasIntegrationSettings(this )) {
82
83
analytics.log(" Mixpanel Destination is enabled" )
83
- this .settings = settings.destinationSettings(key)
84
+ this .mixpanelSettings = settings.destinationSettings(key)
84
85
if (type == Plugin .UpdateType .Initial ) {
85
86
mixpanel = MixpanelAPI .getInstance(
86
87
context,
87
- this .settings ?.token,
88
- this .settings ?.trackAutomaticEvents ? : false
88
+ this .mixpanelSettings ?.token,
89
+ this .mixpanelSettings ?.trackAutomaticEvents ? : false
89
90
)
91
+
92
+ if (mixpanelSettings?.enableEuropeanUnionEndpoint == true ) {
93
+ mixpanel?.setServerURL(" https://api-eu.mixpanel.com" )
94
+ }
95
+
90
96
analytics.log(" Mixpanel Destination loaded" )
91
97
}
92
98
} else {
@@ -95,7 +101,7 @@ class MixpanelDestination(
95
101
}
96
102
97
103
override fun track (payload : TrackEvent ): BaseEvent {
98
- val settings = settings ? : return payload
104
+ val settings = mixpanelSettings ? : return payload
99
105
// Example of transforming event property keys
100
106
val eventName = payload.event
101
107
val properties = payload.properties
@@ -113,7 +119,7 @@ class MixpanelDestination(
113
119
}
114
120
115
121
override fun identify (payload : IdentifyEvent ): BaseEvent {
116
- val settings = settings ? : return payload
122
+ val settings = mixpanelSettings ? : return payload
117
123
val userId: String = payload.userId
118
124
val traits: JsonObject = payload.traits
119
125
@@ -193,7 +199,7 @@ class MixpanelDestination(
193
199
}
194
200
195
201
override fun screen (payload : ScreenEvent ): BaseEvent {
196
- val settings = settings ? : return payload
202
+ val settings = mixpanelSettings ? : return payload
197
203
val screenName = payload.name
198
204
val properties = payload.properties
199
205
val screenCategory = payload.category
@@ -218,15 +224,15 @@ class MixpanelDestination(
218
224
}
219
225
220
226
override fun onActivityCreated (activity : Activity ? , savedInstanceState : Bundle ? ) {
221
- val settings = settings ? : return
227
+ val settings = mixpanelSettings ? : return
222
228
// This is needed to trigger a call to #checkIntentForInboundAppLink.
223
229
// From Mixpanel's source, this won't trigger a creation of another instance. It caches
224
230
// instances by the application context and token, both of which remain the same.
225
231
MixpanelAPI .getInstance(
226
232
activity,
227
233
settings.token,
228
234
false ,
229
- this .settings ?.trackAutomaticEvents ? : false
235
+ this .mixpanelSettings ?.trackAutomaticEvents ? : false
230
236
)
231
237
}
232
238
@@ -250,7 +256,7 @@ class MixpanelDestination(
250
256
251
257
val revenue = properties.getDouble(" revenue" )
252
258
253
- with (settings !! ) {
259
+ with (mixpanelSettings !! ) {
254
260
if (isPeopleEnabled && revenue != null && revenue != 0.0 ) {
255
261
mixpanel?.people?.trackCharge(revenue, props)
256
262
analytics.log(" mixpanel.people.trackCharge($name , $props )" )
0 commit comments