0.1.1004530 • Published 15 days ago

userflow.js-self-hosted v0.1.1004530

Weekly downloads
-
License
-
Repository
-
Last release
15 days ago

Self-hosted Userflow.js

IMPORTANT: This is a WIP! Unless you've been explicitly told by Userflow to use this package, you should use our CDN-hosted version instead. See https://userflow.com/install

Userflow.js is hosted on Userflow's CDN (running on Cloudflare). We always recommend using the official Userflow.js CDN, unless you have very specific requirements as detailed in this document. See Userflow.js installation via CDN

This package allows you to self-host Userflow.js. This may be required in cases such as:

  • Chrome Extensions using manifest v3, which does not allow for loading remote JavaScript code.
  • When Userflow.js is deployed on customers' machines running behind a firewall. In this case, you're also responsible for proxying requests to Userflow's backend, which is not detailed in this document.

Backwards compatibility

Userflow.js connects to Userflow's backend and communicates about flows and user activity. When you use our official CDN, you're always guaranteed to run on the latest Userflow.js version. We occasionally, but rarely, introduce backwards incompatible changes between old Userflow.js versions and the currently deployed Userflow backend. We strive to keep old Userflow.js clients (browsers that have not refreshed in days, for example) working for at least 2 weeks. But this is not a strict guarantee - there could be very rare cases, where outdated and unsupported clients are rejected sooner.

If you choose to self-host, your Userflow.js version may run behind what the Userflow backend is designed to work with. It is therefore your responsibility to periodically upgrade to the latest userflow.js-self-hosted package version.

The consequence of an outdated and unsupported Userflow.js client version connecting to the Userflow backend, would simply be that no Userflow content will show, and calls to userflow.identify(), userflow.start() etc. will fail.

Contact Userflow if you require a more tightly controlled service agreement with explicit backwards compatibility guarantees.

Versioning

userflow.js-self-hosted uses Semantic Versioning, where versions are on the format 1.0.<USERFLOW_BUILD>, where <USERFLOW_BUILD> is a Userflow-internal build number (always incrementing). Example: 1.0.1002407. As long as the major version is 1, you can expect no changes in how to consume the package. If we one day change the structure of the package, requiring you to do some work, it'll be under a new major version, e.g. 2.0.<USERFLOW_BUILD>. This means it should always be safe and maintenance-free for you to upgrade to the latest patch version.

Usage

Install from npm:

npm install userflow.js-self-hosted

The package contains ES modules and a few CSS files. The entrypoint is ./userflow.js, whose default export is the userflow object - the one you call userflow.init() etc. on.

From your own code, you can import ./userflow.js via a dynamic import() call. Then grab the default export from that. Example:

const {default: userflow} = await import(
  'path/to/userflow.js-self-hosted/userflow.js'
)
userflow.init('<TOKEN>')
// userflow.identify(...) etc.

It'll automatically and lazily figure out how to import further modules from the same location as ./userflow.js was loaded from. For example, it won't load the resource center code if you're not using it. It'll also load CSS files from the same location. It never touches the official CDN at js.userflow.com (except if you use our default avatar SVGs).

You may also be able to use a bundler, such as Webpack, to transform the code into whatever format you want.

Usage in Chrome Extensions

Here's a super simple Chrome Extension which installs Userflow.js on myapp.com. It assumes that you've already installed userflow.js-self-hosted as an npm package.

manifest.json:

{
  "manifest_version": 3,
  "name": "Demo",
  "description": "Just a demo of using Userflow.js in manifest v3",
  "version": "0.1.0",
  "content_scripts": [
    {
      "matches": ["https://myapp.com/*"],
      "js": ["content-script.js"]
    }
  ],
  "web_accessible_resources": [
    {
      "matches": ["<all_urls>"],
      "resources": ["node_modules/userflow.js-self-hosted/*"]
    }
  ]
}

content-script.js:

;(async () => {
  const {default: userflow} = await import(
    chrome.runtime.getURL('node_modules/userflow.js-self-hosted/userflow.js')
  )
  userflow.init('<TOKEN>')
  // userflow.identify(...) etc.
})()

Since ./userflow.js is an ES module (so are all other .js files in the package), and Chrome extensions don't use ES modules themselves directly, you have to include it in your content script via this dynamic import() call. It's important to add the userflow.js-self-hosted package's path under web_accessible_resources in your manifest.json.

Userflow.js documentation

0.1.1004530

15 days ago

0.1.1004519

16 days ago

0.1.1004513

17 days ago

0.1.1004474

25 days ago

0.1.1004389

1 month ago

0.1.1004371

1 month ago

0.1.1004377

1 month ago

0.1.1004327

2 months ago

0.1.1004325

2 months ago

0.1.1004280

2 months ago

0.1.1004281

2 months ago

0.1.1004276

2 months ago

0.1.1004235

3 months ago

0.1.1004233

3 months ago

0.1.1004224

3 months ago

0.1.1004223

3 months ago

0.1.1004226

3 months ago

0.1.1004222

3 months ago

0.1.1004209

3 months ago

0.1.1004206

3 months ago

0.1.1004207

3 months ago

0.1.1004191

3 months ago

0.1.1004186

4 months ago

0.1.1004182

