Coder Social home page Coder Social logo

Comments (20)

winsmith avatar winsmith commented on May 28, 2024 1

So far we can. Let's see how the open beta changes that 😂

from swiftclient.

outcoldman avatar outcoldman commented on May 28, 2024 1

Also, consider using JSON streaming format (https://en.wikipedia.org/wiki/JSON_streaming).

This is how I would see the implementation.

The client should collect and store all signals on the disk, appending JSONs line by line to a temporary file to a known unique location of the app. In case of Apple apps could be

try FileManager.default.url(
    for: .libraryDirectory,
    in: .userDomainMask,
    appropriateFor: nil,
    create: true
)
.appendingPathComponent(Bundle.main.bundleIdentifier!)
.appendingPathComponent("apptelemetry.noindex")
.appendingPathComponent("data.json")

As you can see I store it in the library folder, so if the app will crash or Mac will reboot, we still have access to the old telemetry.

There are should be a background Timer (like fired once an hour) that will check on the disk if there is anything to send, will pick up those files and send them to your Telemetry server.

Preferable to send with the JSON streaming format, so there will be just one large HTTP call, and not bunch of small ones. Also, when sending, please consider using gzip-compression (to be honest I am not sure if URLSession does it automatically).

from swiftclient.

winsmith avatar winsmith commented on May 28, 2024 1

JSON streaming looks super cool, I haven't seen that before. Thanks for that. GZIP should be enabled by default but it can't hurt to check that.

from swiftclient.

nik6018 avatar nik6018 commented on May 28, 2024

Storage Choices:

  • If we had a day's worth Signals using Defaults would load the entire thing into the memory before it would be transmitted to the server, so I don't know if this trade off can be made
  • Core Data would bring lots of goodies for storage management but it too has it's own can of worms (mainly migrations)
  • Haven't worked that much on storing data directly to disk, so can't comment on that.

Live Transmission

  • Uploading signals in bunch will truly optimise the process, this is big up side
  • We can have Live signals for Debug Mode only and then bundle up signals while in Productions (Firebase does this ... stream view can only be enabled with a flag in Debug builds and disable them in Production) (Sorry to repeat if you already knew)
  • I don't know if it's your product goal to display Live Signals but IMO they should be restricted to Debugging only (But I like them for my app though 😄)

from swiftclient.

winsmith avatar winsmith commented on May 28, 2024

Why do you want to restrict live signals to debug only? I think live signals is a super neat thing, and I'd really like to keep them at least live-ish (I wouldn't mind a bit of a lag)

from swiftclient.

nik6018 avatar nik6018 commented on May 28, 2024

Well I thought it's a load thing on the server .... (Firebase tutorials given this reason for not enabling their continuous stream even view for production). But if we can have that without degrading server performances than it's a win :)

from swiftclient.

nik6018 avatar nik6018 commented on May 28, 2024

Cool. So were you able to give any thought on the storage part ?

from swiftclient.

winsmith avatar winsmith commented on May 28, 2024

Probably needs to be a JSON file written to a temp location. I can't see any other way to make that work on all supported platforms easily.

from swiftclient.

nik6018 avatar nik6018 commented on May 28, 2024

Cool. Can I help in anyway possible ?

from swiftclient.

winsmith avatar winsmith commented on May 28, 2024

I'm open to pull requests, if you feel like tackling this. Otherwise, you can help by finding out by thinking about when and how often the client should try and send data to the server, and without sending data multiple times, and posting your thoughts into this ticket. (This is an open invitation to all users of the client of course)

from swiftclient.

nik6018 avatar nik6018 commented on May 28, 2024

I think we can use a session based approach, where we gather all the signals for the current session and then when applicationDidEnterBackground(_:) gets called, upload all the signals using a BackgroundTask (we'll have at least 5 - 10 seconds to complete the operation once the app enters background)

from swiftclient.

winsmith avatar winsmith commented on May 28, 2024

Grouping by session is a good idea. We shouldn't forget that the device might have no internet connection at backgrounding time though. Also, I'd like to send signals more often than just when the device backgrounds, so a periodic periodic uploader should be a good addition here.

from swiftclient.

nik6018 avatar nik6018 commented on May 28, 2024

We can implement something that checks for signal count. Uploading 10 signals in a bunch seems like a good conservative approach at least for the time being. So the utility will save 10 signals and once we have more than that we upload the last 10 and save the new signals.

from swiftclient.

winsmith avatar winsmith commented on May 28, 2024

I like that!

from swiftclient.

nik6018 avatar nik6018 commented on May 28, 2024

Nice I can come up with a solution for this, for time being I'll start with Defaults as storage solution .... this will reduce the storage complexity initially

from swiftclient.

winsmith avatar winsmith commented on May 28, 2024

Please do not use Defaults as storage. Using defaults as storage will cause the client to not work under Linux and Windows any more, which are supported platforms.

from swiftclient.

nik6018 avatar nik6018 commented on May 28, 2024

Aaah this is downfall of me coding for Apple Platforms only .... can you suggest any other method ? (Saving to file is the best way to go ?)

from swiftclient.

winsmith avatar winsmith commented on May 28, 2024

I'd like this to be in a temporary JSON file. How about I get started with the general structure and then you can help out with PRs later?

from swiftclient.

nik6018 avatar nik6018 commented on May 28, 2024

from swiftclient.

winsmith avatar winsmith commented on May 28, 2024

This is now done, and I completely forgot to close the ticket. Oops.

from swiftclient.

Related Issues (20)

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.