From 19a16ce506e4625020f3843915566c7a8935c24c Mon Sep 17 00:00:00 2001 From: Ayush Gupta <> Date: Tue, 10 Jan 2023 19:47:24 +0530 Subject: [PATCH 1/2] added track events to hellobar event trigger --- integrations/hello-bar/HISTORY.md | 5 +++++ integrations/hello-bar/lib/index.js | 15 +++++++++++++++ integrations/hello-bar/package.json | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/integrations/hello-bar/HISTORY.md b/integrations/hello-bar/HISTORY.md index 92b511ce3..0b0549e8a 100644 --- a/integrations/hello-bar/HISTORY.md +++ b/integrations/hello-bar/HISTORY.md @@ -1,3 +1,8 @@ +3.0.2 / 2023-01-10 +================== + + * Hook segment track events to hellobar event trigger + 3.0.0 / 2017-06-06 ================== diff --git a/integrations/hello-bar/lib/index.js b/integrations/hello-bar/lib/index.js index 5a00b2302..cf1efbe0c 100644 --- a/integrations/hello-bar/lib/index.js +++ b/integrations/hello-bar/lib/index.js @@ -30,3 +30,18 @@ Hellobar.prototype.initialize = function() { Hellobar.prototype.loaded = function() { return typeof window.hellobar === 'function'; }; + +/** + * Track. + * + * https://hellobarassist.freshdesk.com/support/solutions/articles/44002393650-triggering-popups-and-bars-on-a-user-event + * + * @api public + * @param {Track} track + */ + + Hellobar.prototype.track = function(track) { + var event = track.event(); + var properties = track.properties(); + window.hellobar.trigger.event(event, properties); +}; diff --git a/integrations/hello-bar/package.json b/integrations/hello-bar/package.json index 5575c1fd3..4587f03c9 100644 --- a/integrations/hello-bar/package.json +++ b/integrations/hello-bar/package.json @@ -1,7 +1,7 @@ { "name": "@segment/analytics.js-integration-hellobar", "description": "The Hellobar analytics.js integration.", - "version": "3.0.1", + "version": "3.0.2", "keywords": [ "analytics.js", "analytics.js-integration", From 388c7429e6e0740d2bed2b351adc2f9a9b1a0bc2 Mon Sep 17 00:00:00 2001 From: Ayush Gupta <> Date: Wed, 11 Jan 2023 15:41:01 +0530 Subject: [PATCH 2/2] add track test case and fix loaded condition for hellobar integration --- integrations/hello-bar/lib/index.js | 4 ++-- integrations/hello-bar/test/index.test.js | 28 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/integrations/hello-bar/lib/index.js b/integrations/hello-bar/lib/index.js index cf1efbe0c..3b273c5b3 100644 --- a/integrations/hello-bar/lib/index.js +++ b/integrations/hello-bar/lib/index.js @@ -18,7 +18,7 @@ var Hellobar = (module.exports = integration('Hello Bar') /** * Initialize. * - * https://s3.amazonaws.com/scripts.hellobar.com/bb900665a3090a79ee1db98c3af21ea174bbc09f.js + * https://my.hellobar.com/a18c23dec1b87e9401465165eca61459d405684d.js * * @api public */ @@ -28,7 +28,7 @@ Hellobar.prototype.initialize = function() { }; Hellobar.prototype.loaded = function() { - return typeof window.hellobar === 'function'; + return !!window.hellobarSiteSettings; }; /** diff --git a/integrations/hello-bar/test/index.test.js b/integrations/hello-bar/test/index.test.js index 9f0c87cad..b6ce15331 100644 --- a/integrations/hello-bar/test/index.test.js +++ b/integrations/hello-bar/test/index.test.js @@ -60,6 +60,34 @@ describe('Hellobar', function() { analytics.load(hellobar, done); }); }); + + describe('after loading', function() { + beforeEach(function(done) { + analytics.initialize(); + analytics.page(); + analytics.once('ready', done); + }); + + describe('#track', function() { + beforeEach(function() { + analytics.stub(window.hellobar.trigger, 'event'); + }); + + it('should send trigger an event', function() { + analytics.track('event'); + analytics.called(window.hellobar.trigger.event, 'event', {}); + }); + + it('should send a trigger event and properties', function() { + analytics.track('event', { + property: true + }); + analytics.called(window.hellobar.trigger.event, 'event', { + property: true + }); + }); + }); + }); }); /**