<commit_before>package com.raygun.raygun4android.sample

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.raygun.raygun4android.RaygunClient
import com.raygun.raygun4android.messages.shared.RaygunUserInfo
import android.widget.Button
import android.widget.TextView


class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val initialCustomData = HashMap<String,String>()
        initialCustomData.put("firstkey", "firstvalue")

        RaygunClient.init(application)             // This sets up the client with the API key as provided in your AndroidManifest.xml
        RaygunClient.enableCrashReporting()
        RaygunClient.enableRUM(this)

        RaygunClient.setUserCustomData(initialCustomData)

        val button_send = findViewById(R.id.button_send) as Button
        val button_crash = findViewById(R.id.button_crash) as Button
        val button_set_user_anon = findViewById(R.id.button_set_user_anon) as Button
        val button_set_user_A = findViewById(R.id.button_set_user_A) as Button
        val button_set_user_B = findViewById(R.id.button_set_user_B) as Button
        val textView_appVersion = findViewById(R.id.textView_appVersion) as TextView
        val textView_providerVersion = findViewById(R.id.textView_providerVersion) as TextView

        button_send.setOnClickListener {
            val tw = HashMap<String,String>()
            tw.put("secondkey", "secondvalue")

            // Manual exception creation & sending
            RaygunClient.send(Exception("Congratulations, you have sent errors with Raygun4Android"), null, tw)
        }

        button_crash.setOnClickListener {
            // A real exception will be thrown here, which will be caught & sent by RaygunClient
            val i = 3 / 0
        }

        button_set_user_anon.setOnClickListener {
            var user = RaygunUserInfo()
            RaygunClient.setUser(user)
        }

        button_set_user_A.setOnClickListener {
            var user = RaygunUserInfo("superuser3")
            user.fullName = "<NAME>"
            user.firstName = "<NAME>"
            user.email = "<EMAIL>"
            RaygunClient.setUser(user)
        }

        button_set_user_B.setOnClickListener{
            var user = RaygunUserInfo("superuser4")
            user.fullName = "<NAME>"
            user.firstName = "<NAME>"
            user.email = "<EMAIL>"
            RaygunClient.setUser(user)<commit_msg>Crash App button wouldn't work in release build due to compiler optimisation<commit_after>package com.raygun.raygun4android.sample

import android.app.Application
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import com.raygun.raygun4android.RaygunClient
import com.raygun.raygun4android.messages.shared.RaygunUserInfo
import android.widget.Button
import android.widget.TextView


class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val initialCustomData = HashMap<String,String>()
        initialCustomData.put("firstkey", "firstvalue")

        // This sets up the client with the API key as provided in your AndroidManifest.xml
        RaygunClient.init(applicationContext as Application)
        RaygunClient.enableCrashReporting()
        RaygunClient.enableRUM(this)

        RaygunClient.setUserCustomData(initialCustomData)

        val button_send = findViewById(R.id.button_send) as Button
        val button_crash = findViewById(R.id.button_crash) as Button
        val button_set_user_anon = findViewById(R.id.button_set_user_anon) as Button
        val button_set_user_A = findViewById(R.id.button_set_user_A) as Button
        val button_set_user_B = findViewById(R.id.button_set_user_B) as Button
        val textView_appVersion = findViewById(R.id.textView_appVersion) as TextView
        val textView_providerVersion = findViewById(R.id.textView_providerVersion) as TextView

        button_send.setOnClickListener {
            val tw = HashMap<String,String>()
            tw.put("secondkey", "secondvalue")

            // Manual exception creation & sending
            RaygunClient.send(Exception("Congratulations, you have sent errors with Raygun4Android"), null, tw)
        }

        button_crash.setOnClickListener {
            // A real exception will be thrown here, which will be caught & sent by RaygunClient
            val i = 3 / 0
            Log.d("Raygun4Android-Sample", "This is here purely so that our division by zero calculation in i gets used and not optimised away in a release build: $i")
        }

        button_set_user_anon.setOnClickListener {
            var user = RaygunUserInfo()
            RaygunClient.setUser(user)
        }

        button_set_user_A.setOnClickListener {
            var user = RaygunUserInfo("superuser3")
            user.fullName = "<NAME>"
            user.firstName = "<NAME>"
            user.email = "<EMAIL>"
            RaygunClient.setUser(user)
        }

        button_set_user_B.setOnClickListener{
            var user = RaygunUserInfo("superuser4")
            user.fullName = "<NAME>"
            user.firstName = "<NAME>"
            user.email = "<EMAIL>"
            RaygunClient.setUser(user)
{'fraction_non_alphanumeric': 0.07925493060628196, 'fraction_numerical': 0.0034696859021183346, 'mean_word_length': 2.832750174947516, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '828898', 'n_tokens_mistral': 1524, 'n_tokens_neox': 1459, 'n_words': 333}