Skip to content
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

App installed event tracking problem for iOS #26

Closed
Mik77o opened this issue May 5, 2022 · 27 comments
Closed

App installed event tracking problem for iOS #26

Mik77o opened this issue May 5, 2022 · 27 comments
Labels
help wanted Extra attention is needed

Comments

@Mik77o
Copy link

Mik77o commented May 5, 2022

I have noticed a problem with app installed event not being tracked for iOS. I am using version 3.7.0. In the Segment configuration Segment.config I have trackApplicationLifecycleEvents set: true, but this event does not seem to work.

@danielgomezrico
Copy link
Contributor

Are you talking about Application Installed event?

https://segment.com/docs/connections/spec/mobile/#application-installed

@Mik77o
Copy link
Author

Mik77o commented May 5, 2022

Yes :)

@Mik77o
Copy link
Author

Mik77o commented May 5, 2022

On Android, this type of event is tracked. Maybe it's related to this: https://developer.apple.com/app-store/user-privacy-and-data-use/
Asking permissions to track

What do you think?

@Mik77o
Copy link
Author

Mik77o commented May 10, 2022

@danielgomezrico, I tried to add tracking permissions via app_tracking_transparency but still this event is not being tracked in the Segment.

@ariefwijaya
Copy link
Contributor

ariefwijaya commented May 18, 2022

I don't think so,
It is not because this event is not being tracked in the Segment , the event tracked by segment already, you can test it.
I've tested it.
Untitled-1

As you can see, it was happened because in the default event like "Application Installed" never send fields adTrackingEnabled and advertisingId. Refer to docs :
image

@danielgomezrico
Copy link
Contributor

I checked too for iOS and the events exists 🤔

What else could be missing on your setup?

@ariefwijaya
Copy link
Contributor

@danielgomezrico Yes, the event exists, I think the problem is about IDFA. in some case such as facebook, the event will not received without IDFA

@Mik77o
Copy link
Author

Mik77o commented May 26, 2022

@ariefwijaya, could you please include a snippet of code, what should the configuration look like in the Segment for Flutter app when using the advertising_id and flutter_segment plugin? :)

@ariefwijaya
Copy link
Contributor

I prefer use facebook_app_events together with flutter_segment, so it will solve the problem without many boilerplate

@Mik77o
Copy link
Author

Mik77o commented May 26, 2022

@ariefwijaya @danielgomezrico
How was advertisingId added manually? I added something like this on the Flutter side.

     SegmentDefaultOptions.instance.options = {
          'context': {
            'device': {
              'adTrackingEnabled': true,
              'advertisingId': advertisingId,
            }
          }
        };

Some of the fields for device field that were visible before are no longer present. It looks like the device part has been overwritten. Only the type: ios left.

From Segment:

before my changes

    "device": {
      "id": "test",
      "manufacturer": "test",
      "model": "test',
      "name": "test",
      "type": "ios"
    },

now (Adding a configuration manually)

    "device": {
      "adTrackingEnabled": true,
      "advertisingId": "00000000-0000-0000-0000-000000000000",
      "type": "ios"
    },

@ariefwijaya
Copy link
Contributor

Yes, but it won't delete any other value except the one we want to overwrite, So, it must be

 "device": {
      "id": "test",
      "manufacturer": "test",
      "model": "test',
      "name": "test",
       "adTrackingEnabled": true,
      "advertisingId": "00000000-0000-0000-0000-000000000000",
      "type": "ios"
    },

btw , I mix it with facebook_app_event plugin to track default event such as App Install

@zenled
Copy link
Contributor

zenled commented Jun 1, 2022

Hey, I'm experiencing the same problem.
On Android, it all works as expected.
On iOS, the Application Installed event is not being triggered. (I have set trackApplicationLifecycleEvents totrue)
The problem is probably in the way Segment is being configured:

If I configure Segment using Dart, by calling Segment.config(options: SegmentConfig(... then the Application Installed event will not get triggered.

But If I configure Segment the deprecated way, by modifying the Info.plist then the Application Installed event will get triggered as expected.

In the Segment documentation is says to configure Segment in the application:didFinishLaunchingWithOptions, this is the case when configuring via the Info.plist, but not when configuring with Dart.

@Mik77o
Copy link
Author

Mik77o commented Jun 2, 2022

@danielgomezrico @ariefwijaya I have a problem with advertisingId and adTrackingEnabled fields in Segment for release mode (Android). It doesn't appear :/

I get the advertisingId from the advertising_id package.

@ariefwijaya
Copy link
Contributor

@Mik77o for advertising id, this is how use it along flutter_segment.

image

you can use .setContext method to put any key-value pair under spesific preserved key. it won't delete any other value except the one we want to overwrite,

@ariefwijaya
Copy link
Contributor

...

In the Segment documentation is says to configure Segment in the application:didFinishLaunchingWithOptions, this is the case when configuring via the Info.plist, but not when configuring with Dart.

@danielgomezrico this happened to me, I found it never track Application Installed in iOS for our Dart-Installation. I've tried but now I have no idea to fix it,

@minoesteban
Copy link
Contributor

We are facing the same issue... after upgrading the package to 3.9.0 and removing the Info.plist keys not only we stopped getting Application Installed events but we are also not getting as many Application Opened events as we should.

We are getting Application Backgrounded correctly though.

So most times we get 4/5 Application Backgrounded events in a row from the same device, and not once we get Application Opened

By making the Dart config call conditional to all but iOS platform and adding back the Info.plist keys, we started getting the correct events frequency on iOS

Unfortunately I'm not proficient enough in iOS dev to figure out where is the issue, so I cannot offer any more assistance - I only got to conclude that createConfigFromFile and createConfigFromDict methods in FlutterSegmentPlugin.m look too similar to suspect an issue there 😅

@danielgomezrico danielgomezrico added the help wanted Extra attention is needed label Jun 23, 2022
@Mik77o
Copy link
Author

Mik77o commented Jun 23, 2022

@minoesteban I think that Application Updated event is also not tracked. (for iOS)

@danielgomezrico
Copy link
Contributor

🤔 Its weird, I can see those events for iOS and android on our side, anyone has any clue?

@zenled
Copy link
Contributor

zenled commented Jun 24, 2022

@danielgomezrico
Can you confirm you are configuring Segment via Dart and not via Info.plist.

@b099l3
Copy link
Contributor

b099l3 commented Aug 15, 2022

Hey, I'm experiencing the same problem. On Android, it all works as expected. On iOS, the Application Installed event is not being triggered. (I have set trackApplicationLifecycleEvents totrue) The problem is probably in the way Segment is being configured:

If I configure Segment using Dart, by calling Segment.config(options: SegmentConfig(... then the Application Installed event will not get triggered.

But If I configure Segment the deprecated way, by modifying the Info.plist then the Application Installed event will get triggered as expected.

In the Segment documentation is says to configure Segment in the application:didFinishLaunchingWithOptions, this is the case when configuring via the Info.plist, but not when configuring with Dart.

This looks like it is a method sequence issue with when the dart method Segment.config() is called:

Method flow for App start with flutter-segment:

  1. AppDelegate didFinishLaunchingWithOptions:
  2. GeneratedPluginRegistrant registerWithRegistry:
  3. This is were the info.plist setup is called via createConfigFromFile and eventually SEGAnalytics setupWithConfiguration SEE SEGAnalytics setupWithConfiguration method flow BELOW
  4. Then AppDelegate calls super didFinishLaunchingWithOptions:

For the dart Implementation calling Segment.config():

  1. Calls SEGAnalytics setupWithConfiguration in the native library, SEE SEGAnalytics setupWithConfiguration method flow BELOW

SEGAnalytics setupWithConfiguration method flow

  1. Setups up listeners to the native lifecycle events
  2. Then when didFinishLaunchingWithOptions is called sends the Application Installed event

So if you call Segment.config() after AppDelegate didFinishLaunchingWithOptions: you will miss the first event. The setup instructions state that this needs to be done in a lifecycle event, e.g., didFinishLaunchingWithOptions

I wonder if there is away to call Segment.config() in didFinishLaunchingWithOptions?

@b099l3
Copy link
Contributor

b099l3 commented Aug 15, 2022

I created a potential fix, #56, that manually sends the event Application Installed and Application Updated when we call the dart code Segment.config().

This is in the native iOS code of flutter_segement so will only run on iOS. It works in the same way that the native segment package works, analysis-ios, checks the same NSUserDefaults, the implementation details of that method is here.

Tested and is sending the events now.

@savy-91
Copy link

savy-91 commented Aug 30, 2022

Maybe this can be closed @danielgomezrico ?

@danielgomezrico
Copy link
Contributor

danielgomezrico commented Aug 30, 2022

@Mik77o has updated to the latest version? This should be fixed after #56

@Mik77o
Copy link
Author

Mik77o commented Aug 30, 2022

@danielgomezrico Thanks for reminder. I will check it soon :)

@danielgomezrico
Copy link
Contributor

@Mik77o any updates? 🤓

@Mik77o
Copy link
Author

Mik77o commented Oct 26, 2022

@danielgomezrico Seems to be working now! :)

@danielgomezrico
Copy link
Contributor

You are welcome to reopen if it breaks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants