feat: Added custom event event type for web analytics (#10554)

* feat: Added custom event event type for web analytics

* feat: renamed  to

* Update openmetadata-spec/src/main/resources/json/schema/analytics/webAnalyticEventType/customEvent.json

Co-authored-by: Nahuel <nahuel@getcollate.io>

* Update openmetadata-spec/src/main/resources/json/schema/analytics/webAnalyticEventType/customEvent.json

Co-authored-by: Nahuel <nahuel@getcollate.io>

* feat: move common type to basic.json

* feat: ran linting

---------

Co-authored-by: Nahuel <nahuel@getcollate.io>
This commit is contained in:
Teddy 2023-03-21 10:12:15 +01:00 committed by GitHub
parent 133bdfbf64
commit 64205cf231
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 80 additions and 14 deletions

View File

@ -102,7 +102,7 @@ class WebAnalyticEntityViewReportDataProcessor(DataProcessor):
while True: while True:
event = yield refined_data event = yield refined_data
split_url = [url for url in event.eventData.url.split("/") if url] # type: ignore split_url = [url for url in event.eventData.url.__root__.split("/") if url] # type: ignore
if not split_url or split_url[0] not in ENTITIES: if not split_url or split_url[0] not in ENTITIES:
continue continue
@ -118,9 +118,9 @@ class WebAnalyticEntityViewReportDataProcessor(DataProcessor):
# if we've seen the entity previously but were not able to get # if we've seen the entity previously but were not able to get
# the URL we'll try again from the new event. # the URL we'll try again from the new event.
try: try:
entity_href = re.search(re_pattern, event.eventData.fullUrl).group( entity_href = re.search(
1 re_pattern, event.eventData.fullUrl.__root__
) ).group(1)
refined_data[entity_obj.fqn]["entityHref"] = entity_href refined_data[entity_obj.fqn]["entityHref"] = entity_href
except IndexError: except IndexError:
logger.debug(f"Could not find entity Href for {entity_obj.fqn}") logger.debug(f"Could not find entity Href for {entity_obj.fqn}")
@ -166,9 +166,9 @@ class WebAnalyticEntityViewReportDataProcessor(DataProcessor):
) )
try: try:
entity_href = re.search(re_pattern, event.eventData.fullUrl).group( entity_href = re.search(
1 re_pattern, event.eventData.fullUrl.__root__
) ).group(1)
except IndexError: except IndexError:
entity_href = None entity_href = None

View File

@ -41,7 +41,6 @@ from metadata.generated.schema.metadataIngestion.workflow import WorkflowConfig
from metadata.generated.schema.type.basic import ComponentConfig from metadata.generated.schema.type.basic import ComponentConfig
from metadata.ingestion.models.encoders import show_secrets_encoder from metadata.ingestion.models.encoders import show_secrets_encoder
from metadata.ingestion.ometa.ometa_api import OpenMetadata from metadata.ingestion.ometa.ometa_api import OpenMetadata
from metadata.utils.constants import ES_SOURCE_TO_ES_OBJ_ARGS
def data_insight_workflow(workflow_config: OpenMetadataWorkflowConfig): def data_insight_workflow(workflow_config: OpenMetadataWorkflowConfig):

View File

@ -0,0 +1,6 @@
{
"name": "CustomEvent",
"fullyQualifiedName": "CustomEvent",
"description": "Captures web analytic custom events",
"eventType": "CustomEvent"
}

View File

@ -9,8 +9,25 @@
"description": "event type", "description": "event type",
"type": "string", "type": "string",
"enum": [ "enum": [
"PageView" "PageView",
"CustomEvent"
] ]
},
"fullUrl": {
"description": "complete URL of the page",
"type": "string"
},
"url": {
"description": "url part after the domain specification",
"type": "string"
},
"hostname": {
"description": "domain name",
"type": "string"
},
"sessionId": {
"description": "Unique ID identifying a session",
"$ref": "../type/basic.json#/definitions/uuid"
} }
} }
} }

View File

@ -21,7 +21,8 @@
"eventData": { "eventData": {
"description": "Web analytic data captured", "description": "Web analytic data captured",
"oneOf": [ "oneOf": [
{"$ref": "webAnalyticEventType/pageViewEvent.json"} {"$ref": "webAnalyticEventType/pageViewEvent.json"},
{"$ref": "webAnalyticEventType/customEvent.json"}
] ]
} }
}, },

View File

@ -0,0 +1,43 @@
{
"$id": "https://open-metadata.org/schema/analytics/customEvent.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "customData",
"type": "object",
"javaType": "org.openmetadata.schema.analytics.CustomEvent",
"description": "Event tracker (e.g. clicks, etc.)",
"definitions": {
"customEventTypes": {
"description": "Type of events that can be performed",
"type": "string",
"enum": [
"CLICK"
]
}
},
"properties": {
"fullUrl": {
"description": "complete URL of the page",
"$ref": "../basic.json#/definitions/fullUrl"
},
"url": {
"description": "url part after the domain specification",
"$ref": "../basic.json#/definitions/url"
},
"hostname": {
"description": "domain name",
"$ref": "../basic.json#/definitions/hostname"
},
"sessionId": {
"description": "Unique ID identifying a session",
"$ref": "../basic.json#/definitions/sessionId"
},
"eventType": {
"description": "Type of event that was performed",
"$ref": "#/definitions/customEventTypes"
},
"eventValue": {
"description": "Value of the event",
"type": "string"
}
}
}

View File

@ -8,15 +8,15 @@
"properties": { "properties": {
"fullUrl": { "fullUrl": {
"description": "complete URL of the page", "description": "complete URL of the page",
"type": "string" "$ref": "../basic.json#/definitions/fullUrl"
}, },
"url": { "url": {
"description": "url part after the domain specification", "description": "url part after the domain specification",
"type": "string" "$ref": "../basic.json#/definitions/url"
}, },
"hostname": { "hostname": {
"description": "domain name", "description": "domain name",
"type": "string" "$ref": "../basic.json#/definitions/hostname"
}, },
"language": { "language": {
"description": "language set on the page", "description": "language set on the page",
@ -32,7 +32,7 @@
}, },
"sessionId": { "sessionId": {
"description": "Unique ID identifying a session", "description": "Unique ID identifying a session",
"$ref": "../../type/basic.json#/definitions/uuid" "$ref": "../basic.json#/definitions/sessionId"
}, },
"pageLoadTime": { "pageLoadTime": {
"description": "time for the page to load in seconds", "description": "time for the page to load in seconds",