Skip to Content
DocumentationReferenceCustom Data Reporting

Custom Data Reporting

In some scenarios, especially when APP-embedded H5 pages need to report coverage data, since there is no Canyon Chrome extension similar to PC, custom implementation of coverage data reporting functionality is required.

Applicable Scenarios

  • APP-embedded H5 pages
  • Environments where Canyon Chrome extension cannot be used
  • Scenarios requiring custom reporting logic
  • Mobile web applications

Implementation Solution

The following is a basic custom reporting implementation solution:

const coverageFirstValue = Object.values(window.__coverage__||{})[0]; if (coverageFirstValue) { fetch(coverageFirstValue.dsn,{ method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${coverageFirstValue.reporter}` }, body: JSON.stringify({ coverage: window.__coverage__, ...coverageFirstValue }) }) }