Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pageviews

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pageviews - npm Package Compare versions

Comparing version 1.0.9 to 1.1.0

2

bower.json
{
"name": "pageviews",
"main": "pageviews",
"version": "1.0.9",
"version": "1.1.0",
"homepage": "https://github.com/tomayac/pageviews.js",

@@ -6,0 +6,0 @@ "authors": [

@@ -99,1 +99,23 @@ var pageviews = typeof window === 'undefined' ?

});
pageviews.getUniqueDevices({
project: 'en.wikipedia',
start: '20160301',
end: '20160301',
accessSite: 'desktop-site'
}).then(function(result) {
console.log(JSON.stringify(result, null, 2));
}).catch(function(error) {
console.log(error);
});
pageviews.getUniqueDevices({
project: 'en.wikipedia',
start: '20160301',
end: '20160331',
granularity: 'monthly'
}).then(function(result) {
console.log(JSON.stringify(result, null, 2));
}).catch(function(error) {
console.log(error);
});
{
"name": "pageviews",
"version": "1.0.9",
"version": "1.1.0",
"description": "A lightweight JavaScript client library for the Wikimedia Pageviews API for Wikipedia and various of its sister projects for Node.js and the browser.",

@@ -28,3 +28,3 @@ "main": "pageviews.js",

"dependencies": {
"request": "^2.67.0"
"request": "^2.72.0"
},

@@ -31,0 +31,0 @@ "devDependencies": {

@@ -29,3 +29,3 @@ /**

// The user agent to use
USER_AGENT = 'pageviews.js–v' + packageJson.version + ' (' +
USER_AGENT = 'pageviews.js-v' + packageJson.version + ' (' +
packageJson.repository.url + ')';

@@ -56,2 +56,7 @@ } else {

var _accessSite = {
default: 'all-sites',
allowed: ['all-sites', 'desktop-site', 'mobile-site']
};
var _agent = {

@@ -72,2 +77,7 @@ default: 'all-agents',

var _granularityUniques = {
default: 'daily',
allowed: ['daily', 'monthly']
};
/**

@@ -125,3 +135,3 @@ * Checks the input parameters for validity.

}
if (caller === 'getPerArticlePageviews') {
if (caller === 'getPerArticlePageviews' || caller === 'getUniqueDevices') {
// Required: start

@@ -153,3 +163,3 @@ if (!params.start) {

if (!params.start) {
return new Error('Required parameter "end" missing.');
return new Error('Required parameter "start" missing.');
}

@@ -210,2 +220,7 @@ params.start = typeof params.start === 'object' ?

}
// Optional: accessSite
if ((params.accessSite) &&
(_accessSite.allowed.indexOf(params.accessSite) === -1)) {
return new Error('Invalid optional parameter "accessSite".');
}
// Optional: agent

@@ -225,2 +240,6 @@ if ((params.agent) && (_agent.allowed.indexOf(params.agent) === -1)) {

}
} else if (caller === 'getUniqueDevices') {
if (_granularityUniques.allowed.indexOf(params.granularity) === -1) {
return new Error('Invalid optional parameter "granularity".');
}
}

@@ -431,2 +450,38 @@ }

var _getUniqueDevices = function(params) {
return new Promise(function(resolve, reject) {
params = _checkParams(params, 'getUniqueDevices');
if (params.stack) {
return reject(params);
}
// Required params
var project = params.project;
var start = params.start;
var end = params.end;
// Optional params
var accessSite = params.accessSite ?
params.accessSite : _accessSite.default;
var granularity = params.granularity ?
params.granularity : _granularityUniques.default;
var options = {
url: BASE_URL + '/metrics/unique-devices' +
'/' + project +
'/' + accessSite +
'/' + granularity +
'/' + start +
'/' + end,
headers: {
'User-Agent': USER_AGENT
}
};
request(options, function(error, response, body) {
var result = _checkResult(error, response, body);
if (result.stack) {
return reject(result);
}
return resolve(result);
});
});
};
return {

@@ -459,3 +514,10 @@ /**

*/
getTopPageviews: _getTopPageviews
getTopPageviews: _getTopPageviews,
/**
* Given a project and a date range, returns a timeseries of unique devices
* counts. You can filter by access site and choose between daily and
* monthly granularity.
*/
getUniqueDevices: _getUniqueDevices
};

@@ -462,0 +524,0 @@ })();

@@ -17,2 +17,2 @@ /**

*/
var request,USER_AGENT="pageviews.js",environment="undefined"==typeof window?"node":"browser";if("node"===environment){request=require("request");var packageJson=require("./package.json");USER_AGENT="pageviews.js–v"+packageJson.version+" ("+packageJson.repository.url+")"}else request=function(e,r){var t=new XMLHttpRequest;t.addEventListener("load",function(){return r(null,{statusCode:this.status},this.responseText)}),t.addEventListener("error",function(e){return r(e)}),t.open("GET",e.url),t.send()};var pageviews=function(){var e="https://wikimedia.org/api/rest_v1",r={"default":"all-access",allowed:["all-access","desktop","mobile-web","mobile-app"]},t={"default":"all-agents",allowed:["all-agents","user","spider","bot"]},a={"default":"hourly",allowed:["daily","hourly","monthly"]},n={"default":"daily",allowed:["daily"]},i=function(e,i){var s=function(e){return 10>e?"0"+e:e.toString()};if(!e)return new Error("Required parameters missing.");if(!e.project&&!e.projects)return"getAggregatedPageviews"===i||"getTopPageviews"===i?new Error('Required parameter "project" or "projects" missing.'):new Error('Required parameter "project" missing.');if(e.project&&"all-projects"!==e.project&&"wikidata"!==e.project&&-1===e.project.indexOf("."))return new Error('Required parameter "project" invalid.');if(("getAggregatedPageviews"===i||"getTopPageviews"===i)&&e.projects&&"all-projects"!=e.projects&&(!Array.isArray(e.projects)||!e.projects.length||e.projects.filter(function(e){return-1===e.indexOf(".")&&"all-projects"!==e&&"wikidata"!==e}).length))return new Error('Required parameter "projects" invalid.');if("getPerArticlePageviews"===i){if(!e.article&&!e.articles)return new Error('Required parameter "article" or "articles" missing.');if(e.articles&&(!Array.isArray(e.articles)||!e.articles.length))return new Error('Required parameter "articles" invalid.')}if("getPerArticlePageviews"===i){if(!e.start)return new Error('Required parameter "start" missing.');if(e.start="object"==typeof e.start?e.start.getUTCFullYear()+s(e.start.getUTCMonth()+1)+s(e.start.getUTCDate()):e.start,!/^(?:19|20)\d\d[- \/.]?(?:0[1-9]|1[012])[- \/.]?(?:0[1-9]|[12][0-9]|3[01])$/.test(e.start))return new Error('Required parameter "start" invalid.');if(!e.end)return new Error('Required parameter "end" missing.');if(e.end="object"==typeof e.end?e.end.getUTCFullYear()+s(e.end.getUTCMonth()+1)+s(e.end.getUTCDate()):e.end,!/^(19|20)\d\d[- \/.]?(0[1-9]|1[012])[- \/.]?(0[1-9]|[12][0-9]|3[01])$/.test(e.end))return new Error('Required parameter "end" invalid.')}else if("getAggregatedPageviews"===i){if(!e.start)return new Error('Required parameter "end" missing.');if(e.start="object"==typeof e.start?e.start.getUTCFullYear()+s(e.start.getUTCMonth()+1)+(s(e.start.getUTCDate())+s(e.start.getUTCHours())):e.start,!/^(?:19|20)\d\d[- \/.]?(?:0[1-9]|1[012])[- \/.]?(?:0[1-9]|[12][0-9]|3[01])[- \/.]?(?:[012][0-9])$/.test(e.start))return new Error('Required parameter "start" missing or invalid.');if(!e.end)return new Error('Required parameter "end" missing.');if(e.end="object"==typeof e.end?e.end.getUTCFullYear()+s(e.end.getUTCMonth()+1)+s(e.end.getUTCDate())+s(e.end.getUTCHours()):e.end,!/^(19|20)\d\d[- \/.]?(0[1-9]|1[012])[- \/.]?(0[1-9]|[12][0-9]|3[01])[- \/.]?(?:[012][0-9])$/.test(e.end))return new Error('Required parameter "end" missing or invalid.')}if("getTopPageviews"===i){if(e.date&&(e.date="object"==typeof e.date?e.date:new Date(e.date.substr(0,4)+"-"+e.date.substr(4,2)+"-"+e.date.substr(6,2)),e.year=e.date.getUTCFullYear(),e.month=s(e.date.getUTCMonth()+1),e.day=s(e.date.getUTCDate())),!e.year||!/^(?:19|20)\d\d$/.test(e.year))return new Error('Required parameter "year" missing or invalid.');if(!e.month||!/^(?:0?[1-9]|1[012])$/.test(e.month))return new Error('Required parameter "month" missing or invalid.');if(!e.day||!/^(?:0?[1-9]|[12][0-9]|3[01])$/.test(e.day))return new Error('Required parameter "day" missing or invalid.');if(e.limit&&!/^\d+$/.test(e.limit)&&0<e.limit&&e.limit<=1e3)return new Error('Invalid optional parameter "limit".')}if(e.access&&-1===r.allowed.indexOf(e.access))return new Error('Invalid optional parameter "access".');if(e.agent&&-1===t.allowed.indexOf(e.agent))return new Error('Invalid optional parameter "agent".');if(e.granularity)if("getAggregatedPageviews"===i){if(-1===a.allowed.indexOf(e.granularity))return new Error('Invalid optional parameter "granularity".')}else if("getPerArticlePageviews"===i&&-1===n.allowed.indexOf(e.granularity))return new Error('Invalid optional parameter "granularity".');return e},s=function(e,r,t){var a;if(e||200!==r.statusCode){if(e)return e;if(404===r.statusCode)try{return a=JSON.parse(t),new Error(a.detail)}catch(n){return new Error(n)}return new Error("Status code "+r.statusCode)}try{a=JSON.parse(t)}catch(n){return new Error(n)}return a},o=function(a){return new Promise(function(d,u){if(a=i(a,"getPerArticlePageviews"),a.stack)return u(a);if(a.articles){var l=[];return a.articles.map(function(e,r){var t=a;delete t.articles,t.article=e,l[r]=o(t)}),d(Promise.all(l))}var c=a.project,g=encodeURIComponent(a.article.replace(/\s/g,"_")),p=a.start,f=a.end,m=a.access?a.access:r["default"],w=a.agent?a.agent:t["default"],v=a.granularity?a.granularity:n["default"],j={url:e+"/metrics/pageviews/per-article/"+c+"/"+m+"/"+w+"/"+g+"/"+v+"/"+p+"/"+f,headers:{"User-Agent":USER_AGENT}};request(j,function(e,r,t){var a=s(e,r,t);return a.stack?u(a):d(a)})})},d=function(n){return new Promise(function(o,u){if(n=i(n,"getAggregatedPageviews"),n.stack)return u(n);if("all-projects"===n.projects&&(n.projects=null,n.project="all-projects"),n.projects){var l=[];return n.projects.map(function(e,r){var t=n;delete t.projects,t.project=e,l[r]=d(t)}),o(Promise.all(l))}var c=n.project,g=n.start,p=n.end,f=n.access?n.access:r["default"],m=n.agent?n.agent:t["default"],w=n.granularity?n.granularity:a["default"],v={url:e+"/metrics/pageviews/aggregate/"+c+"/"+f+"/"+m+"/"+w+"/"+g+"/"+p,headers:{"User-Agent":USER_AGENT}};request(v,function(e,r,t){var a=s(e,r,t);return a.stack?u(a):o(a)})})},u=function(t){return new Promise(function(a,n){if(t=i(t,"getTopPageviews"),t.stack)return n(t);if(t.projects){var o=[];return t.projects.map(function(e,r){var a=t;delete a.projects,a.project=e,o[r]=u(a)}),a(Promise.all(o))}var d=t.project,l=t.year,c="number"==typeof t.month&&t.month<10?"0"+t.month:t.month,g="number"==typeof t.day&&t.day<10?"0"+t.day:t.day,p=t.limit||!1,f=t.access?t.access:r["default"],m={url:e+"/metrics/pageviews/top/"+d+"/"+f+"/"+l+"/"+c+"/"+g,headers:{"User-Agent":USER_AGENT}};request(m,function(e,r,t){var i=s(e,r,t);return i.stack?n(i):(p&&(i.items[0].articles=i.items[0].articles.slice(0,p)),a(i))})})},l=function(){return new Promise(function(r,t){var a={url:e+"/metrics/pageviews/",headers:{"User-Agent":USER_AGENT}};request(a,function(e,a,n){var i=s(e,a,n);return i.stack?t(i):r(i)})})};return{getPageviewsDimensions:l,getPerArticlePageviews:o,getAggregatedPageviews:d,getTopPageviews:u}}();"node"===environment&&(module.exports=pageviews);
var request,USER_AGENT="pageviews.js",environment="undefined"==typeof window?"node":"browser";if("node"===environment){request=require("request");var packageJson=require("./package.json");USER_AGENT="pageviews.js-v"+packageJson.version+" ("+packageJson.repository.url+")"}else request=function(e,r){var t=new XMLHttpRequest;t.addEventListener("load",function(){return r(null,{statusCode:this.status},this.responseText)}),t.addEventListener("error",function(e){return r(e)}),t.open("GET",e.url),t.send()};var pageviews=function(){var e="https://wikimedia.org/api/rest_v1",r={"default":"all-access",allowed:["all-access","desktop","mobile-web","mobile-app"]},t={"default":"all-sites",allowed:["all-sites","desktop-site","mobile-site"]},a={"default":"all-agents",allowed:["all-agents","user","spider","bot"]},i={"default":"hourly",allowed:["daily","hourly","monthly"]},n={"default":"daily",allowed:["daily"]},s={"default":"daily",allowed:["daily","monthly"]},o=function(e,o){var l=function(e){return 10>e?"0"+e:e.toString()};if(!e)return new Error("Required parameters missing.");if(!e.project&&!e.projects)return new Error("getAggregatedPageviews"===o||"getTopPageviews"===o?'Required parameter "project" or "projects" missing.':'Required parameter "project" missing.');if(e.project&&"all-projects"!==e.project&&"wikidata"!==e.project&&-1===e.project.indexOf("."))return new Error('Required parameter "project" invalid.');if(!("getAggregatedPageviews"!==o&&"getTopPageviews"!==o||!e.projects||"all-projects"==e.projects||Array.isArray(e.projects)&&e.projects.length&&!e.projects.filter(function(e){return-1===e.indexOf(".")&&"all-projects"!==e&&"wikidata"!==e}).length))return new Error('Required parameter "projects" invalid.');if("getPerArticlePageviews"===o){if(!e.article&&!e.articles)return new Error('Required parameter "article" or "articles" missing.');if(e.articles&&(!Array.isArray(e.articles)||!e.articles.length))return new Error('Required parameter "articles" invalid.')}if("getPerArticlePageviews"===o||"getUniqueDevices"===o){if(!e.start)return new Error('Required parameter "start" missing.');if(e.start="object"==typeof e.start?e.start.getUTCFullYear()+l(e.start.getUTCMonth()+1)+l(e.start.getUTCDate()):e.start,!/^(?:19|20)\d\d[- \/.]?(?:0[1-9]|1[012])[- \/.]?(?:0[1-9]|[12][0-9]|3[01])$/.test(e.start))return new Error('Required parameter "start" invalid.');if(!e.end)return new Error('Required parameter "end" missing.');if(e.end="object"==typeof e.end?e.end.getUTCFullYear()+l(e.end.getUTCMonth()+1)+l(e.end.getUTCDate()):e.end,!/^(19|20)\d\d[- \/.]?(0[1-9]|1[012])[- \/.]?(0[1-9]|[12][0-9]|3[01])$/.test(e.end))return new Error('Required parameter "end" invalid.')}else if("getAggregatedPageviews"===o){if(!e.start)return new Error('Required parameter "start" missing.');if(e.start="object"==typeof e.start?e.start.getUTCFullYear()+l(e.start.getUTCMonth()+1)+(l(e.start.getUTCDate())+l(e.start.getUTCHours())):e.start,!/^(?:19|20)\d\d[- \/.]?(?:0[1-9]|1[012])[- \/.]?(?:0[1-9]|[12][0-9]|3[01])[- \/.]?(?:[012][0-9])$/.test(e.start))return new Error('Required parameter "start" missing or invalid.');if(!e.end)return new Error('Required parameter "end" missing.');if(e.end="object"==typeof e.end?e.end.getUTCFullYear()+l(e.end.getUTCMonth()+1)+l(e.end.getUTCDate())+l(e.end.getUTCHours()):e.end,!/^(19|20)\d\d[- \/.]?(0[1-9]|1[012])[- \/.]?(0[1-9]|[12][0-9]|3[01])[- \/.]?(?:[012][0-9])$/.test(e.end))return new Error('Required parameter "end" missing or invalid.')}if("getTopPageviews"===o){if(e.date&&(e.date="object"==typeof e.date?e.date:new Date(e.date.substr(0,4)+"-"+e.date.substr(4,2)+"-"+e.date.substr(6,2)),e.year=e.date.getUTCFullYear(),e.month=l(e.date.getUTCMonth()+1),e.day=l(e.date.getUTCDate())),!e.year||!/^(?:19|20)\d\d$/.test(e.year))return new Error('Required parameter "year" missing or invalid.');if(!e.month||!/^(?:0?[1-9]|1[012])$/.test(e.month))return new Error('Required parameter "month" missing or invalid.');if(!e.day||!/^(?:0?[1-9]|[12][0-9]|3[01])$/.test(e.day))return new Error('Required parameter "day" missing or invalid.');if(e.limit&&!/^\d+$/.test(e.limit)&&0<e.limit&&e.limit<=1e3)return new Error('Invalid optional parameter "limit".')}if(e.access&&-1===r.allowed.indexOf(e.access))return new Error('Invalid optional parameter "access".');if(e.accessSite&&-1===t.allowed.indexOf(e.accessSite))return new Error('Invalid optional parameter "accessSite".');if(e.agent&&-1===a.allowed.indexOf(e.agent))return new Error('Invalid optional parameter "agent".');if(e.granularity)if("getAggregatedPageviews"===o){if(-1===i.allowed.indexOf(e.granularity))return new Error('Invalid optional parameter "granularity".')}else if("getPerArticlePageviews"===o){if(-1===n.allowed.indexOf(e.granularity))return new Error('Invalid optional parameter "granularity".')}else if("getUniqueDevices"===o&&-1===s.allowed.indexOf(e.granularity))return new Error('Invalid optional parameter "granularity".');return e},l=function(e,r,t){var a;if(e||200!==r.statusCode){if(e)return e;if(404===r.statusCode)try{return a=JSON.parse(t),new Error(a.detail)}catch(i){return new Error(i)}return new Error("Status code "+r.statusCode)}try{a=JSON.parse(t)}catch(i){return new Error(i)}return a},u=function(t){return new Promise(function(i,s){if(t=o(t,"getPerArticlePageviews"),t.stack)return s(t);if(t.articles){var d=[];return t.articles.map(function(e,r){var a=t;delete a.articles,a.article=e,d[r]=u(a)}),i(Promise.all(d))}var c=t.project,g=encodeURIComponent(t.article.replace(/\s/g,"_")),p=t.start,f=t.end,m=t.access?t.access:r["default"],w=t.agent?t.agent:a["default"],v=t.granularity?t.granularity:n["default"],y={url:e+"/metrics/pageviews/per-article/"+c+"/"+m+"/"+w+"/"+g+"/"+v+"/"+p+"/"+f,headers:{"User-Agent":USER_AGENT}};request(y,function(e,r,t){var a=l(e,r,t);return a.stack?s(a):i(a)})})},d=function(t){return new Promise(function(n,s){if(t=o(t,"getAggregatedPageviews"),t.stack)return s(t);if("all-projects"===t.projects&&(t.projects=null,t.project="all-projects"),t.projects){var u=[];return t.projects.map(function(e,r){var a=t;delete a.projects,a.project=e,u[r]=d(a)}),n(Promise.all(u))}var c=t.project,g=t.start,p=t.end,f=t.access?t.access:r["default"],m=t.agent?t.agent:a["default"],w=t.granularity?t.granularity:i["default"],v={url:e+"/metrics/pageviews/aggregate/"+c+"/"+f+"/"+m+"/"+w+"/"+g+"/"+p,headers:{"User-Agent":USER_AGENT}};request(v,function(e,r,t){var a=l(e,r,t);return a.stack?s(a):n(a)})})},c=function(t){return new Promise(function(a,i){if(t=o(t,"getTopPageviews"),t.stack)return i(t);if(t.projects){var n=[];return t.projects.map(function(e,r){var a=t;delete a.projects,a.project=e,n[r]=c(a)}),a(Promise.all(n))}var s=t.project,u=t.year,d="number"==typeof t.month&&t.month<10?"0"+t.month:t.month,g="number"==typeof t.day&&t.day<10?"0"+t.day:t.day,p=t.limit||!1,f=t.access?t.access:r["default"],m={url:e+"/metrics/pageviews/top/"+s+"/"+f+"/"+u+"/"+d+"/"+g,headers:{"User-Agent":USER_AGENT}};request(m,function(e,r,t){var n=l(e,r,t);return n.stack?i(n):(p&&(n.items[0].articles=n.items[0].articles.slice(0,p)),a(n))})})},g=function(){return new Promise(function(r,t){var a={url:e+"/metrics/pageviews/",headers:{"User-Agent":USER_AGENT}};request(a,function(e,a,i){var n=l(e,a,i);return n.stack?t(n):r(n)})})},p=function(r){return new Promise(function(a,i){if(r=o(r,"getUniqueDevices"),r.stack)return i(r);var n=r.project,u=r.start,d=r.end,c=r.accessSite?r.accessSite:t["default"],g=r.granularity?r.granularity:s["default"],p={url:e+"/metrics/unique-devices/"+n+"/"+c+"/"+g+"/"+u+"/"+d,headers:{"User-Agent":USER_AGENT}};request(p,function(e,r,t){var n=l(e,r,t);return n.stack?i(n):a(n)})})};return{getPageviewsDimensions:g,getPerArticlePageviews:u,getAggregatedPageviews:d,getTopPageviews:c,getUniqueDevices:p}}();"node"===environment&&(module.exports=pageviews);

