GithubHelp home page GithubHelp logo

segmentio / analytics-swift Goto Github PK

View Code? Open in Web Editor NEW
89.0 16.0 76.0 1008 KB

The hassle-free way to add Segment analytics to your Swift app (iOS/tvOS/watchOS/macOS/Linux).

License: MIT License

Swift 98.82% Shell 1.18%

analytics-swift's Introduction

Analytics-Swift

🎉 Flagship 🎉

This library is one of Segment’s most popular Flagship libraries. It is actively maintained by Segment, benefitting from new feature releases and ongoing support.

The hassle-free way to add Segment analytics to your Swift app (iOS/tvOS/visionOS/watchOS/macOS/Linux/iPadOS). Analytics helps you measure your users, product, and business. It unlocks insights into your app's funnel, core business metrics, and whether you have product-market fit.

How to get started

  1. Collect analytics data from your app(s).
  • The top 200 Segment companies collect data from 5+ source types (web, mobile, server, CRM, etc.).
  1. Send the data to analytics tools (for example, Google Analytics, Amplitude, Mixpanel).
  • Over 250+ Segment companies send data to eight categories of destinations such as analytics tools, warehouses, email marketing and remarketing systems, session recording, and more.
  1. Explore your data by creating metrics (for example, new signups, retention cohorts, and revenue generation).
  • The best Segment companies use retention cohorts to measure product market fit. Netflix has 70% paid retention after 12 months, 30% after 7 years.

Segment collects analytics data and allows you to send it to more than 250 apps (such as Google Analytics, Mixpanel, Optimizely, Facebook Ads, Slack, Sentry) just by flipping a switch. You only need one Segment code snippet, and you can turn integrations on and off at will, with no additional code. Sign up with Segment today.

Why?

  1. Power all your analytics apps with the same data. Instead of writing code to integrate all of your tools individually, send data to Segment, once.

  2. Install tracking for the last time. We're the last integration you'll ever need to write. You only need to instrument Segment once. Reduce all of your tracking code and advertising tags into a single set of API calls.

  3. Send data from anywhere. Send Segment data from any device, and we'll transform and send it on to any tool.

  4. Query your data in SQL. Slice, dice, and analyze your data in detail with Segment SQL. We'll transform and load your customer behavioral data directly from your apps into Amazon Redshift, Google BigQuery, or Postgres. Save weeks of engineering time by not having to invent your own data warehouse and ETL pipeline.

    For example, you can capture data on any app:

    struct TrackProperties: Codable {
        let price: Double
    }
    
    // ...
    
    analytics.track(name: "Order Completed", properties: TrackProperties(price: 99.84))

    Then, query the resulting data in SQL:

    select * from app.order_completed
    order by price desc

Supported Device Mode Destinations

Partner Package
Amplitude https://github.com/segment-integrations/analytics-swift-amplitude
AppsFlyer https://github.com/segment-integrations/analytics-swift-appsflyer
Braze https://github.com/segment-integrations/analytics-swift-braze
Facebook https://github.com/segment-integrations/analytics-swift-facebook-app-events
Firebase https://github.com/segment-integrations/analytics-swift-firebase
Mixpanel https://github.com/segment-integrations/analytics-swift-mixpanel
Survicate https://github.com/Survicate/analytics-swift-survicate

Documentation

You can find usage documentation at Segment Docs, Analytics-Swift.

Explore more via the example projects which showcase analytics instrumentation on different platforms/languages and usage of plugins. These projects contain sample plugins and destination plugins.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

Integrating with Segment

Interested in integrating your service with us? Check out our Partners page for more details.

Code of Conduct

Before contributing, please also see our code of conduct.

License

MIT License

Copyright (c) 2021 Segment

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

analytics-swift's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

analytics-swift's Issues

Request: Add `options` to all `analytics-swift` callsites

Is your feature request related to a problem? Please describe.
I'm trying to migrate from analytics-ios to analytics-swift and the main issue I'm running into is migrating options.

We use Protocols + Typewriter for our project, so adding options values to parameters will break our schema. We're using options for supplementary, non-critical context, and it would be great to re-add that field for analytics-swift. We will not be able to migrate without it.

To make things more difficult, it seems that newer versions of typewriter ONLY support analytics-swift

Describe the solution you'd like
Add a options: [String: Any]? = nil parameter for track, group, screen, and identify.

Describe alternatives you've considered
Adding options to parameters. This is painful because it requires updating a ton of Protocol schemas with information that will differ across clients & client versions.

Additional context
If theres a reason why options are no longer supported we would love to understand it. In general options seem to be missing from your entire migration guide so some guidance / reasoning would be appreciated.

Publicly Accessible UploadTask

Is your feature request related to a problem? Please describe.
Currently, on iOS, the only way to run an upload as a well behaved background task seems to be to opt-in to lifecycle events. That's because the current implementation seems to rely on an internal UploadTaskInfo in the SegmentDestination which is only accessible to internal clients.

AFAICT this means there is no simple way to create your own background task to upload any outstanding events.

This would be especially useful in low/no network situations. Currently, even if opted-in to iOS lifecycle events, the background task that is created will fail if the network is unavailable.

Describe the solution you'd like
An ideal solution would be one with flexibility and adherence to platform recommendations.

For example, on iOS it is possible to opt-in to 'background modes' one of which is called 'background processing'. This mode allows a developer to use he system's Background Task Scheduler to do additional processing at some point when the battery and network conditions are favourable. The system scheduler enforces adherence to platform recommendations (i.e cancelling when asked, and letting the system know when it's complete) by docking an app's time on the scheduler for non-compliance.

With that in mind, I suggest a task API similar to the one for URLSession but with an additional callback for completion with some kind of TaskState to inform of success, cancellation or failure:

struct SegmentUploadTask {
    func start(_ completion: @escaping (TaskState) -> Void)
    func cancel()
}

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Incorrect timestamp formats

Looking at the raw events delivered to Segment, I've noticed a discrepancy in the timestamps:

...
  -d originalTimestamp=2021-10-16T16:00:27.029:Z \
  -d receivedAt=2021-10-16T16:00:28.078Z \
  -d sentAt=2021-10-16T16:00:27.957:Z \
...

You can see that the originalTimestamp and sentAt dates use a different format than the receivedAt date – there's an additional colon prior to the timezone signifier.

