Skip to content

Introduce service account and project token authentication, migrate README to markdown#135

Open
santigracia wants to merge 7 commits intomasterfrom
api-secret-deprecation
Open

Introduce service account and project token authentication, migrate README to markdown#135
santigracia wants to merge 7 commits intomasterfrom
api-secret-deprecation

Conversation

@santigracia
Copy link
Copy Markdown
Collaborator

Introduce service account and project token authentication for the /import endpoint (breaking change for import using already deprecated api_key).

Tracker#import now accepts a credentials Hash instead of an api_key string; Events and Tracker docs and signatures were updated accordingly.

Consumer now supports HTTP Basic Auth (including project token as username with empty password) and appends project_id as a query param for service-account imports. Request method accepts basic_auth, and tests updated to cover both auth flows. Added demo examples for both auth methods, updated README with 3.1.0 notes.

The .rdoc format is outdated for GitHub READMEs. As the standard is Markdown, converted README to .md

Introduce service account and project token authentication for the /import endpoint (breaking change for import using already deprecated api_key).

Tracker#import now accepts a credentials Hash instead of an api_key string; Events and Tracker docs and signatures were updated accordingly.

Consumer now supports HTTP Basic Auth (including project token as username with empty password) and appends project_id as a query param for service-account imports. Request method accepts basic_auth, and tests updated to cover both auth flows. Added demo examples for both auth methods, updated README (3.1.0 notes)
The .rdoc format is outdated for GitHub READMEs. As the standard is Markdown, the cleanest fix is to convert the README to .md
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Mixpanel Ruby SDK’s /import flow to use supported authentication methods (service accounts or project token via HTTP Basic Auth), deprecating the old api_key import pattern, and migrates the repository README from RDoc to Markdown for better GitHub rendering.

Changes:

  • Change Tracker#import / Events#import to accept a credentials Hash and emit credentials in import payloads (instead of api_key).
  • Add HTTP Basic Auth handling in Consumer for /import (including project_id query param for service-account imports) and expand specs to cover both auth modes + invalid credentials.
  • Add demo scripts for both import auth flows and replace Readme.rdoc with README.md.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
lib/mixpanel-ruby/tracker.rb Updates Tracker#import signature and inline docs to reflect credential-based import auth.
lib/mixpanel-ruby/events.rb Builds credentials payload for import calls and raises on invalid credentials.
lib/mixpanel-ruby/consumer.rb Adds Basic Auth support for /import and threads auth into request handling.
spec/mixpanel-ruby/events_spec.rb Adds coverage for service-account and project-token import payloads + invalid credentials error.
spec/mixpanel-ruby/consumer_spec.rb Verifies Basic Auth headers and service-account project_id query param behavior.
spec/mixpanel-ruby/tracker_spec.rb Updates expectations for new import message format (credentials).
spec/mixpanel-ruby/error_spec.rb Updates import error-handling tests for new import signature.
demo/import_service_account_example.rb Adds service-account import example usage.
demo/import_project_token_example.rb Adds project-token import example usage.
README.md Replaces RDoc README and documents the v3.1.0 breaking change + import auth options.
Readme.rdoc Removed legacy RDoc README.
.gitignore Ignores coverage/ and Readme.rdoc.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- ensure service account payload includes username, password and project_id (error lists missing fields) and require non-blank project_token.

- Update consumer to append project_id to existing endpoint query safely and only pass basic_auth to request when present (avoids nil auth).

- Clarify README wording about the breaking change. Add/adjust specs to cover the new credential validation and error messages.
Add .github/dependabot.yml to enable weekly updates for bundler and GitHub Actions with a 30-day cooldown. Update .github/workflows/ruby.yml to use actions/checkout@v4
updating SHA to latest
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.42%. Comparing base (a3020d2) to head (3535c03).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #135      +/-   ##
==========================================
+ Coverage   96.29%   96.42%   +0.12%     
==========================================
  Files          12       12              
  Lines         567      587      +20     
==========================================
+ Hits          546      566      +20     
  Misses         21       21              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…xes)

Add input validation to Mixpanel::Events#import: raise ArgumentError when credentials is not a Hash and normalize credential keys with transform_keys(&:to_sym) so callers can pass string-keyed hashes. Include specs for accepting string keys and for clear errors when credentials is a String or nil. Also adjust demo scripts to use File.expand_path('../lib', __dir__) when loading the local lib.
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