Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions samcli/commands/build/build_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ def run(self):

for f in self.get_resources_to_build().functions:
EventTracker.track_event("BuildFunctionRuntime", f.runtime)
if f.metadata and f.metadata.get("BuildMethod", "") == "esbuild":
EventTracker.track_event("UsedFeature", "ESBuild")

click.secho("\nBuild Succeeded", fg="green")

Expand Down
2 changes: 2 additions & 0 deletions samcli/commands/sync/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
)
from samcli.cli.cli_config_file import configuration_option, TomlProvider
from samcli.commands._utils.click_mutex import ClickMutex
from samcli.lib.telemetry.event import EventTracker
from samcli.lib.utils.colors import Colored
from samcli.lib.utils.version_checker import check_newer_version
from samcli.lib.bootstrap.bootstrap import manage_stack
Expand Down Expand Up @@ -260,6 +261,7 @@ def do_cli(

set_experimental(ExperimentalFlag.Accelerate)
update_experimental_context()
EventTracker.track_event("UsedFeature", "Accelerate")

with BuildContext(
resource_identifier=None,
Expand Down
10 changes: 8 additions & 2 deletions samcli/lib/telemetry/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
"""

from enum import Enum
import logging
from typing import List

from samcli.local.common.runtime_template import INIT_RUNTIMES


LOG = logging.getLogger(__name__)


class EventName(Enum):
"""Enum for the names of available events to track."""

Expand All @@ -23,7 +27,6 @@ class EventType:
EventName.USED_FEATURE: [
"ESBuild",
"Accelerate",
"LocalTest",
"CDK",
],
EventName.DEPLOY: [
Expand Down Expand Up @@ -110,7 +113,10 @@ def track_event(event_name: str, event_value: str):
EventTracker.track_event("UsedFeature", "FeatureY")
return some_value
"""
EventTracker._events.append(Event(event_name, event_value))
try:
EventTracker._events.append(Event(event_name, event_value))
except EventCreationError as e:
LOG.debug("Error occurred while trying to track an event: %s", e)

@staticmethod
def get_tracked_events() -> List[Event]:
Expand Down
2 changes: 2 additions & 0 deletions samcli/lib/telemetry/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ def wrapped(*args, **kwargs):
try:
template_dict = ctx.template_dict
project_type = ProjectTypes.CDK.value if is_cdk_project(template_dict) else ProjectTypes.CFN.value
if project_type == ProjectTypes.CDK.value:
EventTracker.track_event("UsedFeature", "CDK")
metric_specific_attributes["projectType"] = project_type
except AttributeError:
LOG.debug("Template is not provided in context, skip adding project type metric")
Expand Down