When using it with the Amplitude Actions plugin and trying to map the originalTimestamp to Amplitude's timestamp property this causes the event to be rejected.

By default, the Amplitude Actions destination maps the receivedAt property to its timestamp property which of course means events are appearing out of order. It would be much better if we could use the originalTimestamp property as currently the events are arriving as shuffled.

Integrations object not populated in SDK 1.2.0

Describe the bug
After migrating from analytics-ios v1.1.2 to v1.2.0, the integrations field did not contain any information.
When this happens events are shown in the live debugger for a source but do not reach the source destinations.

To Reproduce

  1. Add an integration like AppsFlyer to the segment client.
  2. On v1.1.2 trigger a track event and notice how the integrations object has a list of integrations.
  3. Update the SDK to v.1.2.0
  4. Trigger the same event. <--- Issue here
  5. The integrations object is empty

Event v1.1.2

{
  "context": {
    "library": {
      "name": "analytics-swift",
      "version": "1.1.2"
    },
    "locale": "en-US",
    "network": {
      "bluetooth": false,
      "cellular": true,
      "wifi": false
    }
  },
  "event": "Application Foregrounded",
  "integrations": {
    "AppsFlyer": false,
    "Segment.io": false
  },
  "receivedAt": "2022-04-11T23:21:53.134Z",
  "sentAt": "2022-04-11T23:21:52.706Z",
  "timestamp": "2022-04-11T23:21:44.226Z",
  "type": "track",
}

Event v1.2.0

{
  "context": {
		"library": {
      "name": "analytics-swift",
      "version": "1.2.0"
    },
    "locale": "en-US",
    "network": {
      "bluetooth": false,
      "cellular": true,
      "wifi": false
    }
	},
  "event": "Application Foregrounded",
  "integrations": {},
  "receivedAt": "2022-04-11T23:20:33.204Z",
  "sentAt": "2022-04-11T23:20:32.773Z",
  "timestamp": "2022-04-11T23:20:32.281Z",
  "type": "track",
}

Expected behavior
The integrations object should remain the same after upgrading from v1.1.X to v1.2.X

Platform (please complete the following information):

  • Library Version in use: v.1.2.0
  • Platform being tested: iOS
  • Integrations in use: AppsFlyer

Additional context
This regression issue was introduced on v1.2.0.

ObjCExample not working

Describe the bug
"I tried your ObjCExample, but events are not being sent. I inserted breakpoints and observed that the event file is not being generated.

To Reproduce
Steps to reproduce the behavior:
Just launch your ObjCExample

Zombie Analytics after deallocation.

Describe the bug
Creating and deallocating the Analytics instances doesn't stop them from sending events to the back-end sources.

To Reproduce
Steps to reproduce the behavior:

  1. Allocate Analytics instance (1) with support for lifecycle events and connected to the Segment source.
  2. Background the app and watch for application lifecycle event to appear in Segment debugger.
  3. Deallocate analytics instance (1) and allocate Analytics instance (2) with support for lifecycle events and connected to the same Segment source.
  4. Background the app and watch for duplicate application lifecycle events to appear in Segment debugger.
  5. Goto 3. for more fun and more events!

Expected behavior
The Analytics instance should clean up after itself and shutdown its plugins when deallocated. To be clear, I'm not expecting two valid instances to coordinate in any way - that would reasonably produce duplicates, but if there is only one app-wide, live instance that hasn't been released, it should be the only one sending events.

Screenshots
image

Platform (please complete the following information):

  • iOS library version 1.3.0

Additional context
My use case requires my app be able to reconfigure Segment between logins so that I can attach to QA and production depending on the user's preference.

Xcode says that i can not use this framework, how i could resolve it ?

i am trying to add segmentio/analytics-ios to my project and use it, but i have got an error that this framework can be compiled only for target 13+ but i have 11+ in my project, probably you could provide some workarounds or how i could use your framework in my case ?

when i am trying to import Segment, i get an error "Compiling for iOS 11.0, but module 'Segment' has a minimum deployment target of iOS 13.0:"

i can not just increase target because i need 11+ in my application

track(event:properties:) takes [String:Any], but screen(screenTitle:properties:) takes [Any:Hashable]

Describe the bug
There's a bit of mismatch/asymmetry between the various track and screen methods. Namely, track(event:properties:) takes [String:Any], but screen(screenTitle:properties:) takes [Any:Hashable]`.

Expected behavior
I'd expect these to take the same thing, unless there's some reason they can't.

Platform (please complete the following information):

  • Library Version in use: 1.0.2
  • Platform being tested: [e.g. iOS]

Application is crashing on Storage errors

Describe the bug

We are getting crash reports coming from the Segment library.
According to crash logs, it's related to problems with writing files by a Storage class.

The problem seems to be related to using some deprecated methods of FileHandler class, which are throwing uncatchable errors:

extension FileHandle {    
    /* The API below may throw exceptions and will be deprecated in a future version of the OS.
     Use their replacements instead. */
    
    @available(macOS, introduced: 10.0, deprecated: 100000)
    open func write(_ data: Data)

To Reproduce
Steps to reproduce the behavior:

  1. Try to send any Segment event when disc has no more space left

Expected behavior
The segment should not cause application crash.
Ideally, the library should allow us to read those errors so we can react to them.

Platform (please complete the following information):

