<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ajin Kabeer on Medium]]></title>
        <description><![CDATA[Stories by Ajin Kabeer on Medium]]></description>
        <link>https://medium.com/@ajinkabeer?source=rss-d1d139f6785------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JeTf_Rn6KFQNxJ4TKtcw-w.jpeg</url>
            <title>Stories by Ajin Kabeer on Medium</title>
            <link>https://medium.com/@ajinkabeer?source=rss-d1d139f6785------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 16:48:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ajinkabeer/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A new primitive for consumer insights]]></title>
            <link>https://medium.com/swlh/a-new-primitive-for-consumer-insights-a2d1295d3ad2?source=rss-d1d139f6785------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2d1295d3ad2</guid>
            <dc:creator><![CDATA[Ajin Kabeer]]></dc:creator>
            <pubDate>Fri, 09 Jan 2026 07:13:26 GMT</pubDate>
            <atom:updated>2026-01-09T15:00:32.828Z</atom:updated>
            <content:encoded><![CDATA[<h4>We set out to build infrastructure for consumer insights. One system that could ingest surveys, social posts, support tickets, interviews, and reviews, then synthesize what customers actually believe. Not summaries of a few cherry-picked quotes, but real understanding across thousands of voices. The texture, the contradictions, the shifts over time. The kind of sense-making that experienced researchers do in their heads, but faster, and at a scale no human can hold.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZZZwXNAWAwPbiw2gCYhtJQ.jpeg" /><figcaption>Photo from <a href="https://unsplash.com/photos/a-landscape-with-trees-and-a-river-B-ifoxyk9as?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>The obvious approach is to dump everything into a foundational model and ask questions. But it breaks quickly. Context windows overflow. Attention degrades with length. The model cherry-picks instead of synthesizing. So you try RAG, retrieving relevant chunks and letting the LLM reason over them. That breaks too, just more slowly. Semantic similarity isn’t synthesis relevance. Embedding space collapses at scale. You’re retrieving noise and calling it insight. We tried map-reduce, chunking data into batches and combining the outputs. It works until you notice what’s missing: the nuance, the contradictions, the minority perspectives that got averaged away. You’re summarizing summaries and losing the texture that matters.</p><p>The standard approaches got us part of the way. But the further we went, the more we found ourselves in territory the existing tools weren’t built for. So we started building our own. Our first attempt was elegant, a graph structure designed specifically for beliefs, and it didn’t survive contact with real data. What we learned from that failure led us somewhere better. This is the story of that journey: the problem we encountered, the assumptions we got wrong, and the architecture we’re running now.</p><p>Behind any system that works at scale, there’s real infrastructure. For Meaningful, it’s state machines orchestrating multi-step processing, serverless functions handling unpredictable workloads, databases, caching, queues, logging, API gateways, CDN for delivery. The usual SaaS stack, tuned for a specific problem. We won’t go deep on that here. This post is about the harder question: once you have the infrastructure in place, how do you actually architect the ingestion and synthesis of consumer data in a way that produces real understanding?</p><p>This is a long post in four parts. Part one explains why synthesizing consumer beliefs is harder than it looks. Part two is about the Perception Graph we built and why it failed. Part three covers what we’re actually running now. Part four is where we’re taking it next. You can read straight through or jump to whatever’s most relevant to you.</p><p>Part 1:<strong> The Synthesis Problem.</strong></p><p>Part 2: <strong>We Built a Perception Graph. It Was Wrong.</strong></p><p>Part 3: <strong>Memory for Qual Insights.</strong></p><p>Part 4: <strong>Where This Goes From Here.</strong></p><h3>The Synthesis Problem</h3><p><em>Part 1 of 4: Building Memory for Consumer Insights</em></p><p>There’s a promise that’s been floating around for a few years now: just connect your customer data to an AI, ask questions in plain English, and get insights back.</p><p>Upload your survey responses. Plug in your Reddit mentions. Feed it your support tickets. Then ask: “How do customers feel about our pricing?” And the AI tells you.</p><p>It sounds right. The technology exists. Large language models can read text and reason about it. Vector databases can store and retrieve documents. The pieces are all there.</p><p>So why doesn’t it work?</p><p>We’ve spent the last year building Meaningful, a platform that synthesizes consumer insights across multiple data sources. We’ve processed hundreds of thousands of fragments: Reddit comments, survey responses, support tickets, interview transcripts, AI perception data. And we’ve learned, sometimes painfully, that the gap between “AI can read your data” and “AI can tell you what customers believe” is enormous.</p><p>This is the first of four posts about what we’ve learned. Not a product pitch, but a genuine account of the problem, the mistakes we made, and what we’re building now.</p><h3>The Promise vs. The Reality</h3><p>Here’s what we wanted to build: a system where you could ask “Why do power users feel differently about our product than new users, and is that changing?” and get a real answer. Not a summary of a few cherry-picked quotes. A synthesis across thousands of data points that surfaces patterns, tensions, and shifts you couldn’t see by reading individual responses.</p><p>Here’s what actually happens when you try to build this with standard approaches.</p><p><strong>Approach 1: Just use a large context window.</strong></p><p>Modern LLMs can handle 200K+ tokens. Why not just dump everything in?</p><p>Because it doesn’t scale. 10,000 Reddit comments exceed any context window. And even when it fits, attention degrades with length. The model “reads” everything but doesn’t synthesize it. It cherry-picks, loses nuance, misses contradictions. The output feels coherent but isn’t grounded in the full picture.</p><p>Cost is prohibitive too. Every query re-processes the entire corpus. At scale, you’re burning thousands of dollars for answers that aren’t even reliable.</p><p><strong>Approach 2: Map-reduce.</strong></p><p>This is the standard pattern for large datasets. Split your data into batches that fit the context window. Process each batch separately. Combine the outputs. Generate a final synthesis.</p><p>We used this for months. It works, until you look closely at what you’re losing.</p><p>Each “map” step summarizes a batch. But it can’t know what matters without seeing everything else. So it compresses aggressively. Nuance disappears. Contradictions get smoothed over. Minority opinions vanish. Temporal patterns flatten.</p><p>By the time you reach the “reduce” step, you’re synthesizing summaries of summaries. The texture is gone. You get an answer, but it’s hollow.</p><p>We were producing confident-sounding insights that missed the real story.</p><p><strong>Approach 3: RAG (Retrieval-Augmented Generation).</strong></p><p>The dominant paradigm for “AI that knows your data.” Convert your documents into embedding vectors, store them in a vector database, retrieve the most relevant chunks at query time, and let the LLM synthesize from what’s retrieved.</p><p>RAG is elegant. It’s also fundamentally wrong for this problem.</p><p>Semantic similarity is not synthesis relevance. When you ask “What do customers believe about our pricing?”, the system retrieves chunks that mention pricing. But two contradictory opinions can be semantically similar. The insight doesn’t live in any single fragment. It emerges from patterns across many fragments. And those patterns aren’t captured by nearest-neighbor search in embedding space.</p><p>Worse, RAG degrades at scale. Research has documented what’s called “semantic collapse”: as your corpus grows, embedding space fills up, distances compress, and retrieval precision craters. At 100K documents, you’re often retrieving noise.</p><p>RAG was designed for retrieval: find relevant documents. Consumer insights requires synthesis: understand what people believe across thousands of voices. These are different problems.</p><h3>Why This Is Harder Than It Looks</h3><p>The deeper issue is that consumer insights data is fundamentally different from the data these systems were designed for.</p><p><strong>It’s perspectival, not factual.</strong></p><p>A knowledge graph stores: “Apple acquired Beats in 2014.” That’s a fact. It’s true or false.</p><p>Consumer insights stores: “The support team is responsive.” That’s a belief. It’s held by some people, contested by others, felt with varying intensity, expressed with different emotions, and it changes over time.</p><p>Existing data structures don’t have primitives for beliefs. They have primitives for entities and facts.</p><p><strong>It’s contradictory by nature.</strong></p><p>People disagree. That’s not noise; it’s signal. “Power users love the flexibility; new users find it overwhelming” is an insight, not an error to be resolved.</p><p>But most synthesis approaches smooth over contradictions. Map-reduce averages them out. RAG retrieves one side or the other depending on the query. Knowledge graphs can’t represent “60% believe X, but segment Y disagrees.”</p><p><strong>It’s distributed across fragments.</strong></p><p>The insight doesn’t live in any single comment. It emerges from seeing patterns across thousands of comments.</p><p>“Support is actually decent now” only means something when you know that three months ago, sentiment was negative. One person saying “better than before” is anecdotal. Five hundred people saying it, with hedging that suggests relative rather than absolute satisfaction, is a finding.</p><p>Retrieval-based systems can’t see this. They fetch individual fragments and hope the LLM notices the pattern. At scale, it doesn’t.</p><h3>What We Needed (And Didn’t Have)</h3><p>We needed a system that could:</p><p><strong>Compress without losing synthesis-relevant signal.</strong> Not summaries that discard nuance, but structured representations that preserve what matters: who believes what, how strongly, with what emotion, and how it’s changing.</p><p><strong>Handle contradiction as first-class data.</strong> Not “the answer is X” but “segment A believes X, segment B believes Y, and here’s why they disagree.”</p><p><strong>Scale without degrading.</strong> More data should mean better synthesis, not noisier retrieval.</p><p><strong>Ground every claim in evidence.</strong> No hallucinated insights. Every pattern traceable to source fragments.</p><p><strong>Let the LLM reason, not just retrieve.</strong> The hard part of synthesis is understanding what fragments mean <em>together</em>. That’s reasoning, not search.</p><p>We looked for existing tools that did this. Vector databases don’t. Knowledge graphs don’t. Agent memory systems don’t. The infrastructure for synthesizing beliefs, as opposed to storing facts or retrieving documents, doesn’t exist.</p><p>So we started building it.</p><h3>What’s Coming</h3><p><em>In the next part, I’ll talk about our first attempt: a thing we called the Perception Graph. It was elegant, theoretically sound, and wrong in ways that taught us a lot about where intelligence actually belongs in a system like this.</em></p><h3>We Built a Perception Graph. It Was Wrong.</h3><p><em>Part 2 of 4: Building Memory for Consumer Insights</em></p><p>After months of watching map-reduce lose nuance and RAG retrieve noise, we thought we understood the problem. Existing data structures were built for facts, not beliefs. We needed a new primitive.</p><p>So we designed one. We called it the Perception Graph.</p><p>The idea was elegant: a graph structure purpose-built for storing and querying what people believe. Unlike knowledge graphs that store entities and facts, the Perception Graph would store claims and perspectives. Unlike vector databases that retrieve by similarity, it would let you query by subject, segment, and time.</p><p>We were excited. We wrote a detailed technical spec. We mapped out the schema, the extraction pipeline, the query patterns. It felt like we’d found the missing piece.</p><p>Then we built it. And it didn’t work the way we expected.</p><p>This is the story of what we got wrong, and why the failure taught us something important about where intelligence belongs in a system like this.</p><h3>The Design</h3><p>The core insight felt right: consumer insights data is perspectival, not factual. So the primitive shouldn’t be an entity (“Apple”) or a fact (“Apple acquired Beats”). It should be a claim (“Apple’s support is responsive”) with metadata about who believes it and how strongly.</p><p>Here’s what we designed:</p><p><strong>Nodes were claims, not entities.</strong></p><p>Each node represented something people believe about a subject:</p><pre>{<br>  claim: &quot;customer support is responsive&quot;,<br>  subject: &quot;customer_support&quot;,<br>  stance_distribution: { positive: 0.63, negative: 0.28, neutral: 0.09 },<br>  confidence: 0.71,<br>  hedging: 0.4,<br>  segments: { <br>    power_user: { stance: -0.2 }, <br>    new_user: { stance: 0.5 } <br>  }<br>}</pre><p>Not just “what did someone say” but “what do people believe, who believes it, how strongly, and with what certainty.”</p><p><strong>Edges were relationships between claims.</strong></p><p>Claims don’t exist in isolation. They contradict each other, support each other, evolve over time. So we added typed edges:</p><pre>{<br>  from: &quot;claim_1&quot;,<br>  to: &quot;claim_2&quot;,<br>  type: &quot;contradicts&quot;,  // or: supports, refines, evolves_into<br>  strength: 0.8,<br>  segment_specific: &quot;power_user&quot;<br>}</pre><p>The graph would encode not just what people believe, but how beliefs relate to each other.</p><p><strong>Query would be structural, not semantic.</strong></p><p>Instead of “find vectors nearest to this query,” you’d ask: “Get all claims about customer_support where power_user segment has negative stance, and find claims that contradict them.”</p><p>No embedding collapse at scale. No retrieval noise. Just structured queries returning structured beliefs.</p><p><strong>The LLM would synthesize at the end.</strong></p><p>Once you had the relevant subgraph (claims, distributions, relationships, exemplar quotes) you’d pass it to an LLM for final synthesis. The graph did the organization; the LLM did the narrative.</p><p>The economics looked good too. Expensive extraction once at ingestion time, cheap structured queries at runtime. One LLM call for final synthesis instead of fifty for map-reduce.</p><p>We thought we’d cracked it.</p><h3>What Went Wrong</h3><p>The problems started as soon as we ran it on real data.</p><p><strong>The edges were forced.</strong></p><p>We wanted the graph to encode relationships: this claim contradicts that one, this claim evolved from that one. But detecting these relationships reliably turned out to be much harder than we expected.</p><p>“Support is responsive” and “Support never replies”: obvious contradiction. But “Support is fast” and “They never understand my problem”: is that a contradiction? Or two different facets? What about “Support has improved” and “Support is decent now”: is that an evolution, or two independent observations?</p><p>We were forcing the LLM to make relationship judgments at extraction time, with limited context, and baking those judgments into the data structure. When it got them wrong, the errors were frozen into the graph.</p><p><strong>Stance scores collapsed the texture.</strong></p><p>We reduced complex human expression to numbers. Stance: 0.6. Hedging: 0.4. Confidence: 0.71.</p><p>But “their support is actually decent now” and “support is good” aren’t the same sentiment with the same score. The first carries surprise, implicit comparison to a worse past, a hedge. The second is straightforward approval. Collapsing them to similar stance scores destroyed exactly the texture we needed for real synthesis.</p><p>We thought we were preserving nuance by adding fields (hedging, confidence, temporal_signal). We were still flattening it.</p><p><strong>Claim normalization was impossibly hard.</strong></p><p>When does a new fragment express the same claim as an existing one? When should we update an existing node versus create a new one?</p><p>“Support is slow.” “Takes forever to get a response.” “Customer service response times are unacceptable.”</p><p>Same claim? Different claims? We tried merging aggressively and lost individual voices. We tried keeping them separate and ended up with thousands of near-duplicate nodes that the aggregation couldn’t make sense of.</p><p>This is entity resolution for beliefs, and it’s much harder than entity resolution for facts. “Apple Inc.” and “Apple” are obviously the same entity. “Support is slow” and “response times are unacceptable” are… maybe the same belief? It depends on context we didn’t have at extraction time.</p><p><strong>The graph was doing the thinking.</strong></p><p>This was the deepest problem, and it took us a while to see it clearly.</p><p>We’d designed a system where intelligence was encoded in the data structure. The edges represented reasoning about relationships. The stance scores represented judgments about sentiment. The claim normalization represented decisions about meaning.</p><p>But those judgments require understanding context that isn’t available at extraction time. Is this a contradiction or a different facet? Depends on the question being asked. Should these claims merge? Depends on what level of granularity matters for the analysis.</p><p>We were trying to pre-compute understanding. And understanding isn’t pre-computable.</p><p>The graph was doing the thinking. But thinking is what LLMs are good at.</p><h3>The Lesson</h3><p>Here’s what we finally understood:</p><p><strong>The storage layer should store observations, not interpretations.</strong></p><p>When someone says “their support is actually decent now,” we should capture that utterance with all its texture: the hedging, the surprise, the implicit comparison. We shouldn’t immediately collapse it into a stance score and a claim category.</p><p><strong>The reasoning layer should reason, not retrieve.</strong></p><p>Pattern recognition, contradiction detection, synthesis across segments: these require understanding context. An LLM at query time has context: the question being asked, the full set of retrieved observations, the ability to reason about how things fit together.</p><p>Encoding that reasoning into edges at extraction time meant making judgments without context and freezing them permanently.</p><p><strong>Structure should enable reasoning, not replace it.</strong></p><p>The Perception Graph tried to be too smart. It tried to pre-compute the relationships, pre-aggregate the stances, pre-determine what claims were related to what.</p><p>What we actually needed was dumber storage and smarter queries. Rich primitives that preserve texture. Let the LLM discover patterns at query time, when it has the context to do so correctly.</p><h3>The Pivot</h3><p>We didn’t throw everything away. The core insight, that we need primitives for beliefs, not just facts, was right. The mistake was trying to encode too much intelligence in the structure.</p><p>So we stripped it back. Removed the edges. Kept richer primitives for individual observations. Let patterns and tensions be discovered by the LLM at query time, not pre-computed at ingestion.</p><p>The architecture became simpler. The results became better.</p><p>In the next post, I’ll walk through what we’re actually running now: the primitives we kept, the ones we added, and the rule we use to decide what the code should do versus what the LLM should do.</p><p>Spoiler: the LLM does a lot more than we originally planned.</p><h3>Memory for Qual Insights</h3><p><em>Part 3 of 4: Building Memory for Consumer Insights</em></p><p>After the Perception Graph didn’t work the way we expected, we had a choice. We could add more complexity: better relationship detection, smarter normalization, more sophisticated edge types. Or we could step back and ask what we’d gotten fundamentally wrong.</p><p>We stepped back.</p><p>The problem wasn’t that our graph needed more features. The problem was that we’d put intelligence in the wrong place. We were encoding reasoning into data structures, when reasoning is what LLMs are actually good at.</p><p>So we rebuilt. Simpler storage. Richer primitives. Let the LLM do the thinking.</p><p>Here’s what we’re running now.</p><h3>The Core Shift</h3><p>The Perception Graph tried to be smart. It had edges encoding relationships between claims. It had stance scores collapsing sentiment to numbers. It had normalization merging similar beliefs into canonical forms.</p><p>All of that is gone.</p><p>The new system (we call it Memory for Qual Insights) inverts the architecture:</p><p><strong>Before</strong></p><p>Graph does the thinking</p><p>Intelligence in edges</p><p>Stance as number (-1 to +1)</p><p>Claims merged/averaged</p><p>Fixed relationship types</p><p><strong>After</strong></p><p>LLM does the thinking</p><p>Intelligence in prompts</p><p>Stance + intensity + emotion + framing + why</p><p>Perceptions preserved individually</p><p>Contextual reasoning at query time</p><p>The storage layer stores observations with full texture. The reasoning layer (the LLM, at query time) discovers patterns, detects tensions, and synthesizes insights.</p><p>Structure enables reasoning. It doesn’t replace it.</p><h3>The Primitives</h3><p>We landed on four core primitives. Each one exists because we found we couldn’t do good synthesis without it.</p><h3>Perception</h3><p>A Perception is one voice expressing one belief about one subject.</p><p>Not a collapsed stance score. Not a normalized claim. One person’s actual perspective, preserved with texture:</p><ul><li><strong>Claim</strong>: What they’re saying (“support has gotten better”)</li><li><strong>Stance</strong>: Positive, negative, mixed, neutral</li><li><strong>Intensity</strong>: How strongly they feel it</li><li><strong>Emotion</strong>: Frustration, delight, disappointment, surprise</li><li><strong>Framing</strong>: How they’re positioning it (“actually decent now” vs “good”)</li><li><strong>Why</strong>: The reasoning behind their belief, if expressed</li><li><strong>Comparison</strong>: Implicit comparisons (“better than before”, “worse than competitors”)</li><li><strong>Certainty</strong>: How confident they seem</li><li><strong>Temporality</strong>: Is this about change over time?</li><li><strong>Segment</strong>: Who is this person, if we know</li></ul><p>Each Perception links back to the source utterance. Full provenance, always.</p><p>This is richer than a stance score, but it’s not pre-interpreted. We’re capturing what was expressed, not what we think it means in aggregate. Aggregation happens at query time, when we have context.</p><h3>Pattern</h3><p>A Pattern is a recurring theme across multiple Perceptions.</p><p>“Power users consistently praise flexibility but express frustration with onboarding”: that’s a Pattern. It’s not a single voice; it’s something that emerges from seeing many voices together.</p><p>Critically: Patterns are LLM-discovered, not hardcoded.</p><p>In the Perception Graph, we tried to pre-compute patterns at ingestion time. Now, the LLM finds them at query time. It sees the retrieved Perceptions, notices what recurs, and surfaces Patterns that are relevant to the question being asked.</p><p>Different questions surface different Patterns from the same data. That’s the point.</p><p>We cache discovered Patterns for efficiency, but they’re always re-derivable from source Perceptions.</p><h3>Tension</h3><p>A Tension is where people disagree, and why.</p><p>This is maybe the most important primitive. In consumer insights, disagreement isn’t noise. It’s signal. “Power users love X, new users hate X” is an insight. But only if you can explain <em>why</em> they disagree.</p><p>A Tension has:</p><ul><li><strong>Two poles</strong>: The opposing positions</li><li><strong>Framing for each pole</strong>: How each side sees it</li><li><strong>Perceptions supporting each pole</strong>: The actual voices</li><li><strong>Segments</strong>: Who falls on which side</li><li><strong>Insight</strong>: What the disagreement reveals</li></ul><p>That last field (the insight) is what makes Tensions useful. Not just “people disagree” but “they disagree because power users value configurability while new users are overwhelmed by options.” The LLM generates this at query time, looking at the actual Perceptions on each side.</p><h3>ResearchClaim</h3><p>A ResearchClaim is secondary data: what reports and studies say people believe, as opposed to primary Perceptions from actual people.</p><p>We added this because consumer insights often involves synthesizing primary research (surveys, social, support tickets) with secondary research (industry reports, analyst commentary). They have different epistemic status. A report saying “60% of consumers prefer X” is different from seeing 60% of your survey respondents say they prefer X.</p><p>ResearchClaims are tagged accordingly. They can inform synthesis, but the system knows they’re secondhand.</p><h3>The Rule: LLM Decides, Code Handles</h3><p>We needed a clear principle for what belongs in code versus what belongs in the LLM. Here’s the rule:</p><p><strong>If the decision requires understanding meaning, the LLM decides.</strong></p><ul><li>Is this enough evidence to make a claim? → LLM</li><li>Is this a real pattern or noise? → LLM</li><li>What confidence level is appropriate? → LLM</li><li>Is this a genuine tension or just variance? → LLM</li><li>What does this disagreement reveal? → LLM</li></ul><p><strong>If the decision is mechanical, code handles it.</strong></p><ul><li>Storage operations → Code</li><li>Batching and chunking → Code</li><li>Caching → Code</li><li>Index updates → Code</li><li>Data format validation → Code</li></ul><p>The Perception Graph violated this rule constantly. Code was deciding whether claims should merge (requires understanding meaning). Code was deciding what relationship type to assign (requires understanding meaning). Code was computing aggregate stance scores (requires understanding what different expressions mean relative to each other).</p><p>Now code handles plumbing. The LLM handles understanding.</p><h3>The Anti-Hallucination Stack</h3><p>Letting the LLM reason more means we need stronger guardrails against hallucination. Here’s what we built:</p><p><strong>Structured extraction with explicit fields.</strong></p><p>When we extract Perceptions from raw utterances, we’re not asking for freeform interpretation. We’re asking for specific fields: claim, stance, emotion, framing. Structure constrains the output.</p><p><strong>Provenance preservation.</strong></p><p>Every Perception links to its source utterance. Every Pattern links to the Perceptions that support it. Every Tension links to the Perceptions on each pole. You can always trace back.</p><p><strong>Retrieved context only.</strong></p><p>At query time, the LLM only sees what’s retrieved. It can’t hallucinate Perceptions that don’t exist because it never sees the full corpus, just the relevant subset.</p><p><strong>Grounding instructions in prompts.</strong></p><p>Every synthesis prompt explicitly instructs: only make claims supported by the retrieved Perceptions. Include quotes. Don’t invent.</p><p><strong>Citation enforcement.</strong></p><p>The output must cite specific Perceptions. This is checkable. If a claim doesn’t have supporting citations, it gets flagged.</p><p><strong>Confidence calibration based on data volume.</strong></p><p>This is crucial. When we only have 7 Perceptions about a topic, the LLM shouldn’t produce high-confidence insights. We explicitly pass data volume to the synthesis step, and the prompts instruct appropriate hedging.</p><p>Thin data → “preliminary findings suggest…” Medium data → “evidence indicates…” Rich data → “clear pattern across N responses…”</p><p>The system is honest about what it knows and doesn’t know.</p><h3>What We’ve Validated</h3><p>We’ve tested this architecture across different data densities and query types. Here’s what we’ve seen:</p><p><strong>Thin data gets appropriate uncertainty.</strong></p><p>On a dataset with only 7–11 Perceptions about a brand, the system returned insights marked “moderate confidence” and “limited sample.” It found both praise and criticism without forcing a narrative. It didn’t hallucinate patterns that weren’t there.</p><p><strong>Tensions surface with <em>why</em>, not just <em>that</em>.</strong></p><p>On a richer dataset (23 Perceptions), the system identified a real tension: convenience versus ethics in purchasing decisions. But it didn’t just flag the disagreement. It explained that convenience-focused customers prioritize speed and reliability, while ethics-focused customers are willing to trade convenience for values alignment.</p><p>That “why” is what makes the insight actionable.</p><p><strong>Facet-specific queries stay clean.</strong></p><p>When asked specifically about pricing for a brand (3 Perceptions), the system returned only pricing-relevant insights, marked as “preliminary” given thin data, with one pattern and no forced conclusions.</p><p>It’s doing what we wanted: synthesize what’s there, be honest about confidence, don’t invent.</p><h3>What’s Different</h3><p>If you’re comparing this to other approaches:</p><p><strong>Versus RAG</strong>: We’re not retrieving chunks and hoping the LLM notices patterns. We’re retrieving structured Perceptions, computing aggregates, and asking the LLM to reason over organized evidence.</p><p><strong>Versus knowledge graphs</strong>: We’re not storing entities and facts. We’re storing beliefs with texture, and letting relationships emerge at query time.</p><p><strong>Versus the Perception Graph</strong>: We’re not pre-computing edges or collapsing stances. We’re preserving individual voices and letting the LLM discover patterns in context.</p><p>The system is simpler than what we originally designed. It’s also better.</p><h3>What’s Next</h3><p>This isn’t done. We’ve validated the architecture on moderate-scale data with specific query types. But we have open questions:</p><ul><li>What happens at 100+ Perceptions per entity? Does aggregation still work, or do we need hierarchical compression?</li><li>Can we handle cross-entity queries? (“What patterns exist across all brands in this category?”)</li><li>How do we incorporate temporal dynamics when timestamps vary?</li><li>What breaks when we scale to production load?</li></ul><p>In the final post, I’ll talk about what we’re still figuring out, and where we think this is heading.</p><h3>Where This Goes From Here</h3><p><em>Part 4 of 4: Building Memory for Consumer Insights</em></p><p>We started this series with a problem: the tools for synthesizing what customers believe don’t work at scale. RAG retrieves fragments without understanding. Map-reduce loses nuance. Knowledge graphs store facts, not beliefs.</p><p>We tried to solve it with an elegant data structure (the Perception Graph) and learned that we’d put intelligence in the wrong layer. The graph was doing the thinking when thinking is what LLMs are good at.</p><p>So we rebuilt. Simpler storage, richer primitives, LLM-driven reasoning. Perceptions that preserve texture. Patterns and Tensions discovered at query time. An architecture that gets more accurate with more data, not noisier.</p><p>It works. We’ve validated it across different data densities and query types. Thin data gets appropriate uncertainty. Rich data surfaces real tensions with explanations, not just observations. Every insight traces back to source.</p><p>Now we’re scaling it.</p><h3>The Roadmap</h3><h4>Density at scale</h4><p>Our architecture handles tens to hundreds of Perceptions per entity cleanly. The next milestone is thousands.</p><p>We’re building tiered retrieval: Perceptions compressed into intermediate summaries that preserve segment differences and temporal patterns, then expanded back to source evidence when needed. The goal is synthesis quality that holds at 10x and 100x current data volumes, without losing the texture that makes insights actionable.</p><h4>Cross-entity intelligence</h4><p>Most queries today are scoped to one brand, one product, one topic. But the most valuable questions span entities: “How does perception of our pricing compare to competitors?” “What patterns exist across this category?”</p><p>The primitives already support this. Perceptions are tagged with their subject. We’re building the retrieval and synthesis layers that reason across entities simultaneously, surfacing comparative insights and category-level patterns.</p><h4>Temporal dynamics</h4><p>Consumer beliefs shift. A product launch changes perception. A PR incident creates a spike. A slow decline signals deeper problems.</p><p>We’re building temporal querying that goes beyond “recent vs. older.” Cohort comparison across time windows. Inflection point detection. Causal reasoning about what changed and why. The data has timestamps and temporal signals; we’re building the synthesis layer that makes them queryable.</p><h4>Production infrastructure</h4><p>We’ve validated correctness. Now we’re validating performance, cost, and reliability at scale. Latency optimization. Cost modeling as data volume grows. Graceful handling of edge cases and malformed outputs. The engineering work that turns a working architecture into production infrastructure.</p><h3>What We’ve Found</h3><p>Building this has taught us something about the problem space that we didn’t fully appreciate when we started.</p><p>The gap isn’t just tooling. It’s primitives.</p><p>Vector databases have primitives for similarity. Knowledge graphs have primitives for entities and relationships. Neither has primitives for beliefs: perspectives held by segments, contested across groups, evolving over time.</p><p>We built those primitives: Perceptions, Patterns, Tensions. They’re not consumer-insights-specific. They’re belief-specific. A Perception is one voice expressing one belief about one subject. That abstraction applies wherever you need to synthesize what people think: customer feedback, employee sentiment, market analysis, policy research.</p><p>We’re focused on consumer insights because that’s where we can validate rigorously and build credibility. But the infrastructure we’re building is more general than the application we’re starting with.</p><p>The insight that made this work (intelligence in the reasoning layer, not the storage layer) isn’t domain-specific either. It’s an architectural pattern. Let storage preserve observations with full texture. Let the LLM discover meaning at query time, when it has context. Don’t pre-compute understanding; enable it.</p><p>We think this is the right pattern for any system that needs to synthesize human perspectives at scale. We haven’t seen anyone else build it this way.</p><h3>Why Consumer Insights First</h3><p>Consumer insights has a structural problem that makes it the right place to prove this out.</p><p>The data is fragmented (surveys, social, support, interviews, reviews) across tools that were never designed to work together. The synthesis happens manually, in someone’s head, compressed into a deck that’s outdated before it’s presented. The pace of decisions has outrun the pace of research.</p><p>Everyone feels this. Insights leaders are drowning in data and starving for synthesis. The market is ready for infrastructure that actually works.</p><p>And the feedback loop is tight. We can validate whether our synthesis matches reality. We can measure whether insights land. We can iterate quickly because customers know immediately whether we’re helping them or not.</p><p>Consumer insights is where we prove the architecture. It’s not where the architecture stops.</p><h3>The Path Forward</h3><p>We set out to build better consumer insights. We ended up building a new kind of memory: infrastructure for storing and synthesizing what people believe.</p><p>The primitives are in place. The architecture is validated. The roadmap is clear.</p><p>We’re not the only ones who’ve noticed that RAG doesn’t work for synthesis, that knowledge graphs don’t handle beliefs, that the current tools are inadequate. But we’ve found a path through it. We’ve built something that works, learned from what didn’t, and have a clear view of where to take it next.</p><p>If you’re working on similar problems, or if you’re drowning in consumer data and want synthesis that actually helps, we’d like to talk.</p><p>Not a demo. A conversation about where this is going and how to get there.</p><p><em>Follow our progress at </em><a href="https://meaningful.app/"><em>meaningful.app</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2d1295d3ad2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/a-new-primitive-for-consumer-insights-a2d1295d3ad2">A new primitive for consumer insights</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Future Beyond Universal Analytics.]]></title>
            <link>https://medium.com/@ajinkabeer/the-future-beyond-universal-analytics-283db8174d0?source=rss-d1d139f6785------2</link>
            <guid isPermaLink="false">https://medium.com/p/283db8174d0</guid>
            <category><![CDATA[web-analytics]]></category>
            <category><![CDATA[gdpr]]></category>
            <category><![CDATA[web-analytics-tool]]></category>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[product-analytics-tools]]></category>
            <dc:creator><![CDATA[Ajin Kabeer]]></dc:creator>
            <pubDate>Tue, 27 Jun 2023 20:29:32 GMT</pubDate>
            <atom:updated>2023-07-21T23:01:42.517Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fzp21EaL-zs9cd4nLzH0Bg.png" /></figure><p>Google sunsets <strong>Universal Analytics on July 1st, 2023</strong>. This change comes as privacy norms evolve and the demand for stronger data protection increases. With Universal Analytics relying on third-party cookies and user identifiers, it has become incompatible with emerging privacy regulations.</p><p><a href="https://privacysandbox.com/intl/de_de/"><strong>The Privacy Sandbox</strong></a> is Google’s response to growing privacy concerns. It aims to replace third-party cookies with a more private system, allowing businesses to reach their customers without compromising individual privacy.</p><p>Let’s shift focus to some tools that excel in balancing data utility and user privacy.</p><ul><li><strong>Matomo</strong> ensures you retain complete ownership of your data.</li><li><strong>Plausible </strong>Analytics sidesteps the use of cookies entirely and adheres strictly to GDPR regulations.</li><li>Then there’s <strong>Fathom</strong> Analytics, which provides straightforward statistics without infringing on personal data privacy.</li></ul><p>While they do a great job of collecting site data while preserving user privacy, they aren’t exactly comprehensive when it comes to product analytics.</p><p>In my research(<em>surface-level</em>) on product analytics tools, a few names kept coming up.</p><ul><li>One is <strong>Amplitude</strong>. It’s known for giving a lot of useful information.</li><li><strong>Heap</strong> can automatically pick up all interactions on a website or app, so there’s no need for manual tracking.</li><li><strong>PostHog —</strong> Product operating system, open-source and great features.</li><li>Lastly, <strong>Mixpanel</strong> has a good reputation in product analytics.</li></ul><p>While exploring enterprise tools, <strong>Adobe Analytics</strong> stood out. It’s part of Adobe’s suite and dives deep into customer journeys.</p><p><strong>SAS Customer Intelligence</strong> cleverly combines predictive analytics with marketing automation for a comprehensive view of customers.</p><p>You might be wondering, why the sudden conversation about analytics tools? It’s because I would like to pitch a new product.</p><p>Yes, the market’s got some great tools already, but hey, who says there can’t be one more?</p><h3>Metriken, privacy-first product analytics.</h3><p><a href="https://www.metriken.ai/"><strong>Metriken</strong></a> is driven by a strong commitment to privacy. We’ve built it to function without cookies or collecting personally identifiable information. With a focus on e-commerce customers, Metriken offers valuable insights while prioritising data protection.</p><p>As a European product, Metriken places data security and GDPR compliance at the forefront. We store data securely in Europe, ensuring utmost privacy and full compliance with GDPR guidelines.</p><blockquote>We are continuously striving to refine and enhance its capabilities as a product analytics tool.</blockquote><p>Can we reach the level of these established products? Let’s find out.</p><p>In conclusion, as we bid farewell to Universal Analytics and witness the rise of more privacy-centric alternatives, it’s clear that the future of web analytics lies in striking a delicate balance between data utility and user privacy.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=283db8174d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimise Your React App Performance By Using the useMemo() and useCallback() Hooks Wisely.]]></title>
            <link>https://medium.com/swlh/optimise-your-react-app-performance-by-using-the-usememo-and-usecallback-hooks-wisely-247011181063?source=rss-d1d139f6785------2</link>
            <guid isPermaLink="false">https://medium.com/p/247011181063</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react-hook]]></category>
            <dc:creator><![CDATA[Ajin Kabeer]]></dc:creator>
            <pubDate>Fri, 04 Sep 2020 05:08:23 GMT</pubDate>
            <atom:updated>2022-09-10T10:11:23.317Z</atom:updated>
            <content:encoded><![CDATA[<h3>Optimise React App Performance Using useMemo() and useCallback() Hooks Wisely.</h3><p><em>Learn how to optimise your React app performance by using the </em><strong><em>useMemo()</em></strong><em> and </em><strong><em>useCallback() </em></strong><em>hooks correctly and also learn when to use the</em><strong><em> React.memo </em></strong><em>function.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aTUZGMNb0tlY4Vcw8_WUiQ.jpeg" /><figcaption>Unsplash</figcaption></figure><p>Did you know that React offers a function called <strong><em>React.memo</em></strong> to optimise performance? And also, did you know that React offers hooks called <strong><em>useCallback() and useMemo() </em></strong>which again can optimise the app performance?. Are you confused about when to use which technique? I will explain the most common use-cases of these techniques with a simple example so that you can learn and ship highly performant react applications in the future.</p><h3>React.memo</h3><p>React.memo is a <strong>Higher Order Component</strong>. You can wrap your component with <strong>React.memo(&lt;Component /&gt;)</strong> for a performance boost by memoising the result of the component.</p><p>Here is a simple example.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53fef7d680e96c7ec7d746d22df622b9/href">https://medium.com/media/53fef7d680e96c7ec7d746d22df622b9/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a2fca85e2f62b8588a02bced14d8abb/href">https://medium.com/media/6a2fca85e2f62b8588a02bced14d8abb/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*W3jO-WuElBXNknd8Qe95Tg.gif" /><figcaption>React app on codesandbox</figcaption></figure><p>If you look closely, every single time we click the Up button to increment the local state<strong>, </strong>our child component re-renders, which is unnecessary as the prop passed down to the child component never changes.</p><p>We can use the <strong>React.memo </strong>function to memoise the child component to avoid this un-necessary re-render. React.memo is a HOC, which will only re-render the component if the props change.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/db98af532f8e748359368e56539ee969/href">https://medium.com/media/db98af532f8e748359368e56539ee969/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*bpe5qfiYWqizLeTMKOBZ3g.gif" /><figcaption>React app on codesandbox</figcaption></figure><h3>useCallback() Hook</h3><blockquote>The useCallback() hook returns a <a href="https://en.wikipedia.org/wiki/Memoization">memoized</a> callback.</blockquote><p>To learn how to use this hook, we first need to break the memoized component we created above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*jPjrMZG-12tz2_BfrLTkdQ.gif" /><figcaption>Michael Scott has no idea, neither do I.</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9ca251a11de7670470c6d9f54b040aa/href">https://medium.com/media/f9ca251a11de7670470c6d9f54b040aa/href</a></iframe><p>I’ve passed the <strong>incrementChildState </strong>function as a prop to the child component.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e851ce9c69d9ea0e7096bee6b5c2e16/href">https://medium.com/media/5e851ce9c69d9ea0e7096bee6b5c2e16/href</a></iframe><p>Let’s now look at how it works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*ICsuj-HDN7mosJj7WpCwFQ.gif" /><figcaption>React app on codesandbox</figcaption></figure><p>So we are back to square one. Our React.memo is not working anymore, and the child component re-renders again if even if we are only incrementing the state in the parent component.</p><p><strong>useCallback()</strong> hook to the rescue :)</p><p>But before we jump in, we need to understand the concept of <strong>referential equality </strong>in JavaScript.</p><p>Here is a super-informative <a href="https://dmitripavlutin.com/how-to-compare-objects-in-javascript/#1-referential-equality">article </a>written by <a href="https://dmitripavlutin.com/"><strong>Dmitri Pavlutin</strong></a><strong> </strong>which clearly explains the concept of referential equality.</p><p>So basically, defining referential equality in our context is on every single render we are creating an entirely brand new <strong>incrementChildState </strong>function.</p><p>So our child component which is wrapped inside a React.memo HOC does a referential equality check and see’s that the <strong>setNumber </strong>prop changes on every render cycle, hence the memoized function re-render.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb3e3cc213cd7588ff821cadaeac6fe1/href">https://medium.com/media/cb3e3cc213cd7588ff821cadaeac6fe1/href</a></iframe><p>The useCallback() hook accepts two arguments and then returns a new function. The first argument is the function that we need to memoize and the second argument is a dependency array which is similar to the useEffect() hook’s dependency array, we never want the function to change, so we pass in an empty dependency array.</p><p>With this change, the <strong>memoizedCallback </strong>function will stay the same referentially.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*sZRZfetLdjr62ZwvewEnpw.gif" /><figcaption>React app on codesandbox</figcaption></figure><h3>useMemo() Hook</h3><blockquote>useMemo will only recompute the memoized value when one of the dependencies has changed. This optimization helps to avoid expensive calculations on every render.</blockquote><p>Let’s take an example where we compute the largest value in an array and render it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/35b2e5b4cc8709143eb364970a82a89c/href">https://medium.com/media/35b2e5b4cc8709143eb364970a82a89c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*2RMOOAWfS-03sAp0Mpw_GQ.gif" /><figcaption>React app on codesandbox</figcaption></figure><p>Every time we try to increment the child component state, we are computing the largest number in the array which is really inefficient and expensive computation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/897e76eb6d1e7a003968c0273dd0b413/href">https://medium.com/media/897e76eb6d1e7a003968c0273dd0b413/href</a></iframe><p><strong>useMemo()</strong> hook will accept a function as an argument, and cache the function until the arguments the function depends on actually changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*LnqWmVg90hbBwMUY1KSQhw.gif" /><figcaption>React app on codesandbox</figcaption></figure><h3>Congratulations ⚡</h3><p>If you manage to reach this far, then I hope you have learned something about useCallback(), useMemo and React.memo.</p><p>My twitter handle is <a href="https://twitter.com/kabeerajin">@kabeerajin</a></p><p>Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=247011181063" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/optimise-your-react-app-performance-by-using-the-usememo-and-usecallback-hooks-wisely-247011181063">Optimise Your React App Performance By Using the useMemo() and useCallback() Hooks Wisely.</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy create-react-app to GitHub Pages using GitHub Actions]]></title>
            <link>https://medium.com/swlh/deploy-create-react-app-to-github-pages-using-github-actions-4e95ae7fd65f?source=rss-d1d139f6785------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e95ae7fd65f</guid>
            <category><![CDATA[github-pages]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[github-actions]]></category>
            <dc:creator><![CDATA[Ajin Kabeer]]></dc:creator>
            <pubDate>Sat, 30 May 2020 14:26:22 GMT</pubDate>
            <atom:updated>2022-12-20T17:40:48.198Z</atom:updated>
            <content:encoded><![CDATA[<p>A step-by-step guide to deploy your create-react-app to GitHub Pages using GitHub Actions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U2doBF3eEw_mHMbeJBpuQg.jpeg" /></figure><p>Spin up a react application</p><p>The first thing we need is a React application of course. We will use create-react-app to build one.</p><blockquote><strong>Create React App</strong> is a comfortable environment for learning React and is the best way to start building a new single-page application to <a href="https://reactjs.org/docs/create-a-new-react-app.html">React</a>.</blockquote><p>To save you some time, I have published a create-react-app <a href="https://github.com/ajinkabeer/cra-gpages-actions-starting">repository </a>on GitHub. It has routing and a basic component setup already.</p><p><strong><em>Note</em></strong>: Make sure you wrap the top-level component with HashRouter instead of the normal BrowserRouter. GitHub Pages does not work well with BrowserRouter.</p><h3>Deploy to GitHub Pages</h3><p>Before using GitHub Actions to deploy our app, let&#39;s first deploy it manually. We will use the gh-pages package, which does all the heavy lifting for us.</p><pre>yarn add gh-pages</pre><p>It’s time to configure the package.json file.</p><pre>{<br>  &quot;name&quot;: &quot;cra-gpages-actions&quot;,<br>  &quot;version&quot;: &quot;0.1.0&quot;,<br>  &quot;private&quot;: true,<br>  &quot;homepage&quot;: &quot;/cra-gpages-actions-starting&quot;,<br>   /* Rest of config */<br>  &quot;scripts&quot;: {<br>    &quot;predeploy&quot;: &quot;yarn run build&quot;,<br>    &quot;deploy&quot;: &quot;gh-pages -d build&quot;,<br>    &quot;start&quot;: &quot;react-scripts start&quot;,<br>    &quot;build&quot;: &quot;react-scripts build&quot;,<br>    &quot;test&quot;: &quot;react-scripts test&quot;,<br>    &quot;eject&quot;: &quot;react-scripts eject&quot;<br>  },<br>  /* Rest of config */<br>}</pre><p>We have added predeploy, deploy scripts and homepage to our package.json file.</p><p><strong><em>Note</em></strong>: Make sure you put the correct repository name for homepage.</p><p>Looking good. It’s time to deploy our application on GitHub Pages.</p><pre>npm run deploy</pre><p>You have now successfully deployed the production build of your react application on GitHub pages. To view it, simply go the settings tab of your repository and scroll down until you find the link.</p><p>So, from now on you can deploy the latest changes on your react application to GitHub pages with just npm run deploy.</p><p>Here comes GitHub Actions, with this, you can just push the changes to your master branch and it will automatically create a production build and deploy it to GitHub pages.</p><h3>Add GitHub Actions to your workflow</h3><blockquote><em>GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want.</em></blockquote><p>Since we already have configured our project to work with GitHub pages, setting Actions is a walk in the park.</p><p>From your project folder, start by creating a new directory to hold the.yml file. This file will hold the configuration for our GitHub Actions. You have to create this file using this path.</p><pre>mkdir .github/workflows/<br>cd .github/workflows<br>touch deploy.yml</pre><p>Add this configuration code to deploy.yml file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5d9afcd6d4485a0460b773c305247b8/href">https://medium.com/media/b5d9afcd6d4485a0460b773c305247b8/href</a></iframe><p>To explain this configuration simply, on each and every push to the master branch, GitHub Actions will perform these set of tasks.</p><p>If you look closely, you will notice that we are using a deploy_key variable. If you have already enabled ssh for your GitHub account, you can use that public/private key pair. Else you will need to create a new one.</p><p>You can create a public/private key like this.</p><pre>cd ~/.ssh<br>ssh-keygen -t rsa -b 4096 -C &quot;$(git config user.email)&quot; -f gh-pages-actions -N &quot;&quot;</pre><p>Don’t forget to replace user.email with your e-mail address. After generating the keys, it&#39;s time to add them to our repository. Go to the settings tab of your repository. Select deploy keys from the sidebar.</p><p>You need to insert the public key you have generated into the text-area. Insert Public key of ACTIONS_DEPLOY_KEY for the title input field. Check Allow write access and click on the Add key button.</p><p>To view the public key, you can run</p><pre>cat ~/.ssh/gh-pages-actions.pub</pre><p>Next, up go to the secrets tab and add a new secret key. This is the private ssh key that you generated. You can view it like this. In the name field, add ACTIONS_DEPLOY_KEY. It&#39;s important.</p><pre>cat ~/.ssh/gh-pages-actions</pre><p>That is it. We have integrated GitHub Actions into your workflow. To test it, make some changes in your components and push it to master. To see it live, go to the GitHub Actions tab in your project repository.</p><h3>Congratulations ⚡</h3><p>If you manage to reach this far, then I hope you have successfully integrated the GitHub Actions into your workflow. If you run into any trouble, shoot a comment below.</p><p>Here is a link to my <a href="https://github.com/ajinkabeer/cra-gpages-actions">repository</a> on GitHub.</p><p>Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e95ae7fd65f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/deploy-create-react-app-to-github-pages-using-github-actions-4e95ae7fd65f">Deploy create-react-app to GitHub Pages using GitHub Actions</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Add Authentication to your React App]]></title>
            <link>https://javascript.plainenglish.io/add-a-simple-authentication-to-your-react-app-de8add1e3278?source=rss-d1d139f6785------2</link>
            <guid isPermaLink="false">https://medium.com/p/de8add1e3278</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[okta]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ajin Kabeer]]></dc:creator>
            <pubDate>Thu, 28 Nov 2019 05:46:56 GMT</pubDate>
            <atom:updated>2019-12-05T10:53:37.814Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to add authentication to your React application with Okta</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*FamqtVlugMzPKH2iVCl1FQ.jpeg" /></figure><p>Today, I will show you how you can add a simple authentication to your React application that uses authentication from Okta which is a user management system that can be used across multiple apps built on multiple language or frameworks.</p><p>It is similar to Auth0. You can use it across multiple apps and you can even use it with the apps built on different languages and platforms.</p><p>Currently Okta supports the following languages:</p><ul><li>Android</li><li>Angular</li><li>iOS</li><li>Java</li><li>.NET</li><li>Node.js</li><li>PHP</li><li>React</li></ul><h3>Sign-Up</h3><p>Before you can integrate Okta into your react application, you will need a Okta developer account. So go ahead and create your free account right now.</p><p><a href="https://developer.okta.com/signup/">Free Okta Developer Account</a></p><h3>Okta Dashboard</h3><p>After creating your free account, you will be redirected to the dashboard. Did you notice the <strong>Org URL</strong> in the dashboard. You will need that for your application. The dashboard also has user metrics and system logs that shows all the activities.</p><figure><img alt="okta dashboard" src="https://cdn-images-1.medium.com/max/1024/1*kYCXeZt-iZxo2buAGy_aiQ.png" /></figure><h3>Register Your React Application</h3><p>Its time to register your react application. Click on the <strong>Applications</strong> link on the dashboard.</p><ul><li>Click on Add Application</li><li>Choose Single Page App</li><li>Add a name to your app in the Name field</li></ul><p>Now, you have to edit the <strong>Base URIs</strong> field. I am going to assume that you are using create-react-app on your local server.</p><p><a href="http://localhost:3000/">http://localhost:3000</a></p><p>Same thing with Login redirect URIs &amp; <strong>Click Done</strong></p><p><a href="http://localhost:3000/implicit/callback">http://localhost:3000/implicit/callback</a></p><p>Now your application is registered and you will get a <strong>Client ID</strong></p><h3>Fire up your code editor</h3><ul><li>Navigate to your project folder</li><li>Add the necessary packages</li></ul><p>yarn add react-router-dom @okta/okta-react @okta/signin-widget</p><p>For the sake of this example, let’s assume that your react application has three pages which are in private routes and only authorized user’s have access to this routes.</p><p>/home /user /order</p><h3>Create a Login component</h3><p>Create a new folder called <em>auth</em> in your components folder and create a new file called Login.js with the following code.</p><pre>import React, { Component } from &#39;react&#39;;<br>import { Redirect } from &#39;react-router-dom&#39;;<br>import OktaSignInWidget from &#39;./SigninWidget&#39;;<br>import { withAuth } from &#39;@okta/okta-react&#39;;<br><br>export default withAuth(class Login extends Component {<br>  constructor(props) {<br>    super(props);<br>    this.state = {<br>      authenticated: null<br>    };<br>    this.checkAuthentication();<br>  }<br><br>  async checkAuthentication() {<br>    const authenticated = await this.props.auth.isAuthenticated();<br>    if (authenticated !== this.state.authenticated) {<br>      this.setState({ authenticated });<br>      this.props.history.push(&#39;/home&#39;)<br><br>    }<br>  }<br><br>  componentDidUpdate() {<br>    this.checkAuthentication();<br>  }<br><br>  onSuccess = (res) =&gt; {<br>    if (res.status === &#39;SUCCESS&#39;) {<br>      return this.props.auth.redirect({<br>        sessionToken: res.session.token<br>      });<br>   } else {<br>    // The user can be in another authentication state that requires further action.<br>    // For more information about these states, see:<br>    //   https://github.com/okta/okta-signin-widget#rendereloptions-success-error<br>    }<br>  }<br><br>  onError = (err) =&gt; {<br>    console.log(&#39;error logging in&#39;, err);<br>  }<br><br>  render() {<br>    if (this.state.authenticated === null) return null;<br>    return this.state.authenticated ?<br>      &lt;Redirect to={{ pathname: &#39;/&#39; }}/&gt; :<br>      &lt;OktaSignInWidget<br>        baseUrl={this.props.baseUrl}<br>        onSuccess={this.onSuccess}<br>        onError={this.onError}/&gt;;<br>  }<br>});</pre><p>Next up, you need to create a new file called <em>SigninWidget</em> in the same <em>auth</em> directory with the following code.</p><pre>*SigninWidget.js*<br><br>import React, { Component } from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom&#39;;<br>import OktaSignIn from &#39;@okta/okta-signin-widget&#39;;<br>import &#39;@okta/okta-signin-widget/dist/css/okta-sign-in.min.css&#39;;<br><br> class SigninWidget extends Component {<br>  componentDidMount() {<br>    const el = ReactDOM.findDOMNode(this);<br>    this.widget = new OktaSignIn({<br>      baseUrl: this.props.baseUrl,<br>      authParams: {<br>        pkce: true<br>      },<br>    });<br>    this.widget.renderEl({el}, this.props.onSuccess, this.props.onError);<br>  }<br><br>  componentWillUnmount() {<br>    this.widget.remove();<br>  }<br><br>  render() {<br>    return &lt;div /&gt;;<br>  }<br>};<br><br>export default SigninWidget</pre><p>Next step is to update your route file. Here is an example from my Okta implementation. Wrap private routes inside <strong>SecureRoute </strong>component and also replace <strong>Client ID</strong> and <strong>issuer </strong>with your own credentials from Okta developer console.</p><pre>import React from &quot;react&quot;;<br>import { BrowserRouter as Router, Route } from &quot;react-router-dom&quot;;<br>import Order from &quot;./pages/Order.js&quot;;<br>import Home from &quot;./pages/Home.js&quot;;<br>import Users from &quot;./pages/Users.js&quot;;<br>import Login from &quot;./components/auth/Login&quot;;<br>import { Security, SecureRoute, ImplicitCallback } from &quot;@okta/okta-react&quot;;<br><br>function onAuthRequired({ history }) {<br>  history.push(&quot;/login&quot;);<br>}<br><br>const AppRoute = () =&gt; (<br>  &lt;Router&gt;<br>    &lt;Security<br>      issuer=&quot;https://dev-944example.okta.com/oauth2/default&quot; //Replace with your ORG URI.<br>      clientId=&quot;0oa1ws12avokObj45C357example&quot; //Replace with your own client id<br>      redirectUri={window.location.origin + &quot;/implicit/callback&quot;}<br>      onAuthRequired={onAuthRequired}<br>    &gt;<br>      &lt;SecureRoute exact path=&quot;/orders&quot; component={Order} /&gt;<br>      &lt;SecureRoute exact path=&quot;/users&quot; component={Users} /&gt;<br>      &lt;Route exact path=&quot;/&quot; component={Home} /&gt;<br>      &lt;Route<br>        path=&quot;/login&quot;<br>        render={() =&gt; &lt;Login baseUrl=&quot;https://dev-968924.okta.com&quot; /&gt;}<br>      /&gt;<br>      &lt;Route path=&quot;/implicit/callback&quot; component={ImplicitCallback} /&gt;<br>    &lt;/Security&gt;<br>  &lt;/Router&gt;<br>);<br><br>export default AppRoute;</pre><h3>Create a Logout function</h3><p>This is the final step. You’ll want to create a logout button in your home.js file or root file which is rendered to the user after logging in and don’t forget to wrap your function inside <strong>withAuth </strong>to use the <strong>auth</strong> props.</p><pre>import { withAuth } from &quot;@okta/okta-react&quot;;<br>import Breadcrumb from &#39;./breadcrumb.js&#39;<br>class Home extends Component {<br>  logout = async () =&gt; {<br>    this.props.auth.logout(&quot;/&quot;);<br>  };<br><br>  render() {<br>    return (<br>      &lt;&gt;<br>        &lt;Breadcrumb home=&quot;Logout&quot; click={this.logout} /&gt;<br>      &lt;/&gt;<br>    );<br>  }<br>}<br><br>export default withAuth(Home);</pre><h3>Congratulations! 🎉</h3><p>If you manage to reach this far, then I hope you have successfully integrated Okta authentication in your react application. If you run into any trouble, shoot a comment below. I will help you solve it.</p><p>This is my first post here. I will be back with a new one soon.</p><p>Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de8add1e3278" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/add-a-simple-authentication-to-your-react-app-de8add1e3278">Add Authentication to your React App</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>