Class: ThisData::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/this_data/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_configuration_fileObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/generators/this_data/install_generator.rb', line 8

def create_configuration_file
  initializer "this_data.rb" do
    <<-EOS
# Specifies configuration options for the ThisData gem.
ThisData.setup do |config|

  # This is where your API key goes. You should almost certainly not have it
  # committed to source control, but instead load it from a secret store.
  # Default: nil
  config.api_key = "#{api_key}"

  # Define a Logger instance if you want to debug or track errors
  # This tells ThisData to log in the development environment.
  # Comment it out to use the default behaviour across all environments.
  # Default: nil
  config.logger = Rails.logger if Rails.env.development?

  # When true, will perform track events asynchronously.
  # It is true by default, but here we explicitly tell ThisData to make it
  # synchronous in test and development mode, to aide getting started.
  # Comment it out to use the default behaviour across all environments.
  # Default: true
  config.async  = !(Rails.env.test? || Rails.env.development?)


  # These configuration options are used when for the TrackRequest module.

  # user_method will be called on a controller to get a user object.
  # Default: :current_user
  # config.user_method =        :current_user

  # The following methods will be called on the object returned by user_method,
  # to capture details about the user

  # Required. This method should return a unique ID for a user.
  # Default: :id
  # config.user_id_method =     :id

  # Optional. This method should return the user's name.
  # Default: :name
  # config.user_name_method =   :name
  # This method should return the user's email.
  # Default: :email
  # config.user_email_method =  :email
  # This method should return the user's mobile phone number.
  # Default: :mobile
  # config.user_mobile_method = :mobile


  # ThisData's JS library (optional) adds a cookie.
  # If you're using the library, set this to true, so that we know to expect
  # a cookie value
  # Default: false
  # config.expect_js_cookie = true

end
EOS
  end
end