  • Library Version in use: 1.3.1
  • Platform being tested: macOS
  • Integrations in use: Amplitude

Additional context
Here is the important part of the stack trace from a crash:

OS Version: macOS 12.5.1 (21G83)
Report Version: 104

Exception Type: EXC_CRASH (SIGABRT)
Crashed Thread: 0

Application Specific Information:
*** -[NSConcreteFileHandle writeData:]: No space left on device

Thread 0 Crashed:
0   CoreFoundation                  0x315d69194         __exceptionPreprocess
1   libobjc.A.dylib                 0x3158eae00         objc_exception_throw
2   Foundation                      0x317bef54c         _NSFileHandleRaiseOperationExceptionWhileReading
3   Foundation                      0x317ac0c40         -[NSConcreteFileHandle writeData:]
4   Raycast                         0x205295b54         Storage.storeEvent (Storage.swift:268)
5   Raycast                         0x20529509c         Storage.write<T> (Storage.swift:37)
6   Raycast                         0x205265178         thunk for closure
7   Raycast                         0x205265198         thunk for closure
8   libdispatch.dylib               0x3158481b0         _dispatch_client_callout
9   libdispatch.dylib               0x315857410         _dispatch_lane_barrier_sync_invoke_and_complete
10  Raycast                         0x20529433c         Storage.write<T> (Storage.swift:32)
11  Raycast                         0x205265984         SegmentDestination.queueEvent<T> (SegmentDestination.swift:99)
12  Raycast                         0x205265858         SegmentDestination.execute<T> (SegmentDestination.swift:78)
13  Raycast                         0x20523f670         [inlined] Mediator.execute<T> (Timeline.swift:78)
14  Raycast                         0x20523f670         [inlined] thunk for closure
15  Raycast                         0x20523f670         [inlined] Sequence.forEach
16  Raycast                         0x20523f670         Mediator.execute<T> (Timeline.swift:73)
17  Raycast                         0x20523aea8         [inlined] Timeline.applyPlugins<T> (Timeline.swift:49)
18  Raycast                         0x20523aea8         Timeline.process<T> (Timeline.swift:37)
19  Raycast                         0x205247d44         [inlined] Analytics.process<T> (Analytics.swift:47)
20  Raycast                         0x205247d44         Analytics.identify<T> (Events.swift:68)

trackPushNotifications missing from SDK

Describe the bug
Based on the Segment Documentation for the SDK there should be a function to enable automatic tracking for push notifications opens. This isn't available on on the latest version 1.3.1. Is this rolled up into deep links perhaps?

https://segment.com/docs/connections/sources/catalog/libraries/mobile/ios/#api-call-queueing-in-analytics-ios

Screen Shot 2022-09-29 at 11 08 25 AM

To Reproduce
Try adding .trackPushNotifications to the Configuration class

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Platform (please complete the following information):

  • 1.3.1
  • iOS

Additional context
Add any other context about the problem here.

Background task not cancelling when requested by system

Describe the bug
As mentioned on our call, here's the warning that I'm regularly getting from the system.

[BackgroundTask] Background task still not ended after expiration handlers were called: <_UIBackgroundTaskInfo: 0x2835fdd40>: taskID = 4, taskName = Called by <AppName>, from $s7Segment0A11DestinationC14UploadTaskInfoV3url4taskAE10Foundation3URLV_So016NSURLSessionDataD0CtcfC, creationTime = 1095354 (elapsed = 27). This app will likely be terminated by the system. Call UIApplication.endBackgroundTask(_:) to avoid this.

I assume this means the app will have to launch cold each time this occurs.

To Reproduce
It seems to happen intermittently.

I believe it usually occurs if I run a build on device, and that put aside the phone with the debugger still running. That message appeared almost 12 mins after the app was launched via a build and run in Xcode.

As mentioned, my current network is a little flakey so it could be related to a low/no network situation, too.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Platform (please complete the following information):

  • Library Version in use: [e.g. 0.0.5]
  • Platform being tested: [e.g. iOS]
  • Integrations in use: [e.g. Firebase, Amplitude]

Additional context
Add any other context about the problem here.

Events passed to Segment through the library are not passed automatically to Amplitude

Describe the bug
We lately switched from our own http client to this library to get batching support, but we noticed that all events that are going through this library are not sent to our Amplitude destination.

We are passing exactly the same properties and events as through our old library and we use exactly same setup, but the one that goes through analytics-swift are only visible in Segment and never lands on Amplitude.

Even weirded when we use Event Tester and send them manually - it all goes through correctly.

To Reproduce
Steps to reproduce the behavior:

  1. Use latest 1.2.2 library
  2. Send some events to Segment that has Amplitude set as destination
  3. Check that events that are visible in Segment are never send to Amplitude automatically

Expected behavior
I would expect to have all events being forwarded to Amplitude

Platform (please complete the following information):

  • Library Version in use: 1.2.2
  • Platform being tested: macOS
  • Integrations in use: Amplitude

Additional context
Making curl request with same content just works and events are forwarded properly to Amplitude.

Traits dictionary not included in event tracking

Describe the bug
I just migrated my app from the old analytics-ios and noticed that the traits dictionary is missing from all of the track event calls. It used to be present within the context dictionary, but no more.

Digging deeper into it, I saw that you have a unit test called testUserIdAndTraitsPersistCorrectly that asserts the following:

let trackTraits = trackEvent?.context?.dictionaryValue?["traits"] as? [String: Any]
XCTAssertNil(trackTraits)

which leads me to believe this was removed intentionally. Is that the case? If so, isn't the intention of the identity call to make sure all the following track events are correctly identified? Is there another approach we should follow to get the traits data? Anything we need to enable in the SDK?

To Reproduce
Steps to reproduce the behavior:

  1. Identify a user
  2. Trigger any event tracking
  3. See error

Expected behavior
I expected the traits dictionary to be present within the context dictionary.

Platform (please complete the following information):

