Skip to content

Commit aee18d2

Browse files
authored
Add signals implementation (#1101)
1 parent 1dbffec commit aee18d2

File tree

107 files changed

+3884
-150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+3884
-150
lines changed

.buildkite/pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ steps:
137137
commands:
138138
- npm config set "//registry.npmjs.org/:_authToken" $${NPM_TOKEN}
139139
- echo "--- Install dependencies"
140-
- PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 HUSKY=0 yarn install --immutable
140+
- HUSKY=0 yarn install --immutable
141141
- echo "--- Build bundles"
142142
- yarn turbo run --filter='./packages/signals/*' build
143143
- echo "+++ Run Lint"

.changeset/big-donkeys-cry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@segment/analytics-next': patch
3+
---
4+
5+
Add edgeFunction to CDNSettings type

.changeset/little-ghosts-jump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@segment/analytics-next': minor
3+
---
4+
5+
Export segment plugin and arg resolvers

.changeset/six-sloths-jam.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
'@segment/analytics-signals': patch
3+
---
4+
Initial release.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ reports/*
3434
playwright-report/
3535
playwright/.cache/
3636
tmp.tsconfig.json
37+
.env

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ module.exports = () =>
1717
'<rootDir>/packages/consent/consent-tools',
1818
'<rootDir>/packages/consent/consent-wrapper-onetrust',
1919
'<rootDir>/scripts',
20-
'<rootDir>/packages/signals/browser-signals',
20+
'<rootDir>/packages/signals/signals',
2121
],
2222
})

packages/browser/src/browser/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,23 @@ export interface CDNSettings {
104104
*/
105105
hasUnmappedDestinations: boolean
106106
}
107+
/**
108+
* Settings for edge function. Used for signals.
109+
*/
110+
edgeFunction?: // this is technically non-nullable according to ajs-renderer atm, but making it optional because it's strange API choice, and we might want to change it.
111+
| {
112+
/**
113+
* The URL of the edge function (.js file).
114+
* @example 'https://cdn.edgefn.segment.com/MY-WRITEKEY/foo.js',
115+
*/
116+
downloadURL: string
117+
/**
118+
* The version of the edge function
119+
* @example 1
120+
*/
121+
version: number
122+
}
123+
| {}
107124
}
108125

109126
export interface AnalyticsBrowserSettings {

packages/browser/src/core/analytics/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ export class AnalyticsInstanceSettings {
8888

8989
constructor(settings: AnalyticsSettings) {
9090
this.writeKey = settings.writeKey
91-
this.cdnSettings = settings.cdnSettings ?? { integrations: {} }
91+
this.cdnSettings = settings.cdnSettings ?? {
92+
integrations: {},
93+
edgeFunction: {},
94+
}
9295
}
9396
}
9497

packages/browser/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ export type { MiddlewareFunction } from './plugins/middleware'
1717
export { getGlobalAnalytics } from './lib/global-analytics-helper'
1818
export { UniversalStorage, Store, StorageObject } from './core/storage'
1919
export { segmentio } from './plugins/segmentio'
20+
export {
21+
resolveAliasArguments,
22+
resolveArguments,
23+
resolvePageArguments,
24+
resolveUserArguments,
25+
} from './core/arguments-resolver'

packages/signals/browser-signals/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)