Coder Social home page Coder Social logo

cfc-servers / gm_mixpanel Goto Github PK

View Code? Open in Web Editor NEW
2.0 4.0 0.0 52 KB

Easy-to-use Mixpanel interface for Garry's Mod

License: GNU General Public License v3.0

MoonScript 100.00%
garrysmod garrysmod-addon gmod gmod-lua gmod-addon garrysmodlua mixpanel mixpanel-api mixpanel-sdk lua

gm_mixpanel's Introduction

Mixpanel Interface

mixpanel.com interface for Gmod

This library can be used in any existing addon, allowing you to track events and interactions with your addons.

This enables better understanding how users interact with your products, allowing you to make better, more impactful products.

Requirements

  • Logger Optional, increases logging capability

Installation

Simply download a copy of the zip, or clone the repository straight into your addons folder!

Pre-compiled versions are available in Releases

The lua branch is a lua-only branch containing the compiled code from the most recent release. One can use this to easily keep gm_mixpanel up to date.

git clone --single-branch --branch lua [email protected]:CFC-Servers/gm_mixpanel.git

Usage

First, be sure to set the Mixpanel Token convar.

You can retrive your Mixpanel Project Token from your project's settings page.

Once you have it, set the following convar:

mixpanel_token "my token"

On both Client and Server, the following method is available.

Mixpanel:TrackEvent( eventName, data, reliable )

Serverside offers another method that allows you to tie an event to a player.

Mixpanel:TrackPlyEvent( eventName, ply, data, reliable )

Parameters

eventName (required)

  • Both functions take an eventName, which you should be familiar with. It's anything you want. Usually this is a short phrase with spaces. (i.e. "user chose weapon")

**ply (required)

  • TrackPlyEvent takes a valid player entity and uses it to attach their SteamID64 and a CRC'd IP address to your event

data (optional)

  • The data parameter is a table of string->string/int/boolean describing any extra information about your event.
  • Defaults to {}, so you can omit it if no additional information is needed

reliable (optional)

  • The reliable flag determines whether or not the event is sent immediately (true), or queued up to be sent in the next batch request (false).
  • It's usually best to leave this as false (the default value) unless it's unacceptable for your event to be lost in the event of a server crash.

TrackPlyEvent is used to track an event relating to a player, whereas TrackEvent is a more general option.

Often, TrackEvent could be used on the server to track player-independent events.

The usage is pretty simple. Here are some examples.

Sends an event for every player chat

-- sv_chat_tracker.lua
require( "mixpanel" )

hook.Add( "PlayerSay", "Mixpanel_Example", function( ply, text, isTeam )
    local eventData = {
        text = text,
        isTeam = isTeam
    }

    Mixpanel:TrackPlyEvent( "Player Say", ply, eventData )
end )

Sends an event when a player clicks on a vgui button

-- cl_button.lua
-- For demonstration purposes only, probably not functional

local lbl = vgui.Create( "DLabel" )
lbl:SetText( "Create Team" )
lbl:SetMouseInputEnabled( true )

function lbl:DoClick()
    Mixpanel:TrackEvent( "Create team clicked" )
    createTeam()
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.