{"_id":"@dlab/onesignal-bulk-unsubscribe","_rev":"4-014faee5e64f31836f0a7dee97b9af55","name":"@dlab/onesignal-bulk-unsubscribe","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.1":{"name":"@dlab/onesignal-bulk-unsubscribe","version":"0.1.1","description":"Script for unsubscribing users of OneSignal app in bulk using filtered queries","keywords":["onesignal","unsubscribe","users"],"main":"src/index.js","scripts":{"test":"jest","format":"npm run prettier -- --write","prettier":"prettier **/*.js"},"author":{"name":"Economia, a.s., Czech Republic"},"license":{"type":"MIT","url":"https://www.opensource.org/licenses/mit-license.php"},"repository":{"type":"git","url":"git+https://github.com/EconomiaPrague/onesignal-bulk-unsubscribe.git"},"dependencies":{"axios":"^0.18.0","csvtojson":"^2.0.8","parallel-transform":"^1.1.0"},"devDependencies":{"eslint":"^5.12.0","eslint-config-prettier":"^3.4.0","eslint-config-standard":"^12.0.0","eslint-plugin-import":"^2.14.0","eslint-plugin-node":"^8.0.1","eslint-plugin-promise":"^4.0.1","eslint-plugin-standard":"^4.0.0","husky":"^1.3.1","jest":"^23.6.0","jest-runner-eslint":"^0.7.1","lint-staged":"^8.1.0","prettier":"^1.15.3"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.js":["eslint --fix","prettier --write","git add","jest --bail --findRelatedTests"]},"gitHead":"dd63b382a234b2b28bfbea5c8b84c2bcce8ab638","bugs":{"url":"https://github.com/EconomiaPrague/onesignal-bulk-unsubscribe/issues"},"homepage":"https://github.com/EconomiaPrague/onesignal-bulk-unsubscribe#readme","_id":"@dlab/onesignal-bulk-unsubscribe@0.1.1","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-7Dxl/2kud8xIcVvjSYostzOFh7fg52oLmmqq3MnbW06fPzafGyf3lkY0J8/s1PXhZax1hlf5bXcLnXzI7qsI2w==","shasum":"d8fee677a18f416267124fffdaf2a32368e69188","tarball":"https://registry.npmjs.org/@dlab/onesignal-bulk-unsubscribe/-/onesignal-bulk-unsubscribe-0.1.1.tgz","fileCount":13,"unpackedSize":14007,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdOC1mCRA9TVsSAnZWagAAUlAQAJB/ai8EuwSMmoisyC2/\nxintAVqUuZ5cGszUiQRk/YgtZU2JAvUl+eaO1QvdwL0J7+I5pxJugDW7Dmzu\nZtivnmo09mcqRwx5VLXwbUKfOteEBhbLBQNJE7O1lI8txpw5vl8wWQRMAsyP\nb/NXFdl+pJckoz4cvnoLlLTBbdGVoW/Vqp1itej0jAOpEAvS0hmqT4uxBQPB\nsjWVSzvfTRI0lRMch39P18U8cZg9rl6KPq8K8aJmshEQoRdUfWNQRt4p4Euw\n7vHI7qFhj18SlP07VRaAMSqSTJWkx/ECAlmK6OQcKhgm6kFIJbCTUsE1fpYg\n8wUbahT/miV58TGLjmpDTrq/hkKcyOC6NmGG+X0TK98FcWHNPUgDlJCGI65p\nG9vLKVlQi46I0hpNMN+BtH0LBTQCgiq58z3iwH5y6JyfFZg+IMYE/f+JFFGo\nsZq7ZGZEm8cACmW9WcBAfNZEu/esLvvMF2Y+Kiq/5nABcibkpB1TqvDp0d/A\niVomrZrA9q2/btyJUQjdRsMPc2VWSHwbAjE3O6hTBJAAzMbw5IGNLKu9mhz4\nHVZ1X48HrfTSYqcuDggOQjVUNRL3KruooJDRGOl7qrqw+nSlcJGL0e/Zd/+6\nkHchI7+XrQ2Ia5gdwqI+Y55y2ZC5jiQqdmeVVOoxgwHC5O5+HKhRXc8r1ind\npiDU\r\n=L9M6\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCIiJRYG/k4omTAA8fqRG+MYJj/6i27IXO4RfJwcNKorAIhAO3remuzCnX0XXQOcueVeHtXBGMzmdnfWB2R4DSCieW5"}]},"maintainers":[{"name":"pascalmayr","email":"pascalmayr2@gmail.com"},{"name":"sven.christian","email":"sven.plangger@stol.it"}],"_npmUser":{"name":"pascalmayr","email":"pascalmayr2@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/onesignal-bulk-unsubscribe_0.1.1_1563962725525_0.843667063502874"},"_hasShrinkwrap":false},"0.1.2":{"name":"@dlab/onesignal-bulk-unsubscribe","version":"0.1.2","description":"Script for unsubscribing users of OneSignal app in bulk using filtered queries","keywords":["onesignal","unsubscribe","users"],"main":"src/index.js","scripts":{"test":"jest","format":"npm run prettier -- --write","prettier":"prettier **/*.js"},"author":{"name":"Economia, a.s., Czech Republic"},"license":{"type":"MIT","url":"https://www.opensource.org/licenses/mit-license.php"},"repository":{"type":"git","url":"git+https://bitbucket.org/internet-technik/onesignal-bulk-unsubscribe.git"},"dependencies":{"axios":"^0.18.0","csvtojson":"^2.0.8","json2csv":"^4.5.2","parallel-transform":"^1.1.0"},"devDependencies":{"eslint":"^5.12.0","eslint-config-prettier":"^3.4.0","eslint-config-standard":"^12.0.0","eslint-plugin-import":"^2.14.0","eslint-plugin-node":"^8.0.1","eslint-plugin-promise":"^4.0.1","eslint-plugin-standard":"^4.0.0","husky":"^1.3.1","jest":"^23.6.0","jest-runner-eslint":"^0.7.1","lint-staged":"^8.1.0","prettier":"^1.15.3"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.js":["eslint --fix","prettier --write","git add","jest --bail --findRelatedTests"]},"gitHead":"76cf4c735c9ad0e4b903778976aea9ee03cfc9b7","homepage":"https://bitbucket.org/internet-technik/onesignal-bulk-unsubscribe#readme","_id":"@dlab/onesignal-bulk-unsubscribe@0.1.2","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-01W0hMk5SxnVlDA9re+rx109HvpIHxBx3wfOjxqAZsihKCLq465ceL4+2SIoqleY7gBhFn2cP57bGKB/uW85Xw==","shasum":"ad65fa35a8deafed59751f9ef4cee1db7b3c01bf","tarball":"https://registry.npmjs.org/@dlab/onesignal-bulk-unsubscribe/-/onesignal-bulk-unsubscribe-0.1.2.tgz","fileCount":13,"unpackedSize":14604,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdOVFuCRA9TVsSAnZWagAA3DEQAIIG+FoGCNg49zVuVA5m\nGM6cAle71/FGyxAsezxaJCHZOqCWWoTJMb62K6w2b+86QcT7m0VTaWhp0FvS\n6i2YvCXJ654cY94quMhKyDuc92gq9JylBNJFEKR/jajBMKU6k/D7o1J4GLmD\nYBsKNhAhw9Utf4Bgz20UlVluojZ8OsixijGyAQDdkFLw2LbO2O1anM/EP7Wk\n4lI4E4vo4siBLpMdalT3E5ePEy9xGClQrKNiEFa7wf/WWpUGlQ3dhQWLz7Mo\nuKb/w+o3Iq7HmdslTe3EtS6F0V1Fh4FvEKBw67/s7RIWOggEl50Z/XvjtPce\nKG/oAXkaJ3Ai7uearp6xvm/JHvzFPeFdhg9PxA/6NkecOaQTp0xEaHxpGgT+\n3p18p/ZYsmZFngHqb2tq3wIHrbmwK9wLJ6yP/xiuD5oWowK2MuRavzD461/8\n9lc8YrzzwpcSBicGdU/41hb1/STOVBfd17B+rI/tS5LNjApLZ/1kUEJHVquq\nBosAFNuvqbvRuaonRzkUJRPTzGv3jETag0w8nWF1Bus+Ctpdjwdan0VxqJDM\nxb27I8t0frE3BxEuZtgQz0iw39ZWtifx7MV3s+ahO9IqDCs89jedVeRSp88I\n4JbZrmdvTYn/yfqNPPRFpu720e4+Cwl2tgevDRAbYIQhL7uRqyvI34egWq7V\n9hNi\r\n=7eN2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDzmzOqnn+fMrCyidK5Lj2omIzVbGe80L4FmyTZS0fuRQIhAPNUYP2suOzgoH3j8moPwYIvyFGRNhD2wgBerduE1xeJ"}]},"maintainers":[{"name":"pascalmayr","email":"pascalmayr2@gmail.com"},{"name":"sven.christian","email":"sven.plangger@stol.it"}],"_npmUser":{"name":"pascalmayr","email":"pascalmayr2@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/onesignal-bulk-unsubscribe_0.1.2_1564037485993_0.0594947397876564"},"_hasShrinkwrap":false}},"time":{"created":"2019-07-24T10:05:25.301Z","0.1.1":"2019-07-24T10:05:25.779Z","modified":"2022-12-14T14:18:39.732Z","0.1.2":"2019-07-25T06:51:26.238Z"},"maintainers":[{"email":"philipp.sorio@athesia.it","name":"ath-sorio"},{"email":"sven.plangger@stol.it","name":"sven.christian"}],"description":"Script for unsubscribing users of OneSignal app in bulk using filtered queries","homepage":"https://bitbucket.org/internet-technik/onesignal-bulk-unsubscribe#readme","keywords":["onesignal","unsubscribe","users"],"repository":{"type":"git","url":"git+https://bitbucket.org/internet-technik/onesignal-bulk-unsubscribe.git"},"author":{"name":"Economia, a.s., Czech Republic"},"license":{"type":"MIT","url":"https://www.opensource.org/licenses/mit-license.php"},"readme":"# OneSignal bulk unsubscribe\n\nThis package can be used to unsubscribe multiple players (users) from your OneSignal app at once based on predefined filters, similar to how Segments work.\n\nOneSignal currently doesn`t provide any API endpoints for working with Segments nor updating players at once. With onesignal-bulk-unsubscribed you can easily unsubscribe players in one go and specify custom filters.\n\n**Caution!** Unsubscribing players is not a destructive job, you can still subscribe them again, but we do NOT provide a way to revert any changes. Use bulk unsubscribe with caution.\n\n## Why\n\nThere is an existing `onesignal-node` (package by zeyneloz)[https://github.com/zeyneloz/onesignal-node] but there are two main reasons why this package doesn't use it.\n\n* `onesignal-node` doesn't use an Agent for limiting number of open connections, unsubscribing thousands of players at once would simply be too much. This package uses `axios` with `httpsAgent` and `maxSockets` set to `10` to not consume all your computer's sockets.\n* `onesignal-node` is an API client, so it only gives out CSV URL, this package can download the CSV, including waiting for it being generated, ungzip it and parse it using `csvtojson` lib.\n\n## How to install\n\n`npm install --save onesignal-bulk-unsubscribe`\n\n## How to use\n\n```\nconst bulkUnsubscribe = require('onesignal-bulk-unsubscribe')\n\nbulkUnsubscribe({\n  appId: '<APP_ID>', // required\n  restApiKey: '<REST_API_KEY>' // required\n  filter: <player> => <boolean>,\n  mutation: <object> | <player> => <object>,\n  timeout: <int>ms,\n  backOff: <int>ms,\n  dryRun: <boolean>,\n  csvFile: <string>,\n  csvUrl: <string>,\n  parallel: <int>\n})\n```\n\n### `appId` and `restApiKey`\n\nYou can find those options in your OneSignal account administration. Keep them secret!\n\n### `filter`\n\nYou should provide a filtering function to filter players you want to unsubscribed.\nIf you do not provide a function, all players will be unsubscribed.\nThere are default filters you can use straight from the package, for example:\n\n```\nconst isInactiveFor30Days = require('onesignal-bulk-unsubscribe/filters').isInactiveFor30Days\n```\n\nList of available filters:\n\n* `isSubscribed` (it might be a good idea to unly unsubscribe players that are subscribed to limit network requests)\n* `isInactiveFor90Days`\n* `isInactiveFor30Days`\n* `isInactiveFor7Days`\n* `isInactiveForNDays(days)` (this is a closure that returns a filter)\n\nYou can also provide a complex or custom filter, such as\n\n```\nfunction filter(player) {\n  return isSubscribed(player) && isInactiveFor30Days(player) && player.language !== 'en'\n}\n```\n\n### `mutation`\n\nBy default, this package marks all players as unsubscribed (state `-1`), but you can specify a different mutation to selected players.\nFor example, after trying out this package using a `dryRun`, you can decide to first mark all players by a tag:\n\n```\nbulkUnsubscribe({\n  mutation: {\n    tags: {\n      toDelete: \"true\"\n    }\n  }\n})\n```\n\nThis way, you can verify your filter really works correctly. You can even re-subscribe all players in this way with caution!\n\nIf you wish to modify users based on current properties, a function returning a mutation can be provided:\n\n```\nbulkUnsubscribe({\n  mutation: player => {\n    if (player.game_version === '1.0') {\n      return {\n        game_version: '1.1'\n      }\n    }\n\n    if (player.game_version === '2.0') {\n      return {\n        game_version: '2.1'\n      }\n    }\n\n    return {}\n  })\n})\n```\n\n### `timeout`\n\nYou can specify a timeout in ms for all requests to OneSignal API. Default value is `5000`.\n\n### `backOff`\n\nYou can specify a backOff time in ms for downloading CSV file.\nIn general, generating a CSV report by OneSignal takes several seconds and provided URL returns 403 status code until the export is generated.\nBy providing a `backOff`, the package wait for specified number of ms before retrying again. Default value is `10000`.\n\n### `dryRun`\n\nWhen testing filters or simply debugging your code, you might wish to not actually unsubscribe any players.\nYou can simply provide `dryRun` option to only console.log players that would be unsubscribed.\n\n### `csvFile and` `csvUrl`\n\nThose options also serve for debugging and testing. By default, this package first creates a CSV export and then downloads it from OneSignal,\ndoing so multiple times might be wasteful, you can either specify CSV export URL or point to existing CSV file on your drive altogether.\n\n### `parallel`\n\nSpecify the limit of `maxSockets` in https Agent and parallelism of mutations. Default value is `64`.\n\n## CLI\n\nThere is currently no CLI support for this package. Feel free to submit a PR.\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n\nSee [LICENSE.md](./LICENSE.md).\n\n## Contributing\n\nFeel free to send a PR and we will take a look at it. See package.json and config files for ESLint and Prettier configuration.\n\n## How to test\n\n1.) Export inactive Users which you want to unsubscribe\n\n2.) clone the repository\n\n3.) Get the APP ID and your REST API KEY and past it into 'bulkUnsubscribe.js'\n\n4.) Set dryRun to true\n\n5.) Run 'node bulkUnsubscribe.js' in the root of the repository\n","readmeFilename":"README.md"}