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

Development/Test Mode #42

Closed
mikz opened this issue Apr 25, 2014 · 5 comments
Closed

Development/Test Mode #42

mikz opened this issue Apr 25, 2014 · 5 comments

Comments

@mikz
Copy link

mikz commented Apr 25, 2014

Would be awesome to have a 'dev mode' when instead of actually sending requests it would do some action (log for example).

This could be implemented as simple dependency injection on Client and Consumer.
Consumer would instead of doing Request.new do @requester.new
Like:

Analytics.init(secret: nil)
Analytics.client.consumer.requester = MyClass

class MyClass
  def post(*)
  end
end
``

This would allow *testing* and *logging* in developer mode.
@mikz mikz changed the title Development Mode Development Mode Apr 25, 2014
@mikz mikz changed the title Development Mode Development/Test Mode Apr 25, 2014
@calvinfo
Copy link
Contributor

calvinfo commented May 8, 2014

Yeah, that makes some sense. I definitely want to have more logging in the library everywhere which can be enabled, so big +1 on logging requests there, though I'm not sure if I'm sold on the DI route yet.

FWIW: what we do currently is set up a "development" project and then use a separate key for prod vs dev setups. We then look at requests going into the segment.io debugger when figuring out what is being sent.

@travisjeffery

@travisjeffery
Copy link
Contributor

ok you'll be able to stub requests when that's pushed, i'm not sold on di in ruby either. http://david.heinemeierhansson.com/2012/dependency-injection-is-not-a-virtue.html

@mikz
Copy link
Author

mikz commented May 9, 2014

Thanks! I'm not going to argue about DI or not even though it would add more extensibility.
This solves testing/dev mode issue so thank you very much!

@olivierlacan
Copy link

@travisjeffery I'm assuming you can enable request stubbing by passing:

Analytics.init({ stub: true, ... })

Correct? Any chance you could add a bit of documentation on Analytics#initialize?

It's a little odd that the setup process isn't documented in the README. I can submit a PR if you folks need some help getting that into shape.

@travisjeffery
Copy link
Contributor

@olivierlacan :stub is documented at the bottom of our dedicated docs page, which is linked on the readme. go here: https://segment.io/docs/libraries/ruby/ and scroll to the bottom. i'll add a section title for that bit, thanks for bringing this up. all the options are documented there.

stub's available in v2, which is namespaced and not a singleton. so you would do:

Analytics = Segment::Analytics.new(stub: true)

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

No branches or pull requests

4 participants