Skip to content

Commit

Permalink
Integration with Matomo
Browse files Browse the repository at this point in the history
  • Loading branch information
tdimeco committed Mar 26, 2019
1 parent a472b84 commit dc4f65d
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github "matomo-org/matomo-sdk-ios"
1 change: 1 addition & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github "matomo-org/matomo-sdk-ios" "v6.0.0"
40 changes: 38 additions & 2 deletions QuickSound.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,26 @@
E91F8D1B1CA204C700BC1B08 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = E91F8D1A1CA204C700BC1B08 /* Constants.swift */; };
E942CF291CA1FBF8004FBCD2 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = E942CF281CA1FBF8004FBCD2 /* Utils.swift */; };
E9451AD61DC3E171004845FA /* PopoverViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E9451AD81DC3E171004845FA /* PopoverViewController.xib */; };
E9501696224AE54C00C5883C /* MatomoTracker.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E9501694224AE53F00C5883C /* MatomoTracker.framework */; };
E9501697224AE54C00C5883C /* MatomoTracker.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E9501694224AE53F00C5883C /* MatomoTracker.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
E9732E171DC3E5C000CD02EE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = E9732E191DC3E5C000CD02EE /* Localizable.strings */; };
E9FC49131C9DD93B001C35B3 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = E9FC49121C9DD93B001C35B3 /* MainMenu.xib */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
E9501698224AE54C00C5883C /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
E9501697224AE54C00C5883C /* MatomoTracker.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
2228E2FF1CA1B0D00041056A /* Model.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model.xcdatamodel; sourceTree = "<group>"; };
2228E3041CA1B1CE0041056A /* Sound.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Sound.swift; sourceTree = "<group>"; };
Expand All @@ -38,6 +54,7 @@
E91F8D1A1CA204C700BC1B08 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
E942CF281CA1FBF8004FBCD2 /* Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = "<group>"; };
E9451AD71DC3E171004845FA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/PopoverViewController.xib; sourceTree = "<group>"; };
E9501694224AE53F00C5883C /* MatomoTracker.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MatomoTracker.framework; path = Carthage/Build/Mac/MatomoTracker.framework; sourceTree = "<group>"; };
E9732E141DC3E31B00CD02EE /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/PopoverViewController.strings; sourceTree = "<group>"; };
E9732E181DC3E5C000CD02EE /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = "<group>"; };
E9732E1A1DC3E5C200CD02EE /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
Expand All @@ -50,6 +67,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
E9501696224AE54C00C5883C /* MatomoTracker.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -62,6 +80,7 @@
E9C2FCB2209A111800001909 /* README.md */,
92BE1D761C9C4B9B004F13BB /* QuickSound */,
92BE1D751C9C4B9B004F13BB /* Products */,
E9501693224AE53F00C5883C /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -88,6 +107,14 @@
path = QuickSound;
sourceTree = "<group>";
};
E9501693224AE53F00C5883C /* Frameworks */ = {
isa = PBXGroup;
children = (
E9501694224AE53F00C5883C /* MatomoTracker.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
E9C2FCAB209A044900001909 /* Manager */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -161,6 +188,7 @@
92BE1D701C9C4B9B004F13BB /* Sources */,
92BE1D711C9C4B9B004F13BB /* Frameworks */,
92BE1D721C9C4B9B004F13BB /* Resources */,
E9501698224AE54C00C5883C /* Embed Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -314,7 +342,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -364,7 +392,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand All @@ -381,6 +409,10 @@
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = LU8GV6C284;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
INFOPLIST_FILE = QuickSound/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -402,6 +434,10 @@
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = LU8GV6C284;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
INFOPLIST_FILE = QuickSound/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
6 changes: 6 additions & 0 deletions QuickSound/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ class AppDelegate: NSObject, NSApplicationDelegate {

// Check for updates
self.checkForUpdates()

// Matomo tracking
Tracking.track(view: ["startup"])
}

func applicationWillTerminate(_ notification: Notification) {

// Save the Core Data context
AppDelegate.dataManager.saveContext()

// Matomo tracking
Tracking.dispatch()
}
}

Expand Down
2 changes: 2 additions & 0 deletions QuickSound/Application/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ import Foundation
struct Constants {
static let updatePlistURL = URL(string: "https://raw.githubusercontent.com/tdimeco/QuickSound/master/QuickSound/Info.plist")!
static let updatesPageURL = URL(string: "https://github.com/tdimeco/QuickSound/releases")!
static let matomoURL = URL(string: "https://analytics.tdimeco.fr/matomo.php")!
static let matomoSiteId = "4"
}
3 changes: 3 additions & 0 deletions QuickSound/Manager/SoundManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class SoundManager {
} else if repeatSound {
self.repeatingSounds.append((object, sound!))
}

// Matomo tracking
Tracking.track(eventWithCategory: "sounds", action: "play")
}

/// Use this method to stop a sound.
Expand Down
3 changes: 3 additions & 0 deletions QuickSound/StatusItem/StatusItemController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class StatusItemController {

// Give the focus to the app
NSApp.activate(ignoringOtherApps: true)

// Matomo tracking
Tracking.track(view: ["popover"])
}

func closePopover() {
Expand Down
22 changes: 22 additions & 0 deletions QuickSound/Utils/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import MatomoTracker

struct Utils {

Expand All @@ -15,3 +16,24 @@ struct Utils {
return NSString(string: lastPathComponent).deletingPathExtension
}
}

// MARK: - Matomo tracker

struct Tracking {

static func track(view: [String]) {
MatomoTracker.shared.track(view: view)
}

static func track(eventWithCategory category: String, action: String) {
MatomoTracker.shared.track(eventWithCategory: category, action: action, name: nil, number: nil, url: nil)
}

static func dispatch() {
MatomoTracker.shared.dispatch()
}
}

extension MatomoTracker {
static let shared = MatomoTracker(siteId: Constants.matomoSiteId, baseURL: Constants.matomoURL)
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

**Quickly play sounds from the macOS status bar.**

Compatible with macOS 10.11+
Compatible with macOS 10.12+

![screenshot](https://raw.githubusercontent.com/tdimeco/QuickSound/develop/Documentation/Screenshot.png)

Expand Down

0 comments on commit dc4f65d

Please sign in to comment.