Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to map API tracking parameter to custom variable in log importer script. #7151

Closed
diosmosis opened this issue Feb 8, 2015 · 16 comments
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Milestone

Comments

@diosmosis
Copy link
Member

This pull request adds two options to import_logs.py that move tracking API parameters to custom variables. This is for a PRO request to allow not tracking user IDs from cs-username using uid and instead track via a custom variable. To do this, you would specify --api-arg-to-visit-cvar="uid=User Name". The option references tracking API parameters so it can be used w/ any format.

I think using API parameters might be limiting however. After thinking about it, it might be better to make it use regex groups. Then we can add two more options, --ignore-fields=userid, --w3c-field-regex=my-custom-field=myregex so users can import any field they want into a custom variable.

Includes change to ImportLogs system test and fix for import log custom variable handling (old behavior was to not set multiple custom variables if they were set already instead of simply adding custom variables).

@mattab @quba Can you let me know what you think?

@mattab mattab added this to the Piwik 2.11.0 milestone Feb 9, 2015
@mattab mattab added Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. c: Design / UI For issues that impact Matomo's user interface or the design overall. c: Log Analytics (import_logs.py) and removed c: Design / UI For issues that impact Matomo's user interface or the design overall. labels Feb 9, 2015
@mattab
Copy link
Member

mattab commented Feb 9, 2015

it's a nice, clean re-usable solution. I like it!

@quba did you have a chance to test it and can confirm the feature?

@diosmosis
Copy link
Member Author

@mattab What did you think about the second paragraph?

@mattab
Copy link
Member

mattab commented Feb 9, 2015

I think using API parameters might be limiting however. After thinking about it, it might be better to make it use regex groups. Then we can add two more options, --ignore-fields=userid, --w3c-field-regex=my-custom-field=myregex so users can import any field they want into a custom variable.

Yes, it could be useful to have this ability but maybe we wait for some use cases? AFAIK it would not invalidate this PR and new options so it could be done later
maybe create a separate issue?

@diosmosis
Copy link
Member Author

It wouldn't invalidate it, but it would be redundant since you could use the other options to do what's in this use case.

@mattab
Copy link
Member

mattab commented Feb 10, 2015

What would be equivalent to --api-arg-to-visit-cvar="uid=User Name" with these options?

@diosmosis
Copy link
Member Author

--regex-group-to-visit-cvar="userid=User Name"

@mattab
Copy link
Member

mattab commented Feb 10, 2015

ok looks nice! btw is there an option to list the regex groups available for a given log file?

@diosmosis
Copy link
Member Author

It would be for a format, I was planning on adding the info to the help documentation.

@diosmosis
Copy link
Member Author

ok looks nice!

I'll make the changes, please don't merge until I finish them.

@diosmosis
Copy link
Member Author

@mattab I've modified the pull request, new options now include:

--regex-group-to-visit-cvar
--regex-group-to-page-cvar
--ignore-fields
--w3c-field-regex

First 3 are for @quba's use case. Last one can be combined w/ other ones to track any w3c log field that the importer doesn't natively recognize in a custom variable.

Let me know what you think.

@quba
Copy link
Contributor

quba commented Feb 11, 2015

@diosmosis how can I choose which custom variable will be used?

@diosmosis
Copy link
Member Author

You mean which index? Or what the custom variable name to use? For name, --regex-group-to-visit-cvar="userid=User Name". I don't think index matters.

@mattab
Copy link
Member

mattab commented Feb 12, 2015

after a quick review, looks good to me! 👍

@mattab
Copy link
Member

mattab commented Feb 12, 2015

@diosmosis in the morning i'm thinking, maybe we could add a test case in python for these new parameters? they can be difficult to grasp and this would ensure we don't regress without noticing.

@diosmosis
Copy link
Member Author

There are tests in ImportLogsTest.php, do you mean add more tests to log-analytics/tests/*?

@mattab
Copy link
Member

mattab commented Feb 12, 2015

do you mean add more tests to log-analytics/tests/*?

yes

diosmosis pushed a commit that referenced this issue Feb 12, 2015
…re userid not set in hit object, fix ignore group option value spliting.
mattab pushed a commit that referenced this issue Feb 13, 2015
Add option to map API tracking parameter to custom variable in log importer script.
@mattab mattab closed this as completed Feb 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

No branches or pull requests

3 participants