Ip address in events
urvashi-k-7span opened this issue · 15 comments
Hi there,
I am using this package.
Called identify events as below
Analytics? analytics;
analytics = createClient(
Configuration(
AppConfig.of(context)?.segmentWriteKey ?? '',
debug: false,
collectDeviceId: true,
trackApplicationLifecycleEvents: true,
),
);
analytics?.identify(
userId: session?.id.toString(),
userTraits: UserTraits(
custom: traits,
),
);
But there is no IP address value in my segment data,
From the IP address mix panel gets the region and country of the user and in my case that shows default region of mixpanel server. because an IP address is not being passed to the segment.
Hi @urvashik-7span thank you for your report, we start looking into this.
Hi any update? I am waiting for this and we had live app.
Hi @urvashik-7span thank you for your report, we start looking into this.
We are seeing this as well, comparing tables to our old implementation
Yep, same here.
I've been doing some investigating and if the field used to be the public IP, I think Segment may be filling this data themselves after receiving the event server-side. I haven't found an Android or iOS API that exposes public API.
For some reason that field may not be filled if received from this library? Who can look into that for us?
Yeah, exactly what I thought. I changed the context.library field to be ContextLibrary("analytics-android", "4.10.4");
in packages/core/lib/plugins/inject_context.dart and my events on the server now have a context.ip in the events.
Seems like the Segment server needs to be updated to recognize analytics-flutter as a library that needs context.ip added after an event is received.
@QoLTech hey, sorry for the wait. I was out of office, but I'm raising this to the backend team.
@oscb I assumed - I hope it was refreshing! Thanks for looking into this. We've got a fork of this library where we're setting the context.library field, so it'd be nice to have this properly supported.
@oscb any updates on this?
We just changed from the 3rd party flutter_segment lib to this, and released a version, and our mixpanel analytics dashboards are going crazy because of the lack of countryCode data. Is there anything that can be done for this?
Fixed it temporarily by adding a custom plugin. This was suggested by Segment support.
import 'dart:async';
import 'package:analytics/event.dart';
import 'package:analytics/plugin.dart';
import 'package:flutter/foundation.dart' show kIsWeb;
// This plugin is a hack to ask segment servers to add the IP in the request.
// This solution was suggested by the segment team as they fix the actual issue.
class IPInAnalyticsPlugin extends Plugin {
IPInAnalyticsPlugin() : super(PluginType.after);
@override
Future<RawEvent?> execute(RawEvent event) async {
final addIp = <String, dynamic>{"direct": true};
final context = event.context;
if (context == null || kIsWeb) {
return event;
}
context.custom.addAll(addIp);
return event;
}
}
Ideally should have been an enrichment plugin that sets context, however mergeContext method ignores merging custom
Sorry for the lack of updates, This was enabled in the backend at the start of this month. IP Addresses are stamped now at the server properly
Thank you @oscb 🙌🏻, This was a much needed fix.
Thank you 👍
@oscb
Hi @oscb, unfortunately we're still having this issue with our Flutter app on the latest version of this package. Do you have any other suggestions, is there a setting that we need to configure to get the IP addresses to be stamped on our events?