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

V4 Updates #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

V4 Updates #1

wants to merge 6 commits into from

Conversation

absolut-zero
Copy link

No description provided.

nevans and others added 6 commits June 1, 2023 10:00
Add `api_secret` and `client_id` requirement to Tracker.  When they are
nil, NoopTracker will be used instead.

Require `client_id`.  This is a big change, but I believe it the most
appropriate approach to Google's v4 API.  Because access to standard
analytics `client_id` is at least partially a matter of end-user
consent, I believe it would be wrong for this library to automatically
generate a missing `client_id`.  Users of the gem may know that it is
reasonable and permissible to generate a missing `client_id`, but they
should manage that themselves.

Other general updates:
* Add many specs for V4::Tracker and V4::Event.
* Some changes to event method names to use nomenclature more similar to
  the Measurement API v4 documentation.
* Added `uri` methods to the Net::HTTP and Validation adapters, for both
  testing and debugging.
* Experimental support for auto-generating `timestamp_micros`.
* Moved all of the default_adapter related methods from V4 and
  V4::Tracker into V4::AdapterDefaults, and then extended V4 and
  V4::Tracker with them.  For V4::Tracker, this moves the methods up to
  the class level, but this also enables memoization at the class level.
* Updated `Staccato::Adapter::Validation` to accept a custom uri.

Updates to Event:
* Adds `Event.param` DSL, backward-compatible with `FIELDS`.  This is a
  step towards changing the `Event` module to a generic superclass.
* Return custom parameters from `#as_json`, in addition to the standard
  recommended parameters.
* Recursively encode `#as_json` parameter values, eg: `items: [...]`.
* Correctly encode Item, without requiring ActiveSupport.
* Add `#engagement_time_msec` and `#session_id` as recommended
  parameters.
* Add `#update`, for adding and updating parameters.
* Add `#apply_defaults`, for adding missing parameters to an event.

Updates to Tracker
* Add a bang-method version of each dynamically generated event type
  method, to immediately post all enqueued events.
* Add `tracker << event` as an alternative form of `#add`.
* Update `#add` to accept simple String, Symbol, and Hash events.
* Update `#add` to accept already constructed Event objects.
* Update `#add` to reverse merge with `#default_event_params`.
* Update `#event` to return a frozen duplicate array.  This protects
  against events being added directly.  `#add`, `#<<`, `#clear`, and
  `#trim` should provide adequate support for generic event data, so
  direct mutation of `#events` shouldn't be necessary.
* Update `#post` visibility to be public.
* Update `#post` to send in batches of 25 events, returning an array.
* Update `#post` to clear `#events` as they are posted.
* Add `#default_event_params`, which are applied to each event.
* Add basic support for `#user_id` and `#user_properties`.
* Convert `NoopTracker` to a subclass of `Tracker`.
* Clear `#events` after successfully calling `#track`.
* Update `#adapters` to memoize the default adapter on the first access.
  This simplifies adding a new adapter without losing the default.
* Document that `#validate!` sends only the first 25 events.
* Document that `#validate!` doesn't clear the #events array.
* Update `#validate!` to use the class-memoized validation adapter.
* Update `#add_adapter` to accept `:net_http`, `:validation`, or
  `:logger` with optional logger arguments.
* Add `tracker.clear` to clear the events array
* Add `tracker.trim` to drop the first events from the events array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants