Skip to content

Integrations field is empty in segment analytics #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MiguelBelotto00 opened this issue Apr 4, 2025 · 4 comments
Closed

Integrations field is empty in segment analytics #152

MiguelBelotto00 opened this issue Apr 4, 2025 · 4 comments

Comments

@MiguelBelotto00
Copy link

MiguelBelotto00 commented Apr 4, 2025

Hello everyone, I've been testing this package and I'm correctly instantiating analytics, as well as adding the AppsFlyer plugin. However, when the event is sent to Segment Twilio, the integration section appears as null.

For example:

//AnalyticsSegment is a singleton when contains the analytics class
AnalyticsSegment().analytics.addPlugin(
  AppsFlyerDestination(),
  settings: {
    'appleAppID': value,
    'appsFlyerDevKey': myKey,
    'httpFallback': false,
    'rokuAppID': null,
    'trackAttributionData': true,
    'type': 'mobile',
    'versionSettings': {
      'prod': [
        appVersion,
      ],
    },
  },
);

Now, if I do:

AnalyticsSegment().analytics.track('event', properties: myProperties)

In Segment, I see that the value of the integrations map is empty, even though I added AppsFlyer:

  "integrations": {}

Packages:
segment_analytics_plugin_appsflyer: ^1.0.1
segment_analytics: ^1.1.4

@MiguelBelotto00
Copy link
Author

Maybe the problem is here:
Image

@neelkanth-kaushik
Copy link
Contributor

neelkanth-kaushik commented May 16, 2025

Hello @MiguelBelotto00 , We're currently testing the changes you suggested.

We've observed that the integrations field in the segment is no longer empty, but it still doesn't include AppsFlyer with Track, Identify, Group, Alias calls even after adding its plugin. However an exception to this is that AppsFlyer is present in the integrations: {} with Screen call.

I am pasting a snapshot of integrations: {} for your reference. Could you please confirm if this is the expected behavior you were aiming for?

"integrations": {
    "Segment.io": {
      "apiKey": "***************************",
      "unbundledIntegrations": [],
      "addBundledMetadata": true,
      "maybeBundledConfigIds": {},
      "versionSettings": {
        "version": "4.4.7",
        "componentTypes": [
          "browser"
        ]
      },
      "apiHost": "api.segment.io/v1"
    }
  },
"integrations": {
    "AppsFlyer": {
      "appsFlyerDevKey": "******************",
      "httpFallback": false,
      "rokuAppID": null,
      "trackAttributionData": true,
      "type": "mobile",
      "versionSettings": {
        "foo": []
      }
    }
  },

For your reference, below is the code in our main.dart file:-

import 'package:segment_analytics/event.dart';
import 'package:segment_analytics/state.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:segment_analytics/client.dart';
import 'package:segment_analytics_plugin_appsflyer/plugin_appsflyer.dart' show AppsFlyerDestination;
import 'package:my_demo_app/my_custom_context.dart';
import 'package:segment_analytics/flush_policies/count_flush_policy.dart';
import 'package:segment_analytics/flush_policies/timer_flush_policy.dart';


void main() {
  runApp(const MyApp());
}

class MyApp extends MaterialApp {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final analytics = createClient(Configuration(
      '*******************************',
      debug: true, // Enable debug logs
      flushPolicies: [
        CountFlushPolicy(10),
        TimerFlushPolicy(100)
      ],
      collectDeviceId: true
  ));

