New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nativescript-version-tracking

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nativescript-version-tracking - npm Package Compare versions

Comparing version 0.1.0-alpha.2 to 0.1.0

4

index.d.ts

@@ -1,1 +0,3 @@

export * from './versionTracking';
import { versionTracking } from './version-tracking.common';
export = versionTracking;
{
"name": "nativescript-version-tracking",
"version": "0.1.0-alpha.2",
"version": "0.1.0",
"description": "Track which versions of your NativeScript App a user has previously installed.",

@@ -14,3 +14,3 @@ "main": "version-tracking",

"scripts": {
"tsc": "npx tsc",
"tsc": "tsc -skipLibCheck",
"build": "npm run tsc && npm run build.native",

@@ -17,0 +17,0 @@ "build.native": "node scripts/build-native.js",

@@ -7,10 +7,6 @@ [![Bazzite Project](https://img.shields.io/badge/Bazzite-project-blue.svg)](https://www.bazzite.com/docs/nativescript-version-tracking?utm_source=github&utm_medium=readme&utm_campaign=nativescript-version-tracking)

# [WIP] NativeScript Version Tracking
# NativeScript Version Tracking ![apple](https://cdn3.iconfinder.com/data/icons/picons-social/57/16-apple-32.png) ![android](https://cdn4.iconfinder.com/data/icons/logos-3/228/android-32.png)
Version Tracking plugin for NativeScript. Works on Android and iOS.
Track which versions of your NativeScript App, a user has previously installed.
*Read this in other languages: [English][documentation], [Español][documentation-es]*
⚠️ **DO NOT USE YET:** This project is in alpha state, under active development.
## Installation

@@ -26,12 +22,81 @@

TODO
The best way to explore the usage of the plugin is to inspect the demo app in the plugin's root folder.
### Initialize the plugin
This plugin needs to be initialized when your app starts.
*TypeScript*
```typescript
import * as app from 'tns-core-modules/application';
import * as versionTracking from 'nativescript-version-tracking';
app.on('launch', () => {
versionTracking.init();
});
```
*Javascript*
```javascript
var app = require('tns-core-modules/application');
var versionTracking = require('nativescript-version-tracking');
app.on('launch', function () {
versionTracking.init();
});
```
### Use the API
You can make use of the plugin whenever you want. For example, a user has launched several previous versions, and this is the first time he's launched the new version 2.0.1:
```javascript
versionTracking.isFirstLaunchEver; // false
versionTracking.isFirstLaunchForVersion; // true
versionTracking.isFirstLaunchForBuild; // true
versionTracking.currentVersion; // 2.0.1
versionTracking.previousVersion; // 2.0.0
versionTracking.firstInstalledVersion; // 1.0.0
versionTracking.versionHistory; // [1.0.0, 1.0.1, 1.0.2, 2.0.0, 2.0.1]
versionTracking.currentBuild; // 18
versionTracking.previousBuild; // 15
versionTracking.firstInstalledBuild; // 1
versionTracking.buildHistory; // [1, 2, 3, 4, 5, 8, 9, 10, 11, 13, 15, 18]
versionTracking.firstLaunchForVersion('3.0.0') // false
versionTracking.firstLaunchForBuild('20') // false
```
## API
TODO
## Documentation & Support
If you want extra details of how to configure and use this plugin, the full documentation is available at [https://www.bazzite.com/docs/nativescript-version-tracking][documentation].
### Properties
| Property | Default | Description |
|-------------------------|:-------:|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| isFirstLaunchEver | - | Check if this is the first time ever that the app is launched. |
| isFirstLaunchForVersion | - | Check if this is the first time the current version is being launched. |
| isFirstLaunchForBuild | - | Check if this is the first time the current build is being launched. |
| currentVersion | - | Returns the current version of the app. |
| previousVersion | - | Returns the previous version of the app. |
| firstInstalledVersion | - | Returns the version which the user first installed the app. |
| versionHistory | [] | Returns a list of versions which the user has had installed, e.g. ['2.1', '3.5', '4.0', '4.1']. The List is ordered from the first version installed to (including) the current version |
| currentBuild | - | Returns the current build of the app. |
| previousBuild | - | Returns the previous build of the app. |
| firstInstalledBuild | - | Returns the build which the user first installed the app. |
| buildHistory | [] | Returns a list of builds which the user has had installed, e.g. ['2100', '3500', '4000', '4100']. The List is ordered from the first build installed to (including) the current build. |
### Methods
| Method | Returns | Description |
|------------------------------------------------|:-------:|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| init(versionsKey?: string, buildsKey?: string) | void | Initializes the plugin. Calling this method is required. A good place to call it is at the application onLaunch() method. |
| firstLaunchForVersion(version: string) | boolean | Check if this is the first launch for a particular version number. Useful if you want to execute some code for the first time launches of a particular version. |
| firstLaunchForBuild(build: string) | boolean | Check if this is the first launch for a particular build number. Useful if you want to execute some code for the first time launches of a particular build. |
## Support
For questions and support, use the [Issues section][issues].

@@ -41,3 +106,3 @@

### Commercial Support
### Professional Support

@@ -58,5 +123,10 @@ This project is sponsored by [Bazzite][bazzite-website]. If you require assistance on your project(s), please contact us at [https://www.bazzite.com/contact][contact-page].

---
[documentation]: https://www.bazzite.com/docs/nativescript-version-tracking?utm_source=github&utm_medium=readme&utm_campaign=nativescript-version-tracking
[documentation-es]: https://www.bazzite.com/es/docs/nativescript-version-tracking?utm_source=github&utm_medium=readme&utm_campaign=nativescript-version-tracking
Originally inspired by [VersionTrackingPlugin](https://github.com/colbylwilliams/VersionTrackingPlugin).
![](https://ga-beacon.appspot.com/UA-130293414-1/nativescript/nativescript-version-tracking?pixel)
[contributing]: https://www.bazzite.com/docs/nativescript-version-tracking/contributing?utm_source=github&utm_medium=readme&utm_campaign=nativescript-version-tracking

@@ -69,4 +139,1 @@ [code-of-conduct]: https://www.bazzite.com/open-source/code-of-conduct?utm_source=github&utm_medium=readme&utm_campaign=nativescript-version-tracking

[license-page]: https://www.bazzite.com/docs/nativescript-version-tracking/license?utm_source=github&utm_medium=readme&utm_campaign=nativescript-version-tracking

@@ -16,4 +16,4 @@ "use strict";

.getPackageInfo(app.android.context.getPackageName(), packageManager.GET_META_DATA);
version_tracking_common_1.versionTracking.currentVersion = packageInfo.versionName;
version_tracking_common_1.versionTracking.currentBuild = packageInfo.VersionCode;
version_tracking_common_1.versionTracking.currentVersion = String(packageInfo.versionName);
version_tracking_common_1.versionTracking.currentBuild = String(packageInfo.versionCode);
version_tracking_common_1.init(version_tracking_common_1.versionTracking, versionsKey, buildsKey);

@@ -20,0 +20,0 @@ };

@@ -6,10 +6,10 @@ interface IVersionTracking {

isFirstLaunchForBuild: boolean;
versionHistory: Array<string>;
currentVersion: string;
previousVersion: string;
firstInstalledVersion: string;
buildHistory: Array<string>;
versionHistory: Array<string>;
currentBuild: string;
previousBuild: string;
firstInstalledBuild: string;
buildHistory: Array<string>;
init(versionsKey?: string, buildsKey?: string): void;

@@ -16,0 +16,0 @@ firstLaunchForVersion(version: string): boolean;

@@ -6,12 +6,12 @@ "use strict";

var versionTrail = {};
var oldVersionList = JSON.parse(appSettings.getString(versionsKey));
var oldBuildList = JSON.parse(appSettings.getString(buildsKey));
var oldVersionList = JSON.parse(appSettings.getString(versionsKey, null));
var oldBuildList = JSON.parse(appSettings.getString(buildsKey, null));
if (oldVersionList == null || oldBuildList == null) {
versionTracking.isFirstLaunchEver = true;
versionTrail[versionsKey] = [];
buildsKey[buildsKey] = [];
versionTrail[buildsKey] = [];
}
else {
versionTrail[versionsKey] = oldVersionList;
buildsKey[buildsKey] = oldBuildList;
versionTrail[buildsKey] = oldBuildList;
versionTracking.isFirstLaunchEver = false;

@@ -26,3 +26,3 @@ }

}
if (versionTrail[buildsKey].includes(versionTracking.currentVersion)) {
if (versionTrail[buildsKey].includes(versionTracking.currentBuild)) {
versionTracking.isFirstLaunchForBuild = false;

@@ -42,4 +42,6 @@ }

versionTracking.firstInstalledBuild = versionTrail[buildsKey][0] || null;
appSettings.getString(versionsKey, JSON.stringify(versionTrail[versionsKey]));
appSettings.getString(buildsKey, JSON.stringify(versionTrail[buildsKey]));
versionTracking.versionHistory = versionTrail[versionsKey];
versionTracking.buildHistory = versionTrail[buildsKey];
appSettings.setString(versionsKey, JSON.stringify(versionTrail[versionsKey]));
appSettings.setString(buildsKey, JSON.stringify(versionTrail[buildsKey]));
};

@@ -51,18 +53,28 @@ exports.versionTracking = {

isFirstLaunchForBuild: null,
versionHistory: [],
currentVersion: null,
previousVersion: null,
firstInstalledVersion: null,
buildHistory: [],
versionHistory: [],
currentBuild: null,
previousBuild: null,
firstInstalledBuild: null,
buildHistory: [],
init: function () { return null; },
firstLaunchForVersion: function (version) {
return exports.versionTracking.currentVersion.toLowerCase() === version.toLowerCase() && exports.versionTracking.isFirstLaunchForVersion;
if (exports.versionTracking.currentVersion) {
return exports.versionTracking.currentVersion.toLowerCase() === version.toLowerCase() && exports.versionTracking.isFirstLaunchForVersion;
}
else {
return false;
}
},
firstLaunchForBuild: function (build) {
return exports.versionTracking.currentBuild.toLowerCase() === build.toLowerCase() && exports.versionTracking.isFirstLaunchForBuild;
if (exports.versionTracking.currentBuild) {
return exports.versionTracking.currentBuild.toLowerCase() === build.toLowerCase() && exports.versionTracking.isFirstLaunchForBuild;
}
else {
return false;
}
}
};
//# sourceMappingURL=version-tracking.common.js.map

@@ -11,4 +11,4 @@ "use strict";

version_tracking_common_1.versionTracking.initialized = true;
version_tracking_common_1.versionTracking.currentVersion = NSBundle.mainBundle.objectForInfoDictionaryKey('CFBundleShortVersionString');
version_tracking_common_1.versionTracking.currentBuild = NSBundle.mainBundle.objectForInfoDictionaryKey('CFBundleVersion');
version_tracking_common_1.versionTracking.currentVersion = String(NSBundle.mainBundle.objectForInfoDictionaryKey('CFBundleShortVersionString'));
version_tracking_common_1.versionTracking.currentBuild = String(NSBundle.mainBundle.objectForInfoDictionaryKey('CFBundleVersion'));
version_tracking_common_1.init(version_tracking_common_1.versionTracking, versionsKey, buildsKey);

@@ -15,0 +15,0 @@ };

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