Skip to content

Commit b7bb820

Browse files
Apply suggestions from code review
1 parent da6eb3a commit b7bb820

File tree

1 file changed

+16
-15
lines changed
  • src/connections/sources/catalog/libraries/website/javascript

1 file changed

+16
-15
lines changed

src/connections/sources/catalog/libraries/website/javascript/faq.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,28 @@ strat: ajs
55

66
## Is there a size limit on requests?
77

8-
Yes, 32KB per event message. Events with a payload larger than 32KB are accepted by Analytics.js, with the browser returning a `200` response from the Segment servers, but the event will be silently dropped once it enters Segment's pipeline.
8+
Yes, the limit is 32KB per event message. Events with a payload larger than 32KB are accepted by Analytics.js and Segment servers return a `200` response , but the event is silently dropped once it enters Segment's pipeline.
99

1010
## If Analytics.js fails to load, are callbacks not fired?
1111

1212
In the event that Analytics.js does not load, callbacks passed into your API calls do not fire. This is as designed, because the purpose of callbacks are to provide an estimate that the event was delivered and if the library never loads, the events won't be delivered.
1313

1414
## Why do I see a network request to `/m`?
1515

16-
In May 2018, Segment released a change to Analytics.js that collects client-side performance metrics in Analytics.js. This includes metrics like:
16+
In May 2018, Segment began collecting client-side performance metrics in Analytics.js. This includes metrics like:
1717

1818
- When client side integrations are initialized and when they fail
1919
- When messages are sent to client side integrations and when they fail
2020

2121
Segment added these metrics to proactively identify and resolve issues with individual client-side integrations. These metrics are connected to alerts that notify Segment's on-call engineers to take action on these quickly.
2222

23-
There should be no noticeable impact to your data flow. You may notice Analytics.js make an extra network request in the network tab to carry the metrics data to Segment's servers. This should be very infrequent since the data is sampled and batched every 30 seconds, and should not have any impact of website performance.
23+
There should be no noticeable impact to your data flow. You may notice Analytics.js make an extra network request in the network tab to carry the metrics data to Segment's servers. This extra network request is not made frequently, since the data is sampled and batched every 30 seconds.
2424

2525
## How are properties with `null` and `undefined` values treated?
2626

27-
Segment uses the [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify){:target="blank"} method under the hood. Property values set to `null` or `undefined` are treated in accordance with the expected behaviour for the standard method:
27+
Segment treats property values set to `null` as null values and drops events set to`undefined`.
28+
29+
For example:
2830

2931
```js
3032
console.log(JSON.stringify({ x: null, y: 6 }));
@@ -33,14 +35,14 @@ console.log(JSON.stringify({ x: null, y: 6 }));
3335
console.log(JSON.stringify({ x: undefined, y: 6 }));
3436
// expected output: "{"y":6}"
3537
```
36-
38+
Segment uses the [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify){:target="blank"} method under the hood.
3739
## Can I overwrite the context fields?
3840

39-
Yes. This can be useful if some of these fields contain information you don't want to collect.
41+
Yes. This can be useful if some of these fields contain information you don't want to collect.
4042

4143
For example, imagine that your website allows users to view a receipt for purchases at the URL `https://mywebsite.com/store/purchases`. Your users click a link that redirects to that specific URL, your app sets a `receiptId` in the query string, and returns the appropriate receipt. You also send a Track call to Segment from this page.
4244

43-
Since this `receiptId` might contain sensitive information, you can prevent the context field `page.url` from being included in your Track call by overwriting the field in the `options` parameter, as in the example below:
45+
Since this `receiptId` might contain sensitive information, you can prevent the context field `page.url` from being included in your Track call by overwriting the field in the `options` parameter, as in the following example:
4446

