@saurabhreo/test-package-with-tracker 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +49 -0
  2. package/TESTING.md +133 -0
  3. package/index.js +21 -0
  4. package/package.json +21 -0
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Test Package with Tracker
2
+
3
+ This is a test package to verify that the package tracker works correctly.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @saurabhreo/test-package-with-tracker
9
+ ```
10
+
11
+ When installed, the tracker should automatically send telemetry data to the configured endpoint.
12
+
13
+ ## Usage
14
+
15
+ ```javascript
16
+ const testPackage = require('@saurabhreo/test-package-with-tracker');
17
+
18
+ testPackage.hello();
19
+ // Output: Hello from test package!
20
+
21
+ const info = testPackage.getInfo();
22
+ console.log(info);
23
+ ```
24
+
25
+ ## Testing Tracker
26
+
27
+ To test with verbose output:
28
+
29
+ ```bash
30
+ PACKAGE_TRACKER_VERBOSE=true npm install @saurabhreo/test-package-with-tracker
31
+ ```
32
+
33
+ ## Configuration
34
+
35
+ The tracker uses the default endpoint (`https://telemetry.reo.dev/data`) automatically. No configuration needed!
36
+
37
+ If you want to customize the endpoint, you can add:
38
+
39
+ ```json
40
+ {
41
+ "reoSettings": {
42
+ "endpoint": "https://your-custom-endpoint.com/track"
43
+ }
44
+ }
45
+ ```
46
+
47
+ ## License
48
+
49
+ MIT
package/TESTING.md ADDED
@@ -0,0 +1,133 @@
1
+ # Testing Guide for Test Package
2
+
3
+ This directory contains a test package that uses `@saurabhreo/package-tracker` to verify tracking functionality.
4
+
5
+ ## Quick Start
6
+
7
+ ### 1. Test Locally (Before Publishing)
8
+
9
+ ```bash
10
+ cd npm-test
11
+
12
+ # Install dependencies (this will trigger the tracker)
13
+ npm install
14
+
15
+ # Test with verbose output to see what's happening
16
+ PACKAGE_TRACKER_VERBOSE=true npm install
17
+ ```
18
+
19
+ ### 2. Test the Package
20
+
21
+ ```bash
22
+ # Test the package functionality
23
+ node -e "const pkg = require('./index.js'); pkg.hello(); pkg.getInfo();"
24
+ ```
25
+
26
+ ### 3. Publish Test Package
27
+
28
+ ```bash
29
+ # Make sure you're logged in
30
+ npm whoami
31
+
32
+ # Publish
33
+ npm publish
34
+ ```
35
+
36
+ ### 4. Test End-to-End (After Publishing)
37
+
38
+ Create a fresh directory and install the published package:
39
+
40
+ ```bash
41
+ # Create fresh test directory
42
+ cd /tmp
43
+ mkdir test-install
44
+ cd test-install
45
+ npm init -y
46
+
47
+ # Install your test package (this will trigger tracker)
48
+ npm install @saurabhreo/test-package-with-tracker
49
+
50
+ # Or with verbose output
51
+ PACKAGE_TRACKER_VERBOSE=true npm install @saurabhreo/test-package-with-tracker
52
+ ```
53
+
54
+ ## What to Verify
55
+
56
+ 1. **Tracker Runs**: Check that the tracker executes during `npm install`
57
+ 2. **Data Sent**: Verify data is sent to `https://telemetry.reo.dev/data`
58
+ 3. **No Blocking**: Installation completes successfully
59
+ 4. **Verbose Output**: With `PACKAGE_TRACKER_VERBOSE=true`, you should see:
60
+ - Configuration details
61
+ - Collected data
62
+ - Send result
63
+
64
+ ## Testing Scenarios
65
+
66
+ ### Scenario 1: Normal Installation
67
+
68
+ ```bash
69
+ cd npm-test
70
+ npm install
71
+ ```
72
+
73
+ Expected: Tracker runs silently, installation completes.
74
+
75
+ ### Scenario 2: Verbose Installation
76
+
77
+ ```bash
78
+ cd npm-test
79
+ PACKAGE_TRACKER_VERBOSE=true npm install
80
+ ```
81
+
82
+ Expected: See detailed logs of what tracker is doing.
83
+
84
+ ### Scenario 3: Opt-Out
85
+
86
+ ```bash
87
+ cd npm-test
88
+ PACKAGE_TRACKER_ANALYTICS=false npm install
89
+ ```
90
+
91
+ Expected: Tracker skips tracking, shows "Tracking disabled" if verbose.
92
+
93
+ ### Scenario 4: Fresh Install (After Publishing)
94
+
95
+ ```bash
96
+ cd /tmp
97
+ mkdir fresh-test && cd fresh-test
98
+ npm init -y
99
+ npm install @saurabhreo/test-package-with-tracker
100
+ ```
101
+
102
+ Expected: Tracker runs automatically when package is installed.
103
+
104
+ ## Troubleshooting
105
+
106
+ ### Issue: Tracker not running
107
+
108
+ - Check that `@saurabhreo/package-tracker` is in dependencies
109
+ - Verify `postinstall` script exists in tracker's package.json
110
+ - Check npm version (should be recent)
111
+
112
+ ### Issue: No data received
113
+
114
+ - Check endpoint URL in `reoSettings.endpoint`
115
+ - Verify network connectivity
116
+ - Use verbose mode to see what's being sent
117
+ - Check backend logs at `https://telemetry.reo.dev/data`
118
+
119
+ ### Issue: Installation hangs
120
+
121
+ - Tracker has 10-second timeout, should not hang
122
+ - Check verbose output for errors
123
+ - Verify tracker version is latest (1.0.2+)
124
+
125
+ ## Next Steps
126
+
127
+ After verifying the test package works:
128
+
129
+ 1. Check your backend dashboard to see tracking data
130
+ 2. Verify data structure matches expected format
131
+ 3. Test with different environments (different OS, Node versions)
132
+ 4. Test opt-out functionality
133
+ 5. Consider publishing the test package for others to test
package/index.js ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Test package that uses the package tracker
3
+ * This is a simple example package to test tracking functionality
4
+ */
5
+
6
+ module.exports = {
7
+ hello: () => {
8
+ console.log('Hello from test package!');
9
+ console.log('This package uses @saurabhreo/package-tracker');
10
+ console.log('When you install this package, tracking data should be sent automatically.');
11
+ },
12
+
13
+ getInfo: () => {
14
+ return {
15
+ name: '@saurabhreo/test-package-with-tracker',
16
+ version: '1.0.0',
17
+ description: 'Test package for package tracker',
18
+ tracker: '@saurabhreo/package-tracker'
19
+ };
20
+ }
21
+ };
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@saurabhreo/test-package-with-tracker",
3
+ "version": "1.0.0",
4
+ "description": "Test package to verify package tracker functionality",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Test package - tracker should run on install\""
8
+ },
9
+ "keywords": [
10
+ "test",
11
+ "tracker-test"
12
+ ],
13
+ "author": "Saurabh <saurabh@reo.dev>",
14
+ "license": "MIT",
15
+ "dependencies": {
16
+ "@saurabhreo/package-tracker": "^1.0.2"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ }
21
+ }