Live Activity Feed on Website

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

Live Activity Feed Implementation on Website

Live Activity Feed is a stream of real-time events: "Ivan bought item", "Maria left review", "5 people viewing now". Creates sense of live activity and social proof.

Server Event Generation

class ActivityFeedService {
  async publishActivity(event: ActivityEvent): Promise<void> {
    // Save to DB for new visitors
    await this.activityRepo.create(event);

    // Publish to Redis for live subscribers
    await this.redis.publish('activity:feed', JSON.stringify(event));

    // Clean old events (keep 24 hours)
    await this.activityRepo.deleteOlderThan(24 * 60 * 60 * 1000);
  }
}

// Integration with business logic
orderService.on('order:created', async (order) => {
  const product = await productRepo.findById(order.items[0].productId);

  await activityFeed.publishActivity({
    type: 'purchase',
    text: `${anonymizeName(order.customerName)} bought "${product.name}"`,
    location: order.customerCity,
    timestamp: new Date(),
    metadata: { productId: product.id }
  });
});

SSE Feed Endpoint

app.get('/api/activity/stream', (req, res) => {
  res.setHeader('Content-Type', 'text/event-stream');
  res.setHeader('Cache-Control', 'no-cache');
  res.setHeader('Connection', 'keep-alive');

  // Send last 10 events
  activityRepo.findRecent(10).then(events => {
    res.write(`event: init\ndata: ${JSON.stringify(events)}\n\n`);
  });

  // Subscribe to new
  const subscriber = redis.duplicate();
  subscriber.subscribe('activity:feed');

  subscriber.on('message', (_, message) => {
    res.write(`event: activity\ndata: ${message}\n\n`);
  });

  const heartbeat = setInterval(() => res.write(':ping\n\n'), 20000);

  req.on('close', () => {
    clearInterval(heartbeat);
    subscriber.unsubscribe();
    subscriber.quit();
  });
});

React Component

function ActivityFeed() {
  const [activities, setActivities] = useState<Activity[]>([]);

  useEffect(() => {
    const source = new EventSource('/api/activity/stream');

    source.addEventListener('init', (e) => {
      setActivities(JSON.parse(e.data));
    });

    source.addEventListener('activity', (e) => {
      const activity = JSON.parse(e.data);
      setActivities(prev => [activity, ...prev].slice(0, 20));
    });

    return () => source.close();
  }, []);

  return (
    <div className="activity-feed">
      {activities.map((activity, i) => (
        <ActivityItem key={activity.id} activity={activity}
          style={{ opacity: Math.max(0.3, 1 - i * 0.05) }} />
      ))}
    </div>
  );
}

function ActivityItem({ activity, style }) {
  const icons = { purchase: '🛍', review: '⭐', view: '👁' };

  return (
    <div className="activity-item" style={style}>
      <span className="icon">{icons[activity.type]}</span>
      <span className="text">{activity.text}</span>
      <span className="time">{formatRelativeTime(activity.timestamp)}</span>
    </div>
  );
}

Anti-Spam and Realism

// Deduplication — don't show same events in a row
const recentTexts = new Set<string>();

async function shouldPublish(event: ActivityEvent): Promise<boolean> {
  const key = `${event.type}:${event.metadata?.productId}`;
  if (recentTexts.has(key)) return false;

  recentTexts.add(key);
  setTimeout(() => recentTexts.delete(key), 30 * 1000);  // 30 sec cooldown
  return true;
}

Timeline

Activity Feed with SSE, Redis and React component: 3–5 days.