  • Library Version in use: 1.3.3
  • Platform being tested: iOS 16
  • Integrations in use: -

Destination plugin calls `update(settings:)` multiple times

Describe the bug
The included AppsFlyer example currently results in the plugin reaching an indeterminate state.

I'm not sure whether this is because the example needs to be re-architected, or because the plugin architecture is not behaving as it was designed.

My expectation is that the set-up for AppsFlyer should always be done prior to AppsFlyerLib.shared().start() being called.

However, with the current example this isn't guaranteed.

From my observations on an iPhone X and iPhone 7 Plus, I can see that update(settings:) is often called twice. This is the method that contains the AppsFlyer set-up code.

The first time it is called is prior to the plugin's applicationDidBecomeActive(application:) method being called. This would be what I expect, but at this point Segment doesn't appear to have loaded the AppsFlyer specific settings and so the majority of this method's execution, and therefore the AppsFlyer set-up, is skipped.

Shortly after, applicationDidBecomeActive(application:) is then called. This invokes AppsFlyerLib.shared().start(), but as the settings were missing previously, AppsFlyer is started without necessary setup having taken place.

So when update(settings:) is called a second time, this time with the associated AppsFlyer settings, the plug-in doesn't behave as expected. For example, the AppsFlyerLibDelegate method onConversionDataSuccess(_:) may not get called at all.

No way to reset user id

Describe the bug
There is a way to set user id and traits but there is no way to reset it (for example, if user logs out). It seems it is just a typo in the method definition as method description actually allows that:

/// Associate a user with their unique ID and record traits about them.
/// - Parameters:
///   - userId: A database ID (or email address) for this user. If you don't have a userId
///     but want to record traits, you should pass nil. For more information on how we
///     generate the UUID and Apple's policies on IDs, see https://segment.io/libraries/ios#ids
///   - traits: A dictionary of traits you know about the user. Things like: email, name, plan, etc.
public func identify<T: Codable>(userId: String, traits: T?) {

Compile error in Release configuration archiving with 1.0.4

Describe the bug
The following compile-time errors occur in Segment 1.0.4 when archiving a Release configuration app:

…/SourcePackages/checkouts/analytics-swift/Sources/Segment/Utilities/JSON.swift:305:19: error: thrown expression type 'String' does not conform to 'Error'
            throw "This JSON object is not an array type."
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
…/SourcePackages/checkouts/analytics-swift/Sources/Segment/Utilities/JSON.swift:328:19: error: thrown expression type 'String' does not conform to 'Error'
            throw "This JSON object is not an array type."
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
…/SourcePackages/checkouts/analytics-swift/Sources/Segment/Utilities/JSON.swift:350:19: error: thrown expression type 'String' does not conform to 'Error'
            throw "This JSON object is not an array type."
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'm not sure why it works in Debug configuration builds, but it seems odd to be throwing a String. I tried searching but couldn't find an Error conformance for String in the package.

The `os.name` context is reported incorrectly on macOS

The MacOSVendorSystem uses device.operatingSystemVersionString for the systemName property. I believe this is incorrect as it is resulting in values such as "Version 12.5.1 (Build 21G83)" being reported as the name of the operating system. On iOS it uses device.systemName which results in "iOS" being reported as the name of the operating system, which is what I would expect.

To Reproduce
Steps to reproduce the behavior:

  1. Implement the SDK in a macOS app.
  2. Run the app then background it to flush the events.
  3. Check the Segment debugger and notice the os context values look like the following.
"os": {
    "name": "Version 12.5.1 (Build 21G83)",
    "version": "12.5.1"
}

Expected behavior
I expect the value for os.name on macOS to be "macOS".

Screenshots
CleanShot 2022-11-08 at 10 56 35@2x

Platform (please complete the following information):

  • Library Version in use: 1.3.2
  • Platform being tested: macOS
  • Integrations in use: None

Xcode 13b4: 'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead.

…/SourcePackages/checkouts/analytics-swift/Sources/Segment/Plugins/Platforms/iOS/iOSLifecycleMonitor.swift:58:37: 'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead.

Xcode 13b4 introduced (erroneously, I think) a bug in which restrictions on APIs like being unavailable in extensions trigger errors, even when building applications. The usual fix for this is to declare the same restriction on the library's published methods.

You get this error by trying to build an iOS app in Xcode 13b4 with Segment as an SPM dependency.

Setting the apiHost in the configuration has no effect

Describe the bug
Setting the apiHost in the configuration has no effect, events are still sent to api.segment.io/v1 regardless of the configuration values for apiHost.

let configuration = Configuration(writeKey: writeKey)
   .trackApplicationLifecycleEvents(true)
   .apiHost("analytics-ingestion.kraftful.com")
   .flushInterval(10)

Analytics.debugLogsEnabled = true
analytics = Analytics(configuration: configuration)

Steps for repro:

I have created an example app with repro in a fork: https://github.com/kraftful/analytics-swift/tree/jgable/api-host-repro (specific commit is ce5331d)

  • Clone the above branch/commit
  • Load the ExampleApp project in XCode (in the Examples/APIHostConfigurationRepro folder)
  • Put breakpoints in the HTTPClient file in Segment package where the batch uploads happen
  • Run the app on simulator (I have tried iPhone 12 Pro)
  • Login using creds: [email protected], test1234
  • Observe the value of uploadURL in the debugger when the batch is uploaded

Expected:

  • Should be analytics-ingestion.kraftful.com since that is passed in the configuration in the SegmentAnalytlics.swift file

Actual:

  • api.segment.io/v1 is used instead.

Expected behavior

Event batches should be sent to the configured apiHost.

Screenshots

Screen Shot 2022-09-20 at 9 41 05 AM

Platform (please complete the following information):

  • Library Version in use: latest
  • Platform being tested: iOS (latest)
  • Integrations in use: none

SwiftUI App not tracking Application Opened event

Describe the bug
When integrating the analytics library into our SwiftUI app, the "Application Opened" event is not being triggered. It appears the UIApplication.didFinishLaunchingNotification notification is not being received and triggering the iOSLifecycle protocol method didFinishLaunchingWithOptions to track the event.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new SwiftUI App with App Delegate.
  2. Add the analytics-swift package.
  3. Initialise Analytics in the didFinishLaunchingWithOptions delegate method.
  4. Launch app and observe the "Application Opened" event is not tracked.

Note: The "Application Foregrounded" and "Application Backgrounded" events are triggered as expected.

Expected behavior
On Application launch, the "Application Opened" event should be triggered.

Screenshots
N/A

Platform (please complete the following information):

  • Library Version in use: 1.1.2
  • Platform being tested: iOS (tested against iOS 14.5 and iOS 15.4 simulators, and iPhone 12 Pro device - iOS 15.3.1)
  • Integrations in use: Firebase

Additional context
N/A

Links in README not working

Describe the bug
Links in the README are not working

To Reproduce
Steps to reproduce the behavior:

  1. click link in readme
  2. view error page

Expected behavior
Links should work!

Platform (please complete the following information):

  • Github

Support for "Application Foregrounded" Events

The SDK automatically tracks lifecycle events, including an "Application Backgrounded" event in the applicationDidResignActive hook. In the corresponding applicationDidBecomeActive hook, the current implementation uses a flag to track an "Application Opened" event the first time it is called (which makes sense) but there is no event tracked on every call of applicationDidBecomeActive.

I am proposing there should be an equivalent "Application Foregrounded" event that is tracked every time applicationDidBecomeActive is called.

The pair of these two events would provide accurate "bookends" for session time tracking in various analytics platforms. I am using Mixpanel and from their documentation you can see we need to supply a "Session Start Event" and a "Session End Event".

https://help.mixpanel.com/hc/en-us/articles/115004695223

There are other ways to track session time (at least in Mixpanel) using a timeout but this approach is less accurate and event then, without an "Application Foregrounded" event there isn't a guaranteed accurate way to signal the beginning of a session.

We need this on macOS and iOS which both seem to have a similar implementation in the applicationDidBecomeActive and appears to be a trivial addition. I can't speak for Linux or watchOS.

Adding SPM dependency to Xcode with default "up to 1.0.0" results in package resolution error due to sovran URL

Describe the bug
When you add analytics-swift to an Xcode project, the default is to have it fetch "up to next major from ". Unfortunately, tag 1.0.0's Package.swift contains a reference to Sovran [email protected]:segmentio/Sovran-Swift.git, which Xcode fails to pull, getting

x-swift-package-repository-authentication://?scm=com.apple.dt.Xcode.sourcecontrol.Git&[email protected]:segmentio/Sovran-Swift.git#error=-1005 Authentication failed because the credentials were missing

Your main branch has an updated Package.swift. You should probably make a new tag in git with that change.

To Reproduce
Steps to reproduce the behavior:

  1. Add analytics-swift using default Xcode version selection
  2. Be sad

Network object is missing carrier information

Describe the bug

In analytics-swift the network object does not include the carrier property whereas analytics-ios did. Below a comparison of both objects

analytics-ios v4.1.3

"library": {
      "name": "analytics-ios",
      "version": "4.1.3"
    },
    "locale": "en-US",
    "network": {
      "carrier": "T-Mobile",
      "cellular": true,
      "wifi": false
    }

analytics-swift v1.2.0

library": {
      "name": "analytics-swift",
      "version": "1.2.0"
    },
    "locale": "en-US",
    "network": {
      "bluetooth": false,
      "cellular": true,
      "wifi": false
    }

To Reproduce
Steps to reproduce the behavior:

