Skip to content

Commit

Permalink
Add organization ID property to analytics events (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirtybit authored Oct 8, 2020
1 parent 479cd81 commit ff42191
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/server/services/configurationService/configurationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ enum ConfigurationTrackingIntegrationType {

interface ConfigurationTrackingParameters {
userId: string;
workspaceType: ConfigurationWorkspaceType;
workspaceId: string;
resourceType: WebhookResourceType;
tenantId: string;
}
Expand Down Expand Up @@ -255,7 +255,7 @@ class ConfigurationService {
private async trackConfigurationCreate(params: ConfigurationTrackingParameters): Promise<void> {
const {
userId,
workspaceType,
workspaceId,
resourceType,
tenantId
} = params;
Expand All @@ -266,7 +266,12 @@ class ConfigurationService {

await mixpanel.trackEvent("Created Microsoft Teams integration", {
"distinct_id": userId,
"Workspace Type": workspaceType,
...(workspaceId === "personal" ? {
"Workspace Type": ConfigurationWorkspaceType.PERSONAL
} : {
"Workspace Type": ConfigurationWorkspaceType.ORGANIZATION,
"Organization ID": workspaceId
}),
"Integration Type": integrationType,
"Tenant ID": tenantId
});
Expand All @@ -275,7 +280,7 @@ class ConfigurationService {
private async trackConfigurationDelete(params: ConfigurationTrackingParameters): Promise<void> {
const {
userId,
workspaceType,
workspaceId,
resourceType,
tenantId
} = params;
Expand All @@ -286,7 +291,12 @@ class ConfigurationService {

await mixpanel.trackEvent("Removed Microsoft Teams integration", {
"distinct_id": userId,
"Workspace Type": workspaceType,
...(workspaceId === "personal" ? {
"Workspace Type": ConfigurationWorkspaceType.PERSONAL
} : {
"Workspace Type": ConfigurationWorkspaceType.ORGANIZATION,
"Organization ID": workspaceId
}),
"Integration Type": integrationType,
"Tenant ID": tenantId
});
Expand Down Expand Up @@ -330,11 +340,7 @@ class ConfigurationService {
await unlock();
await this.trackConfigurationCreate({
userId,
workspaceType: (
params.zeplin.workspaceId === "personal"
? ConfigurationWorkspaceType.PERSONAL
: ConfigurationWorkspaceType.ORGANIZATION
),
workspaceId: params.zeplin.workspaceId,
resourceType: params.zeplin.resource.type,
tenantId: params.microsoftTeams.tenantId
});
Expand All @@ -357,11 +363,7 @@ class ConfigurationService {
]);
await this.trackConfigurationDelete({
userId,
workspaceType: (
configuration.zeplin.workspaceId === "personal"
? ConfigurationWorkspaceType.PERSONAL
: ConfigurationWorkspaceType.ORGANIZATION
),
workspaceId: configuration.zeplin.workspaceId,
resourceType: configuration.zeplin.resource.type,
tenantId: configuration.microsoftTeams.tenantId
});
Expand Down

0 comments on commit ff42191

Please sign in to comment.