-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- #929 - #930 - #935 - Revert migration to go1.18 done in one of the cherry-picked prs, go version kept as go1.13 to avoid all migration of ioutil (migrated as part of model.AppError change) - Bump 3.2.5 Fixes - Telemetry race condition - Telemetry rudder keys
- Loading branch information
Showing
14 changed files
with
657 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ var manifest = struct { | |
Version string | ||
}{ | ||
ID: "jira", | ||
Version: "3.2.4", | ||
Version: "3.2.5", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/mattermost/mattermost-plugin-jira/server/telemetry" | ||
) | ||
|
||
func (p *Plugin) TrackEvent(event string, properties map[string]interface{}) { | ||
err := p.tracker.TrackEvent(event, properties) | ||
if err != nil { | ||
p.API.LogDebug("Error sending telemetry event", "event", event, "error", err.Error()) | ||
} | ||
} | ||
|
||
func (p *Plugin) TrackUserEvent(event, userID string, properties map[string]interface{}) { | ||
err := p.tracker.TrackUserEvent(event, userID, properties) | ||
if err != nil { | ||
p.API.LogDebug("Error sending user telemetry event", "event", event, "error", err.Error()) | ||
} | ||
} | ||
|
||
func (p *Plugin) OnSendDailyTelemetry() { | ||
args := map[string]interface{}{} | ||
|
||
// Jira instances | ||
server, cloud := 0, 0 | ||
instances, err := p.instanceStore.LoadInstances() | ||
if err != nil { | ||
p.API.LogWarn("Failed to get instances for telemetry", "error", err) | ||
} else { | ||
for _, id := range instances.IDs() { | ||
switch instances.Get(id).Type { | ||
case ServerInstanceType: | ||
server++ | ||
case CloudInstanceType: | ||
cloud++ | ||
} | ||
} | ||
args["instance_count"] = server + cloud | ||
if server > 0 { | ||
args["server_instance_count"] = server | ||
} | ||
if cloud > 0 { | ||
args["cloud_instance_count"] = cloud | ||
} | ||
|
||
// Subscriptions | ||
numSubscriptions := 0 | ||
var subs *Subscriptions | ||
for _, id := range instances.IDs() { | ||
subs, err = p.getSubscriptions(id) | ||
if err != nil { | ||
p.API.LogWarn("Failed to get subscriptions for telemetry", "error", err) | ||
} | ||
numSubscriptions += len(subs.Channel.ByID) | ||
} | ||
|
||
args["subscriptions"] = numSubscriptions | ||
} | ||
|
||
// Connected users | ||
connected, err := p.userStore.CountUsers() | ||
if err != nil { | ||
p.API.LogWarn("Failed to get the number of connected users for telemetry", "error", err) | ||
} else { | ||
args["connected_user_count"] = connected | ||
} | ||
|
||
p.TrackEvent("stats", args) | ||
} | ||
|
||
// Initialize telemetry setups the tracker/clients needed to send telemetry data. | ||
// The telemetry.NewTrackerConfig(...) param will take care of extract/parse the config to set the right settings. | ||
// If you don't want the default behavior you still can pass a different telemetry.TrackerConfig data. | ||
func (p *Plugin) initializeTelemetry() { | ||
var err error | ||
|
||
// Telemetry client | ||
p.telemetryClient, err = telemetry.NewRudderClient() | ||
if err != nil { | ||
p.API.LogWarn("Telemetry client not started", "error", err.Error()) | ||
return | ||
} | ||
|
||
// Get config values | ||
p.tracker = telemetry.NewTracker( | ||
p.telemetryClient, | ||
p.API.GetDiagnosticId(), | ||
p.API.GetServerVersion(), | ||
manifest.ID, | ||
manifest.Version, | ||
"jira", | ||
telemetry.NewTrackerConfig(p.API.GetConfig()), | ||
telemetry.NewLogger(p.API), | ||
) | ||
} |
Oops, something went wrong.