  1. Using the analytics-swift library log an event
  2. The event metadata will not include the carrier property in the network object

Expected behavior
The network metadata should be consistent between analytics-ios and analytics-swift SDKs. This is seen as a regression issue after upgrading to the new package.

Platform (please complete the following information):

  • Library Version in use: v1.2.0
  • Platform being tested: iOS
  • Integrations in use: N/A

Additional context
N/A

Feature Request: Build Facebook App Events Destination plugin

Is your feature request related to a problem? Please describe.
We're trying to migrate away from CocoaPods towards Swift Package Manager for our dependency management and the lack of SPM support of FacebookAppEvents is blocking us from completing that goal.

Describe the solution you'd like
We'd like to migrate all of our dependency management to Swift Package Manager, including Segment FacebookAppEvents

Describe alternatives you've considered
Our only option is to continue using CocoaPods for all our Segment, Facebook, and GoogleAnalytics/Firebase needs because Segment FacebookAppEvents pulls all the others in via CocoaPods and trying to import them both via CocoaPods and SPM creates build issues.

Main Thread Checker: UI API called on a background thread: -[UIView init]

Describe the bug
Calling Analytics.init() crashes my app with the following error:

Main Thread Checker: UI API called on a background thread: -[UIView init]

The line causing the crash is this in AppleUtils.swifts userAgent computed property:

return WKWebView().value(forKey: "userAgent") as? String

To Reproduce
Steps to reproduce the behavior:

  1. Call the initializer of Analytics from a background thread (e.g. utility)

Expected behavior
Analytics is a task that I expect to work in the background.

Screenshots
If applicable, add screenshots to help explain your problem.

Platform (please complete the following information):

  • Library Version in use: 1.0.3
  • Platform being tested: iOS 15
  • Integrations in use: N/A

Additional context
N/A

macOS - Support for both x64 and M1 chipset

I'm getting the following error when i add package and rebuild macOS apps. Our apps target both intel chipset as well as M1 apple silicon chipset.

/AppDelegate.swift:14:8: error: could not find module 'Segment' for target 'arm64-apple-macos'; found: x86_64, x86_64-apple-macos, at: ~/Documents/GitHub/********/Build/Products/Debug/Segment.swiftmodule
import Segment

Will you support both chipsets?

Missing Screen Events

Describe the bug
We're integrating Segment into our telemetry system. But we're seeing calls to .screen(title:category:properties) not being processed and visible in the debugger. I've validated that the event is written to disk in Storage.write<T: Codable>(_:value) and that it is being retrieved in SegmentDestination.flush() and sent to the Segment servers, with a success result in the callback. Calls using .screen(title:category) succeed also and are successfully displayed in the debugger. I also validated that swapping in the old analytics library works to send the event and have it appear in the debugger. Because I can validate that the SDK is sending the event properly and receiving a successful result, I don't think it is an SDK problem per-se except that I can swap in the old framework and it works so if this isn't the correct place to report the issue I understand. I've tried replicating the issue in a separate project with a similar setup but it seems to work sending an identical event.

Validation Work Done:

  • Validated that sending an identical event using the track method works
  • Validated that sending the same event through the old ObjC framework works
  • Validated that sending the same event without properties through the .screen<P: Codable>(title:category:properties:) works
  • Validated that sending the same event without properties does not work
  • Validated that changing from the iOS connection to the Swift connection yields the same result

To Reproduce
Steps to reproduce the behavior:

  • Unable to reproduce in external project

Expected behavior
Event appears in debugger

Screenshots
N/A

Platform (please complete the following information):

  • Library Version in use: 1.0.6
  • Platform being tested: iOS 15.0 Sim & iOS 15.1 iPhone 11 Pro
  • Integrations in use: None

Additional context

  • Event is being processed on a background DispatchQueue
  • Event is being processed in an external dynamic framework

Repetitive logging from library

Describe the bug
A clear and concise description of what the bug is. My Xcode debug console is flooded by repetitive thread_policy_set logs

thread_policy_set(1) returned 46
thread_policy_set(1) returned 46
thread_policy_set(1) returned 46
thread_policy_set(1) returned 46
thread_policy_set(1) returned 46
thread_policy_set(1) returned 46
thread_policy_set(1) returned 46

To Reproduce
Steps to reproduce the behavior:

