| 1 |
(function () { |
| 2 |
// Core |
| 3 |
(function(e,t){var n=e.amplitude||{_q:[],_iq:{}};var r=t.createElement("script") |
| 4 |
;r.type="text/javascript" |
| 5 |
;r.integrity="sha384-AUydfiSe1Ky1zDY/KCJrSDvNC/Rb1TyoiQ10xfyB/LUYw8GOwJ07SUTa9SxvinL2" |
| 6 |
;r.crossOrigin="anonymous";r.async=true |
| 7 |
;r.src="https://cdn.amplitude.com/libs/amplitude-7.4.1-min.gz.js" |
| 8 |
;r.onload=function(){if(!e.amplitude.runQueuedFunctions){ |
| 9 |
console.log("[Amplitude] Error: could not load SDK")}} |
| 10 |
;var i=t.getElementsByTagName("script")[0];i.parentNode.insertBefore(r,i) |
| 11 |
;function s(e,t){e.prototype[t]=function(){ |
| 12 |
this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));return this}} |
| 13 |
var o=function(){this._q=[];return this} |
| 14 |
;var a=["add","append","clearAll","prepend","set","setOnce","unset"] |
| 15 |
;for(var c=0;c<a.length;c++){s(o,a[c])}n.Identify=o;var u=function(){this._q=[] |
| 16 |
;return this} |
| 17 |
;var l=["setProductId","setQuantity","setPrice","setRevenueType","setEventProperties"] |
| 18 |
;for(var p=0;p<l.length;p++){s(u,l[p])}n.Revenue=u |
| 19 |
;var d=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","enableTracking","setGlobalUserProperties","identify","clearUserProperties","setGroup","logRevenueV2","regenerateDeviceId","groupIdentify","onInit","logEventWithTimestamp","logEventWithGroups","setSessionId","resetSessionId"] |
| 20 |
;function v(e){function t(t){e[t]=function(){ |
| 21 |
e._q.push([t].concat(Array.prototype.slice.call(arguments,0)))}} |
| 22 |
for(var n=0;n<d.length;n++){t(d[n])}}v(n);n.getInstance=function(e){ |
| 23 |
e=(!e||e.length===0?"$default_instance":e).toLowerCase() |
| 24 |
;if(!n._iq.hasOwnProperty(e)){n._iq[e]={_q:[]};v(n._iq[e])}return n._iq[e]} |
| 25 |
;e.amplitude=n})(window,document); |
| 26 |
// Core --- |
| 27 |
|
| 28 |
const init = (isProd) => { |
| 29 |
const API_KEY_DEV = "90dc46eadb765c371155f07b87b5c18c"; |
| 30 |
const API_KEY_PROD = "d59f9d3c9355095783c11939df104e91"; |
| 31 |
const API_KEY = isProd ? API_KEY_PROD : API_KEY_DEV; |
| 32 |
amplitude.getInstance().init(API_KEY); |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
const setUser = (email) => { |
| 37 |
amplitude.getInstance().setUserId(email) |
| 38 |
}; |
| 39 |
|
| 40 |
const eventsByPathname = { |
| 41 |
'/wp-admin/admin.php?page=wtotem_dashboard' : 'DASHBOARD_PAGE_VIEWED', |
| 42 |
'/wp-admin/admin.php?page=wtotem_firewall' : 'FIREWALL_PAGE_VIEWED', |
| 43 |
'/wp-admin/admin.php?page=wtotem_antivirus' : 'ANTIVIRUS_PAGE_VIEWED', |
| 44 |
'/wp-admin/admin.php?page=wtotem_settings' : 'OPTIONS_PAGE_VIEWED', |
| 45 |
'/wp-admin/admin.php?page=wtotem_documentation' : 'HELP_CENTER_PAGE_VIEWED', |
| 46 |
'/wp-admin/admin.php?page=wtotem_reports' : 'REPORTS_PAGE_VIEWED', |
| 47 |
} |
| 48 |
|
| 49 |
const getEventTypeByPage = (pathname) => { |
| 50 |
for (const [path, eventType] of Object.entries(eventsByPathname)) { |
| 51 |
if (pathname?.includes(path)) { |
| 52 |
return eventType; |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
return null; |
| 57 |
} |
| 58 |
|
| 59 |
const analytics = { |
| 60 |
|
| 61 |
loggedIn: ( |
| 62 |
email, // string, |
| 63 |
tariff, // string, |
| 64 |
sitesCount, // number, |
| 65 |
teammatesCount, // number |
| 66 |
) => { |
| 67 |
const identify = new amplitude.Identify() |
| 68 |
.set('PLAN', tariff) |
| 69 |
.set('WEBSITES', sitesCount) |
| 70 |
.set('TEAMMATES', teammatesCount) |
| 71 |
amplitude.getInstance().identify(identify) |
| 72 |
amplitude.getInstance().setUserId(email) |
| 73 |
amplitudeEvent('LOGGED_IN') |
| 74 |
}, |
| 75 |
|
| 76 |
loggedOut: () => { |
| 77 |
amplitudeEvent('LOGGED_OUT') |
| 78 |
}, |
| 79 |
|
| 80 |
accountVerified: ( |
| 81 |
email, // string, |
| 82 |
tariff, // string, |
| 83 |
sitesCount, // number, |
| 84 |
teammatesCount, // number, |
| 85 |
source, // 'appsumo' | 'regular' | 'teammate' |
| 86 |
) => { |
| 87 |
const identify = new amplitude.Identify() |
| 88 |
.set('PLAN', tariff) |
| 89 |
.set('WEBSITES', sitesCount) |
| 90 |
.set('TEAMMATES', teammatesCount) |
| 91 |
.set('SIGN_UP_DATE', new Date().toISOString()) |
| 92 |
amplitude.getInstance().identify(identify) |
| 93 |
amplitude.getInstance().setUserId(email) |
| 94 |
amplitudeEvent('ACCOUNT_VERIFIED', { |
| 95 |
source, |
| 96 |
}) |
| 97 |
}, |
| 98 |
|
| 99 |
// status: 'finished' | 'skipped' |
| 100 |
onboarding: (status) => { |
| 101 |
if (status === 'finished') { |
| 102 |
amplitudeEvent('ONBOARDING_COMPLETED') |
| 103 |
} else { |
| 104 |
amplitudeEvent('ONBOARDING_CLOSED') |
| 105 |
} |
| 106 |
}, |
| 107 |
|
| 108 |
// source: 'preonboarding' | 'other' |
| 109 |
agentInstallPopup: (source) => { |
| 110 |
amplitudeEvent('AGENT_INSTALL_CLICKED', { |
| 111 |
source, |
| 112 |
}) |
| 113 |
}, |
| 114 |
|
| 115 |
// type: 'automatic' | 'manual' | 'WP Plugin' |
| 116 |
agentInstallType: (type) => { |
| 117 |
amplitudeEvent('AGENT_INSTALL_CHOSEN', { |
| 118 |
type, |
| 119 |
}) |
| 120 |
}, |
| 121 |
|
| 122 |
// antivirus: boolean, firewall: boolean |
| 123 |
agentInstallConfirm: (antivirus, firewall) => { |
| 124 |
amplitudeEvent('AGENT_INSTALLED', { |
| 125 |
antivirus, |
| 126 |
firewall, |
| 127 |
}) |
| 128 |
}, |
| 129 |
|
| 130 |
siteAdded: () => { |
| 131 |
amplitudeEvent('SITE_ADDED') |
| 132 |
}, |
| 133 |
|
| 134 |
teammateAdded: () => { |
| 135 |
amplitudeEvent('TEAMMATE_ADDED') |
| 136 |
}, |
| 137 |
|
| 138 |
// source: 'report' | 'profile' |
| 139 |
whiteLabelLogoAdded: (source) => { |
| 140 |
amplitudeEvent('LOGO_ADDED', { |
| 141 |
source, |
| 142 |
}) |
| 143 |
}, |
| 144 |
reportGenerated: (period) => { |
| 145 |
amplitudeEvent('REPORT_GENERATED', { |
| 146 |
period, |
| 147 |
}) |
| 148 |
}, |
| 149 |
// type: 'slack' |
| 150 |
addIntegrations: (type) => { |
| 151 |
amplitudeEvent('INTEGRATION_ADDED', { |
| 152 |
type, |
| 153 |
}) |
| 154 |
}, |
| 155 |
|
| 156 |
wafSettingsChanged: ( |
| 157 |
gdn, // boolean, |
| 158 |
dos, // boolean, |
| 159 |
loginAttempts, // boolean, |
| 160 |
dosLimit, // number, |
| 161 |
loginAttemptsLimit, // number |
| 162 |
) => { |
| 163 |
amplitudeEvent('WAF_SETTINGS_CHANGED', { |
| 164 |
gdn, |
| 165 |
dos, |
| 166 |
loginAttempts, |
| 167 |
dosLimit, |
| 168 |
loginAttemptsLimit, |
| 169 |
}) |
| 170 |
}, |
| 171 |
|
| 172 |
fileQuarantined: () => { |
| 173 |
amplitudeEvent('FILE_QUARANTINED') |
| 174 |
}, |
| 175 |
|
| 176 |
fileRestored: () => { |
| 177 |
amplitudeEvent('FILE_RESTORED') |
| 178 |
}, |
| 179 |
|
| 180 |
avRescanDemanded: () => { |
| 181 |
amplitudeEvent('AV_RESCAN_DEMANDED') |
| 182 |
}, |
| 183 |
|
| 184 |
apiKeyActivated: () => { |
| 185 |
amplitudeEvent('API_KEY_ACTIVATED') |
| 186 |
}, |
| 187 |
|
| 188 |
errorNotification: ( |
| 189 |
error, // string, |
| 190 |
) => { |
| 191 |
amplitudeEvent('ERROR_NOTIFICATION', { |
| 192 |
error, |
| 193 |
}) |
| 194 |
}, |
| 195 |
|
| 196 |
/** Dashboard triggers */ |
| 197 |
showTooltip: ( |
| 198 |
service, // string, |
| 199 |
) => { |
| 200 |
amplitudeEvent('SHOW_TOOLTIP', { |
| 201 |
service, |
| 202 |
}) |
| 203 |
}, |
| 204 |
selectGraphPeriod: ( |
| 205 |
period, // string, |
| 206 |
service, // string, |
| 207 |
) => { |
| 208 |
amplitudeEvent('SELECT_GRAPH_PERIOD', { |
| 209 |
period, |
| 210 |
service, |
| 211 |
}) |
| 212 |
}, |
| 213 |
selectGraphStartDay: ( |
| 214 |
service, // string, |
| 215 |
) => { |
| 216 |
amplitudeEvent('SELECT_GRAPH_START_DAY', { |
| 217 |
service, |
| 218 |
}) |
| 219 |
}, |
| 220 |
selectGraphEndDay: ( |
| 221 |
service, // string, |
| 222 |
) => { |
| 223 |
amplitudeEvent('SELECT_GRAPH_END_DAY', { |
| 224 |
service, |
| 225 |
}) |
| 226 |
}, |
| 227 |
showGraphDetailed: ( |
| 228 |
service, // string, |
| 229 |
period, |
| 230 |
start_date, |
| 231 |
end_date, |
| 232 |
) => { |
| 233 |
amplitudeEvent('SHOW_GRAPH_DETAILED', { |
| 234 |
service, |
| 235 |
period, |
| 236 |
start_date, |
| 237 |
end_date, |
| 238 |
}) |
| 239 |
}, |
| 240 |
openSupportDialog: ( |
| 241 |
service, // string, |
| 242 |
) => { |
| 243 |
amplitudeEvent('OPEN_SUPPORT_DIALOG', { |
| 244 |
service, |
| 245 |
}) |
| 246 |
}, |
| 247 |
addPsExclusion: ( |
| 248 |
user_input, // string, |
| 249 |
) => { |
| 250 |
amplitudeEvent('ADD_PS_EXCLUSION', { |
| 251 |
user_input, |
| 252 |
}) |
| 253 |
}, |
| 254 |
savePsExclusion: () => { |
| 255 |
amplitudeEvent('SAVE_PS_EXCLUSION') |
| 256 |
}, |
| 257 |
removePsExclusionPort: ( |
| 258 |
user_input, // string, |
| 259 |
) => { |
| 260 |
amplitudeEvent('REMOVE_PS_EXCLUSION_PORT', { |
| 261 |
user_input, |
| 262 |
}) |
| 263 |
}, |
| 264 |
closePsExclusion: () => { |
| 265 |
amplitudeEvent('CLOSE_PS_EXCLUSION') |
| 266 |
}, |
| 267 |
|
| 268 |
/** Firewall triggers */ |
| 269 |
worldMap: ( |
| 270 |
attack_count, // string, |
| 271 |
block_count, // string, |
| 272 |
) => { |
| 273 |
amplitudeEvent('WORLD_MAP', { |
| 274 |
attack_count, |
| 275 |
block_count, |
| 276 |
}) |
| 277 |
}, |
| 278 |
addCountry: ( |
| 279 |
country_list, // string, |
| 280 |
) => { |
| 281 |
amplitudeEvent('ADD_COUNTRY', { |
| 282 |
country_list, |
| 283 |
}) |
| 284 |
}, |
| 285 |
searchCountry: ( |
| 286 |
user_input, // string, |
| 287 |
) => { |
| 288 |
amplitudeEvent('SEARCH_COUNTRY', { |
| 289 |
user_input, |
| 290 |
}) |
| 291 |
}, |
| 292 |
addAllCountry: ( |
| 293 |
country_list, // string, |
| 294 |
) => { |
| 295 |
amplitudeEvent('ADD_ALL_COUNTRY', { |
| 296 |
country_list, |
| 297 |
}) |
| 298 |
}, |
| 299 |
addContinent: ( |
| 300 |
continent, // string, |
| 301 |
) => { |
| 302 |
amplitudeEvent('ADD_CONTINENT', { |
| 303 |
continent, |
| 304 |
}) |
| 305 |
}, |
| 306 |
saveCountryBlock: ( |
| 307 |
country_list, // string, |
| 308 |
) => { |
| 309 |
amplitudeEvent('SAVE_COUNTRY_BLOCK', { |
| 310 |
country_list, |
| 311 |
}) |
| 312 |
}, |
| 313 |
closeCountry: () => { |
| 314 |
amplitudeEvent('CLOSE_COUNTRY') |
| 315 |
}, |
| 316 |
|
| 317 |
/** Antivirus triggers */ |
| 318 |
avFileType: () => { |
| 319 |
amplitudeEvent('AV_FILE_TYPE') |
| 320 |
}, |
| 321 |
avChangedFiles: () => { |
| 322 |
amplitudeEvent('AV_CHANGED_FILES') |
| 323 |
}, |
| 324 |
downloadAvExcel: () => { |
| 325 |
amplitudeEvent('DOWNLOAD_AV_EXCEL') |
| 326 |
}, |
| 327 |
rescan: ( |
| 328 |
service, // string, |
| 329 |
) => { |
| 330 |
amplitudeEvent('RESCAN', { |
| 331 |
service, |
| 332 |
}) |
| 333 |
}, |
| 334 |
|
| 335 |
/** Settings triggers */ |
| 336 |
flipModules: ( |
| 337 |
service, // string, |
| 338 |
) => { |
| 339 |
amplitudeEvent('FLIP_MODULES', { |
| 340 |
service, |
| 341 |
}) |
| 342 |
}, |
| 343 |
flipNotification: ( |
| 344 |
service, // string, |
| 345 |
) => { |
| 346 |
amplitudeEvent('FLIP_NOTIFICATION', { |
| 347 |
service, |
| 348 |
}) |
| 349 |
}, |
| 350 |
addWhiteIp: ( |
| 351 |
user_input, // string, |
| 352 |
) => { |
| 353 |
amplitudeEvent('ADD_WHITE_IP', { |
| 354 |
user_input, |
| 355 |
}) |
| 356 |
}, |
| 357 |
addWhiteIpList: () => { |
| 358 |
amplitudeEvent('ADD_WHITE_IP_LIST') |
| 359 |
}, |
| 360 |
inputWhiteIpList: ( |
| 361 |
user_input, // string, |
| 362 |
) => { |
| 363 |
amplitudeEvent('INPUT_WHITE_IP_LIST', { |
| 364 |
user_input, |
| 365 |
}) |
| 366 |
}, |
| 367 |
saveWhiteIpList: ( |
| 368 |
user_input, // string, |
| 369 |
) => { |
| 370 |
amplitudeEvent('SAVE_WHITE_IP_LIST', { |
| 371 |
user_input, |
| 372 |
}) |
| 373 |
}, |
| 374 |
closeWhiteIp: () => { |
| 375 |
amplitudeEvent('CLOSE_WHITE_IP') |
| 376 |
}, |
| 377 |
addBlackIp: ( |
| 378 |
user_input, // string, |
| 379 |
) => { |
| 380 |
amplitudeEvent('ADD_BLACK_IP', { |
| 381 |
user_input, |
| 382 |
}) |
| 383 |
}, |
| 384 |
addBlackIpList: () => { |
| 385 |
amplitudeEvent('ADD_BLACK_IP_LIST') |
| 386 |
}, |
| 387 |
inputBlackIpList: ( |
| 388 |
user_input, // string, |
| 389 |
) => { |
| 390 |
amplitudeEvent('INPUT_BLACK_IP_LIST', { |
| 391 |
user_input, |
| 392 |
}) |
| 393 |
}, |
| 394 |
saveBlackIpList: ( |
| 395 |
user_input, // string, |
| 396 |
) => { |
| 397 |
amplitudeEvent('SAVE_BLACK_IP_LIST', { |
| 398 |
user_input, |
| 399 |
}) |
| 400 |
}, |
| 401 |
closeBlackIp: () => { |
| 402 |
amplitudeEvent('CLOSE_BLACK_IP') |
| 403 |
}, |
| 404 |
reinstallAgent: () => { |
| 405 |
amplitudeEvent('REINSTALL_AGENT') |
| 406 |
}, |
| 407 |
|
| 408 |
/** Reports triggers */ |
| 409 |
generateReport: () => { |
| 410 |
amplitudeEvent('GENERATE_REPORT') |
| 411 |
}, |
| 412 |
includeReportModule: ( |
| 413 |
service, // string, |
| 414 |
) => { |
| 415 |
amplitudeEvent('INCLUDE_REPORT_MODULE', { |
| 416 |
service, |
| 417 |
}) |
| 418 |
}, |
| 419 |
createReport: ( |
| 420 |
select_report_period, // string, |
| 421 |
select_report_start_day, // string, |
| 422 |
select_report_end_day, // string, |
| 423 |
include_report_module, // string, |
| 424 |
select_site, // string, |
| 425 |
) => { |
| 426 |
amplitudeEvent('CREATE_REPORT', { |
| 427 |
select_report_period, |
| 428 |
select_report_start_day, |
| 429 |
select_report_end_day, |
| 430 |
include_report_module, |
| 431 |
select_site, |
| 432 |
}) |
| 433 |
}, |
| 434 |
downloadReport: ( |
| 435 |
site_name, // string, |
| 436 |
) => { |
| 437 |
amplitudeEvent('DOWNLOAD_REPORT', { |
| 438 |
site_name, |
| 439 |
}) |
| 440 |
}, |
| 441 |
|
| 442 |
pageVisited: ()=>{ |
| 443 |
const path = document.location.href; |
| 444 |
|
| 445 |
const eventType = getEventTypeByPage(path); |
| 446 |
if (eventType) { |
| 447 |
amplitudeEvent(eventType) |
| 448 |
} |
| 449 |
}, |
| 450 |
|
| 451 |
init, |
| 452 |
setUser, |
| 453 |
} |
| 454 |
|
| 455 |
const amplitudeEvent = (event, props) => { |
| 456 |
const identify = new amplitude.Identify().set('LAST_SEEN_DATE', new Date().toISOString()) |
| 457 |
amplitude.getInstance().identify(identify) |
| 458 |
|
| 459 |
const additionalProps = {'WT_PLATFORM': 'wordpress'}; |
| 460 |
const resultProps = props ? Object.assign(props, additionalProps) : additionalProps; |
| 461 |
amplitude.getInstance().logEvent(event, resultProps) |
| 462 |
} |
| 463 |
|
| 464 |
window.AmplitudeAnalytics = analytics; |
| 465 |
})(); |
| 466 |
// *** Events list *** |
| 467 |
// pageVisited |
| 468 |
// reportGenerated (with params) |
| 469 |
// wafSettingsChanged |
| 470 |
// fileQuarantined |
| 471 |
// fileRestored |
| 472 |
// avRescanDemanded |
| 473 |
// agentInstallConfirm (with params) |
| 474 |
// apiKeyActivated |
| 475 |
// loggedOut |
| 476 |
// loggedIn (with params) |
| 477 |
// accountVerified |
| 478 |
// onboarding (with params) |
| 479 |
// agentInstallPopup (with params) |
| 480 |
// agentInstallType (with params) |
| 481 |
// siteAdded |
| 482 |
// teammateAdded |
| 483 |
// whiteLabelLogoAdded (with params) |
| 484 |
// addIntegrations (with params) |
| 485 |
|
| 486 |
|
| 487 |
// *** Additional functions *** |
| 488 |
// init |
| 489 |
// setUser(email) |
| 490 |
|
| 491 |
// *** Example |
| 492 |
// AmplitudeAnalytics.reportGenerated(period); |
| 493 |
// AmplitudeAnalytics.loggedOut(); |
| 494 |
|
| 495 |
// *** For every page need to add page visited event |
| 496 |
// * check pages pathnames in eventsByPathname variable |
| 497 |
// AmplitudeAnalytics.pageVisited(); |
| 498 |
|
| 499 |
// if not prod - use test api key |
| 500 |
const isProd = false; |
| 501 |
AmplitudeAnalytics.init(isProd) |