Skip to content

Commit 0000c60

Browse files
authored
include deployment id (#258)
We want to start including the deployment id when reporting metrics. This will be especially helpful for extensions, as then we can track # of logged in users by deployment - [X] I ran `make setup && make` to update the generated code after editing a `.atd` file (TODO: have a CI check) - [X] I made sure we're still backward compatible with old versions of the CLI. For example, the Semgrep backend need to still be able to *consume* data generated by Semgrep 1.17.0. See https://atd.readthedocs.io/en/latest/atdgen-tutorial.html#smooth-protocol-upgrades
1 parent 8c781d2 commit 0000c60

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

semgrep_metrics.atd

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ type environment = {
102102
~isDiffScan <python default="False"> <ocaml mutable> : bool;
103103
?integrationName <ocaml mutable>: string option;
104104
~isAuthenticated <python default="False"> <ocaml mutable>: bool;
105+
?deployment_id: int option;
105106
}
106107

107108
(*****************************************************************************)

semgrep_metrics.py

+4
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,7 @@ class Environment:
10591059
isDiffScan: bool = field(default_factory=lambda: False)
10601060
integrationName: Optional[str] = None
10611061
isAuthenticated: bool = field(default_factory=lambda: False)
1062+
deployment_id: Optional[int] = None
10621063

10631064
@classmethod
10641065
def from_json(cls, x: Any) -> 'Environment':
@@ -1074,6 +1075,7 @@ def from_json(cls, x: Any) -> 'Environment':
10741075
isDiffScan=_atd_read_bool(x['isDiffScan']) if 'isDiffScan' in x else False,
10751076
integrationName=_atd_read_string(x['integrationName']) if 'integrationName' in x else None,
10761077
isAuthenticated=_atd_read_bool(x['isAuthenticated']) if 'isAuthenticated' in x else False,
1078+
deployment_id=_atd_read_int(x['deployment_id']) if 'deployment_id' in x else None,
10771079
)
10781080
else:
10791081
_atd_bad_json('Environment', x)
@@ -1092,6 +1094,8 @@ def to_json(self) -> Any:
10921094
if self.integrationName is not None:
10931095
res['integrationName'] = _atd_write_string(self.integrationName)
10941096
res['isAuthenticated'] = _atd_write_bool(self.isAuthenticated)
1097+
if self.deployment_id is not None:
1098+
res['deployment_id'] = _atd_write_int(self.deployment_id)
10951099
return res
10961100

10971101
@classmethod

0 commit comments

Comments
 (0)