Skip to content

Commit fe28284

Browse files
Merge pull request #367 from mozilla/jmendez/addon-install-telemetry
Add enterprise-specific addon install event with addon name
2 parents 0b86f33 + 599f142 commit fe28284

File tree

2 files changed

+137
-2
lines changed

2 files changed

+137
-2
lines changed

toolkit/mozapps/extensions/AddonManager.sys.mjs

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5594,6 +5594,32 @@ AMTelemetry = {
55945594
return null;
55955595
},
55965596

5597+
/**
5598+
* Retrieve the addon name for the given AddonInstall instance.
5599+
*
5600+
* @param {AddonInstall} install
5601+
* The AddonInstall instance to retrieve the addon name from.
5602+
*
5603+
* @returns {string | null}
5604+
* The addon name for the given AddonInstall instance (if any).
5605+
*/
5606+
getAddonNameFromInstall(install) {
5607+
// Returns the name of the extension that is being installed, as soon as the
5608+
// addon is available in the AddonInstall instance (after being downloaded
5609+
// and validated successfully).
5610+
if (install.addon) {
5611+
return install.addon.name;
5612+
}
5613+
5614+
// While updating an addon, the existing addon can be
5615+
// used to retrieve the addon id since the first update event.
5616+
if (install.existingAddon) {
5617+
return install.existingAddon.name;
5618+
}
5619+
5620+
return null;
5621+
},
5622+
55975623
/**
55985624
* Retrieve the telemetry event's object property value for the given
55995625
* AddonInstall instance.
@@ -5847,6 +5873,7 @@ AMTelemetry = {
58475873
}
58485874

58495875
let addonId = this.getAddonIdFromInstall(install);
5876+
let addonName = this.getAddonNameFromInstall(install);
58505877
let object = this.getEventObjectFromInstall(install);
58515878

58525879
let installId = String(install.installId);
@@ -5899,7 +5926,25 @@ AMTelemetry = {
58995926
})
59005927
);
59015928
#ifdef MOZ_ENTERPRISE
5902-
GleanPings.enterprise.submit();
5929+
if (eventMethod == "install" && extra.step == "completed") {
5930+
Glean.addonsManager.installComplete.record(
5931+
this.formatExtraVars({
5932+
addon_id: extra.addon_id,
5933+
addon_name: addonName,
5934+
addon_type: object,
5935+
install_id: installId,
5936+
download_time: extra.download_time,
5937+
error: extra.error,
5938+
source: extra.source,
5939+
source_method: extra.method,
5940+
num_strings: extra.num_strings,
5941+
updated_from: extra.updated_from,
5942+
install_origins: extra.install_origins,
5943+
step: extra.step,
5944+
})
5945+
);
5946+
GleanPings.enterprise.submit();
5947+
}
59035948
#endif
59045949
},
59055950

toolkit/mozapps/extensions/metrics.yaml

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,100 @@ addons_manager:
315315
download_started, download_completed, download_failed
316316
type: string
317317
expires: 154
318+
318319
#ifdef MOZ_ENTERPRISE
320+
install_complete:
321+
type: event
322+
description: |
323+
This event is recorded when an extension or theme is installed
324+
in enterprise builds.
325+
Contains security-relevant metadata for monitoring and analysis.
326+
Only collected when MOZ_ENTERPRISE is defined and enabled.
327+
bugs:
328+
- https://bugzilla.mozilla.org/show_bug.cgi?id=TBD
329+
data_reviews:
330+
- https://bugzilla.mozilla.org/show_bug.cgi?id=TBD
331+
data_sensitivity:
332+
- interaction
333+
notification_emails:
334+
- security-telemetry@mozilla.org
335+
- enterprise-telemetry@mozilla.org
336+
extra_keys:
337+
addon_id:
338+
description: Id of the addon (when available).
339+
type: string
340+
addon_name:
341+
description: Name of the addon (when available).
342+
type: string
343+
addon_type:
344+
description: |
345+
Addon type, one of: extension, theme, locale, dictionary,
346+
sitepermission, siteperm_deprecated, other, unknown.
347+
type: string
348+
install_id:
349+
description: |
350+
Shared by events related to the same install or update flow.
351+
type: string
352+
download_time:
353+
description: The number of ms needed to complete the download.
354+
type: quantity
355+
error:
356+
description: |
357+
The AddonManager error related to an install or update failure.
358+
type: string
359+
source:
360+
description: |
361+
The source that originally triggered the installation, one
362+
of: "about:addons", "about:debugging", "about:preferences",
363+
"amo", "browser-import", "disco", "distribution",
364+
"extension", "enterprise-policy", "file-url",
365+
"geckoview-app", "gmp-plugin", "internal", "plugin",
366+
"rtamo", "siteperm-addon-provider" "sync", "system-addon",
367+
"temporary-addon", "unknown", "about:editprofile", "about:newprofile",
368+
"nimbus-newtabTrainhopAddon".
369+
For events with method set to "sideload", the source value
370+
is derived from the XPIProvider location name (e.g. possible
371+
values are "app-builtin", "app-global", "app-profile",
372+
"app-system-addons", "app-system-defaults",
373+
"app-system-local", "app-system-profile",
374+
"app-system-share", "app-system-user", "winreg-app-user",
375+
"winreg-app-gobal").
376+
type: string
377+
source_method:
378+
description: |
379+
The method used by the source to install the add-on
380+
(included when the source can use more than one, e.g.
381+
install events with source "about:addons" may have
382+
"install-from-file" or "url" as method), one of: "amWebAPI",
383+
"drag-and-drop", "installTrigger", "install-from-file",
384+
"link", "management-webext-api", "sideload", "onboarding",
385+
"synthetic-install", "url", "product-updates".
386+
type: string
387+
num_strings:
388+
description: |
389+
The number of permission description strings in the
390+
extension permission doorhanger.
391+
type: quantity
392+
updated_from:
393+
description: |
394+
Determine if an update has been requested by the user or
395+
the application ("app" / "user").
396+
type: string
397+
install_origins:
398+
description: |
399+
This flag indicates whether install_origins is defined in
400+
the addon manifest. ("1" / "0")
401+
type: string
402+
step:
403+
description: |
404+
The current step in the install or update flow: started,
405+
postponed, cancelled, failed, permissions_prompt, completed,
406+
site_warning, site_blocked,install_disabled_warning,
407+
download_started, download_completed, download_failed
408+
type: string
409+
expires: never
319410
send_in_pings:
320411
- enterprise
321-
- default
322412
#endif
323413

324414
update: *install_update_event

0 commit comments

Comments
 (0)