Support for multiple write keys.

Đang mở
#367 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, typescript
Lĩnh vực
analytics

Hướng nghiên cứu

Start with the linked reproduction, using public/index.html and src/index.tsx to load both analytics-next instances with separate write keys. Reload the application and inspect requests to the p endpoint while only the window.analytics instance sends a page event. Done means concurrent loading no longer produces a request from the other instance.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

Hello,

We were led to believe that it is possible to run two instances of analytics-next with different write keys side by side. One via segment source snippet (exposed on window.analytics) and the other one as an npm module.

When we try to do this, it mostly works with one quirk/bug. If the two instances are loading concurrently (which is the common scenario), it can happen that events fired via window.analytics (segment source snippet) cause two network requests - one using the segment source snippet write key and the other one using npm module's source key. Once both instances are finished loading they behave as expected with each only firing network requests for its own events.

We were speculating that this is due to the fact that window.analytics as provided by snippet creates a queueing implementation of methods (to be used before the analytics-next is fully loaded) and then somehow snippet and npm module versions both read and fire events on that queue. Not sure if this is actually the case - it's just a guess.

I assembled a small sample application that demonstrates the issue. It loads analytics-next from both snippet and npm module, but only fires a page event on the snippet version. If you reload the page several times, you should see examples of that single page event causing two requests to be sent to a p endpoint. See:
Two requests to p

You will of course need to provide your own write keys here and here.

Using multiple instances of analytics with different write keys seems to have been something that was "advertised" as a feature, and when talking to our Segment representative they said that this should be possible with analytics-next as well.

Thanks for any help or further info.

Ngôn ngữ chính
TypeScript
Star
480
Fork
163
Merge trung bình
6 ngày 6 giờ
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của segmentio/analytics-next

Tất cả issue của segmentio/analytics-next

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.