Class: LogBrew::ProductTimeline

Inherits:
Object
  • Object
show all
Defined in:
lib/logbrew/product_timeline.rb

Overview

Builders for app-owned product and network timeline action events.

Constant Summary collapse

PRODUCT_ANALYTICS_SCHEMA_VERSION =
1
MAX_PRODUCT_ANALYTICS_SURFACE_LENGTH =
256

Class Method Summary collapse

Class Method Details

.network_milestone(route_template:, method: "GET", status_code: nil, duration_ms: nil, status: nil, name: nil, session_id: nil, trace_id: nil, metadata: nil) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/logbrew/product_timeline.rb', line 43

def self.network_milestone(
  route_template:,
  method: "GET",
  status_code: nil,
  duration_ms: nil,
  status: nil,
  name: nil,
  session_id: nil,
  trace_id: nil,
  metadata: nil
)
  route = sanitize_route_template("network milestone route_template", route_template)
  normalized_method = normalize_method(method)
  validate_status_code(status_code)
  validate_duration_ms(duration_ms)
  normalized_status = normalize_status(status || (status_code && status_code >= 400 ? "failure" : "success"))

   = ("network_timeline", )
  ["routeTemplate"] = route
  ["method"] = normalized_method
  put_if_present(, "statusCode", status_code)
  put_if_present(, "durationMs", duration_ms)
  put_if_present(, "sessionId", optional_label("session_id", session_id))
  put_if_present(, "traceId", optional_label("trace_id", trace_id))

  {
    "name" => name.nil? ? "network.#{normalized_method.downcase} #{route}" : required_label("network milestone name", name),
    "status" => normalized_status,
    "metadata" => 
  }
end

.product_action(name:, status: "success", route_template: nil, session_id: nil, trace_id: nil, screen: nil, funnel: nil, step: nil, metadata: nil) ⇒ Object



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
# File 'lib/logbrew/product_timeline.rb', line 11

def self.product_action(
  name:,
  status: "success",
  route_template: nil,
  session_id: nil,
  trace_id: nil,
  screen: nil,
  funnel: nil,
  step: nil,
  metadata: nil
)
   = ("product_timeline", )
  sanitized_route = sanitize_optional_route_template("product route_template", route_template)
  sanitized_screen = optional_label("screen", screen)
  put_if_present(, "routeTemplate", sanitized_route)
  put_if_present(, "sessionId", optional_label("session_id", session_id))
  put_if_present(, "traceId", optional_label("trace_id", trace_id))
  put_if_present(, "screen", sanitized_screen)
  put_if_present(, "funnel", optional_label("funnel", funnel))
  put_if_present(, "step", optional_label("step", step))
  ["analyticsSchemaVersion"] = PRODUCT_ANALYTICS_SCHEMA_VERSION
  ["analyticsKind"] = "interaction"
  surface = bounded_product_analytics_surface(sanitized_route || sanitized_screen)
  surface.nil? ? .delete("analyticsSurface") : ["analyticsSurface"] = surface

  {
    "name" => required_label("product action name", name),
    "status" => normalize_status(status),
    "metadata" => 
  }
end