@segment/cookie not found in npm registery
ahaider48 opened this issue · comments
Is @segment/cookie a published package?
It is listed as a new dependency in the last version!
I started getting:
error Couldn't find package "@segment/cookie@^1.1.5" required by "@segment/analytics.js-core@^3.9.0" on the "npm"
registry.
Hey, thanks for the report! This package is currently published privately. We're in process of making it public, I'll keep you updated here.
In the meantime, if you're not interested in the SameSite
feature, you can fallback to the previous release (v3.10.1
).
As a follow-up, we'll add a script in CI to ensure that every dependency is public.
Is there an ETA on when this package will be made public? @fathyb
+1 Also registering interest in @segment/cookie being public.
+1 blocked on this right now too.
@fathyb any update on this?
Any updates? It would be awesome to be able to include segment into our bundle.
Obviously not optimal but for a short term fix I pulled the cookie package's compiled code from analytics.js, made a few updates to pass strict mode validation and all tests out fine:
'use strict';
var debug = require('debug')('cookie');
/**
* Set or get cookie `name` with `value` and `options` object.
*
* @param {String} name
* @param {String} value
* @param {Object} options
* @return {Mixed}
* @api public
*/
/**
* Set cookie `name` to `value`.
*
* @param {String} name
* @param {String} value
* @param {Object} options
* @api private
*/
function set(name, value, options) {
options = options || {};
var str = encode(name) + '=' + encode(value);
if (value === null) options.maxage = -1;
if (options.maxage) {
options.expires = new Date(+new Date + options.maxage);
}
if (options.path) str += '; path=' + options.path;
if (options.domain) str += '; domain=' + options.domain;
if (options.expires) str += '; expires=' + options.expires.toUTCString();
if (options.secure) str += '; secure';
document.cookie = str;
}
/**
* Return all cookies.
*
* @return {Object}
* @api private
*/
function all() {
return parse(document.cookie);
}
/**
* Get cookie `name`.
*
* @param {String} name
* @return {String}
* @api private
*/
function get(name) {
return all()[name];
}
/**
* Parse cookie `str`.
*
* @param {String} str
* @return {Object}
* @api private
*/
function parse(str) {
var obj = {};
var pairs = str.split(/ *; */);
var pair;
if (pairs[0] === '') return obj;
for (var i = 0; i < pairs.length; ++i) {
pair = pairs[i].split('=');
obj[decode(pair[0])] = decode(pair[1]);
}
return obj;
}
/**
* Encode.
*/
function encode(value){
try {
return encodeURIComponent(value);
} catch (e) {
debug('error `encode(%o)` - %o', value, e)
}
}
/**
* Decode.
*/
function decode(value) {
try {
return decodeURIComponent(value);
} catch (e) {
debug('error `decode(%o)` - %o', value, e)
}
}
module.exports = function(name, value, options){
switch (arguments.length) {
case 3:
case 2:
return set(name, value, options);
case 1:
return get(name);
default:
return all();
}
};
Any updates here @fathyb ?
Can we please get a timeline for open sourcing this?
came across this problem too
Sorry for the long delay to fix this. The package is public now 🎉