4 months ago

0.1.1004175

4 months ago

0.1.1004158

4 months ago

0.1.1004155

4 months ago

0.1.1004153

4 months ago

0.1.1004123

5 months ago

0.1.1004122

5 months ago

0.1.1004108

5 months ago

0.1.1004104

5 months ago

0.1.1004068

5 months ago

0.1.1003917

6 months ago

0.1.1003916

6 months ago

0.1.1004059

6 months ago

0.1.1003880

7 months ago

0.1.1004053

6 months ago

0.1.1004080

5 months ago

0.1.1004081

5 months ago

0.1.1004005

6 months ago

0.1.1004001

6 months ago

0.1.1003955

6 months ago

0.1.1004071

5 months ago

0.1.1004077

5 months ago

0.1.1004075

5 months ago

0.1.1003850

7 months ago

0.1.1003972

6 months ago

0.1.1004024

6 months ago

0.1.1003973

6 months ago

0.1.1003968

6 months ago

0.1.1003967

6 months ago

0.1.1004041

6 months ago

0.1.1004042

6 months ago

0.1.1003914

6 months ago

0.1.1003878

7 months ago

0.1.1003988

6 months ago

0.1.1003773

7 months ago

0.1.1003416

10 months ago

0.1.1003813

7 months ago

0.1.1003417

10 months ago

0.1.1003364

10 months ago

0.1.1003804

7 months ago

0.1.1003829

7 months ago

0.1.1003270

11 months ago

0.1.1003278

11 months ago

0.1.1003557

9 months ago

0.1.1003816

7 months ago

0.1.1003268

11 months ago

0.1.1003662

8 months ago

0.1.1003825

7 months ago

0.1.1003308

11 months ago

0.1.1003826

7 months ago

0.1.1003821

7 months ago

0.1.1003269

11 months ago

0.1.1003607

9 months ago

0.1.1003450

10 months ago

0.1.1003617

9 months ago

0.1.1003614

9 months ago

0.1.1003459

10 months ago

0.1.1003698

8 months ago

0.1.1003443

10 months ago

0.1.1003840

7 months ago

0.1.1003441

10 months ago

0.1.1003606

9 months ago

0.1.1003329

11 months ago

0.1.1003602

9 months ago

0.1.1003206

11 months ago

0.1.1003510

10 months ago

0.1.1003594

9 months ago

0.1.1003515

10 months ago

0.1.1003512

10 months ago

0.1.1003618

9 months ago

0.1.1003224

11 months ago

0.1.1003343

10 months ago

0.1.1003469

10 months ago

0.1.1003622

9 months ago

0.1.1002918

1 year ago

0.1.1002761

1 year ago

0.1.1002564

1 year ago

0.1.1002726

1 year ago

0.1.1002888

1 year ago

0.1.1002842

1 year ago

0.1.1002964

1 year ago

0.1.1002920

1 year ago

0.1.1002884

1 year ago

0.1.1002643

1 year ago

0.1.1002904

1 year ago

0.1.1003124

12 months ago

0.1.1002872

1 year ago

0.1.1002990

1 year ago

0.1.1003123

12 months ago

0.1.1002870

1 year ago

0.1.1002912

1 year ago

0.1.1002558

1 year ago

0.1.1002559

1 year ago

0.1.1003129

12 months ago

0.1.1002876

1 year ago

0.1.1002874

1 year ago

0.1.1002859

1 year ago

0.1.1002738

1 year ago

0.1.1002739

1 year ago

0.1.1003114

1 year ago

0.1.1003034

1 year ago

0.1.1002661

1 year ago

0.1.1003153

12 months ago

0.1.1002989

1 year ago

0.1.1002902

1 year ago

0.1.1002743

1 year ago

0.1.1002865

1 year ago

0.1.1002744

1 year ago

0.1.1002667

1 year ago

0.1.1002863

1 year ago

0.1.1002929

1 year ago

0.1.1002848

1 year ago

0.1.1002727

1 year ago

0.1.1002893

1 year ago

0.1.1003142

12 months ago

0.1.1002934

1 year ago

0.1.1002856

1 year ago

0.1.1002975

1 year ago

0.1.1002775

1 year ago

0.1.1002544

1 year ago

0.1.1002542

1 year ago

0.1.1002534

1 year ago

0.1.1002513

1 year ago

0.1.1002512

1 year ago

0.1.1002497

1 year ago

0.1.1002486

1 year ago

0.1.1002482

1 year ago

0.1.1002477

1 year ago

0.1.1002471

1 year ago

0.1.1002468

1 year ago

0.1.1002465

1 year ago

0.1.1002463

1 year ago

0.1.1002462

1 year ago

0.1.1002461

1 year ago

0.1.1002460

1 year ago

0.1.1002459

1 year ago

0.1.1002458

1 year ago

0.1.1002457

1 year ago

0.1.1002455

1 year ago

0.0.2000010

1 year ago

0.0.2000009

1 year ago

0.0.2000008

1 year ago

0.0.2000007

1 year ago

0.0.2000006

1 year ago

0.0.2000005

1 year ago

0.0.2000004

1 year ago

0.0.2000003

1 year ago

0.0.2000002

1 year ago

0.0.2000001

1 year ago