From 0bb72f0d9d5d8bb2ab764190944f47a47b227b18 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Mon, 30 Oct 2023 10:56:04 +0100 Subject: [PATCH] fix: Get back metrics by using old specific Receive log method (#56) --- .vscode/tasks.json | 3 ++- Speckle.query.pq | 2 +- speckle/api/Api.CommitReceived.pqm | 4 +-- speckle/{logging => helpers}/LogEvent.pqm | 18 ++++++++++--- speckle/logging/Log.Receive.pqm | 33 ----------------------- 5 files changed, 20 insertions(+), 40 deletions(-) rename speckle/{logging => helpers}/LogEvent.pqm (64%) delete mode 100644 speckle/logging/Log.Receive.pqm diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 214fec0..993f70f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -25,7 +25,8 @@ "${workspaceFolder}\\tests", "--prettyPrint" ], - "problemMatcher": [] + "problemMatcher": [], + "dependsOn": ["build"] } ] } diff --git a/Speckle.query.pq b/Speckle.query.pq index 9a0e156..3112ede 100644 --- a/Speckle.query.pq +++ b/Speckle.query.pq @@ -1,2 +1,2 @@ // Use this file to write queries to test your data connector -let result = Speckle.GetByUrl("https://latest.speckle.dev/streams/c1faab5c62/commits/aefb7a5fff") in result +let result = Speckle.GetByUrl("https://latest.speckle.dev/streams/4e51c4025f/commits/766c20c5fb") in result diff --git a/speckle/api/Api.CommitReceived.pqm b/speckle/api/Api.CommitReceived.pqm index c1b0799..37aa4c2 100644 --- a/speckle/api/Api.CommitReceived.pqm +++ b/speckle/api/Api.CommitReceived.pqm @@ -1,6 +1,6 @@ let Speckle.Api.Fetch = Extension.LoadFunction("Api.Fetch.pqm"), - Speckle.Log.Receive = Extension.LoadFunction("Log.Receive.pqm"), + Speckle.LogEvent = Extension.LoadFunction("LogEvent.pqm"), Extension.LoadFunction = (fileName as text) => let binary = Extension.Contents(fileName), asText = Text.FromBinary(binary) @@ -27,7 +27,7 @@ in sourceApplication = "PowerBI" ] ], - s = Speckle.Log.Receive(server, commit) + s = Speckle.LogEvent(server, commit) in // Read receipts should fail gracefully no matter what try Speckle.Api.Fetch(s, query, variables)[commitReceive] otherwise false diff --git a/speckle/logging/LogEvent.pqm b/speckle/helpers/LogEvent.pqm similarity index 64% rename from speckle/logging/LogEvent.pqm rename to speckle/helpers/LogEvent.pqm index 1ad8487..bb08ae8 100644 --- a/speckle/logging/LogEvent.pqm +++ b/speckle/helpers/LogEvent.pqm @@ -1,4 +1,7 @@ let + GetApplicationSlug = Extension.LoadFunction("GetApplicationSlug.pqm"), + GetUser = Extension.LoadFunction("Api.GetUser.pqm"), + Hash = Extension.LoadFunction("Hash.pqm"), Extension.LoadFunction = (fileName as text) => let binary = Extension.Contents(fileName), asText = Text.FromBinary(binary) @@ -13,12 +16,21 @@ let Detail = [File = fileName, Error = e] ] in - (server as text, event as text, properties as record) => + (server as text, commit as any) => let trackUrl = "https://analytics.speckle.systems/track?ip=1", + user = GetUser(server), + isMultiplayer = user[id] <> commit[authorId], body = [ - event = event, - properties = properties + event = "Receive", + properties = [ + server_id = Hash(server), + token = "acd87c5a50b56df91a795e999812a3a4", + hostApp = "powerbi", + sourceHostApp = GetApplicationSlug(commit[sourceApplication]), + sourceHostAppVersion = commit[sourceApplication], + isMultiplayer = user[id] <> commit[authorId] + ] ], Result = Web.Contents( trackUrl, diff --git a/speckle/logging/Log.Receive.pqm b/speckle/logging/Log.Receive.pqm deleted file mode 100644 index 9be0bd7..0000000 --- a/speckle/logging/Log.Receive.pqm +++ /dev/null @@ -1,33 +0,0 @@ -let - GetApplicationSlug = Extension.LoadFunction("GetApplicationSlug.pqm"), - GetUser = Extension.LoadFunction("Api.GetUser.pqm"), - LogEvent = Extension.LoadFunction("LogEvent.pqm"), - Hash = Extension.LoadFunction("Hash.pqm"), - Extension.LoadFunction = (fileName as text) => - let - binary = Extension.Contents(fileName), asText = Text.FromBinary(binary) - in - try - Expression.Evaluate(asText, #shared) catch (e) => - error - [ - Reason = "Extension.LoadFunction Failure", - Message.Format = "Loading '#{0}' failed - '#{1}': '#{2}'", - Message.Parameters = {fileName, e[Reason], e[Message]}, - Detail = [File = fileName, Error = e] - ] -in - (server as text, commit as text) => - let - user = GetUser(server), - event = "Receive", - properties = [ - server_id = Hash(server), - token = "acd87c5a50b56df91a795e999812a3a4", - hostApp = "powerbi", - sourceHostApp = GetApplicationSlug(commit[sourceApplication]), - sourceHostAppVersion = commit[sourceApplication], - isMultiplayer = commit[authorId] <> user[id] - ] - in - LogEvent(server, event, properties)