Class: FastlaneCore::AnalyticsSession
- Inherits:
-
Object
- Object
- FastlaneCore::AnalyticsSession
- Defined in:
- fastlane_core/lib/fastlane_core/analytics/analytics_session.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#session_id ⇒ Object
Returns the value of attribute session_id.
Instance Method Summary collapse
- #action_completed(completion_context: nil) ⇒ Object
- #action_launched(launch_context: nil) ⇒ Object
- #finalize_session ⇒ Object
-
#initialize(analytics_ingester_client: AnalyticsIngesterClient.new(GA_TRACKING)) ⇒ AnalyticsSession
constructor
A new instance of AnalyticsSession.
- #should_show_message? ⇒ Boolean
- #show_message ⇒ Object
Constructor Details
#initialize(analytics_ingester_client: AnalyticsIngesterClient.new(GA_TRACKING)) ⇒ AnalyticsSession
Returns a new instance of AnalyticsSession.
13 14 15 16 17 18 19 20 21 |
# File 'fastlane_core/lib/fastlane_core/analytics/analytics_session.rb', line 13 def initialize(analytics_ingester_client: AnalyticsIngesterClient.new(GA_TRACKING)) # GA4 requires a numeric session ID for events to be attributed to a session @session_id = Time.now.to_i.to_s @session_start_time = Time.now @client = analytics_ingester_client @threads = [] @launch_event = nil @launch_event_captured = false end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
11 12 13 |
# File 'fastlane_core/lib/fastlane_core/analytics/analytics_session.rb', line 11 def client @client end |
#session_id ⇒ Object
Returns the value of attribute session_id.
10 11 12 |
# File 'fastlane_core/lib/fastlane_core/analytics/analytics_session.rb', line 10 def session_id @session_id end |
Instance Method Details
#action_completed(completion_context: nil) ⇒ Object
46 47 |
# File 'fastlane_core/lib/fastlane_core/analytics/analytics_session.rb', line 46 def action_completed(completion_context: nil) end |
#action_launched(launch_context: nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'fastlane_core/lib/fastlane_core/analytics/analytics_session.rb', line 23 def action_launched(launch_context: nil) if end if @launch_event_captured || launch_context.p_hash.nil? return end @launch_event_captured = true builder = AnalyticsEventBuilder.new( p_hash: launch_context.p_hash, session_id: session_id, action_name: nil, fastlane_client_language: launch_context.fastlane_client_language, build_tool_version: launch_context.build_tool_version ) # The event is not posted until finalize_session, so that the # run duration can be reported as GA4 engagement time @launch_event = builder.new_event(:launch) end |
#finalize_session ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'fastlane_core/lib/fastlane_core/analytics/analytics_session.rb', line 67 def finalize_session unless @launch_event.nil? @launch_event[:engagement_time_msec] = ((Time.now - @session_start_time) * 1000).round post_thread = client.post_event(@launch_event) unless post_thread.nil? @threads << post_thread end @launch_event = nil end @threads.map(&:join) end |
#should_show_message? ⇒ Boolean
56 57 58 59 60 61 62 63 64 65 |
# File 'fastlane_core/lib/fastlane_core/analytics/analytics_session.rb', line 56 def return false if FastlaneCore::Env.truthy?("FASTLANE_OPT_OUT_USAGE") file_name = ".did_show_opt_info" new_path = File.join(FastlaneCore.fastlane_user_dir, file_name) return false if File.exist?(new_path) File.write(new_path, '1') true end |
#show_message ⇒ Object
49 50 51 52 53 54 |
# File 'fastlane_core/lib/fastlane_core/analytics/analytics_session.rb', line 49 def UI.("Sending anonymous analytics information") UI.("Learn more at https://docs.fastlane.tools/#metrics") UI.("No personal or sensitive data is sent.") UI.("You can disable this by adding `opt_out_usage` at the top of your Fastfile") end |