Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
1
1weather
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
1weather
Commits
1cb9d692
Commit
1cb9d692
authored
May 27, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Analytics: add support for attributes.
parent
9b3dc978
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
85 additions
and
8 deletions
+85
-8
1Weather.xcodeproj/project.pbxproj
+4
-0
1Weather/Analytics/AnalyticsAttribute.swift
+31
-0
1Weather/Analytics/AnalyticsGlobal.swift
+4
-0
1Weather/Analytics/AppAnalytics.swift
+21
-0
1Weather/Analytics/Services/AnalyticsService.swift
+2
-0
1Weather/Analytics/Services/AppsFlyerAnalyticsService.swift
+5
-0
1Weather/Analytics/Services/FlurryAnalyticsService.swift
+5
-0
1Weather/Analytics/Services/MoEngageAnalyticsService.swift
+5
-0
1Weather/Model/LocationManager.swift
+2
-1
1Weather/Network/PushNotificationsManager.swift
+6
-7
No files found.
1Weather.xcodeproj/project.pbxproj
View file @
1cb9d692
...
...
@@ -178,6 +178,7 @@
CE14445F2638B6CF008E2162
/* StoreKit.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CE14445E2638B6CF008E2162
/* StoreKit.framework */
;
};
CE376C98261EE484000B1159
/* LaunchScreen.storyboard in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CE376C97261EE484000B1159
/* LaunchScreen.storyboard */
;
};
CE3C1DB6265536360031BD72
/* AppsFlyerAnalyticsService.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CE3C1DB5265536360031BD72
/* AppsFlyerAnalyticsService.swift */
;
};
CE46711F265FAD4300EAD03E
/* AnalyticsAttribute.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CE46711E265FAD4300EAD03E
/* AnalyticsAttribute.swift */
;
};
CE578FE525FB415F00E8B85D
/* CityCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CE578FE225FB415F00E8B85D
/* CityCell.swift */
;
};
CE578FE625FB415F00E8B85D
/* LocationViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CE578FE325FB415F00E8B85D
/* LocationViewController.swift */
;
};
CE578FE725FB415F00E8B85D
/* LocationsViewModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CE578FE425FB415F00E8B85D
/* LocationsViewModel.swift */
;
};
...
...
@@ -429,6 +430,7 @@
CE14445E2638B6CF008E2162
/* StoreKit.framework */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
wrapper.framework
;
name
=
StoreKit.framework
;
path
=
System/Library/Frameworks/StoreKit.framework
;
sourceTree
=
SDKROOT
;
};
CE376C97261EE484000B1159
/* LaunchScreen.storyboard */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
file.storyboard
;
path
=
LaunchScreen.storyboard
;
sourceTree
=
"<group>"
;
};
CE3C1DB5265536360031BD72
/* AppsFlyerAnalyticsService.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppsFlyerAnalyticsService.swift
;
sourceTree
=
"<group>"
;
};
CE46711E265FAD4300EAD03E
/* AnalyticsAttribute.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AnalyticsAttribute.swift
;
sourceTree
=
"<group>"
;
};
CE578FE225FB415F00E8B85D
/* CityCell.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CityCell.swift
;
sourceTree
=
"<group>"
;
};
CE578FE325FB415F00E8B85D
/* LocationViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
LocationViewController.swift
;
sourceTree
=
"<group>"
;
};
CE578FE425FB415F00E8B85D
/* LocationsViewModel.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
LocationsViewModel.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -1224,6 +1226,7 @@
CEF959972600C88100975FAA
/* AnalyticsParameter.swift */
,
CEF959922600C63500975FAA
/* AppAnalytics.swift */
,
CEF959952600C84D00975FAA
/* Services */
,
CE46711E265FAD4300EAD03E
/* AnalyticsAttribute.swift */
,
);
path
=
Analytics
;
sourceTree
=
"<group>"
;
...
...
@@ -1549,6 +1552,7 @@
CD32CE08260C743B00235081
/* MenuViewModel.swift in Sources */
,
CD866A76260F77C500E96A5C
/* SettingsDetailsCoordinator.swift in Sources */
,
CE0457902632B3BC00B3C19A
/* NotificationsViewModel.swift in Sources */
,
CE46711F265FAD4300EAD03E
/* AnalyticsAttribute.swift in Sources */
,
CE13B81A262480B3007CBD4D
/* AdManager.swift in Sources */
,
CE13B76326246743007CBD4D
/* CCPAHelper.swift in Sources */
,
CDE2BF222609D4250085C930
/* ForecastWindSpeedCell.swift in Sources */
,
...
...
1Weather/Analytics/AnalyticsAttribute.swift
0 → 100644
View file @
1cb9d692
//
// AnalyticsAttribute.swift
// 1Weather
//
// Created by Demid Merzlyakov on 27.05.2021.
//
import
Foundation
public
enum
AnalyticsAttribute
{
/// Format: Country Code:State Code:City name. Example: US:NY:New York, US:CA:San Francisco
case
lastSeenCity
case
fipsList
case
lastSeenFipsCodeNonTracfone
/// True/False; Wether the splash screen has been shown to the user for the first time or not.
case
splashFTUE
/// Use this instead of rawValue, because we might have different attributes with the same string value.
var
attributeName
:
String
{
switch
self
{
case
.
lastSeenCity
:
return
"LAST_SEEN_CITY"
case
.
fipsList
:
return
"FIPS_LIST"
case
.
lastSeenFipsCodeNonTracfone
:
return
"LAST_SEEN_FIPS_CODE_NON_TRACFONE"
case
.
splashFTUE
:
return
"SPLASH_FTUE"
}
}
}
1Weather/Analytics/AnalyticsGlobal.swift
View file @
1cb9d692
...
...
@@ -10,3 +10,7 @@ import Foundation
public
func
analytics
(
log
event
:
AnalyticsEvent
,
params
:
[
AnalyticsParameter
:
Any
]?
=
nil
)
{
AppAnalytics
.
shared
.
log
(
event
:
event
,
params
:
params
)
}
public
func
analytics
(
set
attribute
:
AnalyticsAttribute
,
to
value
:
Any
?)
{
AppAnalytics
.
shared
.
set
(
attribute
:
attribute
,
to
:
value
)
}
1Weather/Analytics/AppAnalytics.swift
View file @
1cb9d692
...
...
@@ -41,4 +41,25 @@ public class AppAnalytics {
log
.
info
(
"Event
\(
event
.
rawValue
)
sent to
\(
loggedToString
)
"
)
}
}
public
func
set
(
attribute
:
AnalyticsAttribute
,
to
value
:
Any
?)
{
var
servicesSetTo
=
[
String
]()
for
service
in
services
{
if
let
attributesWhitelist
=
service
.
attributesWhitelist
{
if
!
attributesWhitelist
.
contains
(
attribute
)
{
continue
}
}
servicesSetTo
.
append
(
service
.
name
)
service
.
set
(
attribute
:
attribute
,
to
:
value
)
}
let
servicesSetToString
=
servicesSetTo
.
joined
(
separator
:
", "
)
if
let
value
=
value
{
log
.
info
(
"Attribute
\(
attribute
.
attributeName
)
set to '
\(
value
)
' for
\(
servicesSetToString
)
"
)
}
else
{
log
.
info
(
"Attribute
\(
attribute
.
attributeName
)
set to nil for
\(
servicesSetToString
)
"
)
}
}
}
1Weather/Analytics/Services/AnalyticsService.swift
View file @
1cb9d692
...
...
@@ -10,7 +10,9 @@ import Foundation
public
protocol
AnalyticsService
{
var
name
:
String
{
get
}
var
eventsWhitelist
:
Set
<
AnalyticsEvent
>
?
{
get
}
var
attributesWhitelist
:
Set
<
AnalyticsAttribute
>
?
{
get
}
func
log
(
event
:
AnalyticsEvent
,
params
:
[
AnalyticsParameter
:
Any
]?)
func
set
(
attribute
:
AnalyticsAttribute
,
to
value
:
Any
?)
}
extension
AnalyticsService
{
...
...
1Weather/Analytics/Services/AppsFlyerAnalyticsService.swift
View file @
1cb9d692
...
...
@@ -11,8 +11,13 @@ import AppsFlyerLib
internal
struct
AppsFlyerAnalyticsService
:
AnalyticsService
{
public
let
name
:
String
=
"AppsFlyer"
let
eventsWhitelist
:
Set
<
AnalyticsEvent
>
?
=
[
.
ANALYTICS_APP_OPEN
,
.
ANALYTICS_USER_QUALIFIED
,
.
ANALYTICS_D3_RETAINED
,
.
ANALYTICS_FIRST_OPEN
]
let
attributesWhitelist
:
Set
<
AnalyticsAttribute
>
?
=
[]
// block all
func
log
(
event
:
AnalyticsEvent
,
params
:
[
AnalyticsParameter
:
Any
]?)
{
AppsFlyerLib
.
shared
()
.
logEvent
(
event
.
rawValue
,
withValues
:
stringKeyedParams
(
from
:
params
))
}
func
set
(
attribute
:
AnalyticsAttribute
,
to
value
:
Any
?)
{
// do nothing
}
}
1Weather/Analytics/Services/FlurryAnalyticsService.swift
View file @
1cb9d692
...
...
@@ -11,8 +11,13 @@ import Flurry_iOS_SDK
internal
struct
FlurryAnalyticsService
:
AnalyticsService
{
public
let
name
=
"Flurry"
let
eventsWhitelist
:
Set
<
AnalyticsEvent
>
?
=
nil
let
attributesWhitelist
:
Set
<
AnalyticsAttribute
>
?
=
[]
// block all
func
log
(
event
:
AnalyticsEvent
,
params
:
[
AnalyticsParameter
:
Any
]?)
{
Flurry
.
logEvent
(
event
.
rawValue
,
withParameters
:
stringKeyedParams
(
from
:
params
))
}
func
set
(
attribute
:
AnalyticsAttribute
,
to
value
:
Any
?)
{
// do nothing
}
}
1Weather/Analytics/Services/MoEngageAnalyticsService.swift
View file @
1cb9d692
...
...
@@ -11,6 +11,7 @@ import MoEngage
internal
struct
MoEngageAnalyticsService
:
AnalyticsService
{
public
let
name
=
"MoEngage"
let
eventsWhitelist
:
Set
<
AnalyticsEvent
>
?
=
nil
let
attributesWhitelist
:
Set
<
AnalyticsAttribute
>
?
=
nil
// allow all
func
log
(
event
:
AnalyticsEvent
,
params
:
[
AnalyticsParameter
:
Any
]?)
{
let
stringKeyedParams
=
stringKeyedParams
(
from
:
params
)
...
...
@@ -25,4 +26,8 @@ internal struct MoEngageAnalyticsService: AnalyticsService {
MoEngage
.
sharedInstance
()
.
trackEvent
(
event
.
rawValue
,
with
:
nil
)
}
}
func
set
(
attribute
:
AnalyticsAttribute
,
to
value
:
Any
?)
{
MoEngage
.
sharedInstance
()
.
setUserAttribute
(
value
,
forKey
:
attribute
.
attributeName
)
}
}
1Weather/Model/LocationManager.swift
View file @
1cb9d692
...
...
@@ -91,7 +91,8 @@ public class LocationManager {
.
ANALYTICS_KEY_LAST_SEEN_CITY_CITY
:
newLocation
?
.
cityName
??
""
,
.
ANALYTICS_KEY_LAST_SEEN_CITY_CITY_ID
:
newLocation
?
.
cityId
??
"::"
])
MoEngage
.
sharedInstance
()
.
setUserAttribute
(
newLocation
?
.
cityId
,
forKey
:
"LAST_SEEN_CITY"
)
analytics
(
set
:
.
lastSeenCity
,
to
:
newLocation
?
.
cityId
)
lastSeenCityId
=
newLocation
?
.
cityId
}
}
...
...
1Weather/Network/PushNotificationsManager.swift
View file @
1cb9d692
...
...
@@ -55,25 +55,24 @@ public class PushNotificationsManager: NSObject {
internal
var
lastSetFIPSCode
:
String
?
=
""
private
func
updateNwsSubscriptions
(
with
fipsList
:
String
?,
currentFipsCode
:
String
?)
{
let
lastFipsCodeAttributeName
=
"LAST_SEEN_FIPS_CODE_NON_TRACFONE"
if
configManager
.
config
.
nwsAlertsViaMoEngageEnabled
{
if
fipsList
!=
lastSetFIPSList
{
log
.
info
(
"Set
FIPS_LIST
to '
\(
fipsList
??
""
)
'"
)
log
.
info
(
"Set
\(
AnalyticsAttribute
.
fipsList
.
attributeName
)
to '
\(
fipsList
??
""
)
'"
)
lastSetFIPSList
=
fipsList
}
if
currentFipsCode
!=
lastSetFIPSCode
{
log
.
info
(
"Set
\(
lastFipsCodeA
ttributeName
)
to '
\(
currentFipsCode
??
""
)
'"
)
log
.
info
(
"Set
\(
AnalyticsAttribute
.
lastSeenFipsCodeNonTracfone
.
a
ttributeName
)
to '
\(
currentFipsCode
??
""
)
'"
)
lastSetFIPSCode
=
currentFipsCode
}
}
else
{
log
.
info
(
"Set
FIPS_LIST
to nil, because nwsAlertsViaMoEngage are disabled via config."
)
log
.
info
(
"Set
\(
AnalyticsAttribute
.
fipsList
.
attributeName
)
to nil, because nwsAlertsViaMoEngage are disabled via config."
)
lastSetFIPSList
=
nil
log
.
info
(
"Set
\(
lastFipsCodeA
ttributeName
)
to nil, because nwsAlertsViaMoEngage are disabled via config"
)
log
.
info
(
"Set
\(
AnalyticsAttribute
.
lastSeenFipsCodeNonTracfone
.
a
ttributeName
)
to nil, because nwsAlertsViaMoEngage are disabled via config"
)
lastSetFIPSCode
=
nil
}
MoEngage
.
sharedInstance
()
.
setUserAttribute
(
lastSetFIPSList
,
forKey
:
"FIPS_LIST"
)
MoEngage
.
sharedInstance
()
.
setUserAttribute
(
lastSetFIPSCode
,
forKey
:
lastFipsCodeAttributeNam
e
)
analytics
(
set
:
.
fipsList
,
to
:
lastSetFIPSList
)
analytics
(
set
:
.
lastSeenFipsCodeNonTracfone
,
to
:
lastSetFIPSCod
e
)
}
public
func
updateNwsSubscriptions
(
for
locations
:
[
Location
],
selectedLocation
:
Location
?)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment