Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge in Q2: Remove undocumented AnalyticsNode from @segment/analytics-next #847

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/plenty-peaches-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@segment/analytics-next': major
---

Remove experimental/undocumented AnalyticsNode library from browser. @segment/analytics-node should be used.
Should also fix https://github.com/segmentio/analytics-next/issues/837.
9 changes: 2 additions & 7 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
"main": "./dist/cjs/index.js",
"module": "./dist/pkg/index.js",
"types": "./dist/types/index.d.ts",
"browser": {
"./dist/cjs/node": "./dist/cjs/node/node.browser.js",
"./dist/cjs/node.js": "./dist/cjs/node/node.browser.js",
"./dist/pkg/node": "./dist/pkg/node/node.browser.js",
"./dist/pkg/node.js": "./dist/pkg/node/node.browser.js"
},
"files": [
"dist/",
"src/",
Expand Down Expand Up @@ -54,13 +48,13 @@
"@segment/tsub": "1.0.1",
"dset": "^3.1.2",
"js-cookie": "3.0.1",
"node-fetch": "^2.6.7",
"spark-md5": "^3.0.1",
"tslib": "^2.4.1",
"unfetch": "^4.1.0"
},
"devDependencies": {
"@internal/config": "0.0.0",
"@segment/analytics-node": "*",
"@segment/analytics.js-integration": "^3.3.3",
"@segment/analytics.js-integration-amplitude": "^3.3.3",
"@size-limit/preset-big-lib": "^7.0.8",
Expand Down Expand Up @@ -88,6 +82,7 @@
"log-update": "^4.0.0",
"micro-memoize": "^4.0.9",
"mime": "^2.4.6",
"node-fetch": "^2.6.7",
"node-gyp": "^9.0.0",
"playwright": "^1.28.1",
"serve-handler": "^6.1.3",
Expand Down
45 changes: 19 additions & 26 deletions packages/browser/qa/lib/stats.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,44 @@
import { Analytics } from '../../src/index'
import { Context } from '../../src/core/context'
import { AnalyticsNode } from '../../src/node'
import { Analytics, Context } from '@segment/analytics-node'
import ex from 'execa'

let analytics!: Analytics


const getBranch = async () =>
(await ex('git', ['branch', '--show-current'])).stdout

async function client(): Promise<Analytics> {

function client(): Analytics {
if (!process.env.STATS_WRITEKEY) {
throw new Error('no process.env.STATS_WRITEKEY')
}

if (analytics) {
return analytics
}

const [nodeAnalytics] = await AnalyticsNode.load({
const analytics = new Analytics({
writeKey: process.env.STATS_WRITEKEY,
maxEventsInBatch: 1,
})

analytics = nodeAnalytics
return analytics
}

export async function gauge(
metric: string,
value: number = 0,
tags: string[] = []
): Promise<Context> {
const ajs = await client()
) {
const ajs = client()

const branch = process.env.BUILDKITE_BRANCH || (await getBranch())

const ctx = await ajs.track(
metric,
{
value,
tags: [...tags, `branch:${branch}`],
type: 'gauge',
},
{
userId: 'system',
}
const ctx = await new Promise<Context>((resolve, reject) =>
ajs.track(
{
event: metric,
properties: {
value,
tags: [...tags, `branch:${branch}`],
type: 'gauge',
},
userId: 'system',
},
(err, res) => (err ? reject(err) : resolve(res!))
)
)

return ctx
Expand Down
1 change: 0 additions & 1 deletion packages/browser/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from './core/analytics'
export * from './browser'
export * from './node'

export * from './core/context'
export * from './core/events'
Expand Down
19 changes: 0 additions & 19 deletions packages/browser/src/node/__tests__/node-integration.test.ts

This file was deleted.

36 changes: 0 additions & 36 deletions packages/browser/src/node/index.ts

This file was deleted.

7 changes: 0 additions & 7 deletions packages/browser/src/node/node.browser.ts

This file was deleted.

This file was deleted.

64 changes: 0 additions & 64 deletions packages/browser/src/plugins/analytics-node/index.ts

This file was deleted.

1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1733,6 +1733,7 @@ __metadata:
"@internal/config": 0.0.0
"@lukeed/uuid": ^2.0.0
"@segment/analytics-core": 1.2.4
"@segment/analytics-node": "*"
"@segment/analytics.js-integration": ^3.3.3
"@segment/analytics.js-integration-amplitude": ^3.3.3
"@segment/analytics.js-video-plugins": ^0.2.1
Expand Down