Skip to content

Instantly share code, notes, and snippets.

@garymathews
Last active August 27, 2019 22:58
Show Gist options
  • Save garymathews/0170fecd310936f1c8030651bb5aed0e to your computer and use it in GitHub Desktop.
Save garymathews/0170fecd310936f1c8030651bb5aed0e to your computer and use it in GitHub Desktop.
ACA Tests

TEST 1 - Validate breadcrumbs are retained for new session

  1. QUEUE 5 BREADCRUMBS
  2. Background application (not quit).
  3. Re-enter application.
  4. CRASH
  5. Crash Analytics -> Breadcrumbs should show a session with five breadcrumbs.

TEST 2 - Validate breadcrumbs can send data payloads

  1. Start logging events with Chimera Web
  2. QUEUE BREADCRUMB WITH DATA
  3. CRASH
  4. View crash.breadcrumb event in Chimera Web, validate it contains:
data: {
  ...
  "test": "data"
}

TEST 3 - Validate Date objects are parsed correctly

  1. Start logging events with Chimera Web
  2. SEND DATE OBJECT
  3. View test.date event in Chimera Web, validate it contains:
data: {
  ...
  "date": "2019-08-27T22:23:07.287+000Z"
}
  1. CRASH
  2. View crash.report event in Chimera Web, validate it contains:
data: {
  ...
  "meta": {
    "test_date": "2019-08-27T22:23:07.287+000Z"
  }
}
NOTE: Although the date will be different, the format must be the same.

TEST 3 - Validate breadcrumb limits can be changed

  1. SET BREADCRUMB LIMIT (MAX)
[INFO]  current breadcrumbLimit: 10
[INFO]  new breadcrumbLimit: 100
  1. SET BREADCRUMB LIMIT (1)
[INFO]  current breadcrumbLimit: 100
[INFO]  new breadcrumbLimit: 1
  1. QUEUE 5 BREADCRUMBS
  2. CRASH
  3. Crash Analytics -> Breadcrumbs should show a session with one breadcrumb.

TEST 4 - Validate events are queued and sent after being offline

  1. Enable Airplane mode on test device
  2. Launch test application
  3. QUEUE 5 BREADCRUMBS
  4. Background application
  5. Re-enter application
  6. SEND DATE OBJECT
  7. CRASH
  8. Close application
  9. Disable Airplane mode on test device
  10. Launch test application
  11. Crash Analytics -> Breadcrumbs should show a session with breadcrumbs and test.date event (Check Include feature events).
  • May need to wait 30 seconds to see new crash on dashboard.
  1. In Field enter content.app
  2. In Value enter Titanium application guid
  3. Click Add Filter
  4. Click Subscribe
NOTE: Only look at events with header x-client-id: gatekeeper.

app.js

const aca = require('com.appcelerator.aca');

const win = Ti.UI.createWindow({ backgroundColor: 'gray', layout: 'vertical', top: 50 });
const btn_a = Ti.UI.createButton({ title: 'QUEUE 5 BREADCRUMBS (200ms)' });
const btn_b = Ti.UI.createButton({ title: 'QUEUE BREADCRUMB WITH DATA' });
const btn_c = Ti.UI.createButton({ title: 'SEND DATE OBJECT' });
const btn_d = Ti.UI.createButton({ title: 'SET BREADCRUMB LIMIT (MAX)' });
const btn_e = Ti.UI.createButton({ title: 'SET BREADCRUMB LIMIT (1)' });
const btn_f = Ti.UI.createButton({ title: 'CRASH' });

btn_a.addEventListener('click', e => {
    for (let i = 0; i < 5; i++) {
        setTimeout(() => {
            aca.leaveBreadcrumb('breadcrumb.queue_' + i);
        }, i*200);
    }
});

btn_b.addEventListener('click', e => {
    aca.leaveBreadcrumb('breadcrumb.withData', { test: 'data' });
});

btn_c.addEventListener('click', e => {
    Ti.Analytics.featureEvent('test.date', { date: new Date() });
    aca.setMetadata('test_date', new Date());
});

btn_d.addEventListener('click', e => {
    Ti.API.info(`current breadcrumbLimit: ${aca.getBreadcrumbLimit()}`);

    // set limit above max
    aca.setBreadcrumbLimit(200);

    // should be 100, seting above will reset to max (100)
    Ti.API.info(`new breadcrumbLimit: ${aca.getBreadcrumbLimit()}`);
});

btn_e.addEventListener('click', e => {
    Ti.API.info(`current breadcrumbLimit: ${aca.getBreadcrumbLimit()}`);

    // set limit to 1
    aca.setBreadcrumbLimit(1);

    // should be 1
    Ti.API.info(`new breadcrumbLimit: ${aca.getBreadcrumbLimit()}`);
});

btn_f.addEventListener('click', e => {
    Titanium.crash();
});

win.add([ btn_a, btn_b, btn_c, btn_d, btn_e, btn_f ]);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment