Document String metric API for Swift

This commit is contained in:
Jan-Erik Rediger 2019-09-18 14:42:02 +02:00
Родитель 5165769052
Коммит 64e6775871
1 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -22,6 +22,8 @@ search.default:
## API
### Kotlin
```Kotlin
import org.mozilla.yourApplication.GleanMetrics.SearchDefault
@ -43,6 +45,27 @@ assertTrue(SearchDefault.name.testHasValue())
assertEquals("wikipedia", SearchDefault.name.testGetValue())
```
### Swift
```Swift
// Record a value into the metric.
SearchDefault.name.set("duck duck go")
// If it changed later, you can record the new value:
SearchDefault.name.set("wikipedia")
```
There are test APIs available too:
```Kotlin
@testable import Glean
// Was anything recorded?
XCTAssert(SearchDefault.name.testHasValue())
// Does the string metric have the expected value?
// IMPORTANT: It may have been truncated -- see "Limits" below
XCTAssertEqual("wikipedia", try SearchDefault.name.testGetValue())
```
## Limits
* Fixed maximum string length: 50. Longer strings are truncated. For the original Kotlin implementation of the Glean SDK, this is measured in Unicode characters. For the Rust implementation, this is measured in the number of bytes when the string is encoded in UTF-8.