4547
```js
4648
analytics.track("Receipt Viewed", {}, {
@@ -51,7 +53,7 @@ analytics.track("Receipt Viewed", {}, {
5153
```
5254
This works for any [context field](/docs/connections/spec/common/#context) that Segment automatically collects.
5355

54-
When working with Page calls, you can overwrite context fields by following the same instructions above. However, because the `context.page` fields are also available in the `properties` parameter for page calls, you must also prevent the same fields in the `properties` parameter from being included in your Page call. The example below will allow you to overwrite `url` available in context field `page.url` and properties parameter:
56+
When working with Page calls, you can overwrite context fields by following the above instructions. However, because the `context.page` fields are also available in the `properties` parameter for page calls, you must also prevent the same fields in the `properties` parameter from being included in your Page call. Use the code in the following example to overwrite `url` available in context field `page.url` and properties parameter:
5557

5658
```js
5759
analytics.page("Receipt Page", {
@@ -65,7 +67,7 @@ analytics.page("Receipt Page", {
6567

6668
## Can I add context fields that do not already exist?
6769

68-
Yes. Similar to overwriting context, you can add context fields by passing them into the options object as the third argument of the event call. For example, the analytics.js library does not automatically collect location information. To add this into the context object, pass it into the third argument as in the example below:
70+
Yes. You can add context fields by passing them into the options object as the third argument of the event call. For example, the analytics.js library does not automatically collect location information, but you can add it to the context object. To add location information into the context object, pass it into the third argument as in the following example:
6971

7072
```js
7173
analytics.track("Order Completed", {}, {
@@ -77,23 +79,22 @@ analytics.track("Order Completed", {}, {
7779
```
7880

7981
> info ""
80-
> You must pass the context object with the call, event if it's empty, as shown by the empty object in the example above.
82+
> You must pass the context object with the call, even if it's empty.
8183
8284
Some destinations accept properties only. As a result, custom context fields you add may not forward to these destinations.
8385

8486
## What is the impact of exposing the source's write keys?
8587

86-
For the Segment script to work in the browser, you need to expose the write key in order for client-side tracking to work. Segment's library architecture requires the write key to be exposed, similar to that of other major tools like Google Analytics, Mixpanel, Kissmetrics, Hubspot, and Marketo.
88+
Segment's library architecture requires you to expose the write key for client-side tracking to work. Other major tools, like Google Analytics, Mixpanel, Kissmetrics, Hubspot, and Marketo, also require you to expose your write key.
8789

88-
If you see any unusual behavior associated with your write key, you can generate a new key. Navigate to **Connections > Sources** and select your source. On the **Settings** tab, go to the **API Keys** section, and click **Generate New Key**.
90+
If you see any unusual behavior associated with your write key, generate a new key immediately. To generate a new key, navigate to **Connections > Sources** and select your source. On the **Settings** tab, go to the **API Keys** section and click **Generate New Key**.
8991

9092
If you want to hide the write key, you can use Segment's [HTTP Tracking API source](/docs/connections/sources/catalog/libraries/server/http-api/) or one of the other [server-side libraries](/docs/connections/sources/catalog/#server).
9193

9294
## Will Google Chrome's third-party cookie changes impact Segment Analytics.js?
9395

94-
No, Analytics.js isn't affected by this change. This is because Analytics.js only creates first-party cookies. Unlike third-party cookies, which are set by external services and blocked by the [new Chrome update](https://developers.google.com/privacy-sandbox/3pcd){:target="_blank"}.
96+
No, Analytics.js isn't affected by this change. Google's [third-party cookie deprecation](https://developers.google.com/privacy-sandbox/3pcd){:target="_blank"} only blocks third-party cookies, or cookies set by external services. Analytics.js creates first-party cookies, which are cookies created and stored by the website an end-user is browsing.
9597

96-
Regarding cookies set by [device-mode destinations](/docs/connections/destinations/#connection-modes), it's important to note that Segment's primary function is to load third-party SDKs and forward events to them. As a result, the usage and management of cookies are entirely at the discretion of each individual SDK. For instance, if you have concerns about destinations setting third-party cookies, it's best to consult directly with the destination providers for detailed information. For example, Amplitude, one of the destinations in the Segment catalog, offers [more information on this topic](https://www.docs.developers.amplitude.com/guides/cookies-consent-mgmt-guide/#frequently-asked-questions){:target="_blank"}.
9798

9899
## Does Segment support using strict Content Security Policy (CSP) on the page?
99100

@@ -113,7 +114,7 @@ You'll also need to modify the Segment script with your `nonce` tag, which shoul
113114
114115
## How is the referrer value set?
115116

116-
The Analytics.js library sets the `context.page.referrer` value from the `window.document.referrer` [property](https://developer.mozilla.org/en-US/docs/Web/API/Document/referrer){:target="_blank"} set in the browser. If you notice unexpected referrer values reaching Segment, check how this value is being set on your website.
117+
The Analytics.js library sets the `context.page.referrer` value from the [`window.document.referrer` property](https://developer.mozilla.org/en-US/docs/Web/API/Document/referrer){:target="_blank"} set in the browser. If you notice unexpected referrer values reaching Segment, check how this value is being set on your website.
117118

118119
## Are there any rate limits in place for the CDN settings endpoint?
119120

0 commit comments

Comments
 (0)