Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ Hellotext.initialize('HELLOTEXT_BUSINESS_ID', configurationOptions)
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- | ----------------------------------------- |
| session | A valid Hellotext session which was stored previously. When not set, Hellotext attempts to retrieve the stored value from `document.cookie` when available, otherwise it creates a new session. | String | null |
| autoGenerateSession | Whether the library should automatically generate a session when no session is found in the query or the cookies | Boolean | true |
| tracking | Whether `Hellotext.track` sends events. Pass `false` when the visitor refused analytics: popups, webchat and forms keep working. | Boolean | true |
| forms | An object that controls how Hellotext should control the forms on the page. See [Forms](/docs/forms.md) documentation for more information. | Object | { autoMount: true, successMessage: true } |
| popup | Options for the dashboard popup, or `false` to disable automatic popup mounting. See [Popups](/docs/popups.md). | Object \| false | Dashboard popup when configured |
| webchat | An object that overrides the dashboard webchat configuration, or `false` to disable automatic webchat mounting. See [Webchat](/docs/webchat.md). | Object \| false | Dashboard webchat when configured |
Expand Down
12 changes: 12 additions & 0 deletions __tests__/hellotext_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,18 @@ describe("when the class is initialized successfully", () => {
expect(response.succeeded).toEqual(true)
});

it("sends nothing when the visitor refused tracking", async () => {
global.fetch = jest.fn()
Configuration.assign({ tracking: false })

try {
await expect(Hellotext.track("page.viewed")).resolves.toBeUndefined()
expect(global.fetch).not.toHaveBeenCalled()
} finally {
Configuration.assign({ tracking: true })
}
});

it("records supported popup activity only after the server accepts it", async () => {
global.fetch = jest.fn().mockResolvedValue({
json: jest.fn().mockResolvedValue({received: "success"}),
Expand Down
2 changes: 1 addition & 1 deletion dist/hellotext.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/webchat-emoji-en.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/webchat-emoji-es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/webchat-emoji.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface HellotextConfig {
push?: false | HellotextPushConfig
session?: string
autoGenerateSession?: boolean
tracking?: boolean
}

export type HellotextWebchatMode = 'modal' | 'popover'
Expand Down
2 changes: 2 additions & 0 deletions lib/core/configuration.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var _push = require("./configuration/push");
* Configuration for Hellotext
* @property {Boolean} [autoGenerateSession=true] - whether to auto generate session or not
* @property {String} [session] - session id
* @property {Boolean} [tracking=true] - whether events are sent, false when the visitor refused tracking
* @property {Forms} [forms] - form configuration
* @property {Popup} [popup] - popup configuration
* @property {Webchat} [webchat] - webchat configuration
Expand All @@ -28,6 +29,7 @@ class Configuration {
static actionCableUrl = 'wss://www.hellotext.com/cable';
static autoGenerateSession = true;
static session = null;
static tracking = true;
static forms = _forms.Forms;
static popup = _popup.Popup;
static webchat = _webchat.Webchat;
Expand Down
2 changes: 2 additions & 0 deletions lib/core/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Push } from './configuration/push';
* Configuration for Hellotext
* @property {Boolean} [autoGenerateSession=true] - whether to auto generate session or not
* @property {String} [session] - session id
* @property {Boolean} [tracking=true] - whether events are sent, false when the visitor refused tracking
* @property {Forms} [forms] - form configuration
* @property {Popup} [popup] - popup configuration
* @property {Webchat} [webchat] - webchat configuration
Expand All @@ -23,6 +24,7 @@ class Configuration {
static actionCableUrl = 'wss://www.hellotext.com/cable';
static autoGenerateSession = true;
static session = null;
static tracking = true;
static forms = Forms;
static popup = Popup;
static webchat = Webchat;
Expand Down
1 change: 1 addition & 0 deletions lib/hellotext.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class Hellotext {
if (this.notInitialized) {
throw new _errors.NotInitializedError();
}
if (_core.Configuration.tracking === false) return;
const business = this.business;
const session = this.session;
const headers = {
Expand Down
1 change: 1 addition & 0 deletions lib/hellotext.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class Hellotext {
if (this.notInitialized) {
throw new NotInitializedError();
}
if (Configuration.tracking === false) return;
const business = this.business;
const session = this.session;
const headers = {
Expand Down
2 changes: 2 additions & 0 deletions src/core/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Push } from './configuration/push'
* Configuration for Hellotext
* @property {Boolean} [autoGenerateSession=true] - whether to auto generate session or not
* @property {String} [session] - session id
* @property {Boolean} [tracking=true] - whether events are sent, false when the visitor refused tracking
* @property {Forms} [forms] - form configuration
* @property {Popup} [popup] - popup configuration
* @property {Webchat} [webchat] - webchat configuration
Expand All @@ -24,6 +25,7 @@ class Configuration {

static autoGenerateSession = true
static session = null
static tracking = true

static forms = Forms
static popup = Popup
Expand Down
2 changes: 2 additions & 0 deletions src/hellotext.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ class Hellotext {
throw new NotInitializedError()
}

if (Configuration.tracking === false) return

const business = this.business
const session = this.session
const headers = {
Expand Down
Loading