[Pendo] initialize pendo with segment anonymous_id
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- api
Research direction
Start by reading the referenced analytics-next browser initialization flow and the Pendo integration in integrations/pendo/lib/index.js, especially its identify behavior. Reproduce initialization through Segment with an anonymous_id, then trace whether Pendo receives it before integrations load. Done means Pendo receives the Segment anonymous ID during initialization without overwriting existing Pendo visitor or account data.
Written by the indexing model from the issue text.
Description
When using pendo through segment, the segment anonymous id does not always reach pendo. I am not entirely sure what the issue in this library is, but it is likely related to issues: #317, #325, and #349.
It seems like the pendo integration is initialized before segment. I came to this conclusion after seeing this comment
With AJS classic, we allow users to call setAnonymousId before the library initialization.
This is important because some of the destinations will use the anonymousId during the initialization,
and if we set anonId afterwards, that wouldn’t impact the destination.Also Ensures events can be registered before library initialization.
This is important so users can register to 'initialize' and any events that may fire early during setup.
in analytics-next library and then attempting to call setAnonymousId before segment is initialized. This change should ensure that it is flushed and create a segment anonymous id before the integrations are loaded/initialized however even after this change the pendo destination was not receiving that segment anonymous id even though it did exist.
A temporary fix for this is hooking into segments 'initialize' event and forcing the expected pendo behavior (the stuff that the pendo integration does on identify):
// analytics.js snippet file
analytics.setAnonymousId();
analytics.on("initialize", function () {
// we want to make sure that we use segments pendoified anonymous id or
// segments user id
var isUserAnonymous = !this._user.id();
var id = isUserAnonymous
? "_PENDO_T_" + this._user.anonymousId()
: this._user.id();
// pendo options only requires visitor/account metadata
var options = {};
var visitor = Object.assign({ id: id }, this._user.traits());
options.visitor = visitor;
var account = Object.assign(
{ id: this._group.id() },
this._group.traits()
);
options.account = account;
// ensure that on initialize pendo will have segment data and that if
// segment data already exists it is not overwritten
window.pendo_options.visitor = Object.assign(
options.visitor,
window.pendo_options.visitor
);
window.pendo_options.account = Object.assign(
options.account,
window.pendo_options.account
);
});
analytics.load()
- Dominant language
- JavaScript
- Stars
- 125
- Forks
- 134
- Avg merge
- 2d 53m
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from segmentio/analytics.js-integrations
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
segmentio/analytics.js-integrations#784 · 2 comments · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
segmentio/analytics.js-integrations#761 · 8 comments ·
All issues in segmentio/analytics.js-integrations
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
t0ggles
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
nolimits4web/swiper#8240 · 1 comment ·
-
netbox status: backlog topic: testing type: housekeeping
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
netbox-community/netbox#23395 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
[scanner] check:spelling skips blog/ — posts and author metadata are never spell-checkedPossibly taken @hivecommons-hive claimed this today. Openagent/scanner bug hive/covered-by-pr hive/hosted-available-lke648397-260827-5n31
Difficulty 1/5 Under an hour Newbie friendliness 72/100
cncf/endusers#1452 · 1 comment ·
Maintainers usually reply within 1 day