Skip to main content

User class that defines a user based on clickstream data.

Project description


Defines the vaknl User dataclass. A user (here identified by a dmp_user_id) is an object that is defined by website clickstream data as a basis. The User class contains functions that can transform raw Firestore website clickstream data to well defined Event dataclasses and update the statistics of the User accordingly. These Event dataclasses are read and translated into user information. The User dataclass also includes methods to read from and write to Firestore.


Date Name
2020-08-06 Merijn van Es


Firestore read and write permissions within the Google Cloud Platform (GCP), if one wants to make use of the Firestore functionality.

Project structure

    |__ data
        |__ ...                                     # Data used for testing.
    |__ tests
        |__ event
            |__                         # Empty, but required for package.
            |__                # Unit testing on create_event() function.
            |__                       # Unit testing on Event and Events dataclasses.
            |__    # Unit testing on SearchPageSearchQuery (Event) dataclass.
        |__ user
            |__                         # Empty, but required for package.
            |__                       # Unit testing on Email dataclass.
            |__                  # Unit testing on Statistics dataclass.
            |__                        # Unit testing on User dataclass.
            |__       # Unit testing on update_firestore_user() function.
        |__                               # Explanation on testing.
        |__                                # Utility functions for testing.
    |__ vaknl_NBC                                   # Package that creates a NBC API on local data.
        |__                             # Includes NBC class.
        |__ (NBC.pkl)                               # NBC data; should not be included in distributed versions.
    |__ vaknl_user
        |__ event
            |__                         # Imports all package modules and contains create_event function.
            |__                            # Contains Event and Events dataclasses.
            |__                           # Contains all filter event dataclasses.
            |__                            # Contains all other event dataclasses.
            |__                         # Contains all pageview event dataclasses.
            |__                      # Contains all reservation event dataclasses.
            |__                            # Utility functions for testing.
        |__ user
            |__                         # Imports all package modules.
            |__                            # Contains Email dataclass.
            |__                       # Contains all statistic dataclasses and subsidiaries.
            |__                             # Contains User dataclass.
            |__                            # Utility functions for testing.
        |__                             # Empty, but required for package.
    |__ LICENSE                                     # Licensing information.
    |__                                 # Adds and removes files from distribution.
    |__                                   # Project explanation.
    |__                                    # Package build script.

User dataclass

Can be found under vaknl_user.user.user.User and has the following useful methods:

update(self, client: utils.firestore.Client, nbc_api: NBC = None)

Gets all raw clickstream events that has occurred after the latest event tracked in the statistics and updates the user with it.

@classmethod from_firestore_clickstream(cls, client: utils.firestore.Client, dmp_user_id: str, nbc_api: NBC = None)

Creates user with all raw clickstream events available.

@classmethod from_firestore_user(cls, client: utils.firestore.Client, dmp_user_id: str)

Create User dataclass from a Firestore user.

to_firestore(self, client: utils.firestore.Client)

Exports user to Firestore user collection, overwriting it.

update_firestore_user(client: utils.firestore.Client, dmp_user_id: str, nbc_api: NBC = None)

The update_firestore_user() function is used to update the document in the dmp_user Firestore collection for a user with given dmp_user_id.

Event dataclass

This dataclass has many children (can be found in the same package directory under,, or, which represent the individual clickstream events of interest. The Event dataclass can be found under vaknl_user.event.event.Event and should, in practice, only be called through the methods of the User dataclass.

Events dataclass

This dataclass contains a list of Event instances, but has some useful methods that make it more desirable than a plain list. The Events dataclass can be found under vaknl_user.event.event.Events and should, in practice, only be called through the methods of the User dataclass.

create_event(data: dict)

The create_event() function is used to transform single raw clickstream event dictionaries to a instance of Event (and one of it child dataclasses). The create_event() function can be found under vaknl_user.event.event.Event and should, in practice, only be called through the methods of the User dataclass.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vaknl-user-2.1.3.tar.gz (18.9 kB view hashes)

Uploaded Source

Built Distribution

vaknl_user-2.1.3-py3-none-any.whl (23.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page