Commit Graph
76 Commits
Author SHA1 Message Date
Paul Beusterien 54d28547d3 Remove GDT from repo (#7384) 2021-01-27 07:51:12 -08:00
BJ Homer 3642b56224 Delay GDTCORUploadCoordinator timer initial run (#7173)
If an upload coordinator gets created during `+load` calls, it can end up running its immediately, while +load calls are still running. It's generally a bad idea to be splitting off threads while +load calls are still running.

The upload coordinator checks every 30 seconds, and doesn't really need to run right away. Since it's easy to transitively create an upload coordinator from other calls that happen during +load, we'll just push off the initial run of the timer slightly. That makes it less likely to interfere (or deadlock) with other load calls.

See #7171 for an example of a problem solved by this change.
2020-12-15 17:03:29 -05:00
Visu 94ab466f50 Make the URLs used by Google Data Transport available in a Public API. (#7167) 2020-12-15 12:35:50 -08:00
Maksym Malyhin 92db10edb4 GDT storage cleanup: optimizations for big amount of pending events (#7014)
* GDT storage cleanup performance testing

* style

* GDTCORDirectorySizeTracker - autoreleasepool in cycles

* [GDTCORFlatFileStoragecheckForExpirations] - autoreleasepool in cycles

* TestApp: Performance testing tweeks

* Revert "[GDTCORFlatFileStoragecheckForExpirations] - autoreleasepool in cycles"

This reverts commit e0573f5a1b.

* [GDTCORUploadCoordinator signalToStoragesToCheckExpirations]: signal once per storage

* Revert "Revert "[GDTCORFlatFileStoragecheckForExpirations] - autoreleasepool in cycles""

This reverts commit 34e9eee131.

* style

* changelog
2020-11-24 12:46:50 -05:00
Maksym Malyhin 57123ae0d5 Update clang-format to 11 (#6905)
* Update clang-format to 11

* Upgrade clang format

* Install clang-format@11

* Update readme

* brew update
2020-11-05 12:58:48 -05:00
bff6b664d1 Merge release-6.34.0 branch after patch (#6701)
* Update versions for Release 6.34.0

* 6.34.0 updates for SwiftPM (#6614)

* M81 FIS cherry pick of #6570 (#6616)

* FIS: Additional FIRInstallationsItem validation (#6570)

* FIS API tests for no FID in response

* FIRInstallationsIDControllerTests: test names

* FIRInstallationsIDControllerTests: corrupted storage tests

* FIRInstallationsItem validation

* Fix FIRInstallationsItem.IIDDefaultToken copy

* Improve error description.

* FIRInstallationsItem validation error

* FIRInstallationsItem validation tests

* ./scripts/style.sh

* FIRInstallationsIDController: validate stored installation

* FIRInstallationsAPIService installation validation

* Changelog

* Update versions

* patch version

* release manifest

* FIS: don't log anything on success validation (#6635)

* Update changelogs (#6649)

* GoogleDataTransport: deprecated API conditions (#6697)

* GoogleDataTransport: deprecated API conditions

* Version bump

* use `TARGET_OS_IOS`

* changelog

* changelog

* style

* Fix merge

Co-authored-by: Ryan Wilson <wilsonryan@google.com>
Co-authored-by: Paul Beusterien <paulbeusterien@google.com>
Co-authored-by: Morgan Chen <morganchen12@gmail.com>
2020-10-08 15:11:00 -04:00
Maksym Malyhin bde8e07844 GDT: move some headers from public to internal (#6643)
* Move extra public headers to Internal and fix imports

* Cleanup

* Use relative paths in internal headers

* Fix imports in internal headers

* ./scripts/style.sh

* Fix GDTTestApp

* Fix test app

* Use real uploader for watchOS test app

* comma
2020-10-05 14:00:49 -04:00
Maksym Malyhin babd8e63bd GDT: Move GDTCORAssert.h to internal headers (#6638)
* Move GDTCORAssert.h to internal headers

* Fix import
2020-10-01 20:56:26 -04:00
Maksym Malyhin 38be2cc8c6 GDTCORDirectorySizeTracker: fix NSURL constructor (#6580)
* GDTCORDirectorySizeTracker: replace optional NSURL constructor with non-optional.

* GDTCORDirectorySizeTracker tests for the issue

* ./scripts/style.sh

* changelog
2020-09-28 11:01:32 -04:00
Maksym Malyhin ca44b646b8 GDT: remove pre Xcode 10 availability checks (#6486)
* GDT: remove pre Xcode 11 availability checks

* Revert Xcode 10 required availability checks

* Changelog
2020-09-17 15:31:44 -04:00
Maksym Malyhin 57101b28a9 GDTTransformer: fix background tasks handling (#6457)
* GDTCORTransformer: background task tests

* GDTCORTransformer: background tasks handling fix

* Copyright

* Changelog

* Comments

* rand() -> arc4random()

* GDTCORTransformer tests for default initializer

* Fix default initializer

* ./scripts/style.sh

* Pass weak application reference to the blocks
2020-09-15 11:02:48 -04:00
Maksym Malyhin a59febae5a GDT: storage size limit (#6365)
* GDTCORFlatFileStorageTest: test storage size limit

* Size limit slow implementation.

* GDTCORFlatFileStorage: prefetch file size

* GDTCORDirectorySizeCalculator introduced

* GDTCORDirectorySizeCalculator integration with GDTCORFlatFileStorage

* Storage size calculation tests

* Cleanup

* Cleanup

* API docs

* Fix type

* Tests

* Tests - don't hardcode event size

* Changelog

* Fix tests on slower CI.

* API docs

* Tests comments

* GDTCORFlatFileStorageTest failure debug

* GDTCORFlatFileStorageTest debug: make sure all generated events stored.

* GDTCORFlatFileStorageTest debug

* GDTCORFlatFileStorageTest debug: dynamically generate events

* Cleanup

* Renaming GDTCORDirectorySizeCalculator->GDTCORDirectorySizeTracker

* Size tracker lazy initialization

* Remove old code

* Size tracker methods renaming

* Cleanup

* Additional tests
2020-09-11 10:42:30 -04:00
Maksym Malyhin 802cb6a716 GDT: revert cc_scub annotations (#6274) 2020-08-13 16:06:43 -04:00
Tejas Deshpande ab6fc616b4 Fix clang-tidy (#6270) 2020-08-13 11:18:40 -04:00
Tejas Deshpande b449bee0a2 Create an additional URL target for internal use (#6254)
#no-changelog
2020-08-12 18:20:21 -04:00
Maksym Malyhin 2683e9da53 GDTCORClock: use NSTimeZone to get a timezone with respect of daylight (#6246)
* GDTCORClock: use NSTimeZone to get a timezone with respect of daylight

* Changelog
2020-08-10 17:00:26 -04:00
Paul Beusterien 70d4e8a6e6 GDT remove @import (#6178) 2020-07-31 09:26:49 -07:00
Paul Beusterien 85e3354346 GDT - new public header structure (#6177) 2020-07-31 08:12:23 -07:00
Maksym Malyhin fa26512015 GDT: fix time units for the request and events uptime (#6102)
* GDTCORClock: fix uptime and kernelBootTime units

* GDTCCTNanopbHelpers: fix time units for the batch and events snapshot uptime

* Formatting

* GDTCORClock: properties rename and deprecation.

* Changelog updates

* Fix renaming issues

* Cleanup

* GDTCORClockTest: reduce timestamp comparison accuracy
2020-07-22 11:49:55 -04:00
Maksym Malyhin ec018dcbd7 [GDTCORUploadCoordinator startTimer]: don't restart timer if already started (#6032)
* [GDTCORUploadCoordinator startTimer]: don't restart timer if already started

* style

* `GDTCORUploadCoordinator.timer` - nullable

* GDTCORUploadCoordinator test utils thread safety.
2020-07-13 17:35:20 -04:00
Maksym Malyhin 744fd1865b GDTCORFlatFileStorage: keep not expired events when expired batch removed (#6010)
* GDTCORFlatFileStorage: expiration clean up tests

* GDTCORFlatFileStorage: keep not expired events when expired batch removed

* Cleanup

* Cleanup

* Comments

* Comments

* Remove additional delays in tests

* style

* Changelog
2020-07-09 17:12:54 -04:00
Maksym Malyhin 4dd48bdcd9 GDT: Retry uploading batches failed to upload before the app termination (#5942)
* GDTCCTUploaderTest: test a lost batch upload retry

* GDTCCTUploader: refactoring to prepare for lost batches uploading

* GDTCCTUploader: Upload previously batched events first

* Fix GDTCCTTestStorage

* Refactor GDTCCTUploaderTest

* GDTCORFlatFileStorageTest: batch tests

* GDTCORFlatFileStorage: refactor removeBatchWithID to prepare for eventsForbatchID

* eventsInBatchWithID implementation

* Fix tests

* Uploader fix for empty batch state

* GDTCORUploadCoordinator: high priority targets

* style

* GDTCCTUploaderTest

* GDTCCTUploaderTest: cleanup

* Cleanup and API docs.

* GDTCORUploadCoordinator: revert high priority targets

* GDTCCTUploader: make sure GDTCOREventQoSFast is part of a regular batch as well.

* Cleanup

* GDTCCTUploader: don't report ready for upload until there are events.

* GDTCCTUploaderTest: move failed batch back to the queue

* GDTCORFlatFileStorage: removeBatchWithID with deleteEvents==NO

* GDTCORFlatFileStorage: remove batch directory

* style

* GDTCORFlatFileStorage: comments and debug logs

* formatting

* GDTCCTUploaderTest: recover tests

* GDTCCTTestServer: support for async request handler

* GDTCCTUploaderTest: ongoing request tests

* GDTCORStorageProtocol: remove redundant `eventsInBatchWithID` method.

* GDTCORFlatFileStorageTest: `removeBatchWithID` tests

* Cleanup

* GDTCORFlatFileStorage: cleanup

* GDTCORFlatFileStorageTest: better coverage and cleanup

* Comments and improvements

* GDTCCTUploaderTest: reduce code duplication

* GDTCCTUploaderTest: conditions tests

* GDTCCTUploader: fix next request wait time

* run ./scripts/style.sh
2020-07-07 09:10:22 -04:00
Paul Beusterien d653c9584c Update copyright presubmit and fix 2020 copyrights (#5944) 2020-06-29 13:16:19 -07:00
Maksym Malyhin 527ce9049f Use UUID as GDTCOREvent.eventID (#5907)
* Remove unused header from FIRCoreDiagnosticsTest

* Use UUID as GDTCOREvent

* Fix analyzer issue

* run ./scripts/style.sh

* Code review comments
2020-06-25 09:46:01 -04:00
Paul Beusterien 5a5914da7e GDT Repo-relative imports and SPM (#5909) 2020-06-24 17:50:15 -07:00
Michael Haney a00703a543 Completely reimplement storage in GDT (#5877)
* Revert "Revert GDTCORStorage changes for now (#5778)"

This reverts commit 93eb6d8c48.

* Store events and implement unit tests (#5790)

Resolves many TODOs in the flat file storage system
Bug fixes found by unit tests are also included.

* Get rid of event iterators and add separate folders for batching (#5829)

* Store events and implement unit tests (#5790)

Resolves many TODOs in the flat file storage system
Bug fixes found by unit tests are also included.

* Change to explicit nil comparison

* Address test comments

- Makes all APIs async
- Add thread-safety test
- Comments on where files are stored
- Broke up the library data get/set API into two blocks

* Implement events and batch expirations (#5842)

The upload coordinator will signal an expiration check whenever the app foregrounds.

* Remove prioritizers, upload packages, data futures, and backwards compatibility (#5874)

* Remove prioritizers, upload packages, data futures, and backwards compatibility

* Update a comment and console logging

* Reset the storage for every unit test, move event generation out of core init

* Return a nil request if data is nil.

* Fix prioritizer reference in watchOS test app

* Remove unnecessary check for termination

* Give more leeway for eventID generation

Change the transport API to a GDTCORTarget
Don't continue a long test after a failure

* Return nil if an eventID couldn't be created

Fix some swift in the watchOS test app

* Fix all rawValue GDTCORTarget usage

* Update CHANGELOGs

* Remove initializer annotations (#5878)

* Remove initializer designation from GDTCOREvent

Change the target property to the target type

* Add a couple more types

* Make implicit retain explicit

Nothing I do seems to get this warning to trigger locally...

* Address loss of precision issue

* Re-enable a disabled test

Don't delete while enumerating

* Additional test tweaks and hasEvents is now on the queue and async

* Adjust GDTCCT to the new API

* Always attempt to create a path, get rid of implicit self refs

* Change all waiting for be DISPATCH_TIME_FOREVER for debugging purposes

I suspect the travis machines are just overwhelmed, since the test errors don't make any sense.

* Try using a different separator

* Enable debug logging

* Enable verbose pod lib lint output

* Handle cases where the mappingID contains path components

* Revert "Enable debug logging"

This reverts commit b3e4a6ecc5.

* Revert "Enable verbose pod lib lint output"

This reverts commit a5b54460f9.

* Revert "Change all waiting for be DISPATCH_TIME_FOREVER for debugging purposes"

This reverts commit 55e4fff5dc.

* Attempt to create a folder before writing

* Temporarily enable verbose pod lib lint, again

* Temporarily add debug logging back in

* Don't double store events

Also print out errors if there are any

* Remove debug logging

* Put debug logs back in for Crashlytics test

* Update mock APIs to match and use a real target

* remove debug logging

* Apply nullability specifiers to Crashlytics mock class
2020-06-23 16:04:18 -07:00
Visu de94d1d7a2 Make the deviceModel to be a static variable to avoid overwrites. (#5847) 2020-06-18 10:07:18 -07:00
VisuandPaul Beusterien 4a6f6135be Update the device model identified by GDTCCTLibrary to be more detailed and in parity with Clearcut. (#5836)
Update the device model identified by GDTCCT library to be more detailed and in parity with Clearcut.

Current GDT implementation returns "iPhone". With this change, the device model identified would be iPhoneA,B (Eg. iPhone 8,1).

Co-authored-by: Paul Beusterien <paulbeusterien@google.com>
2020-06-17 09:42:18 -07:00
Michael Haney 93eb6d8c48 Revert GDTCORStorage changes for now (#5778)
* Revert "Refactor event saving and searching (#5773)"

This reverts commit a61786cbf1.

* Revert "Expand the storage protocol and provide an event iterator (#5742)"

This reverts commit 641d8531a3.

* Revert "Implement helpers for storing and finding events (#5738)"

This reverts commit 9a0aed81b0.
2020-06-09 13:55:15 -07:00
Michael Haney a61786cbf1 Refactor event saving and searching (#5773)
* Refactor event saving and searching

No more symlinks to try and speed searching. Just get a directory's contents and check the filename, which will contain metadata about the event.

* Change one string formatter

* Fix the type of some params, remove unused code

* Minor update

* Continue running after failing to process a file
2020-06-09 11:19:38 -07:00
Michael Haney 641d8531a3 Expand the storage protocol and provide an event iterator (#5742)
* Expand the storage protocol and provide an event iterator

* Remove unused variable

* Remove unused variable

* Make implicit self retain explicit

* Just check for NSFileTypeRegular instead

And fix a comment

* Missed a damned implicit self retain

* Implement some tests for the new API

* Fix yet another implicit self retain
2020-06-05 12:16:33 -07:00
Michael Haney 9a0aed81b0 Implement helpers for storing and finding events (#5738)
* Implement helpers for storing and finding events

* Fix missing imports

* Add clarifying comments and remove unneeded nullability

Also remove a test and fix the behavior of searchPathsWithEventSelector

* Added missing docs and properly implemented +reset
2020-06-03 14:10:08 -07:00
Michael Haney 0d526fd19c Change upload coordinator to not block main thread (#5712)
* Change upload coordinator to not block main thread

Fixes #5707 
Fixes #5708

* Update CHANGELOG.md
2020-06-01 12:33:51 -07:00
Michael Haney 65e0a9896b Add a global function to get storage instances (#5682)
* Add a global function to get storage instances

* Fix missing header

* Update CHANGELOG.md
2020-05-27 13:23:54 -07:00
Michael Haney 1be5de4899 Provide an arbitrary data persistence mechanism on storage instances (#5637)
* Provide a library data mechanism on storage instances

This could allow most singletons to no longer need NSCoding, they just store the individual fields they need with an appropriately unique key

* Additional  tests

And no more implicit removal

* Implement read error capture

* Make test file data keys more unique

Also, there _should_ be an error reading from a non-existent file.
2020-05-19 15:29:05 -07:00
Michael Haney 08938f7c32 Fixes the count file not being found (#5584)
* Fixes the count file not being found

Calling the new GDTCORRootDirectory() function ensures that the directory needed is created before an attempt to write is made.

Fixes #5549

* Update CHANGELOG and versions
2020-05-12 15:17:09 -07:00
Michael Haney 7ddbb42034 Print out counter error message. (#5552)
* Print out counter error message.

* style
2020-05-08 13:45:49 -07:00
Michael Haney 54c7fc63e9 Move reachability flags initialization to +initialize from +load (#5477) 2020-04-27 14:56:22 -07:00
Doudou Nan 68fb6624f4 Expand watchOS support for GoogleDataTransport (#5443)
* Add watchOS support for GoogleDataTransport with specifying notification center and WKExtensionDelegate for watchOS application, handling background tasks and network reachability flags on watchOS.

* Add independent watchOS test app for GoogleDataTransport and GoogleDataTransportCCTSupport.

* Add companion watchOS test app and notification service extension for GoogleDataTransportCCTSupport.
2020-04-24 15:19:43 -07:00
Michael Haney 7b78ac7866 Don't leak upload packages or deadlock on lifecycle events (#5382)
* Don't leak upload packages or deadlock on lifecycle events

GDTCORUploadPackages would call targetToStorage in -initWithTarget. When this method was running during app terminate, this would cause a deadlock because calling targetToStorage is re-entrant while GDTCORRegistrar is sending lifecycle events to all the instances it's tracking.

NSTimer's invalidate method is also called whenever a package is completed, retried, or expired, without regard to the presence of a package handler.

A unit test is added to ensure that GDTCORUploadPackage's are not leaked by a retain

TSAN caught no issues

* Don't mark GDTCORUploadPackage -init as unavailable
2020-04-15 13:03:18 -07:00
Michael Haney 78ee63dab3 Handle events that fail to write or are missing and add logging levels (#5357)
* Change removeItemAtURL to removeItemAtPath

It seems to work better, for reasons that aren't clear. It may have something to do with forming URLs being more strict.

* Add logging levels, fix failed write events

* Update comment
2020-04-14 12:30:29 -07:00
Michael Haney 77394a4ef1 Fix < 0 comparison for an unsigned long long (#5353)
* Fix < 0  comparison for an unsigned long long

* Remove an unused file and fix init of a ULL
2020-04-13 14:27:52 -07:00
Michael Haney c57ae0f155 More safely handle event IDs in migrations (#5348)
* More safely handle event IDs in migrations

* Change to an explicit nil check
2020-04-12 16:26:18 -07:00
Michael Haney 6c14c21bc9 Merge storage refactor back to master (#5322)
* Make mph-gdtsqlite run travis (#3861)

* Implement a SQLite helper (#4075)

* Add support for in-memory and other types of stores (#4158)

* Add support for in-memory and other types of stores

* Temporarily add -x to know what's causing check.sh to fail

* Remove -x

* DO NOT MERGE TO MASTER: Remove commit math from check.sh temporarily

* Initial implementation of GDTCORDatabase (#4180)

* Initial implementation of GDTCORDatabase

* Style

* Check result of running a statement

* Simplify init

Also support >1 :memory: db

* Write test docs and fix one tsan issue (#4211)

* wip moving storage to sqlite

* Revert "wip moving storage to sqlite"

This reverts commit ee1895f1bd.

* Address tsan issue and document tests

* Address implicit self retains

Don't know why these aren't surfaced locally, I have the warning on.

* Implement bulk sql execution (#4528)

* Change custom prioritization dictionary to bytes (#4534)

* Change custom prioritization dictionary to bytes

* Fix a missed change for customBytes

* Refactor GDT's storage to be an interface (#5022)

* Refactor GDT's storage to be an interface

- Events are now removed by eventID
  - Events now generate an ID when they are alloc/inited
  - Copying events also copies their eventID
  - Event hashing takes into account the eventID
  - A static method in GDTCOREvent creates  event IDs as the concat of <session counter><event counter during session>
  - Session counters are incremented and stored in user defaults at app start
- Storage instances register themselves with GDTCORRegistrar like prioritizers and uploaders
- Storage fakes are refactored to be registered with GDTCORRegistrar
- Added some missing docs and fixed some typos

* Remove an unintended change from assert macro

* Use a variable

* Additional docs and test fixes

* Move saving the counter value to a file

* Update docs

* Rename GDTCORStorage to GDTCORFlatFileStorage (#5079)

* Rename GDTCORStorage to GDTCORFlatFileStorage

* Fix the NSCoding keys

* Fixes to get building and unit tests passing

* Address lack of thread safety affecting lifecycle tests

* Style

* Transition customPrioritizationDict to customBytes

Adds a category  on GDTCOREvent to make checking network connection info easier.

* Remove all sqlite and database stufff or the purposes of merging back to maste (#5330)

* Update .travis.yml
2020-04-09 13:14:15 -07:00
Michael Haney e403d965d5 Fix a couple of race conditions and module import of a private header (#5187)
* Fix a couple of race conditions and module import of a private header

The header and API in question should be considered hidden. An alternative would be expose the API in the private header .

A race condition existed in the upload package itself--it should hand copies of itself and not self to prevent asynchronous mutation whilst a different queue is also executing an asynchronous mutation. One alternative would be to create mutable an immutable variants of the package. This could manifest as an EXC_BAD_ACCESS in GDTCCTPrioritizer.m

* Assert that the IMP is present, because there shouldn't be a silent failure
2020-03-25 11:10:56 -07:00
Michael Haney 4e900ca551 Address GDT test issues (#5186)
* Address GDT test issues

1. Fixes the event  generator such that derived event fileURL will now be non-nil
2. Removes reachability check for integration tests since being locally connected via LAN but not connected to the internet would cause the test disabling check to pass. Instead, we attempt an actual NSURLRequest to a WAN target and set the value based on the success of that request.

* Create GDT's directory on first usage
2020-03-24 17:35:33 -07:00
Michael Haney ea3521d263 Only delete events when package was successfully delivered (#5172)
* Only delete events when package was successfully delivered

* Add unit test to check that retrying a package delivery doesn't delete an event file
2020-03-23 14:11:40 -07:00
Michael Haney aeb4def61d Libraries should save state if a completion block is requested (#5147)
* Libraries should save state if a completion block is requested

Currently, the onComplete block of sendXEvent:onComplete: is invoked when the event bytes are written to disk. However, if the app crashes before a lifecycle event occurs (trigger GDTCORStorage to serialize to disk), that event if effectively lost because the metadata has all been lost. This change triggers the saving of state of GDTCORStorage and prioritizers (if they implement it) if an onComplete block has been given.

* Remove flaky check

* Update GDTCORStorage.m
2020-03-18 15:00:37 -07:00
Michael Haney 27847eea38 Refactor event fileURLs to be derived (#5137)
* Refactor event fileURLs to be derived

Apparently, since iOS 8, it's possible for the app's bundle to change directories as often as every launch. This is a mechanism that's hopefully slightly more robust against that, as data is supposed to carry over, the UUID component of the app's absolute directory might just change.

* Convert a couple of tests, actually use a non-absolute URL in GDTCOREvent

* Make sure to use the event fileURL property as the source of truth.

Add some additional logs and improve the integration test

* Fix KVC not working for the removed property
2020-03-18 08:09:18 -07:00
Michael Haney 4ee3288747 Fix deprecation warnings by consolidating coding calls (#5131)
* Fix deprecation warnings by consolidating coding calls

Fixes #5086

* Fix all NSSecureCoding references

* Fix changed API usage
2020-03-17 19:06:05 -07:00