  1. Setup simple integration
        let configuration = Segment.Configuration(writeKey: apiKey)
            .trackApplicationLifecycleEvents(true)
            .flushAt(10)
                
        let analytics = Segment.Analytics(configuration: configuration)
        
        Self.analytics = analytics
  1. Run the app
  2. See the logs

Expected behavior
Logs should not have repetitive and unneeded logs from library

Screenshots

thread_policy_set(1) returned 46
thread_policy_set(1) returned 46
thread_policy_set(1) returned 46
thread_policy_set(1) returned 46
thread_policy_set(1) returned 46
thread_policy_set(1) returned 46
thread_policy_set(1) returned 46

Platform (please complete the following information):

  • Library Version in use: 1.0.6 and 1.3.0
  • Platform being tested: iOS
  • Integrations in use: none

Crashed: io.segment.analytics.segmentio

Crashed: io.segment.analytics.segmentio
0 libobjc.A.dylib 0x3554 objc_release_x0 + 16
1 libobjc.A.dylib 0x3554 objc_release + 16
2 CoreFoundation 0x29fcc cow_cleanup + 168
3 CoreFoundation 0xb2bf0 -[__NSFrozenDictionaryM dealloc] + 124
4 CoreFoundation 0x29fcc cow_cleanup + 168
5 CoreFoundation 0xb2bf0 -[__NSFrozenDictionaryM dealloc] + 124
6 CoreFoundation 0x29fcc cow_cleanup + 168
7 CoreFoundation 0xb2bf0 -[__NSFrozenDictionaryM dealloc] + 124
8 CoreFoundation 0x3055c -[__NSArrayI dealloc] + 80
9 Segment 0xceb0 __destroy_helper_block_e8_32s40s + 24
10 libsystem_blocks.dylib 0x2124 _call_dispose_helpers_excp + 48
11 libsystem_blocks.dylib 0x1d54 _Block_release + 252
12 libsystem_blocks.dylib 0x2124 _call_dispose_helpers_excp + 48
13 libsystem_blocks.dylib 0x1d54 _Block_release + 252
14 libdispatch.dylib 0x3fdc _dispatch_client_callout + 20
15 libdispatch.dylib 0xb694 _dispatch_lane_serial_drain + 672
16 libdispatch.dylib 0xc1e0 _dispatch_lane_invoke + 384
17 libdispatch.dylib 0x16e10 _dispatch_workloop_worker_thread + 652
18 libsystem_pthread.dylib 0xdf8 _pthread_wqthread + 288
19 libsystem_pthread.dylib 0xb98 start_wqthread + 8

Enable macOSLifecycleEvents

Describe the bug
trackApplicationLifecycleEvents has no impact when running under macOS. No life cycle events are tracked.

To Reproduce
Steps to reproduce the behavior:

  1. Setup analytics in a macOS environment with .trackApplicationLifecycleEvents(true)
  2. Inspect networking no life cycle events get tracked

Expected behavior
Expected life cycle events Application Installed, Application Opened, etc...

Platform (please complete the following information):

  • Library Version in use: 1.2.3
  • Platform being tested: macOS 12.3
  • Integrations in use: Mixpanel

Logging is pretty excessive

Describe the bug
Despite having debugLogsEnabled = false in my code, I get a lot of frequent logging like this:

2021-10-25 16:23:56.712058-0700 Whatnot[14783:3008793] [Log] [Segment Debug  - startBatchUpload(writeKey:batch:completion:):92]
Server rejected payload with HTTP code 400.
2021-10-25 16:23:56.712477-0700 Whatnot[14783:3008793] [Log] [Segment Debug  - flush():145]
Processed: 196-segment-events.temp
2021-10-25 16:24:26.369930-0700 Whatnot[14783:3008612] [Log] [Segment Debug  - cleanupUploads():176]
Cleaned up 5 non-running uploads.
2021-10-25 16:24:26.370098-0700 Whatnot[14783:3008612] [Log] [Segment Debug  - flush():131]
Uploads in-progress: 0
2021-10-25 16:24:26.370260-0700 Whatnot[14783:3008612] [Log] [Segment Debug  - flush():135]
Processing Batch:
199-segment-events.temp
2021-10-25 16:24:26.374740-0700 Whatnot[14783:3008612] [Log] [Segment Debug  - flush():135]

Is there something else I need to do?

To Reproduce
Simple use of the library.

Expected behavior
Minimal (even no) logging for normal operation.

Screenshots
If applicable, add screenshots to help explain your problem.

Platform (please complete the following information):

  • Xcode 13.1, iOS 15, device and simulator.

Analytics class is not singleton

Hello,
Analytics class is not singleton, so Do I need to create a new one with new configuration each time I want to track an event, or manage a custom singleton in my project ?

Drop SPM watchOS min version to 6.0

Is your feature request related to a problem? Please describe.
We need to support watchOS 6.0 for our app and would really like to this this SDK.

Describe the solution you'd like
Drop the min supported watchOS version from 7.1 to 6.0

Describe alternatives you've considered
Not using this SDK

Additional context
Since you already support iOS 13 and I can't seem to find any used APIs that would prevent 6.0, perhaps this is a much easier change than you think!

Crashes observed in OutputFileStream due to EXC_BAD_ACCESS.

Recently we've noticed crashes coming from the new OutputFileStream code. An example stack trace is included at the end of this issue.

While digging into this, we noticed the switch from the foundation FileHandle API to the older POSIX API. The rationale presumably is the deprecation of the write(data: Data) function. This left us perplexed and we believe this to be a misunderstanding. The specific write(data: Data) function was deprecated, yes, but it was replaced with the generic write<T>(contentsOf: T) throws where T : DataProtocol function. As well as being more flexible in its input parameter, the new function also properly communicates errors via throws (related: unhandled exceptions at the write(data: Data) call site was previously an issue we saw coming from your code). It is a welcome replacement (:

If I may, it seems the best course of action would be to remove the OutputFileStream addition, specifically, and simply update the code as it was previously so that it uses the non-deprecated write function from FileHandle. And, the new API forces you to handle the errors I mentioned we had also been encountering, 2 birds...

But, if you must stick with the POSIX API, which, while fun to use at times, I would strongly discourage, then the implementation needs some work. There are numerous issues (lack of handling for short writes, unnecessary string conversions, generally thread safety, dubious pointer handling, etc.) which I'm happy to help you through if you decide to stick with this route. But, it's super tricky to get all this right when using the POSIX API hence why the first class Apple-supported Foundation APIs are preferred over the POSIX ones.

Hardware Model:     iPhone14,3
Process:            Uno
Identifier:         app.Uno
Version:            1.0
Role:               Background
OS Version:         iOS 16.0
Exception Type:     EXC_BAD_ACCESS 
Exception Subtype:  KERN_INVALID_ADDRESS


EXC_BAD_ACCESS: Attempted to dereference garbage pointer 0x68.

0  libsystem_c.dylib _flockfile
1  libsystem_c.dylib _fwrite
2  Uno               closure #1 in OutputFileStream.write(_:) (OutputFileStream.swift:69:17)
3  Uno               specialized String.UTF8View.withContiguousStorageIfAvailable<A>(_:) (<compiler-generated>)
4  Uno               OutputFileStream.write(_:) (OutputFileStream.swift:67:29)
5  Uno               closure #1 in Storage.write<A>(_:value:) (Storage.swift:42:26)
6  Uno               thunk for @callee_guaranteed () -> () (<compiler-generated>)
7  Uno               thunk for @escaping @callee_guaranteed () -> () (<compiler-generated>)
8  libdispatch.dylib __dispatch_client_callout
9  libdispatch.dylib __dispatch_lane_barrier_sync_invoke_and_complete
10 Uno               Storage.write<A>(_:value:) (Storage.swift:37:19)
11 Uno               SegmentDestination.queueEvent<A>(event:) (SegmentDestination.swift:126:17)
12 Uno               SegmentDestination.execute<A>(event:) (SegmentDestination.swift:106:13)
13 Uno               specialized closure #1 in Mediator.execute<A>(event:) (Timeline.swift:78:32)
14 Uno               specialized Timeline.process<A>(incomingEvent:) (Timeline.swift:37:13)
15 Uno               closure #1 in StartupQueue.replayEvents() (StartupQueue.swift:60:28)
16 Uno               thunk for @callee_guaranteed () -> () (<compiler-generated>)
17 Uno               thunk for @escaping @callee_guaranteed () -> () (<compiler-generated>)
18 libdispatch.dylib __dispatch_client_callout
19 libdispatch.dylib __dispatch_lane_barrier_sync_invoke_and_complete
20 Uno               StartupQueue.replayEvents() (StartupQueue.swift:58:19)
21 Uno               closure #1 in StartupQueue.analytics.didset (StartupQueue.swift:21:23)
22 Uno               thunk for @escaping @callee_guaranteed (@in_guaranteed A) -> () (<compiler-generated>)
23 Uno               thunk for @escaping @callee_guaranteed (@in_guaranteed A) -> (@out ()) (<compiler-generated>)
24 Uno               closure #1 in Store.notify<A>(subscribers:state:) (Store.swift:250:21)
25 Uno               thunk for @escaping @callee_guaranteed () -> () (<compiler-generated>)
26 libdispatch.dylib __dispatch_call_block_and_release
27 libdispatch.dylib __dispatch_client_callout
28 libdispatch.dylib __dispatch_main_queue_drain
29 libdispatch.dylib __dispatch_main_queue_callback_4CF
30 CoreFoundation    ___CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
31 CoreFoundation    ___CFRunLoopRun
32 CoreFoundation    _CFRunLoopRunSpecific
33 GraphicsServices  _GSEventRunModal
34 UIKitCore         -[UIApplication _run]
35 UIKitCore         _UIApplicationMain
36 SwiftUI           0x18a82fce4 (0x18a82fc40 + 164)
37 SwiftUI           0x18a78cc20 (0x18a78cb8c + 148)
38 SwiftUI           0x18a775b40 (0x18a775ac4 + 124)
39 Uno               static App.$main() (App.swift:74:1)
40 dyld              start

[Segment ERROR - finish(file:):320] Unable to rename to temp warning/error

Describe the bug
A clear and concise description of what the bug is.

Coming across a very weird debug message lately since the last update. The message appears around 20 secs post starting the app. The message says:

[Segment ERROR - finish(file:):320] Unable to rename to temp: file:///Users/chetanmalhotra/Library/Developer/CoreSimulator/Devices/094C9BEE-0AB5-4345-AB1D-2CA907B66033/data/Containers/Data/Application/1688B1EE-1CCC-44B7-AA72-FB7A9A272B3E/Documents/segment/XVFH4DGT0ufXKfxlMQzNMQDosdD9eKLW/7-segment-events, Error: Error Domain=NSCocoaErrorDomain Code=4 "“7-segment-events” couldn’t be moved to “XVFH4DGT0ufXKfxlMQzNMQDosdD9eKLW” because either the former doesn’t exist, or the folder containing the latter doesn’t exist." UserInfo={NSSourceFilePathErrorKey=/Users/chetanmalhotra/Library/Developer/CoreSimulator/Devices/094C9BEE-0AB5-4345-AB1D-2CA907B66033/data/Containers/Data/Application/1688B1EE-1CCC-44B7-AA72-FB7A9A272B3E/Documents/segment/XVFH4DGT0ufXKfxlMQzNMQDosdD9eKLW/7-segment-events, NSUserStringVariant=( Move ), NSDestinationFilePath=/Users/chetanmalhotra/Library/Developer/CoreSimulator/Devices/094C9BEE-0AB5-4345-AB1D-2CA907B66033/data/Containers/Data/Application/1688B1EE-1CCC-44B7-AA72-FB7A9A272B3E/Documents/segment/XVFH4DGT0ufXKfxlMQzNMQDosdD9eKLW/7-segment-events.temp, NSFilePath=/Users/chetanmalhotra/Library/Developer/CoreSimulator/Devices/094C9BEE-0AB5-4345-AB1D-2CA907B66033/data/Containers/Data/Application/1688B1EE-1CCC-44B7-AA72-FB7A9A272B3E/Documents/segment/XVFH4DGT0ufXKfxlMQzNMQDosdD9eKLW/7-segment-events, NSUnderlyingError=0x600001e34e40 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

To Reproduce
Steps to reproduce the behavior:

  1. Just run any project that uses identify() and track()
  2. Wait for ~20 secs
  3. See error

Expected behavior
There should be no warnings/werrors

Screenshots
If applicable, add screenshots to help explain your problem.
Screenshot 2022-10-15 at 2 54 57 AM

Platform (please complete the following information):

  • Library Version in use: 1.3.1
  • Platform being tested: Ios 15
  • Integrations in use: Firebase and Amplitude

Additional context
Kinda urgent. Pls help saviours

SegmentDestination is causing huge CPU spikes when blocked by LittleSnitch

Describe the bug
When using LittleSnitch to block traffic to Segement.io from our application, we are getting huge CPU Spikes really often, and when entering foreground/background - basically every time the flush is called.

I think there are several problems in SegmentDestination:

  1. Storage can grow without limits - old events that are not sent are never removed.
  2. Storage is keeping files infinitely - which is causing a snowball effect for every sync.
  3. Flush logic is not well prepared for having a lot of data to work with.
    First of all, it read all the data from the filesystem every time it's called.
    Then for each of the files, it creates a network request straight away iterating over all of them - which in my case ends up being over 1500 requests created and failing in milliseconds. This is when CPU spikes are kicking in.
    The whole process is repeated every time the flush() is called and things are getting worse and worse over time when more un-send events are piling up in the storage.

To Reproduce
Steps to reproduce the behavior:

  1. Install LittleSnitch
  2. Block segment.io traffic in LittleSnitch
  3. Create around 100.000 tracked events in Segment
  4. Observe the CPUSpikes when flush logic is called.
  5. Log an enormous amount of network connections created during the flush() call.

Expected behavior

  1. If the user decides to block segment.io coming from our application using external software there should be no performance drop or CPU spikes coming out of this library.

  2. Storage should not grow infinitely - at some point, older events should be removed when newer events are added - there should be the maximum amount of files that are allowed to be cached for sending.

  3. flush() method should not go so aggressive with creating network events for all un-send files - instead it should either go one by one and read the next files only when the previous one succeeded or it should pre-check if segment batch API is reachable before trying to create a massive amount of requests.

Platform (please complete the following information):

  • Library Version in use: 1.2.2
  • Platform being tested: macOS
  • Integrations in use: Amplitude

Workaround
As for now, I am using an ugly workaround from this fork that simply deleted all failed events if the error is URLError.networkConnectionLost - which is the case for LittleSnitch.

Current Status?

Hey! I was upgrading my segment libraries and I saw this, I think it would be very useful to have a current status of the project in a README, so prospective's like me can decide whether or not we want to switch from analytics-ios to this

Identify call doesn't appear in web debugger with certain userId value

Describe the bug
I am calling the identify method with a hashed copy of the user's email address. This never appears in the web debugger, but when I change the userId to something short, such as my first name or "test", it works without issue. Is there a character limit applied? The segment debugger doesn't show any signs of errors.

To Reproduce
Steps to reproduce the behavior:

  1. Do identify(userId: "ee1d83696ded26626ad9fd3f9ad4a28f207cab5a")
  2. Notice no debugging errors in Xcode, but web debugger doesn't receive event.3.
  3. Do identify(userId: "test")
  4. Notice that the event appears in web debugger.

Expected behavior
The event should be sent to Segment, and shown in the web debugger.

Platform (please complete the following information):

  • Library Version in use: 1.3.1
  • Platform being tested: iOS
  • Integrations in use: Amplitude

CocoaPod installation supprot

Hi! Do you plan to add CocoaPods support for this library as it is done for the Objective-C one? Or down the road Swift Package Manager will be the only supported one?

Asking mostly to understand if I should go through the hassle of integrating with source codes or wait for pods support.

Thanks!

Unable to add package

Describe the bug

I've been trying to add this library for many days / have added other libraries via Swift Package Manager (e.g. Firebase) successfully, but have been running into issues with Segment specifically. I believe it was initially related to Segment requiring being added via SSH vs HTTPS but I've added my laptop's SSH keys to Github and believe it's working correctly (correct status in Xcode / I can clone [email protected]:segmentio/analytics-swift.git from the CLI, etc...).

To Reproduce
Steps to reproduce the behavior:

  1. Go to File → Add Packages…
  2. Enter [email protected]:segmentio/analytics-swift.git into the "Search or Enter Package URL" field.

Expected behavior
Name of library and README show up. Library is added successfully.

Observed behavior

  1. Title, readme, etc... aren't pulled. Size is displayed. (See screenshot)
  2. That said, I am still able to add the library and metadata displays. (See next screenshot)
  3. However once it's added to the project, I see the error /Users/vthommeret/Code/Loopable/github.com:segmentio/analytics-swift.git: The remote repository could not be accessed. Make sure a valid repository exists at the specified location and that the correct credentials have been supplied.

It seems like this is maybe a credential issue but it's strange that it does pull the metadata in some instances and actually does download and add the project, which previously didn't work when I didn't set up SSH key authentication.

Screenshots

Screen Shot 2021-12-03 at 10 45 17 AM

Screen Shot 2021-12-03 at 10 38 40 AM

Screen Shot 2021-12-03 at 10 40 48 AM

Screen Shot 2021-12-03 at 10 41 33 AM

Platform (please complete the following information):

  • Library Version in use: 1.0.6
  • Platform being tested: iOS Swift app
  • Integrations in use: None yet.

Data loss after quick successive calls to `flush()`

Describe the bug
Assuming the Segment debugger is showing all events, I've noticed that certain event are frequently lost when there are multiple calls to flush in a row.

To Reproduce
Add the following to your sceneDidBecomeActive(_:) or similar:

for i in 0..<10 {
    analytics.track(name: "rapid event \(i)")
    analytics.flush()
}

Expected behavior
Events 0-9 appearing in Segment's source debugger.

Actual behavior
Most events arrive but... missing one or two here and there!

Screenshots
Screenshot 2021-08-21 at 13 48 33
Here we're missing 2 and 8

Platform (please complete the following information):

  • Library Version in use: master
  • Platform being tested: iOS latest
  • Integrations in use: None

Additional context

  • Lifecycle events are OFF
  • flush() called regularly at key events

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.