|
| 1 | +{{ define "main" }} |
| 2 | +{{/* |
| 3 | +Dedicated Adobe Analytics inventory emitter. |
| 4 | +This page is intended for scheduled automation, not regular user traffic. |
| 5 | +*/}} |
| 6 | + |
| 7 | +{{/* Build LP step-level rows */}} |
| 8 | +{{ $lpRows := slice }} |
| 9 | +{{ range where .Site.Pages "Section" "learning-paths" }} |
| 10 | + {{ $lpPage := . }} |
| 11 | + {{ if and $lpPage.File (eq $lpPage.File.TranslationBaseName "_index") }} |
| 12 | + {{ $authors := $lpPage.Params.author }} |
| 13 | + {{ if not (reflect.IsSlice $authors) }} |
| 14 | + {{ if $authors }} |
| 15 | + {{ $authors = slice $authors }} |
| 16 | + {{ else }} |
| 17 | + {{ $authors = slice }} |
| 18 | + {{ end }} |
| 19 | + {{ end }} |
| 20 | + |
| 21 | + {{ $subjects := $lpPage.Params.subjects }} |
| 22 | + {{ if not (reflect.IsSlice $subjects) }} |
| 23 | + {{ if $subjects }} |
| 24 | + {{ $subjects = slice $subjects }} |
| 25 | + {{ else }} |
| 26 | + {{ $subjects = slice }} |
| 27 | + {{ end }} |
| 28 | + {{ end }} |
| 29 | + |
| 30 | + {{ $armIps := $lpPage.Params.armips }} |
| 31 | + {{ if not (reflect.IsSlice $armIps) }} |
| 32 | + {{ if $armIps }} |
| 33 | + {{ $armIps = slice $armIps }} |
| 34 | + {{ else }} |
| 35 | + {{ $armIps = slice }} |
| 36 | + {{ end }} |
| 37 | + {{ end }} |
| 38 | + |
| 39 | + {{ $operatingSystems := $lpPage.Params.operatingsystems }} |
| 40 | + {{ if not (reflect.IsSlice $operatingSystems) }} |
| 41 | + {{ if $operatingSystems }} |
| 42 | + {{ $operatingSystems = slice $operatingSystems }} |
| 43 | + {{ else }} |
| 44 | + {{ $operatingSystems = slice }} |
| 45 | + {{ end }} |
| 46 | + {{ end }} |
| 47 | + |
| 48 | + {{ $tools := $lpPage.Params.tools_software_languages }} |
| 49 | + {{ if not (reflect.IsSlice $tools) }} |
| 50 | + {{ if $tools }} |
| 51 | + {{ $tools = slice $tools }} |
| 52 | + {{ else }} |
| 53 | + {{ $tools = slice }} |
| 54 | + {{ end }} |
| 55 | + {{ end }} |
| 56 | + |
| 57 | + {{ $lastUpdated := partial "server-side-processing/calculate-last-update.html" $lpPage }} |
| 58 | + {{ $category := $lpPage.Parent.Title }} |
| 59 | + |
| 60 | + {{ range $lpPage.Site.Pages.ByWeight }} |
| 61 | + {{ $step := . }} |
| 62 | + {{ if and $step.File (eq $step.File.Dir $lpPage.File.Dir) (ne $step.Params.hide_from_navpane true) }} |
| 63 | + {{ $lpRows = $lpRows | append (dict |
| 64 | + "full-url" ($step.RelPermalink | absURL) |
| 65 | + "learning-path-title" $lpPage.Title |
| 66 | + "weight" $step.Weight |
| 67 | + "step-title" $step.Title |
| 68 | + "author" (delimit $authors ", ") |
| 69 | + "skill-level" $lpPage.Params.skillLevels |
| 70 | + "subjects" (delimit $subjects ", ") |
| 71 | + "arm-ip" (delimit $armIps ", ") |
| 72 | + "os" (delimit $operatingSystems ", ") |
| 73 | + "tools-software-languages" (delimit $tools ", ") |
| 74 | + "content-category" $category |
| 75 | + "minutes-to-complete" $lpPage.Params.minutes_to_complete |
| 76 | + "last-updated-date" ($lastUpdated.Format "2-Jan-06") |
| 77 | + ) }} |
| 78 | + {{ end }} |
| 79 | + {{ end }} |
| 80 | + {{ end }} |
| 81 | +{{ end }} |
| 82 | + |
| 83 | +{{/* Build Install Guide rows */}} |
| 84 | +{{ $installGuideRows := slice }} |
| 85 | +{{ range where .Site.Pages "Section" "install-guides" }} |
| 86 | + {{ $igStep := . }} |
| 87 | + {{ if and $igStep.File (ne $igStep.RelPermalink "/install-guides/") }} |
| 88 | + {{ $igRoot := $igStep }} |
| 89 | + {{ if and $igStep.Parent $igStep.Parent.File (eq $igStep.Parent.File.TranslationBaseName "_index") }} |
| 90 | + {{ $igRoot = $igStep.Parent }} |
| 91 | + {{ end }} |
| 92 | + |
| 93 | + {{ $igAuthors := $igRoot.Params.author }} |
| 94 | + {{ if not (reflect.IsSlice $igAuthors) }} |
| 95 | + {{ if $igAuthors }} |
| 96 | + {{ $igAuthors = slice $igAuthors }} |
| 97 | + {{ else }} |
| 98 | + {{ $igAuthors = slice }} |
| 99 | + {{ end }} |
| 100 | + {{ end }} |
| 101 | + |
| 102 | + {{ $igOperatingSystems := $igRoot.Params.operatingsystems }} |
| 103 | + {{ if not (reflect.IsSlice $igOperatingSystems) }} |
| 104 | + {{ if $igOperatingSystems }} |
| 105 | + {{ $igOperatingSystems = slice $igOperatingSystems }} |
| 106 | + {{ else }} |
| 107 | + {{ $igOperatingSystems = slice }} |
| 108 | + {{ end }} |
| 109 | + {{ end }} |
| 110 | + |
| 111 | + {{ $igTools := $igRoot.Params.tools_software_languages }} |
| 112 | + {{ if not (reflect.IsSlice $igTools) }} |
| 113 | + {{ if $igTools }} |
| 114 | + {{ $igTools = slice $igTools }} |
| 115 | + {{ else }} |
| 116 | + {{ $igTools = slice }} |
| 117 | + {{ end }} |
| 118 | + {{ end }} |
| 119 | + |
| 120 | + {{ $installGuideRows = $installGuideRows | append (dict |
| 121 | + "full-url" ($igStep.RelPermalink | absURL) |
| 122 | + "install-guide-title" $igRoot.Title |
| 123 | + "weight" $igStep.Weight |
| 124 | + "step-title" $igStep.Title |
| 125 | + "author" (delimit $igAuthors ", ") |
| 126 | + "os" (delimit $igOperatingSystems ", ") |
| 127 | + "tools-software-languages" (delimit $igTools ", ") |
| 128 | + "content-category" "Install Guides" |
| 129 | + "minutes-to-complete" $igRoot.Params.minutes_to_complete |
| 130 | + "last-updated-date" ($igStep.Lastmod.UTC.Format "2-Jan-06") |
| 131 | + ) }} |
| 132 | + {{ end }} |
| 133 | +{{ end }} |
| 134 | + |
| 135 | +<main id="main"> |
| 136 | + <div class="content-box"> |
| 137 | + <h2>Content Inventory Emitter</h2> |
| 138 | + <p>This page supports anonymous analytics reporting so our teams can prioritize the content developers care about most.</p> |
| 139 | + <p>It emits Adobe Analytics inventory events only when query param <code>aa_inventory=1</code> is present.</p> |
| 140 | + <p>Example: <code>/stats/content-inventory/?aa_inventory=1</code></p> |
| 141 | + <p>Learning Path rows: {{ len $lpRows }} | Install Guide rows: {{ len $installGuideRows }}</p> |
| 142 | + </div> |
| 143 | +</main> |
| 144 | + |
| 145 | +<script id="inventory-lp-rows" type="application/json">{{ $lpRows | jsonify }}</script> |
| 146 | +<script id="inventory-install-guide-rows" type="application/json">{{ $installGuideRows | jsonify }}</script> |
| 147 | + |
| 148 | +<script> |
| 149 | +(function () { |
| 150 | + var params = new URLSearchParams(window.location.search); |
| 151 | + if (params.get("aa_inventory") !== "1") { |
| 152 | + return; |
| 153 | + } |
| 154 | + |
| 155 | + if (!window._satellite || typeof window._satellite.track !== "function") { |
| 156 | + console.warn("Adobe _satellite is unavailable. Inventory events were not sent."); |
| 157 | + return; |
| 158 | + } |
| 159 | + |
| 160 | + function parseRows(id) { |
| 161 | + var el = document.getElementById(id); |
| 162 | + if (!el || !el.textContent) return []; |
| 163 | + try { |
| 164 | + var parsed = JSON.parse(el.textContent); |
| 165 | + if (typeof parsed === "string") return JSON.parse(parsed); |
| 166 | + return Array.isArray(parsed) ? parsed : []; |
| 167 | + } catch (error) { |
| 168 | + console.warn("Failed to parse inventory rows for", id, error); |
| 169 | + return []; |
| 170 | + } |
| 171 | + } |
| 172 | + |
| 173 | + var lpRows = parseRows("inventory-lp-rows"); |
| 174 | + var installGuideRows = parseRows("inventory-install-guide-rows"); |
| 175 | + |
| 176 | + _satellite.track("content-inventory-summary", { |
| 177 | + "inventory-type": "all", |
| 178 | + "inventory-run-date": new Date().toISOString(), |
| 179 | + "learning-path-row-count": lpRows.length, |
| 180 | + "install-guide-row-count": installGuideRows.length, |
| 181 | + "total-row-count": lpRows.length + installGuideRows.length |
| 182 | + }); |
| 183 | + |
| 184 | + for (var i = 0; i < lpRows.length; i++) { |
| 185 | + _satellite.track("learning-path-row-metadata", lpRows[i]); |
| 186 | + } |
| 187 | + |
| 188 | + for (var j = 0; j < installGuideRows.length; j++) { |
| 189 | + _satellite.track("install-guide-row-metadata", installGuideRows[j]); |
| 190 | + } |
| 191 | +})(); |
| 192 | +</script> |
| 193 | +{{ end }} |
0 commit comments