  @override
  void initState() {
    super.initState();
    initPlatformState();
    analytics.addPlugin(AppsFlyerDestination(), settings: {
      'appsFlyerDevKey': '******************',
      'httpFallback': false,
      'rokuAppID': null,
      'trackAttributionData': true,
      'type': 'mobile',
      'versionSettings': {'foo': []}
    });
    analytics.addPlugin(MyCustomContext());
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(navigatorObservers: [
      ScreenObserver()
    ], routes: {
      '/': (context) => Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
            child:
            Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
              TextButton(
                onPressed: () {
                  Navigator.pushNamed(context, "/next");
                },
                child: const Text('Next Screen'),
              ),
              TextButton(
                onPressed: () {
                  analytics
                      .track("Test Event", properties: {"prop1": "value1"});
                },
                child: const Text('Track Product Viewed'),
              ),
              TextButton(
                onPressed: () {
                  analytics.track('Products Searched',
                      properties: {"query": 'blue roses'});
                  analytics.track('Product List Viewed', properties: {
                    "list_id": 'hot_deals_1',
                    "category": 'Deals',
                    "products": [
                      {
                        "product_id": '507f1f77bcf86cd799439011',
                        "sku": '45790-32',
                        "name": 'Monopoly: 3rd Edition',
                        "price": 19,
                        "position": 1,
                        "category": 'Games',
                        "url": 'https://www.example.com/product/path',
                        "image_url": 'https://www.example.com/product/path.jpg'
                      },
                      {
                        "product_id": '505bd76785ebb509fc183733',
                        "sku": '46493-32',
                        "name": 'Uno Card Game',
                        "price": 3,
                        "position": 2,
                        "category": 'Games'
                      }
                    ]
                  });
                  analytics.track('Promotion Viewed', properties: {
                    "promotion_id": 'promo_1',
                    "creative": 'top_banner_2',
                    "name": '75% store-wide shoe sale',
                    "position": 'home_banner_top'
                  });
                  analytics.track('Product Clicked', properties: {
                    "product_id": '507f1f77bcf86cd799439011',
                    "sku": 'G-32',
                    "category": 'Games',
                    "name": 'Monopoly: 3rd Edition',
                    "brand": 'Hasbro',
                    "variant": '200 pieces',
                    "price": 18.99,
                    "quantity": 1,
                    "coupon": 'MAYDEALS',
                    "position": 3,
                    "url": 'https://www.example.com/product/path',
                    "image_url": 'https://www.example.com/product/path.jpg'
                  });
                  analytics.track('Product Shared', properties: {
                    "share_via": 'email',
                    "share_message": 'Hey, check out this item',
                    "recipient": '[email protected]',
                    "product_id": '507f1f77bcf86cd799439011',
                    "sku": 'G-32',
                    "category": 'Games',
                    "name": 'Monopoly: 3rd Edition',
                    "brand": 'Hasbro',
                    "variant": '200 pieces',
                    "price": 18.99,
                    "url": 'https://www.example.com/product/path',
                    "image_url": 'https://www.example.com/product/path.jpg'
                  });
                  analytics.track('Cart Shared', properties: {
                    "share_via": 'email',
                    "share_message": 'Hey, check out this item',
                    "recipient": '[email protected]',
                    "cart_id": 'd92jd29jd92jd29j92d92jd',
                    "products": [
                      {"product_id": '507f1f77bcf86cd799439011'},
                      {"product_id": '505bd76785ebb509fc183733'}
                    ]
                  });
                },
                child: const Text('Track eCommerce events'),
              ),
              TextButton(
                onPressed: () {
                  analytics.reset();
                },
                child: const Text('Reset'),
              ),
              TextButton(
                onPressed: () {
                  analytics.flush();
                },
                child: const Text('Flush'),
              ),
            ])),
      ),
      '/next': (context) => Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
            child:
            Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
              TextButton(
                onPressed: () {
                  Navigator.pop(context);
                },
                child: const Text('Next Screen'),
              ),
              TextButton(
                onPressed: () {
                  analytics.identify(
                      userId: "testUserId",
                      userTraits: UserTraits(name: "Test User"));
                },
                child: const Text('Identify Event'),
              ),
            ])),
      )
    });
  }
}

neelkanth-kaushik added a commit that referenced this issue May 19, 2025
MichaelGHSeg pushed a commit that referenced this issue May 20, 2025
* Patch for Github Issue #144

* Patch for Github issue #147

* Patch for Github issue #147

* Patch for Github issue #144

* Patch for Github issue #147

* Patch for Github issue #147

* Patch for Github issue #138

* Patch for Github issue #138

* Patch for Github Issue #152

* Patch for Github Issue #152

* Testing patch for Github Issue #157

* Patch for Github Issue #157
MichaelGHSeg added a commit that referenced this issue May 20, 2025
* Patches for Github Issues (#159)

* Patch for Github Issue #144

* Patch for Github issue #147

* Patch for Github issue #147

* Patch for Github issue #144

* Patch for Github issue #147

* Patch for Github issue #147

* Patch for Github issue #138

* Patch for Github issue #138

* Patch for Github Issue #152

* Patch for Github Issue #152

* Testing patch for Github Issue #157

* Patch for Github Issue #157

* Updating for 1.1.7 release

* Removing unnecessary library name

---------

Co-authored-by: Neelkanth Kaushik <[email protected]>
@neelkanth-kaushik
Copy link
Contributor

Please update to version 1.1.7.

@MiguelBelotto00
Copy link
Author

Hello, sorry for the delay, I've had a lot of work and couldn't focus on this.
It's good that it now adds the integrations, but I believe the expected behavior here is that the track calls also have the integration done. Were you able to resolve it?

Regards, have a nice Wednesday!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants