CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-expo-application

A universal module that gets native application information such as its ID, app name, and build version at runtime

Overall
score

98%

Overview
Eval results
Files

task.mdevals/scenario-4/

Device Analytics Tracker

Build a device analytics utility that captures and stores device-specific information for app analytics purposes on Android devices.

Requirements

Create a module that provides device identification functionality:

  1. Device ID Retrieval: Implement a function getDeviceIdentifier() that:

    • Returns the unique device identifier on Android
    • Returns null on non-Android platforms
    • Handles errors gracefully by returning null if the identifier cannot be retrieved
  2. Analytics Event Logging: Implement a function logAnalyticsEvent(eventName, eventData) that:

    • Creates an analytics event object containing:
      • deviceId: The device identifier (or null if unavailable)
      • eventName: The name of the event
      • eventData: Additional event data
      • timestamp: ISO 8601 timestamp of when the event was logged
    • Returns the complete analytics event object
  3. Platform Detection: Implement a function isAndroidDevice() that:

    • Returns true if running on Android
    • Returns false otherwise

Test Cases

  • The getDeviceIdentifier() function successfully retrieves a device identifier on Android @test
  • The getDeviceIdentifier() function returns null when device identification fails @test
  • The logAnalyticsEvent() function creates event objects with all required fields @test
  • The isAndroidDevice() function correctly identifies the platform @test

Implementation

@generates

API

/**
 * Retrieves the unique device identifier for Android devices.
 * Returns null on non-Android platforms or if retrieval fails.
 *
 * @returns {string | null} The device identifier or null
 */
function getDeviceIdentifier() {
  // IMPLEMENTATION HERE
}

/**
 * Creates an analytics event object with device information.
 *
 * @param {string} eventName - The name of the event
 * @param {object} eventData - Additional event data
 * @returns {object} Analytics event with deviceId, eventName, eventData, and timestamp
 */
function logAnalyticsEvent(eventName, eventData) {
  // IMPLEMENTATION HERE
}

/**
 * Checks if the current platform is Android.
 *
 * @returns {boolean} True if running on Android, false otherwise
 */
function isAndroidDevice() {
  // IMPLEMENTATION HERE
}

module.exports = {
  getDeviceIdentifier,
  logAnalyticsEvent,
  isAndroidDevice
};

Dependencies { .dependencies }

expo-application { .dependency }

Provides native application information and device identification.

Install with Tessl CLI

npx tessl i tessl/npm-expo-application

tile.json