Skip to content

Commit 7662ad4

Browse files
Update references from JSMs to ES Modules (#652)
This patch updates all our remaining links to JSMs in SearchFox and code samples to use the new ESMs (.sys.mjs). It also updates some links inside aboutwelcome/newtab/asrouter that have changed since the components were refactored. Additionally, the links to Firefox Source Docs for newtab/asrouter pages have been updated.
1 parent 808e9b5 commit 7662ad4

File tree

8 files changed

+44
-41
lines changed

8 files changed

+44
-41
lines changed

docs/deep-dives/desktop/desktop-targeting-debug.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Inside the textarea targeting expressions can be written and evaluated using the
2929

3030
## Builtin functions and examples
3131

32-
The full list of available functions can be seen in [FilterExpressions.jsm](https://searchfox.org/mozilla-central/source/toolkit/components/utils/FilterExpressions.jsm).
32+
The full list of available functions can be seen in [FilterExpressions.sys.mjs](https://searchfox.org/mozilla-central/source/toolkit/components/utils/FilterExpressions.sys.mjs).
3333

3434
A JEXL function is called using the `|` operator followed by the function name, example: `[1,2,3]|length == 3`.
3535

docs/getting-started/engineers/desktop-feature-api.mdx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This guide will help you use the Nimbus Feature API in Desktop Firefox to run ex
1313

1414
### Can I use this?
1515

16-
For the JS implementation you can import `ExperimentAPI.jsm` in the parent process or a privileged child process. We _do_ support First run experiments on Windows, holdbacks, and rollouts.
16+
For the JS implementation you can import `ExperimentAPI.sys.mjs` in the parent process or a privileged child process. We _do_ support First run experiments on Windows, holdbacks, and rollouts.
1717

1818
For the C++ implementation you can import `#include "mozilla/browser/NimbusFeatures.h"` and we support early startup experiments and holdbacks.
1919

@@ -105,8 +105,9 @@ Import the `NimbusFeatures` module:
105105
<TabItem value="js">
106106

107107
```js
108-
XPCOMUtils.defineLazyModuleGetters(this, {
109-
NimbusFeatures: "resource://nimbus/ExperimentAPI.jsm",
108+
const lazy = {}
109+
ChromeUtils.defineESModuleGetters(lazy, {
110+
NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs",
110111
});
111112
```
112113

@@ -344,11 +345,12 @@ NimbusFeatures::OffUpdate("aboutwelcome"_ns, "skipFocus"_ns,
344345
If you need to know whether an experiment is active or get access to the experiment or branch identifier (for example, to report in `utm_params`), you can use `ExperimentAPI.getExperimentMetaData`:
345346
346347
```js
347-
XPCOMUtils.defineLazyModuleGetters(this, {
348-
ExperimentAPI: "resource://nimbus/ExperimentAPI.jsm",
348+
const lazy = {}
349+
ChromeUtils.defineESModuleGetters(lazy, {
350+
NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs",
349351
});
350352
351-
const data = ExperimentAPI.getExperimentMetaData({ featureId: "myFeature" });
353+
const data = lazy.ExperimentAPI.getExperimentMetaData({ featureId: "myFeature" });
352354
353355
// If there is no experiment, data will be null.
354356
const slug = data?.slug;

docs/getting-started/engineers/desktop-migration-guide.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ This guide will help you migrate your Desktop front-end code to run experiments
99

1010
Prerequisites:
1111
* Your experimental variables are already instrumented with Firefox preferences
12-
* You don't use the `user branch` of each pref for anything other than actual user-defined values or testing (see docs on [order of precedence](/desktop-feature-api#configuration-sources)
13-
* Your code can import a `jsm`
12+
* You don't use the `user branch` of each pref for anything other than actual user-defined values or testing (see docs on [order of precedence](/desktop-feature-api#configuration-sources))
13+
* Your code can import a ESM
1414

1515
### An illustrative example (about:myself)
1616

@@ -48,15 +48,16 @@ aboutmyself:
4848
4949
## Step 2: Update your feature code
5050
51-
First, you will need to import `ExperimentAPI.jsm`:
51+
First, you will need to import `ExperimentAPI.sys.mjs`:
5252

5353
```js
54-
XPCOMUtils.defineLazyModuleGetters(this, {
55-
NimbusFeatures: "resource://nimbus/ExperimentAPI.jsm",
54+
const lazy = {}
55+
ChromeUtils.defineESModuleGetters(lazy, {
56+
NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs",
5657
});
5758
```
5859

59-
Then anywhere in your code that uses `Services.prefs` to get experiment-defined values, use `NimbusFeatures` instead:
60+
Then anywhere in your code that uses `Services.prefs` to get experiment-defined values, use `lazy.NimbusFeatures` instead:
6061

6162
```js
6263
element.style.backgroundColor = Services.prefs.getBoolPref("browser.aboutmyself.bgColor");

docs/glossary.mdx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
id: glossary
2+
id: glossary
33
title: Glossary
44
slug: /glossary
55
---
66

7-
## A
7+
## A
88

99
----
1010

@@ -16,61 +16,61 @@ slug: /glossary
1616

1717
----
1818

19-
## C
19+
## C
2020

2121
**Cirrus**: The codename of Nimbus for Web applications. [PRD](https://docs.google.com/document/d/1bg7GUoGeGusiSHE945P0XWkX_beGDQCb7gTMImliI44/edit#heading=h.hs9kv3uaq67s) and [ADR](https://docs.google.com/document/d/1ub46GXVz0rD6vsdS85UF_LvUfJItMwE9jicFCXc1jvw/edit)
2222

2323
**Co-enrolling**: [here](/fml/coenrolling-features)
2424

2525
**Custom targeting**: coming soon
26-
* [Targeting attributes](https://firefox-source-docs.mozilla.org/browser/components/newtab/content-src/asrouter/docs/targeting-attributes.html)
26+
* [Targeting attributes](https://firefox-source-docs.mozilla.org/browser/components/asrouter/docs/targeting-attributes.html)
2727
* [Mobile messaging behavioral targeting](/mobile-behavioral-targeting)
2828
* See also: "Targeting Considerations" on the Nimbus Experiment Brief template available [here](/for-product#where-do-i-start)
2929

3030
----
3131

32-
## E
32+
## E
3333

34-
**Experimenter**:
34+
**Experimenter**:
3535
<ul>
36-
Nimbus is the whole experimentation system (handles enrolling/unenrolling users, sending branch configurations, etc). Nimbus was the code name of the experimentation project.
36+
Nimbus is the whole experimentation system (handles enrolling/unenrolling users, sending branch configurations, etc). Nimbus was the code name of the experimentation project.
3737
</ul>
3838
<ul>
3939
Experimenter is the customer interface to both Nimbus and Jetstream - that you access at <a href="https://experimenter.services.mozilla.com/">experimenter.services.mozilla.com/</a>. In Experimenter users can configure experiments, manage them (launch, monitor, end), and can see the results.
4040
</ul>
4141

4242
----
4343

44-
## F
44+
## F
4545

4646
**First-run experiment**: [here](/mobile-first-run-experiments)
4747

4848
**Feature Manifest Language (FML)**: [here](/fml-spec)
4949

5050
----
5151

52-
## J
52+
## J
5353

54-
**Jetstream**:
54+
**Jetstream**:
5555
<ul>
5656
Jetstream is the whole analysis system (interfaces with data, runs analysis, formats results). See more <a href="/deep-dives/jetstream/overview">here</a>
5757
</ul>
5858

5959
----
6060

61-
## K
61+
## K
6262

6363
**Kinto**: [docs](https://docs.kinto-storage.org/en/stable/index.html)
6464

6565
----
6666

67-
## R
67+
## R
6868

69-
**Remote Settings**:
69+
**Remote Settings**:
7070
* [Docs](https://remote-settings.readthedocs.io/en/latest/)
7171
* [Integration with Experimenter](https://github.com/mozilla/experimenter/tree/main/docs/experimenter#overview)
7272

73-
**Rollout**:
73+
**Rollout**:
7474
<ul>
7575
A single-branch experiment, often the "winning branch" from an experiment, that can be used to "roll out" a feature to your Audience. See the <a href="/deep-dives/experimenter/rollouts">Rollouts deep dive</a> for more info.
7676
</ul>
@@ -80,8 +80,8 @@ A single-branch experiment, often the "winning branch" from an experiment, that
8080
## S
8181

8282
**Smoke Test**:
83-
<ul>
84-
A smoke test is a preliminary trial/experiment with minimal setup/limited parameters/minimal user population to ensure that the experiment is operational and that there are no obvious issues. The objective is to catch any major problems early on, allowing us to address them before conducting more in-depth/resource-intensive (stat.sig) experiments. This is common when there are new pieces (like many newly added telemetry probes or complex targeting or triggers) coming together. It is better to learn in a small (hundreds instead of hundreds of thousands people) experiment that your message is triggering at the wrong time to the wrong users, or that your telemetry isn't capturing something you need to learn.
83+
<ul>
84+
A smoke test is a preliminary trial/experiment with minimal setup/limited parameters/minimal user population to ensure that the experiment is operational and that there are no obvious issues. The objective is to catch any major problems early on, allowing us to address them before conducting more in-depth/resource-intensive (stat.sig) experiments. This is common when there are new pieces (like many newly added telemetry probes or complex targeting or triggers) coming together. It is better to learn in a small (hundreds instead of hundreds of thousands people) experiment that your message is triggering at the wrong time to the wrong users, or that your telemetry isn't capturing something you need to learn.
8585
</ul>
8686

8787
----

docs/workflow/implementing/messaging/desktop-messaging-journey.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ From inception to launch, a message goes through the below three steps for Firef
99

1010
## Message Design
1111

12-
Once an idea has been developed, the next step is designing the experiment message. A good place to start for some inspiration, is to look through previous messaging system experiments (Examples in Source doc) as well as looking into the available capabilities through the [Messaging Surfaces](/messaging/desktop-messaging-surfaces). The OMC team has vast experience with running these experiments and can provide feedback and answer any questions in the #omc Slack channel.
12+
Once an idea has been developed, the next step is designing the experiment message. A good place to start for some inspiration, is to look through previous messaging system experiments (Examples in Source doc) as well as looking into the available capabilities through the [Messaging Surfaces](/messaging/desktop-messaging-surfaces). The OMC team has vast experience with running these experiments and can provide feedback and answer any questions in the #omc Slack channel.
1313

1414
## Running an Experiment
1515

@@ -20,12 +20,12 @@ For a more in-depth guide and step by step process, visit [OMC: Experimenter onb
2020

2121
Once the experiment has successfully concluded and analysis shows promising results, we can land the new message in tree. Depending on the messaging surface, the following files is where the JSON for our different messages exists
2222

23-
```
24-
browser/components/newtab/aboutwelcome/lib/AboutWelcomeDefaults.jsm
25-
browser/components/newtab/lib/FeatureCalloutMessages.jsm
26-
browser/components/newtab/lib/OnboardingMessageProvider.jsm
27-
```
28-
29-
Visit [Firefox Source docs](https://firefox-source-docs.mozilla.org/browser/components/newtab/docs/index.html): newtab for details on how to develop within our components.
23+
* [`browser/components/aboutwelcome/modules/AboutWelcomeDefaults.sys.mjs`][AboutWelcomeDefaults]
24+
* [`browser/components/asrouter/modules/FeatureCalloutMessages.sys.mjs`][FeatureCalloutMessages]
25+
* [`browser/components/asrouter/modules/OnboardingMessageProvider.sys.mjs`][OnboardingMessageProvider]
3026

27+
Visit [Firefox Source docs](https://firefox-source-docs.mozilla.org/browser/components/newtab/docs/index.html): newtab for details on how to develop within our components.
3128

29+
[AboutWelcomeDefaults]: https://searchfox.org/mozilla-central/source/browser/components/aboutwelcome/modules/AboutWelcomeDefaults.sys.mjs
30+
[FeatureCalloutMessages]: https://searchfox.org/mozilla-central/source/browser/components/asrouter/modules/FeatureCalloutMessages.sys.mjs
31+
[OnboardingMessageProvider]: https://searchfox.org/mozilla-central/source/browser/components/asrouter/modules/OnboardingMessageProvider.sys.mjs

docs/workflow/implementing/messaging/display-logic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Sometimes you want to limit messages to a particular group of users, to users wi
3030

3131
> All users in the `US`, for `beta and nightly channels`, `version 98.01 or higher`, who `do not have Firefox set to their default browser`.
3232
33-
You can see a complete [list of the available attributes](https://firefox-source-docs.mozilla.org/browser/components/asrouter/docs/targeting-attributes.html#available-attributes) in Firefox Source docs, but here are some common examples:
33+
You can see a complete [list of the available attributes](https://firefox-source-docs.mozilla.org/browser/components/asrouter/docs/targeting-attributes.html) in Firefox Source docs, but here are some common examples:
3434

3535
* `locale` (language, e.g. `en-CA`)
3636
* `region` (based on IP, e.g. `US`, `FR`)

docs/workflow/implementing/messaging/how-a-message-gets-shown.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ All messages belong to a message provider (a source):
1212

1313
All messages have an associated [trigger](/messaging/display-logic/#triggers) (user action targeted by the message) and targeting condition. Additionally messages have a frequency cap and they can belong to a group that also has a frequency cap.
1414

15-
Deciding to show a message [starts with the trigger action](https://searchfox.org/mozilla-central/rev/65d4d3399afa79c8de5a0cc11752d2ba7c31edc1/browser/components/newtab/lib/ASRouter.jsm#1323), when this happens we look at all the messages matching that trigger. We filter out blocked messages or messages that reached their frequency cap (or their groups frequency cap) and we evaluate targeting returning the first message that matched targeting.
15+
Deciding to show a message [starts with the trigger action](https://searchfox.org/mozilla-central/rev/d1e731d931b7b46237175de1701849a7cf5c8579/browser/components/asrouter/modules/ASRouter.sys.mjs#1655), when this happens we look at all the messages matching that trigger. We filter out blocked messages or messages that reached their frequency cap (or their groups frequency cap) and we evaluate targeting returning the first message that matched targeting.
1616

1717
This cycle can result in a message being shown (which will send an Exposure event + message specific telemetry events) or no message being shown if targeting didn’t match (but it can still result in a Reach event being sent).
1818

docs/workflow/implementing/messaging/telemetry.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Event telemetry is sent for any interaction with the messaging surfaces and addi
1313

1414
Telemetry pings will include the message id, experiment and branch slug (if enrolled) and the event type.
1515

16-
Telemetry from all messaging surfaces ([except doorhangers when not enrolled in an experiment](https://searchfox.org/mozilla-central/rev/65d4d3399afa79c8de5a0cc11752d2ba7c31edc1/browser/components/newtab/lib/TelemetryFeed.jsm#645)) includes client id in the event ping. **Special care should be taken not to associate any browsing history with messaging events: showing a message when the user visits a particular website is not allowed because it would accidentally leak information about that visit.**
16+
Telemetry from all messaging surfaces ([except doorhangers when not enrolled in an experiment](https://searchfox.org/mozilla-central/rev/d1e731d931b7b46237175de1701849a7cf5c8579/browser/components/newtab/lib/TelemetryFeed.sys.mjs#526)) includes client id in the event ping. **Special care should be taken not to associate any browsing history with messaging events: showing a message when the user visits a particular website is not allowed because it would accidentally leak information about that visit.**
1717

1818
[Additional telemetry](/telemetry/) is available when the message is delivered as an <u>experiment</u>:
1919
- Exposure
@@ -29,6 +29,6 @@ Example: Experiment has 3 branches [control, treatment-1, treatment-2]. If the u
2929

3030
**Debugging telemetry pings**
3131

32-
Make sure `browser.ping-centre.log` pref is enabled. Open the Browser Toolbox and interact with the message, any telemetry pings will be logged to the console.
32+
Make sure `browser.ping-centre.log` pref is enabled. Open the Browser Toolbox and interact with the message, any telemetry pings will be logged to the console.
3333

3434
_Because of the implementation of moments pages, telemetry is only sent for when a message is matched (the page will be shown in the next browsing session). No other telemetry is available._

0 commit comments

Comments
 (0)