LethalAnalytics

v1.0.1·Updated 2024-06-14

Allows mod creators to see how their mods are used, easily catch errors, and learn about their audience. Supports Google Analytics!

Screenshots 8 screenshots

About this mod Author’s original text

LethalAnalytics

Allows mod creators to see how their mods are used, easily catch errors, and learn about their audience.

This is a mod library or dependency. If you're playing with this mod installed, check out its LethalConfig for more info.

Dependencies

| Required | Name | Version |

|:--------:|:-------------|:------|

| ✅ | LethalConfig | 1.4.2 |

| ✅ | BepInExPack | 5.4.2100 |

Overview

  • Supported Analytics Sites
  • Usage
  • Setting up
  • Creating a GA session
  • Sending GA events
  • Creating a README note
  • Creating a GA4 property
  • Telemetrics
  • Issues and Contributions
  • Licencing

Supported Analytics Sites:

  • Google Analytics (GA4) [Free]

-

  • User & new user charts supported
  • Location (city) map & charts supported
  • Events (with dimensions and metrics) supported
  • Engagement time charts supported
  • Screen resolution chart supported
  • More coming soon (upon request)

Usage

Setting up

First, reference the `LethalAnalytics.dll` file (downloaded or Github) from your project.

In order to access the LethalAnalytics API, use the `LethalAnalytics` namespace:

using LethalAnalytics;

Also include LethalAnalytics as a `BepInDependency` of your mod so that BepInEx can work its dependency graphing magic (and properly load LethalAnalytics):

[BepInPlugin(modGUID, modName, modVersion)]

[BepInDependency("net.RB007.LethalAnalytics")] NEVER collect PII or otherwise private info. Please be transparent and respect user privacy. Make the Lethal Company modding community proud! |

| measurementId | string | Your GA4 measurement ID (ex. G-RB007ONKOFI). Check that this is correct. Be careful about sharing it and feel free to hide/obfuscate it in your code if desired. |

| screenTitle | string (optional) | The title name to send when a session is created for GA4 (default: MainMenu). |

| renewScreenTitle | string (optional) | The title name to send when a session is continued for GA4 (default: InGame). |

| sendSystemInfo | bool (optional) | Whether to send the user's CPU and GPU type along with the GA4 session_start event (as event params). OS info and screen res. will be sent regardless. |

| sessionLengthMins | int (optional) | How long a GA4 user session is set to last in minutes (default: 30). By default, sessions are re-created if they timeout (as long as the game is still open). Only change this if you know what you're doing. |

By default, every instance of `GASession` sends a few user events:

| Event Name | Description |

|:--------|:-------------|

| session_start | This event is sent as soon as the `registerGASession(...)` method is called for each user. It starts each user's session. |

| page_visit | This event is sent as soon as the `registerGASession(...)` method is called for each user. Includes some basic version info (and their CPU (type) and GPU (type) if enabled). |

| first_visit | This event is sent as soon as `registerGASession(...)` method is called for each user (for the first time). It's what lets you know if a user ran your mod for the first time. |

| update | This event is sent as soon as each user reaches Lethal Company's main menu (and they just updated your mod). It's what lets you know if a user recently updated your mod (and to what version). |

| session_end | This event is sent as soon as each user quits Lethal Company (through the main menu). It ends each user's session. |

Sending GA events

In order to send GA events, you'll need an instance of a `GASession`. It's recommended that you store the previously shown GASession instance in an internal static variable. That way, you can safely access it throughout your mod assembly.

internal static GASession gaSession = AnalyticsManager.registerGASession(...);

Then, call the `sendGAEvent(...) method, from your GASession` instance, to send custom GA events to your property.

gaSession.sendGAEvent("category", "name", new Dictionary() { ["event_param"] = "event_value" });

Please be careful about sending events too quickly and keep event params minimal. Y

Install & use Install: BepInEx plugin

  1. The archive from playbuff is the mod itself — usually a BepInEx plugin (a .dll or a plugin folder once unzipped).
  2. Recommended: use a community mod manager (such as r2modman) — pick this game, import the mod, and the manager sets up BepInEx and its dependencies for you.
  3. Manual route: install the BepInEx loader in the game folder, then drop the unzipped .dll or plugin folder into BepInEx/plugins/.
  4. Launch the game — the BepInEx console logs every plugin it loads; seeing this mod in the log means it is installed.

Mods with listed dependencies need those installed too, or they will not load. Options are usually changed in-game or in the plugin's config file.

Dependencies

Install these first, or the mod will not work:

BepInEx-BepInExPackAinaVT-LethalConfig

File & checksum

Filename
LethalAnalytics-1.0.1.zip
File size
26.8 KiB