Skip to content

Commit aea6706

Browse files
nalchevanidzeclaude
andcommitted
refactor(web-sdk_angular): replace observation mode with manualTracking boolean
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8c6cce2 commit aea6706

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

implementations/web-sdk_angular/src/app/components/entry-card/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
type MergeTagMode,
1111
} from '../../fixtures'
1212
import type { ContentfulEntry } from '../../services/contentful-client'
13-
import { injectContentfulEntry, type ObservationMode } from '../../services/entry'
13+
import { injectContentfulEntry } from '../../services/entry'
1414
import { NgLiveUpdates } from '../../services/live-updates'
1515
import { isRecord } from '../../utils'
1616

@@ -112,7 +112,7 @@ function isContentfulEntry(value: unknown): value is ContentfulEntry {
112112
})
113113
export class EntryCard {
114114
readonly entry = input.required<ContentfulEntry>()
115-
readonly observation = input<ObservationMode>('auto')
115+
readonly manualTracking = input(false)
116116
readonly clickScenario = input<EntryClickScenario | undefined>(undefined)
117117
readonly liveUpdates = input<boolean | undefined>(undefined)
118118

@@ -124,8 +124,6 @@ export class EntryCard {
124124
return this.liveUpdates() ?? this.liveUpdatesService.globalLiveUpdates()
125125
})
126126

127-
private readonly manualTracking = computed(() => this.observation() === 'manual')
128-
129127
protected readonly resolved = injectContentfulEntry({
130128
entry: this.entry,
131129
isLive: this.isLive,
@@ -147,7 +145,7 @@ export class EntryCard {
147145
const nested: unknown = this.resolved().entry.fields.nested
148146
return Array.isArray(nested) ? nested.filter(isContentfulEntry) : []
149147
})
150-
protected readonly isAuto = computed(() => this.observation() === 'auto')
148+
protected readonly isAuto = computed(() => !this.manualTracking())
151149
protected readonly badges = computed(() => {
152150
const r = this.resolved()
153151
const mergeTag = mergeTagKey(r.mergeTagResolved)
@@ -156,7 +154,7 @@ export class EntryCard {
156154
...(mergeTag ? [mergeTag] : []),
157155
...(scenario ? [scenario] : []),
158156
this.isVariant() ? 'variant' : 'baseline',
159-
this.observation(),
157+
this.manualTracking() ? 'manual' : 'auto',
160158
liveModeKey(this.liveUpdates(), this.isLive()),
161159
]
162160
return keys.map((k) => BADGE_MAP[k])

implementations/web-sdk_angular/src/app/pages/home/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ <h2>Live updates</h2>
1414
</header>
1515
@let liveEntry = entryFor(liveUpdatesEntryId); @if (liveEntry) {
1616
<div class="sections-row">
17-
<app-entry-card [entry]="liveEntry" observation="auto" />
18-
<app-entry-card [entry]="liveEntry" observation="auto" [liveUpdates]="true" />
19-
<app-entry-card [entry]="liveEntry" observation="auto" [liveUpdates]="false" />
17+
<app-entry-card [entry]="liveEntry" />
18+
<app-entry-card [entry]="liveEntry" [liveUpdates]="true" />
19+
<app-entry-card [entry]="liveEntry" [liveUpdates]="false" />
2020
</div>
2121
}
2222
</section>
@@ -28,7 +28,7 @@ <h2>Auto-observed</h2>
2828
</header>
2929
<div id="auto-observed" class="entry-grid">
3030
@for (id of autoIds; track id) { @let entry = entryFor(id); @if (entry) {
31-
<app-entry-card [entry]="entry" observation="auto" [clickScenario]="clickScenarios[id]" />
31+
<app-entry-card [entry]="entry" [clickScenario]="clickScenarios[id]" />
3232
} }
3333
</div>
3434
</section>
@@ -39,7 +39,7 @@ <h2>Manually-observed</h2>
3939
</header>
4040
<div id="manually-observed" class="entry-grid">
4141
@for (id of manualIds; track id) { @let entry = entryFor(id); @if (entry) {
42-
<app-entry-card [entry]="entry" observation="manual" />
42+
<app-entry-card [entry]="entry" [manualTracking]="true" />
4343
} }
4444
</div>
4545
</section>

implementations/web-sdk_angular/src/app/pages/page-two/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ <h1>Page Two</h1>
1515
<h2>Auto-observed</h2>
1616
</header>
1717
<div class="entry-grid">
18-
<app-entry-card [entry]="entry" observation="auto" />
18+
<app-entry-card [entry]="entry" />
1919
</div>
2020
</section>
2121
} @if (manualEntry(); as entry) {
@@ -24,7 +24,7 @@ <h2>Auto-observed</h2>
2424
<h2>Manually-observed</h2>
2525
</header>
2626
<div class="entry-grid">
27-
<app-entry-card [entry]="entry" observation="manual" />
27+
<app-entry-card [entry]="entry" [manualTracking]="true" />
2828
</div>
2929
</section>
3030
}

0 commit comments

Comments
 (0)