Skip to content

Commit

Permalink
feat: Added mixpanel user and server hashed
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanRynne committed Apr 7, 2022
1 parent 5973aae commit 685384b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Speckle/Speckle.pq
Original file line number Diff line number Diff line change
Expand Up @@ -302,30 +302,31 @@ shared Speckle.Api.GetUser = (server) =>
try Speckle.Api.Fetch(server, query)[user] otherwise null;


Hash = (Value as text) =>
shared Hash = (Value as text) =>
let
Solution = Binary.ToText(
Binary.FromList(
Binary.ToList(
Binary.Compress( Text.ToBinary(Value, BinaryEncoding.Base64), Compression.GZip))))
in
if Value = null then null else Value;
if Value = null then null else Solution;


/* Since everything is lazily evaluated, we must join and split the result of the matomo call with the server, and spit back the server url for PowerBI to actually log the calls to Matomo */
Speckle.LogEvent = (server as text, optional serverId as text, optional userId as text) =>
Speckle.LogEvent = (server as text) =>
let
matomoUrl = "https://analytics.speckle.systems/track?ip=1",
trackUrl = "https://analytics.speckle.systems/track?ip=1",
user = Speckle.Api.GetUser(server),
body = [
event = "receive",
properties = [
distinct_id = userId,
server_id = serverId,
distinct_id = if user = null then null else Hash(user),
server_id = Hash(server),
token = "acd87c5a50b56df91a795e999812a3a4",
hostApp = "powerbi"
]
],
Result = Web.Contents(matomoUrl,
Result = Web.Contents(trackUrl,
[
Headers=[
#"Method"="POST",
Expand Down

0 comments on commit 685384b

Please sign in to comment.