Repository: learningequality/kolibri

Issue:
In analytics payload, the "installer" field should indicate when a user is running Kolibri locally for dev purposes
<!--
Instructions:
 * Fill out the sections below, replace …'s with information about your issue
 * Use the 'preview' function above this text box to verify formatting before submitting
-->

### Observed behavior
Sometimes, when running Kolibri in development mode, this line:

https://github.com/learningequality/kolibri/blob/032aa228597fdd14098796d8ccd98668e6a6f5a3/kolibri/core/analytics/utils.py#L431

will return values that are indistinguishable from a device that is running Kolibri in a "production" setting.

### Expected behavior
<!--
Description of what behavior was expected but did not occur
-->

…

### User-facing consequences
<!--
Implications and real-world consequences for learners, coaches, admins, and other users of the application
-->

…

### Errors and logs
<!--
Relevant logs from:
 * the command line
 * ~/.kolibri/logs/kolibri.txt
 * the browser console

Please wrap errors in triple backticks for clean formatting like this:
```
01:10 info: something happened
01:12 error: something bad happened
```
-->

…

### Steps to reproduce
<!--
Precise steps that someone else can follow in order to see this behavior
-->

…

### Context
<!--
Tell us about your environment, including:
 * Kolibri version
 * Operating system
 * Browser
-->

…


Discussion:
github-actions[bot]: ### [**Build Artifacts**](https://github.com/learningequality/kolibri/actions/runs/2756479194)
| Asset type | Download link |
|-|-|
| PEX file | [kolibri-0.16.0.dev0_git.20220728201631.pex](https://github.com/learningequality/kolibri/suites/7569131453/artifacts/312887291) |
| Unsigned Windows installer | [kolibri-0.16.0.dev0+git.20220728201631-unsigned.exe](https://github.com/learningequality/kolibri/suites/7569131453/artifacts/312887295) |
| Debian Package | [kolibri_0.16.0.dev0+git.20220728201631-0ubuntu1_all.deb](https://github.com/learningequality/kolibri/suites/7569131453/artifacts/312887290) |
| Mac Installer (DMG) | [kolibri-0.16.0.dev0+git.20220728201631-0.3.0.dmg](https://github.com/learningequality/kolibri/suites/7569131453/artifacts/312887293) |
| Source Tarball | [kolibri-0.16.0.dev0+git.20220728201631.tar.gz](https://github.com/learningequality/kolibri/suites/7569131453/artifacts/312887292) |
| WHL file | [kolibri-0.16.0.dev0+git.20220728201631-py2.py3-none-any.whl](https://github.com/learningequality/kolibri/suites/7569131453/artifacts/312887294) |

Patch:
diff --git a/kolibri/utils/server.py b/kolibri/utils/server.py
index b4c56c5e2b..01a7499cde 100644
--- a/kolibri/utils/server.py
+++ b/kolibri/utils/server.py
@@ -1030,12 +1030,12 @@ def installation_type(cmd_line=None):  # noqa:C901
     if install_type == "Unknown":
         if on_android():
             install_type = installation_types.APK
+        elif os.environ.get("KOLIBRI_DEVELOPER_MODE", False):
+            install_type = "devserver"
         elif len(cmd_line) > 1 or "uwsgi" in cmd_line:
             launcher = cmd_line[0]
             if launcher.endswith(".pex"):
                 install_type = installation_types.PEX
-            elif "runserver" in cmd_line:
-                install_type = "devserver"
             elif launcher == "/usr/bin/kolibri":
                 install_type = is_debian_package()
             elif launcher == "uwsgi":


Test patch:
diff --git a/kolibri/utils/tests/test_server.py b/kolibri/utils/tests/test_server.py
index d15751cb34..d88e3d092b 100755
--- a/kolibri/utils/tests/test_server.py
+++ b/kolibri/utils/tests/test_server.py
@@ -25,15 +25,7 @@ class TestServerInstallation(object):
         assert install_type == installation_types.PEX
 
     def test_dev(self):
-        sys_args = [
-            "kolibri",
-            "--debug",
-            "manage",
-            "runserver",
-            "--settings=kolibri.deployment.default.settings.dev",
-            '"0.0.0.0:8000"',
-        ]
-        with mock.patch("sys.argv", sys_args):
+        with mock.patch("os.environ", {"KOLIBRI_DEVELOPER_MODE": "True"}):
             install_type = server.installation_type()
             assert install_type == "devserver"