@@ -109,2 +109,14 @@ # pageviews.js

});
// Getting unique devices
pageviews.getUniqueDevices({
project: 'en.wikipedia',
start: '20160301',
end: '20160301',
accessSite: 'desktop-site'
}).then(function(result) {
console.log(JSON.stringify(result, null, 2));
}).catch(function(error) {
console.log(error);
});
```

@@ -143,3 +155,3 @@

The API is modeled along the [Wikimedia Pageviews API](https://wikimedia.org/api/rest_v1/?doc#!/Pageviews_data)
The API is modeled along the [Wikimedia Pageviews API](https://wikimedia.org/api/rest_v1/?doc#!/Pageviews_data) and the [Wikimedia Unique Devices API](https://wikimedia.org/api/rest_v1/?doc#!/Unique_devices_data)
and offers the following methods:

@@ -174,4 +186,15 @@ ```

getTopPageviews
/**
* Given a project and a date range, returns a timeseries of unique devices
* counts. You can filter by access site and choose between daily and
* monthly granularity.
*/
getUniqueDevices
```
# Contributors
- [@nuria](https://github.com/nuria)
- [@marcelrf](https://github.com/marcelrf)
# License

@@ -178,0 +201,0 @@ Copyright 2016 Thomas Steiner (@tomayac)

@@ -23,3 +23,4 @@ var environment = typeof window === 'undefined' ? 'node' : 'browser';

'getAggregatedPageviews',
'getTopPageviews']);
'getTopPageviews',
'getUniqueDevices']);
});

@@ -226,3 +227,3 @@

function() {
pageviews.getTopPageviews({
return pageviews.getTopPageviews({
project: 'en.wikipedia',

@@ -240,3 +241,3 @@ year: 2015,

function() {
pageviews.getTopPageviews({
return pageviews.getTopPageviews({
project: 'en.wikipedia',

@@ -249,2 +250,54 @@ date: new Date(new Date() - 3 * 24 * 60 * 60 * 1000),

});
it('Returns the unique devices for a project (date object).', function() {
return pageviews.getUniqueDevices({
project: 'en.wikipedia',
start: new Date('2016-01-01'),
end: new Date('2016-01-02')
}).then(function(result) {
assert.equal(result.items.length, 2);
assert.isNotNull(result.items[0].devices);
assert.isNotNull(result.items[1].devices);
assert.equal(result.items[0].timestamp, '20160101');
assert.equal(result.items[1].timestamp, '20160102');
});
});
it('Returns the unique devices for a project (textual date).', function() {
return pageviews.getUniqueDevices({
project: 'en.wikipedia',
start: '20160101',
end: '20160102'
}).then(function(result) {
assert.equal(result.items.length, 2);
assert.isNotNull(result.items[0].devices);
assert.isNotNull(result.items[1].devices);
assert.equal(result.items[0].timestamp, '20160101');
assert.equal(result.items[1].timestamp, '20160102');
});
});
it('Returns the unique devices for a project (given accessSite).',
function() {
return pageviews.getUniqueDevices({
project: 'en.wikipedia',
start: '20160101',
end: '20160102',
accessSite: 'desktop-site'
}).then(function(result) {
assert.isNotNull(result.items[0].devices);
});
});
it('Returns the unique devices for a project (given granularity).',
function() {
return pageviews.getUniqueDevices({
project: 'en.wikipedia',
start: '20160101',
end: '20160131',
granularity: 'monthly'
}).then(function(result) {
assert.isNotNull(result.items[0].devices);
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc