Analytics improvement (#9)
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Co-authored-by: Quentin Bandera <q.bandera@openium.fr> Reviewed-on: #9 Co-authored-by: Loris Perret <l.perret@openium.fr> Co-committed-by: Loris Perret <l.perret@openium.fr>
This commit is contained in:
83
README.md
83
README.md
@ -133,7 +133,7 @@ swift run -c release ResgenSwift strings tags $FORCE_FLAG "./Tags/tags.txt" \
|
||||
6. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppTags+GreatApp.swift`)
|
||||
7. `--static-members` *(optional)*: generate static properties or not
|
||||
|
||||
> ⚠️ If extension name is not set or is `Tags`, it will generate the following typaloas `typealias Tags = String`.
|
||||
> ⚠️ If extension name is not set or is `Tags`, it will generate the following typealias `typealias Tags = String`.
|
||||
|
||||
|
||||
## Analytics
|
||||
@ -141,7 +141,7 @@ swift run -c release ResgenSwift strings tags $FORCE_FLAG "./Tags/tags.txt" \
|
||||
Analytics will generate all you need to analyze UX with Matomo or Firebase Analytics. Input files are formatted in YAML. This command will generate a manager for each target and an AnalyticsManager. This is this one you will need to use. And it will generate a method for all tags you have declared in the YAML file. Next, you will need to use the `configure()` method of AnalyticsManager and if you want to use matomo to set up the `siteId` and the `url` of the site.
|
||||
|
||||
```sh
|
||||
swift run -c release ResgenSwift strings tags $FORCE_FLAG "./Tags/tags.txt" \
|
||||
swift run -c release ResgenSwift analytics $FORCE_FLAG "./Tags/analytics.yml" \
|
||||
--target "matomo firebase" \
|
||||
--extension-output-path "./Analytics/Generated" \
|
||||
--extension-name "AppAnalytics" \
|
||||
@ -159,7 +159,7 @@ swift run -c release ResgenSwift strings tags $FORCE_FLAG "./Tags/tags.txt" \
|
||||
6. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppAnalytics+GreatApp.swift`)
|
||||
7. `--static-members` *(optional)*: generate static properties or not
|
||||
|
||||
> ⚠️ If extension name is not set or is `Analytics`, it will generate the following typaloas `typealias Analytics = String`.
|
||||
> ⚠️ If extension name is not set or is `Analytics`, it will generate the following typealias `typealias Analytics = String`.
|
||||
|
||||
### YAML
|
||||
|
||||
@ -186,19 +186,83 @@ swift run -c release ResgenSwift strings tags $FORCE_FLAG "./Tags/tags.txt" \
|
||||
7. `comments` *(optional)*
|
||||
8. `parameters` *(optional)*
|
||||
|
||||
**Parameters**
|
||||
**Parameters**
|
||||
|
||||
You can use parameters in generate methods.
|
||||
|
||||
1. `name`: name of the parameter
|
||||
2. `type`: type of the parameter (Int, String, Bool, Double)
|
||||
3. `value`: value of the parameter
|
||||
4. `defaultValue`: defaultValue of the parameter
|
||||
3. `replaceIn` *(optional)*
|
||||
|
||||
**Value**
|
||||
|
||||
If you want to send another parameter with a static value. For example, you want to send to which screen the event is triggered.
|
||||
You can add the parameter 'screenName' for example and its 'value' is 'Home'. With this, you do not need to specify the value in the function call.
|
||||
|
||||
**DefaultValue**
|
||||
|
||||
If you want ta add a parameter in the call of the function but you want to make it optionnal with a default value you need to use this property.
|
||||
|
||||
Example:
|
||||
```
|
||||
events:
|
||||
id: id_of_tag
|
||||
name: _TITLE_
|
||||
tags: ios,droid
|
||||
parameters:
|
||||
- name: title
|
||||
type: String
|
||||
defaultValue: someTitle
|
||||
```
|
||||
|
||||
The generated method will be:
|
||||
```
|
||||
logIdOfTag(title: String = "someTitle")
|
||||
```
|
||||
|
||||
**Replace in**
|
||||
|
||||
This is section is equivalent of `%s | %d | %f | %@`. You can put the content of the parameter in *name*, *path*, *action*, *category*.
|
||||
You need to put `_` + `NAME OF THE PARAMETER` + `_` in the target and which target you want in the value of `replaceIn`. (name need to be in uppercase)
|
||||
You need to put `_` + `NAME OF THE PARAMETER` + `_` in the target and which target you want in the value of `replaceIn`. (name need to be in uppercase).
|
||||
You can't use `value`and `replaceIn`in thge same time.
|
||||
|
||||
Example:
|
||||
```
|
||||
events:
|
||||
id: id_of_tag
|
||||
name: _TITLE_
|
||||
tags: ios,droid
|
||||
parameters:
|
||||
- name: title
|
||||
type: String
|
||||
replaceIn: name
|
||||
```
|
||||
|
||||
In this sample, we want to add the parameter `title` in the field `name`. So, we need to place `_TITLE_` in the field `name`.
|
||||
|
||||
The generated method will be:
|
||||
```
|
||||
logIdOfTag(title: String)
|
||||
```
|
||||
|
||||
You can also want to replace a parameter in an other parameter. You can do this with the `replaceIn` property. The condition is that the parameter which will use the `replaceIn`need to have the `value`property
|
||||
|
||||
Example:
|
||||
```
|
||||
events:
|
||||
id: id_of_tag
|
||||
name: title
|
||||
tags: ios,droid
|
||||
parameters:
|
||||
- name: something
|
||||
type: String
|
||||
value: test _TEXT_
|
||||
- name: text
|
||||
type: String
|
||||
replaceIn: something
|
||||
```
|
||||
|
||||
## Images
|
||||
|
||||
@ -287,6 +351,15 @@ tags:
|
||||
extensionName: String?
|
||||
extensionSuffix: String?
|
||||
staticMembers: Bool?
|
||||
|
||||
analytics:
|
||||
-
|
||||
inputFile: String
|
||||
target: String
|
||||
extensionOutputPath: String
|
||||
extensionName: String?
|
||||
extensionSuffix: String?
|
||||
staticMembers: Bool?
|
||||
```
|
||||
|
||||
### Multiple configurations
|
||||
|
Reference in New Issue
Block a user