Skip to content

Commit ce4c6f7

Browse files
committed
edits
1 parent ad10607 commit ce4c6f7

File tree

3 files changed

+39
-30
lines changed

3 files changed

+39
-30
lines changed

src/connections/sources/catalog/libraries/server/node/classic.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ hidden: true
66
---
77

88
> warning "Deprecation of Analytics Node.js Classic"
9-
> On [date], Segment will end support for Analytics Node.js Classic, which includes versions [1.x.x] and older. Upgrade to the new version of Analytics Node.js. See the updated [Analytics Node.js] docs to learn more.
9+
> On April 1, 2023, Segment will end support for Analytics Node.js Classic, which includes versions 6.2.0 and older. Upgrade to the new version of Analytics Node.js. See the updated [Analytics Node.js docs](/docs/connections/sources/catalog/libraries/server/node) to learn more.
1010
1111
Segment's Node.js library lets you record analytics data from your node code. The requests hit Segment's servers, and then Segment routes your data to any destinations you have enabled.
1212

1313
The [Segment Node.js library is open-source](https://github.com/segmentio/analytics-node) on GitHub.
1414

15-
All of Segment's server-side libraries are built for high-performance, so you can use them in your web server controller code. This library uses an internal queue to make `identify` and `track` calls non-blocking and fast. It also batches messages and flushes asynchronously to our servers.
15+
All of Segment's server-side libraries are built for high-performance, so you can use them in your web server controller code. This library uses an internal queue to make `identify` and `track` calls non-blocking and fast. It also batches messages and flushes asynchronously to Segment's servers.
1616

1717
Want to stay updated on releases? Subscribe to the [release feed](https://github.com/segmentio/analytics-node/releases.atom).
1818

@@ -24,7 +24,7 @@ Run:
2424
npm install --save analytics-node
2525
```
2626

27-
This will add our Node library module to your `package.json`. The module exposes an `Analytics` constructor, which you need to initialize with your Segment source's **Write Key**, like so:
27+
This will add Segment's Node library module to your `package.json`. The module exposes an `Analytics` constructor, which you need to initialize with your Segment source's **Write Key**, like so:
2828

2929
```javascript
3030
var Analytics = require('analytics-node');
@@ -91,18 +91,18 @@ Field | Details
9191
`userId` _String, optional_ | The ID for this user in your database. _Note: at least one of `userId` or `anonymousId` must be included in any identify call._
9292
`anonymousId` _String, optional_ | An ID associated with the user when you don't know who they are (for example, [the anonymousId generated by `analytics.js`](/docs/connections/sources/catalog/libraries/website/javascript/#anonymous-id)). _Note: You must include at least one of `userId` or `anonymousId` in all identify calls._
9393
`traits` _Object, optional_ | A dictionary of [traits](/docs/connections/spec/identify#traits) you know about the user. Things like: `email`, `name` or `friends`.
94-
`timestamp` _Date, optional_ | A JavaScript date object representing when the identify took place. If the identify just happened, leave it out and we'll use the server's time. If you're importing data from the past make sure you to send a `timestamp`.
94+
`timestamp` _Date, optional_ | A JavaScript date object representing when the identify call took place. If the identify just happened, leave it out as Segment will use the server's time. If you're importing data from the past make sure you to send a `timestamp`.
9595
`context` _Object, optional_ | A dictionary of extra [context](https://segment.com/docs/connections/spec/common/#context) to attach to the call. _Note: `context` differs from `traits` because it is not attributes of the user itself._
9696

9797
Find details on the **identify method payload** in the Segment [Spec](/docs/connections/spec/identify/).
9898

9999
## Track
100100

101-
`track` lets you record the actions your users perform. Every action triggers what we call an "event", which can also have associated properties.
101+
`track` lets you record the actions your users perform. Every action triggers what Segment calls an "event", which can also have associated properties.
102102

103103
You'll want to track events that are indicators of success for your site, like **Signed Up**, **Item Purchased** or **Article Bookmarked**.
104104

105-
To get started, we recommend tracking just a few important events. You can always add more later!
105+
To get started, Segment recommends tracking just a few important events. You can always add more later.
106106

107107
Example anonymous `track` call:
108108

@@ -130,7 +130,7 @@ analytics.track({
130130
});
131131
```
132132

133-
This example `track` call tells us that your user just triggered the **Item Purchased** event with a revenue of $39.95 and chose your hypothetical '2-day' shipping.
133+
This example `track` call tells that your user just triggered the **Item Purchased** event with a revenue of $39.95 and chose your hypothetical '2-day' shipping.
134134

135135
`track` event properties can be anything you want to record. In this case, revenue and shipping method.
136136

@@ -140,9 +140,9 @@ Field | Details
140140
----- | --------
141141
`userId` _String, optional_ | The ID for this user in your database. _Note: at least one of `userId` or `anonymousId` must be included in any track call.
142142
`anonymousId` _String, optional_ | An ID associated with the user when you don't know who they are (for example, [the anonymousId generated by `analytics.js`](/docs/connections/sources/catalog/libraries/website/javascript/#anonymous-id)). _Note: You must include at least one of `userId` or `anonymousId` in all track calls._
143-
`event` _String_ | The name of the event you're tracking. We recommend human-readable names like `Song Played` or `Status Updated`.
143+
`event` _String_ | The name of the event you're tracking. Segment recommends you use human-readable names like `Song Played` or `Status Updated`.
144144
`properties` _Object, optional_ | A dictionary of properties for the event. If the event was `Product Added`, it might have properties like `price` or `product`.
145-
`timestamp` _Date, optional_ | A JavaScript date object representing when the track took place. If the track just happened, leave it out and we'll use the server's time. If you're importing data from the past make sure you to send a `timestamp`.
145+
`timestamp` _Date, optional_ | A JavaScript date object representing when the track took place. If the track just happened, leave it out as Segment will use the server's time. If you're importing data from the past make sure you to send a `timestamp`.
146146
`context` _Object, optional_ | A dictionary of extra [context](https://segment.com/docs/connections/spec/common/#context) to attach to the call. _Note: `context` differs from `traits` because it is not attributes of the user itself._
147147

148148
Find details on **best practices in event naming** as well as the **`track` method payload** in the Segment [Spec](/docs/connections/spec/track/).
@@ -151,7 +151,7 @@ Find details on **best practices in event naming** as well as the **`track` meth
151151

152152
The [`page`](/docs/connections/spec/page/) method lets you record page views on your website, along with optional extra information about the page being viewed.
153153

154-
If you're using our client-side set up in combination with the Node.js library, page calls are **already tracked for you** by default. However, if you want to record your own page views manually and aren't using our client-side library, read on!
154+
If you're using Segment's client-side set up in combination with the Node.js library, page calls are already tracked for you by default.
155155

156156
Example `page` call:
157157

@@ -174,11 +174,11 @@ The `page` call has the following fields:
174174
Field | Details
175175
----- | --------
176176
`userId` _String, optional_ | The ID for this user in your database. _Note: at least one of `userId` or `anonymousId` must be included in any page call.
177-
`anonymousId` _String, optional_ | An ID associated with the user when you don't know who they are (eg., [the anonymousId generated by `analytics.js`](/docs/connections/sources/catalog/libraries/website/javascript/#anonymous-id)). _Note: at least one of `userId` or `anonymousId` must be included in any page call._
177+
`anonymousId` _String, optional_ | An ID associated with the user when you don't know who they are (for example, [the anonymousId generated by `analytics.js`](/docs/connections/sources/catalog/libraries/website/javascript/#anonymous-id)). _Note: at least one of `userId` or `anonymousId` must be included in any page call._
178178
`category` _String, optional_ | The category of the page. Useful for things like ecommerce where many pages often live under a larger category.
179179
`name` _String, optional_ | The name of the page, for example **Signup** or **Home**.
180180
`properties` _Object, optional_ | A dictionary of properties of the page. A few properties specially recognized and automatically translated: `url`, `title`, `referrer` and `path`, but you can add your own too.
181-
`timestamp` _Date, optional_ | A JavaScript date object representing when the track took place. If the track just happened, leave it out and we'll use the server's time. If you're importing data from the past make sure you to send a `timestamp`.
181+
`timestamp` _Date, optional_ | A JavaScript date object representing when the track took place. If the track just happened, leave it out as Segment will use the server's time. If you're importing data from the past make sure you to send a `timestamp`.
182182
`context` _Object, optional_ | A dictionary of extra [context](https://segment.com/docs/connections/spec/common/#context) to attach to the call. _Note: `context` differs from `traits` because it is not attributes of the user itself._
183183

184184
Find details on the **`page` payload** in the Segment [Spec](/docs/connections/spec/page/).
@@ -207,11 +207,11 @@ The `group` call has the following fields:
207207
Field | Details
208208
----- | --------
209209
`userId` _String, optional_ | The ID for this user in your database. _Note: at least one of `userId` or `anonymousId` must be included in any group call.
210-
`anonymousId` _String, optional_ | An ID associated with the user when you don't know who they are (eg., [the anonymousId generated by `analytics.js`](/docs/connections/sources/catalog/libraries/website/javascript/#anonymous-id)). _Note: at least one of `userId` or `anonymousId` must be included in any group call._
210+
`anonymousId` _String, optional_ | An ID associated with the user when you don't know who they are (for example, [the anonymousId generated by `analytics.js`](/docs/connections/sources/catalog/libraries/website/javascript/#anonymous-id)). _Note: at least one of `userId` or `anonymousId` must be included in any group call._
211211
`groupId` _string | The ID of the group.
212212
`traits` _dict, optional_ | A dict of traits you know about the group. For a company, they might be things like `name`, `address`, or `phone`. [Learn more about traits](/docs/connections/spec/group/#traits).
213213
`context` _dict, optional_ | A dict containing any context about the request. To see the full reference of supported keys, check them out in the [context reference](/docs/connections/spec/common/#context)
214-
`timestamp` _datetime, optional_ | A `datetime` object representing when the group took place. If the group just happened, leave it out and we'll use the server's time. If you're importing data from the past make sure you send `timestamp`.
214+
`timestamp` _datetime, optional_ | A `datetime` object representing when the group took place. If the group just happened, leave it out as Segment uses the server's time. If you're importing data from the past make sure you send `timestamp`.
215215
`integrations` _dict, optional_ | A dictionary of destinations to enable or disable.
216216

217217
Find more details about `group`, including the **`group` payload**, in the Segment [Spec](/docs/connections/spec/group/).
@@ -238,7 +238,7 @@ Field | Details
238238
`userId` _String_ | The ID for this user in your database.
239239
`previousId` _String_ | The previous ID to alias from.
240240

241-
Here's a full example of how we might use the `alias` call:
241+
Here's a full example of how Segment might use the `alias` call:
242242

243243
```javascript
244244
// the anonymous user does actions ...
@@ -251,7 +251,7 @@ analytics.identify({ userId: '[email protected]', traits: { plan: 'Free' }
251251
analytics.track({ userId: '[email protected]', event: 'Identified Action' })
252252
```
253253

254-
For more details about `alias`, including the **`alias` call payload**, check out our [Spec](/docs/connections/spec/alias/).
254+
For more details about `alias`, including the **`alias` call payload**, check out the [Spec](/docs/connections/spec/alias/).
255255

256256
---
257257

@@ -327,13 +327,13 @@ analytics.track({
327327
})
328328
```
329329

330-
In this case, we're specifying that we want this `track` to only go to Vero. `All: false` says that no destination should be enabled unless otherwise specified. `Vero: true` turns on Vero, etc.
330+
In this case, Segment specifies the `track` to only go to Vero. `All: false` says that no destination should be enabled unless otherwise specified. `Vero: true` turns on Vero, etc.
331331

332-
Destination flags are **case sensitive** and match [the destination's name in the docs](/docs/connections/destinations/) (i.e. "AdLearn Open Platform", "awe.sm", "MailChimp", etc.). In some cases, there may be several names for a destination; if that happens you'll see a "Adding (destination name) to the Integrations Object" section in the destination's doc page with a list of valid names.
332+
Destination flags are **case sensitive** and match [the destination's name in the docs](/docs/connections/destinations/) (for example, "AdLearn Open Platform", "awe.sm", "MailChimp"). In some cases, there may be several names for a destination; if that happens you'll see a "Adding (destination name) to the Integrations Object" section in the destination's doc page with a list of valid names.
333333

334334
**Note:**
335335

336-
- Available at the business level, filtering track calls can be done right from the Segment UI on your source schema page. We recommend using the UI if possible since it's a much simpler way of managing your filters and can be updated with no code changes on your side.
336+
- Available at the business level, filtering track calls can be done right from the Segment UI on your source schema page. Segment recommends using the UI if possible since it's a much simpler way of managing your filters and can be updated with no code changes on your side.
337337

338338
- If you are on a grandfathered plan, events sent server-side that are filtered through the Segment dashboard will still count towards your API usage.
339339

@@ -343,16 +343,16 @@ You can import historical data by adding the `timestamp` argument to any of your
343343

344344
Historical imports can only be done into destinations that can accept historical timestamped data. Most analytics tools like Mixpanel, Amplitude, Kissmetrics, etc. can handle that type of data just fine. One common destination that does not accept historical data is Google Analytics since their API cannot accept historical data.
345345

346-
**Note:** If you're tracking things that are happening right now, leave out the `timestamp` and our servers will timestamp the requests for you.
346+
**Note:** If you're tracking things that are happening right now, leave out the `timestamp` and Segment's servers will timestamp the requests for you.
347347

348348

349349
## Batching
350350

351-
Our libraries are built to support high performance environments. That means it is safe to use our Node library on a web server that's serving hundreds of requests per second.
351+
Segment's libraries are built to support high performance environments. That means it is safe to use the Segment Node library on a web server that's serving hundreds of requests per second.
352352

353353
Every method you call **does not** result in an HTTP request, but is queued in memory instead. Messages are then flushed in batch in the background, which allows for much faster operation.
354354

355-
By default, our library will flush:
355+
By default, Segment's library flushes:
356356

357357
- The very first time it gets a message.
358358
- Every 20 messages (controlled by `options.flushAt`).

src/connections/sources/catalog/libraries/server/node/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ All of Segment's server-side libraries are built for high-performance, so you ca
1313

1414
> info "Using Analytics for Node.js Classic?"
1515
> If you’re still using the classic version of Analytics for Node.js, you can refer to the documentation [here](/docs/connections/sources/catalog/libraries/server/node/classic).
16-
> <br><br>On [date], Segment will end support for Analytics Node.js Classic, which includes versions [1.x.x] and older. Upgrade to Analytics Node.js 2.0. See the Analytics Node.js 2.0 docs to learn more.
16+
> <br><br>On April 1, 2023, Segment will end support for Analytics Node.js Classic, which includes versions 6.2.0 and older. Upgrade to new Analytics Node.js. See the updated [Analytics Node.js quickstart guide](/docs/connections/sources/catalog/libraries/server/node/quickstart/) to learn more.
1717
1818
## Getting Started
1919

src/connections/sources/catalog/libraries/server/node/quickstart.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
title: 'Quickstart: Node.js Classic'
2+
title: 'Quickstart: Node.js'
33
redirect_from: '/connections/sources/catalog/libraries/server/node-js/quickstart/'
44
strat: node-js
55
---
66

77
> warning "Deprecation of Analytics Node.js Classic"
8-
> On [date], Segment will end support for Analytics Node.js Classic, which includes versions [1.x.x] and older. Upgrade to Analytics Node.js 2.0. See the [Analytics Node.js 2.0] docs to learn more.
8+
> On [date], Segment will end support for [Analytics Node.js Classic](/docs/connections/sources/catalog/libraries/server/node/classic/), which includes versions [6.2.0] and older. Upgrade to Analytics Node.js 2.0. See the [Analytics Node.js 2.0] docs to learn more.
99
1010
This tutorial will help you start sending data from your Node servers to Segment and any destination, using Segment's Node library. Check out the full documentation for [Analytics Node.js](/docs/connections/sources/catalog/libraries/server/node) to learn more.
1111

@@ -17,19 +17,28 @@ To get started with Analytics Node.js:
1717
4. Give the source a display name, and enter the URL the source will collect data from.
1818
* When you create a Source in the Segment web app, it tells the Segment servers that you'll be sending data from a specific source type. When you create or change a Source in the Segment app, Segment generates a new Write Key for that source. You use the write key in your code to tell the Segment servers where the data is coming from, so Segment can route it to your destinations and other tools.
1919
2. Install the module.
20-
1. Run the following npm command to install Segment:
20+
1. Run the following commands to install Segment:
2121
```
22-
npm install --save analytics-node
22+
# npm
23+
npm install @segment/analytics-node
24+
# yarn
25+
yarn add @segment/analytics-node
26+
# pnpm
27+
pnpm install @segment/analytics-node
2328
```
2429
2530
This will add the Node library module to your `package.json`. The module exposes an `Analytics` constructor, which you need to initialize with your Segment project's **Write Key**, like so:
2631
2732
```javascript
28-
var Analytics = require('analytics-node');
29-
var analytics = new Analytics('YOUR_WRITE_KEY');
33+
import { Analytics } from '@segment/analytics-node'
34+
// or, if you use require:
35+
const { Analytics } = require('@segment/analytics-node')
36+
37+
// instantiation
38+
const analytics = new Analytics({ writeKey: '<YOUR_WRITE_KEY>' })
3039
```
3140
32-
This will create an instance of `Analytics` that you can use to send data to Segment for your project. The default initialization settings are production-ready and queue 20 messages before sending any requests. In development you might want to use [development settings](/docs/connections/sources/catalog/libraries/server/node#development).
41+
This creates an instance of `Analytics` that you can use to send data to Segment for your project. The default initialization settings are production-ready and queue 20 messages before sending any requests. In development you might want to use [development settings](/docs/connections/sources/catalog/libraries/server/node#development).
3342
3. Identify Users.
3443
3544
* **Note:** For any of the different methods described in this quickstart, you can replace the properties and traits in the code samples with variables that represent the data collected.

0 commit comments

Comments
 (0)