Skip to content

Commit ffdd49c

Browse files
author
Julio Farah
authored
Remove component-cookie in favor of js-cookies (#24)
* pardot * vero * segmentio
1 parent 36bc495 commit ffdd49c

File tree

8 files changed

+51
-14
lines changed

8 files changed

+51
-14
lines changed

integrations/pardot/lib/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Module dependencies.
55
*/
66

7-
var cookie = require('component-cookie');
7+
var cookie = require('js-cookie');
88
var integration = require('@segment/analytics.js-integration');
99
var load = require('@segment/load-script');
1010
var querystring = require('component-querystring');
@@ -93,9 +93,9 @@ Pardot.prototype.getRequestVariables = function() {
9393
var variables = {
9494
account_id: window.piAId,
9595
campaign_id: window.piCId,
96-
pi_opt_in: cookie('pi_opt_in' + (this.options.piAId - 1e3)),
96+
pi_opt_in: cookie.get('pi_opt_in' + (this.options.piAId - 1e3)),
9797
ver: 3,
98-
visitor_id: cookie('visitor_id' + (this.options.piAId - 1e3))
98+
visitor_id: cookie.get('visitor_id' + (this.options.piAId - 1e3))
9999
};
100100

101101
// get all the query parameters

integrations/pardot/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@segment/analytics.js-integration-pardot",
33
"description": "The Pardot analytics.js integration.",
4-
"version": "2.0.1",
4+
"version": "2.0.2",
55
"keywords": [
66
"analytics.js",
77
"analytics.js-integration",
@@ -26,7 +26,7 @@
2626
"dependencies": {
2727
"@segment/analytics.js-integration": "^3.3.2",
2828
"@segment/load-script": "^1.0.1",
29-
"component-cookie": "^1.1.2",
29+
"js-cookie": "^2.2.1",
3030
"component-querystring": "^1.3.3",
3131
"use-https": "^0.1.1"
3232
},

integrations/segmentio/lib/index.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
var ads = require('@segment/ad-params');
88
var clone = require('component-clone');
9-
var cookie = require('component-cookie');
9+
var JSCookie = require('js-cookie');
1010
var extend = require('@ndhoule/extend');
1111
var integration = require('@segment/analytics.js-integration');
1212
var keys = require('@ndhoule/keys');
@@ -24,7 +24,7 @@ var Queue = require('@segment/localstorage-retry');
2424

2525
var cookieOptions = {
2626
// 1 year
27-
maxage: 31536000000,
27+
maxage: '31536000000',
2828
secure: false,
2929
path: '/'
3030
};
@@ -64,6 +64,21 @@ var Segment = (exports = module.exports = integration('Segment.io')
6464
.option('addBundledMetadata', false)
6565
.option('unbundledIntegrations', []));
6666

67+
var cookie = function(name, value, options){
68+
switch (arguments.length) {
69+
case 3:
70+
case 2:
71+
if (value === null) {
72+
return JSCookie.remove(name, { path: ''})
73+
}
74+
return JSCookie.set(name, value, options);
75+
case 1:
76+
return JSCookie.get(name);
77+
default:
78+
return JSCookie.get();
79+
}
80+
};
81+
6782
/**
6883
* Get the store.
6984
*

integrations/segmentio/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@segment/analytics.js-integration-segmentio",
33
"description": "The Segmentio analytics.js integration.",
4-
"version": "4.2.6",
4+
"version": "4.2.7",
55
"keywords": [
66
"analytics.js",
77
"analytics.js-integration",
@@ -34,7 +34,7 @@
3434
"@segment/top-domain": "^3.0.0",
3535
"@segment/utm-params": "^2.0.0",
3636
"component-clone": "^0.2.2",
37-
"component-cookie": "^1.1.2",
37+
"js-cookie": "^2.2.1",
3838
"component-type": "^1.2.1",
3939
"uuid": "^2.0.2",
4040
"yields-store": "^1.0.2"

integrations/segmentio/test/index.test.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var Analytics = require('@segment/analytics.js-core').constructor;
44
var Segment = require('../lib/');
55
var assert = require('proclaim');
6-
var cookie = require('component-cookie');
6+
var JSCookie = require('js-cookie');
77
var integration = require('@segment/analytics.js-integration');
88
var protocol = require('@segment/protocol');
99
var sandbox = require('@segment/clear-env');
@@ -21,6 +21,23 @@ var lolex = require('lolex');
2121
// this hackery
2222
var isPhantomJS = /PhantomJS/.test(window.navigator.userAgent);
2323

24+
25+
var cookie = function(name, value, options){
26+
switch (arguments.length) {
27+
case 3:
28+
case 2:
29+
if (value === null) {
30+
return JSCookie.remove(name, { path: ''})
31+
}
32+
return JSCookie.set(name, value, options);
33+
case 1:
34+
return JSCookie.get(name);
35+
default:
36+
return JSCookie.get();
37+
}
38+
};
39+
40+
2441
describe('Segment.io', function() {
2542
var segment;
2643
var analytics;

integrations/vero/lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Module dependencies.
55
*/
66

7-
var cookie = require('component-cookie');
7+
var cookie = require('js-cookie');
88
var integration = require('@segment/analytics.js-integration');
99
var push = require('global-queue')('_veroq');
1010

@@ -31,7 +31,7 @@ Vero.prototype.initialize = function() {
3131
// basically, they have window.addEventListener('unload')
3232
// which then saves their "command_store", which is an array.
3333
// so we just want to create that initially so we can reload the tests.
34-
if (!cookie('__veroc4')) cookie('__veroc4', '[]');
34+
if (!cookie.get('__veroc4')) cookie.set('__veroc4', '[]');
3535
push('init', { api_key: this.options.apiKey });
3636
this.load(this.ready);
3737
};

integrations/vero/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@segment/analytics.js-integration-vero",
33
"description": "The Vero analytics.js integration.",
4-
"version": "2.2.0",
4+
"version": "2.2.1",
55
"keywords": [
66
"analytics.js",
77
"analytics.js-integration",
@@ -25,7 +25,7 @@
2525
},
2626
"dependencies": {
2727
"@segment/analytics.js-integration": "^3.3.2",
28-
"component-cookie": "^1.1.2",
28+
"js-cookie": "^2.2.1",
2929
"global-queue": "^1.0.1"
3030
},
3131
"devDependencies": {

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6736,6 +6736,11 @@ jquery@^2.2.4:
67366736
resolved "https://registry.yarnpkg.com/jquery/-/jquery-2.2.4.tgz#2c89d6889b5eac522a7eea32c14521559c6cbf02"
67376737
integrity sha1-LInWiJterFIqfuoywUUhVZxsvwI=
67386738

6739+
js-cookie@^2.2.1:
6740+
version "2.2.1"
6741+
resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8"
6742+
integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ==
6743+
67396744
js-sha256@^0.3.0:
67406745
version "0.3.2"
67416746
resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.3.2.tgz#db09592455164191ce8171a4888cd957c67bf0ed"

0 commit comments

Comments
 (0)