Skip to content

Latest commit

 

History

History
150 lines (123 loc) · 5.65 KB

README.md

File metadata and controls

150 lines (123 loc) · 5.65 KB

Pulse Unicorn Android

Build Status

Pulse Unicorn is an extension over Android event SDK It makes your life easier!

Current version

1.1.8

What is the purpose?

The purpose of this project is to help with Pulse Tracking development and maintenance using Android event SDK library.
This extension allows quick examination of traffic that is sent by event-sdk library.
Pulse Unicorn provides basic UI that displays events in list, so that you can verify, if events send by your app are implemented and sent exactly as you wanted them to be implemented.

Current Features

  • Watch for ongoing events in the real time in a easy to read format
  • Easy opening by tapping the notification
  • Quick overview for number of collected events via notification information
  • Receive notification about invalid / failed events
  • Search across events by any matching phrase
  • Search for any value in event Json body in event details view
  • Add any custom Json property display in event cell for easy quick value debugging
  • Filter events by default pulse EVENT_TYPE, OBJECT_TYPE, TRACKER_TYPE and STATUS
  • Sharing Json of event

Pulse Unicorn Integration

  1. Be sure that you have access to Schibsted Artifactory configured in your project or mavenCentral
  2. Add Pulse Unicorn maven to gradle.build file.
implementation("com.schibsted.pulse:unicorn-android:{$current-version}")
  1. Initialize Pulse Unicorn in declared Application class in your application.

Easy mode

PulseUnicorn.init(this)
# Place initialization at the top of your Application class, before any DI and other parts of code.

Advanced mode

To manipulate Pulse Unicorn notification settings from code you can pass PulseUnicornConfig class to do so. It will set up your desired settings on each Pulse Unicorn run. Any settings change made through UI will persistent during PulseUnicorn lifecycle. They will be lost after relaunch / reinstall.

PulseUnicorn.init(
            this, PulseUnicornConfig(
                enableStickyNotification = true,
                stickyNotificationType = StickyNotificationEnum.SIMPLE_NOTIFICATION,
                enablePopupNotification = true,
                enableInvalidEventNotification = true,
                enableFailedEventNotification = false,
                notificationChannelIdConfig = PulseUnicornNotificationChannelConfig(
                    stickyNotificationChannelId = "123123123",
                    failedPopUpNotificationChannelId = "234234234",
                    invalidPopUpNotificationChannelId = "345345345"
                )
            )
        )

Default settings for Notification settings

data class PulseUnicornConfig(
    var enableStickyNotification: Boolean = true,
    var stickyNotificationType: StickyNotificationEnum = StickyNotificationEnum.DETAILED_NOTIFICATION,
    var enablePopupNotification: Boolean = true,
    var enableInvalidEventNotification: Boolean = true,
    var enableFailedEventNotification: Boolean = true,
    var notificationChannelIdConfig: PulseUnicornNotificationChannelConfig?
)
  1. Add PulseUnicorn.getUnicornInterceptor() in PulseEnvironment.Builder via addInterceptor method.
PulseEnvironment.Builder(context, clientId).apply {
    addInterceptor(PulseUnicorn.getUnicornInterceptor())
}.build()

Starting Pulse Unicorn Activity

You can open Pulse Unicorn from notification card or use dedicated method

PulseUnicorn.openPulseUnicorn(context = this)

Testing the validity of events

To simply check the validation of event Json before sending or during your tests you can use PulseUnicorn().getUnicornValidator(). It creates a quick HTTP request to Pulse Console and returns PulseValidatorResponse class which holds information about validation results.

Validator response

success - bool information about validation
errorsJsonString - Json String with errors

Example

lifecycleScope.launch(Dispatchers.IO) {
  // async
  PulseUnicorn.getUnicornValidator().validate(eventJsonString)
    ?.let { pulseValidator ->
      if (pulseValidator.success) {
        // event is valid -> send
        PulseTrackerProvider().get().track(event)
      } else {
        // event is not valid -> check errors
        Log.d(
          "PulseValidator",
          pulseValidator.errorsJsonString
            ?: "Received empty error msg from validator"
        )
      }
    }
}

Contact

When, for technical reasons Slack cannot work for you, please make sure to use GitHub issues link instead. We will provide all the necessary answers within the relevant Slack threads (or in Github issue when your case is inserted there). Thank you for your cooperation!