Repository navigation
Expand file tree
/
Copy pathserver.R
More file actions
executable file
·189 lines (163 loc) · 6.08 KB
/
Copy pathserver.R
File metadata and controls
executable file
·189 lines (163 loc) · 6.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
library(shiny)
library(shinyBS)
library(ggplot2)
library(dplyr)
library(DT)
library(readxl)
library(RSiteCatalyst)
library(DataCache)
##readRenviron(paste0(getwd(),"/.Renviron"))
rsid = Sys.getenv('AW_REPORTSUITE_ID')
appCache = cache.info(cache.dir="cache", cache.name=rsid)
# LOAD DATA ####
getConfiguration = function(rsid){
SCAuth(Sys.getenv('AW_USERNAME'), Sys.getenv('AW_SECRET'), debug.mode = FALSE)
# GET REPORT SUITES #### #####################################################
reportSuites = GetReportSuites()
# GET PROPS #### #############################################################
props = GetProps(rsid)
props = subset(props, select = -c(enabled, participation_enabled, case_insensitive, case_insensitive_date_enabled, report_suite)) # delete some cols
props = props[, c("id", "name", "pathing_enabled", "list_enabled", "list_delimiter", "description") ] # change col order
colnames(props) = c("Prop", "Label", "Pathing", "List Support", "Delimiter", "Description")
# GET EVARS #### #############################################################
evars = GetEvars(rsid)
evars = subset(evars, select = -c(enabled, has_custom_name_matching_default, expiration_custom_days, report_suite)) # delete some cols
evars = evars[, c("id","name", "type", "expiration_type", "allocation_type", "description") ] # change col order
colnames(evars) = c("eVar","Label","Type","Expiration","Allocation","Description")
# GET EVENTS #### ############################################################
events = GetSuccessEvents(rsid)
events = subset(events, select = -c(default_metric, participation, polarity, visibility, report_suite, site_title,ecommerce_level)) # delete some cols
events = events[, c("id","name","type", "serialization", "description") ] # change col order
colnames(events) = c("Event","Label","Type","Serialisation", "Description")
# GET PROCESSING RULES #### ##################################################
procRules = ViewProcessingRules(rsid)
procRules = subset(procRules, select = -c(rsid, editable)) # delete some cols
procRules = procRules[, c("ruleNum","title","rules", "matchOn", "actions", "comment") ] # change col order
colnames(procRules) = c("Rule","Section","Conditions","Match Type","Actions","Comments")
# GET LIST VARS #### ##################################################$$$$$$$
listvars = GetListVariables(rsid)
listvars = subset(listvars, select = -c(rsid, site_title)) # delete some cols
listvars = listvars[, c("name","allocation_type","enabled", "value_delimiter", "max_values", "id", "expiration_custom_days", "expiration_type", "description") ] # change col order
colnames(listvars) = c("ListVar","Allocation","Enabled","Delimiter","Max","ID", "Expiry Days", "Expiry Type", "Description")
# GET MARKETING CHANNELS #### ##################################################$$$$$$$
mktChannels = GetMarketingChannels(rsid)
mktChannels = subset(mktChannels, select = -c(rsid, type, color, channel_breakdown)) # delete some cols
colnames(mktChannels) = c("Marketing Channel Name","Channel ID","Enabled","Override Last Touch Channel")
# GET MARKETING CHANNELS #### ##################################################$$$$$$$
mktProcRules = GetMarketingChannelRules(rsid)
mktProcRules = subset(mktProcRules, select = -c(rsid)) # delete some cols
colnames(mktProcRules) = c("Ruleset", "Channel ID", "Junction", "Type", "ID", "Query String", "Rule ID", "Hit Attribute", "Hit Query Param", "Operator", "Matches")
results = list(
"props" = props,
"evars" = evars,
# "metrics" = GetMetrics(rsid),
"events" = events,
"listvars" = listvars,
"procRules" = procRules,
"mktChannels" = mktChannels,
"mktProcRules"= mktProcRules,
"reportSuites"= reportSuites
)
return(results)
}
tableExtensions = c('Buttons', 'ColReorder')
tableOptions = list(
rowId = 0,
pageLength = -1,
paging = FALSE,
orderClasses = TRUE,
dom = 'Blfrtip',
buttons = list('copy', 'colvis', list(extend = "collection",
buttons = list('csv', 'excel', 'pdf'), text = 'Download')
),
colReorder = TRUE,
searchHighlight = TRUE,
selection = "single"
)
## Uncomment during dev, and to force cache refresh
#unlink('cache', recursive=TRUE, force=TRUE)
data.cache(getConfiguration, cache.name=rsid, rsid=rsid, frequency = "hourly")
function(input, output) {
# [PROPS] - Traffic Variables ####
output$propsTBL <- renderDataTable(
datatable(
data = props,
extensions = tableExtensions,
options = tableOptions,
rownames = FALSE,
),
server = FALSE
)
# [EVARS] - Conversion Variables ####
output$evarsTBL <- renderDataTable(
datatable(
data = evars,
extensions = tableExtensions,
options = tableOptions,
rownames = FALSE
)
)
# [SUCCESS EVENTS] - Success Events ####
output$eventsTBL <- renderDataTable(
datatable(
data = events,
extensions = tableExtensions,
options = tableOptions,
rownames = FALSE
)
)
# [LISTVARS] - List Vars ####
output$listvarsTBL <- renderDataTable(
datatable(
data = listvars,
extensions = tableExtensions,
options = tableOptions,
rownames = FALSE
)
)
# [PROCESSING RULES] Processing Rules ####
output$procRulesTBL <- renderDataTable(
datatable(
data = procRules,
options = tableOptions,
rownames = FALSE
)
%>% formatStyle(c('Actions','Conditions'), fontFamily = 'monospace')
)
# [MARKETING CHANNELS]
output$mktChannelsTBL <- renderDataTable(
datatable(
data = mktChannels,
extensions = tableExtensions,
options = tableOptions,
rownames = FALSE
)
)
# [MARKETING CHANNELS PROCESSING RULES]
output$mktProcRulesTBL <- renderDataTable(
datatable(
data = mktProcRules,
options = tableOptions,
rownames = FALSE
)
%>% formatStyle(c('Query String','Hit Attribute','Hit Query Param','Matches'), fontFamily = 'monospace')
)
# [REPORT SUITES]
output$reportSuitesTBL <- renderDataTable(
datatable(
data = reportSuites,
extensions = tableExtensions,
options = tableOptions,
rownames = FALSE
)
)
# [CACHE]
output$cacheTBL <- renderDataTable(
datatable(
data = appCache,
extensions = tableExtensions,
options = tableOptions,
rownames = FALSE
)
)
}