segmentio / segmentio/analytics.js-integrations

[appboy] integration snippet needs update (or replacement with npm require)

Open
#111 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
125
Forks
136
Avg merge
2h 45m
Merged PRs (30d)
1

Description

Migrated from #33 by @froodian

The current integration is using a loading snippet at https://github.com/segment-integrations/analytics.js-integration-appboy/blob/fd6b5cdd65398c6cdaddb30d4f952e5a5de35384/lib/index.js#L124 that's somewhat different from the default one at https://github.com/Appboy/appboy-web-sdk#getting-started, and it's causing loading failures (js errors) in some environments. The issue is that it explicitly gives appboy and appboyQueue the window namespace (window.appboy, window.appboyQueue), but pushes to the appboyQueue in the global namespace. There were some updates on the Braze end around this snippet a while back to improve this situation, so it's possible it's simply outdated.

A larger point I want to raise here though is that this entire snippet with the appboyQueue structure was designed to be put in the <head> of an HTML page for naive clients in a raw html environment, and exists to handle method calls that happen before the script has loaded. Given that in this integration, the script is instead loaded with this.load('v2', function() {, that snippet could be removed entirely and all methods on appboy simply called within the callback function.

Even simpler in fact, given the npm environment, would be to do npm install --save-dev appboy-web-sdk, var appboy = require('appboy-web-sdk'); and then you can just immediately call appboy.initialize and start calling methods from there. I'm not sure how you'd want to handle your v1 and v2 support however.

Given that there are a few different options here, I leave it to you to choose which one you want in your codebase, but that mismatch between window.appboyQueue= and appboyQueue.push should be rectified somehow, and I can tell you that internally the SDK draws from appboyQueue if it exists (and ignores it gracefully if it doesn't), so this code should either define and push to that, or omit it entirely.

Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/index.js around line 124 and compare the current loading snippet with Appboy's getting-started snippet. Trace how this.load('v2', function() { handles the SDK and consider the stated snippet, callback, and npm-require options, including v1 and v2 support. Done means loading no longer fails from the appboyQueue namespace mismatch and the chosen approach works consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.